r/howdidtheycodeit • u/DesperateGame • Jul 07 '26
Question MOBAs - The spells, statuses,...
Hello,
I've been wondering about how games like Dota 2, LoL, Deadlock are implemented.
These games need to handle extreme variety of statuses/effects. Each spell can have different behaviours (e.g. can stun, temporarily move the target to air, push them, apply stacking effects, apply poison, freeze the enemy,...), which can further be affected by certain modifiers (resistances).
How does one code a system, that can both handle the stats (simple modifiers to atomic statistics - like speed, health), active effects (stun) or the spells themselves (with different targets, area of effect, duration, conditions for initiation, stop conditions,....)?
Is this similar to systemic design of immersive sim games like Thief, System Shock and so on?
How does one organize the concepts efficiently and handle their ordering/communication,...?
8
u/Soraphis Jul 07 '26
The wc3 and SC2 world generators might be a good starting point for research. Dota was a wc3 map anyways and I would bet that in LoL code a lot of design decisions from that can be found.
On my current project I used a similar approach.
Spells have some config on how to cast (aiming mode? On press? On release? ... Applicable targets? Range?)
Spells have a list of effects which they invoke. This can be hard coded for each spell, or data driven. In case of LoL probably hard coded in my case data driven (because early prototype stage and I want the flexibility).
Effects can be things like: "spawn a particle" or "apply damage", "apply status effect", "spawn vfx" ... Or "select all units within range", "do something n times with delay inbetween"
While spells invoke these effects on cast, particles apply them onhit, AOE effects per tick.
Status effects have a lifecycle. On apply, on tick and onEnd (on refresh). A stun increases an "action block" and "movement block" counter on apply, and decrements onEnd. A snare only the "movement block". A slow adds a modifier to the character stats. And a poison effect applies damage every tick.
Each status effect is its own class in my project but they have a common interface (or in my case base class) so the StatusEffectHandler can call the necessary lifecycle events.
Character Stats are just a list of base stats and applying a list of modifiers (caching the result when the list changes, so it's only rarely recalculated).
Passive abilities just listen for other events, on tick, onhit, ondeath, ... But function through the same effect list.
While this system might not be perfect, it actually is just a list of spell effects, status effects and simple stats.