Discussion Theory/Engine for Attack/Spell System


--- wraith it ! ---
I'm sorry if the title isn't clear. In my mind, these things are... vague, I don't know exactly what I should ask :banghead:

I develop an Attack/Spell System for my map but somehow I feel it still lacking some thing, maybe my "theory" isn't right.

here goes:

? Attack System:
Basically, my system works like this:

  • [Attack Detect] A unit is attacked: create Attack Object with attacker and attacked unit along with other data
  • [onAttack] Right after above event, I called it "onAttack" event: during this, runs some functions (*) for attacker and attacked unit with Attack Object as an argument.
    (this is for the purpose of play animation for ability such as critical strike, bash, pulverize)
  • [Wait Animation] Now I use timer to "wait" for the attacker to finish its "animation damage point" time
  • [onDamagePoint] The "onDamagePoint" event occur: during this, run functions (*) for attacker and attacked unit (with Attack Object as an argument).
    These fucntions are: "miss check" functions and, then, ability functions. (auto-cast abilities, buff that count attacks,...)
  • [Attack Process] After that, calculate damage of the attack and process the attack
    If the attack is: (melee and ranged attack for the moment)
    • Melee: run function that does damage of the attack (let just call this: "Attack Hit")
    • Range: run function that create projectile from attacker to attacked unit ---> projectile hit: run function that does damage of the attack
  • [Attack Hit] check damage (mainly, Crit), deal damage, run functions (*) for attacker and attacked unit

(*) the mentioned functions (for attacker and attacked unit) are run using function interface, I use AutoData to attach them to units.
I used to hard-code these but that's inefficient so I use function interface, run fucntions for specific unit.

and here are my problems:
  • onAttack, onDamagePoint at some cases, there are abilities that are "not stacked" with others (e.g: Orb Effects) but I don't know if one of these abilities has been "actived" or not.

    example: I have ability A and B which are actived at "onDamagePoint", but these two are not stacked with each other (if one has effect, other must not)

    my solution: create a variable (member) in the Attack Object. But I don't like this way very much, it's nearly "hard-coded" :(
    so, any suggestions for this?

  • on "miss check": this will check evasion abilities of attacked unit and "accuracy" of attacker. Generally, evasion abilities do not stack with each other, so single ability check is fine :) but if I want one ability (or more) to stack -> "single ability check" does not work.

    my solution: create a variable (member) in the Attack Object (again). This will have the "chance to miss" of the stacking ability in it and then all the other abilities will have their chance + this stacking chance
    is this ok?

  • A problem regards "count attack ability" and "effect ability": when I want an attack that does not have any "special bonus" (effect ability such as critical strike, bash,...), I just don't run the functions at "onAttack" or "onDamagePoint"
    because of that, some "count attack ability" are not checked as well (it should be checked instead), right?

    my solution: gives the functions that are run at "onAttack" or "onDamagePoint" a priority and check to run functions that have: minPriorty < funcPriority < maxPriority
    (the "priority" name here is silly, I know)
    so: "effect ability" will have priority higher than "count attack ability" -> this works
    I'm pretty satisfied with this but I'm still looking for another way.

? Spell System: (this is not really a "system" but well, I will just use the word)

so, errm, my spell would work like the following:
  • Single Target spells:
    • (1) run a function to check if the caster "missed" -> yes = do nothing
    • (2) run a function to check if the spell is "reflected" (back to caster) (In case of missile spell, this will check when the missile hit target) -> yes = swap caster & target
    • (3) run a function to check if the target can "resist" the spell -> yes = do nothing
    • (4) before target takes effect/damage from spell, run an "onHit" function (yes, caster hit target with the spell)
    • do effect/damage to the target
  • Area of Effect (No Target, Ground Target) spells:
    • (3) run a function to check if the affected units can "resist" the spell -> yes = do nothing
    • (4) before affected units take effect/damage from spell, run an "onHit" function (yes, caster hit affected units with the spell)
    • do effect/damage to affected units

for (1),(2),(3),(4) I have functions that take a set number of arguments that describe the spell and when I want more arguments (more detailed) I have to fix the code; yes, very tiring :(

so the solution should be using a struct instead?
and I need suggestions about the... name for "properties" of the spell (you probably think this is what I have to do by myself but I can't really think of some things "ok" right now), currently I have:
  • caster
  • target
  • ability
  • level
  • element (Fire, Cold,...)
  • affection type (the name is :nuts:): single target, area of effect,... (any suggestions for this name?)
  • "what does the spell do" :)eek:): damage, debuff, dot,... (any suggestions for this name?)

should I make this like the Attack System above? (lol)


phew, I feel so relived after writing all this. (I will be happier if I have my problem solved, though :D)

thank you for reading!


Hey Listen!!
Attack System

onAttack, onDamagePoint
You can use this.

on "miss check"
You could use Buff for it, Buff ins't stackable.

A problem regards "count attack ability" and "effect ability"
Maybe another event for non-(onAttack/onDamagePoint)

Spell System

so the solution should be using a struct instead?
I suggest AIDS Struct or something like this

and I need suggestions about the... name for "properties" of the spell
My old Template of Tooltip:

Action Type: ¹
Effect Type: ²
Effect Name:
Effect Duration:
Damage Type: Spell/Pure/Physical
Area of Effect:
Aura Range:
Cast Area:
Cast Range:
Cast Time:

Effect Description:

¹Action Type
- Passive
- Aura
- Untarget
- Target Enemy
- Target Friendly
- Ground AoE
- Ground Target
- Auto-Cast
- Active/Deactive

²Effect Type
[Damage] - A pure damage skill, a pure nuke
[Attack] - A skill that is part of your attack
[Self-AoE] - AoE centered on your hero
[Cone-AoE] - Cone AoE, fire from your hero in a direction
[Channeled] - You must maintain this skill. Moving, being stunned, or using other abilities ends this skill.
[Finisher] - A skill designed to kill a hero when their health is below a certain point.

[Heal] - Recovers Health
[Mana] - Recovers Mana

[Debuff] - Applies negative status
[Debuff-Aura] - Passive AoE debuff centered on hero
[Disarm] - Prevents attacking
[Silence] - Prevents Spellcasting
[Slow] - Reduces movement speed

[Buff] - Applies positive status
[Boost] - Improves hero, passively
[Buff-Aura] - Passive AoE boost centered on hero

[Vision] - Gain vision of an area or unit

[Warp] - Moves you to target location, path does not matter
[Charge] - Moves you to target location, path matters
[Stealth] - Makes you invisible unless revealed

[Summon] - Makes a unit for you
[Control] - Steals a unit and puts it under your control
[Morph] - Changes your hero's form

[Stun] - Prevents enemy from doing anything
[MiniStun] - A very short stun
[Grab] - Pulls enemy to you
[Push] - Pushes enemy unit
[Disable] - Prevents enemy from moving, using abilities, or attacking

[Root] - Prevents enemy from moving or attacking
[Trap] - Surrounds an enemy, to prevent movement

[Protection] - Buffs that prevent and reduce damage
[Defense] - Passive defensive buff


Vastly intelligent whale-like being from the stars
[Wait Animation] Now I use timer to "wait" for the attacker to finish its "animation damage point" time
Wouldn't it be more reliable to detect if the unit actually lands a hit (eg. a unit takes damage)? What happens if a unit begins an attack, but is interrupted in the process?


--- wraith it ! ---
you're right! but actually, I have that covered (well, most of the cases)

the above is only "basic structure", I think it will confuse people if I post the whole system :)


Hey Listen!!
In my map, the system used to 'custom missile' is like:

Unit takes damage > block damage
if hero is ranged
> Create missile and launch > deals damage when missile touch the target
else if hero is melee
> deals damage

In the object editor, to make things ok, I use instantly attack (no missile or melee), so the animation run ok and the hit just happen when animation ends

<Sorry for bad english>
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    that sucks
  • jonas jonas:
    @midnight8 how is it looking
  • midnight8 midnight8:
    meh, me, wife and her friend thaty traveled with us all have covid, seems to be winding down some for me at least. Felt like complete shit, been sleeping a lot, just bieng lazy as hell. I feel like that today has probably been like 11 or 12 days since exposure. Have not had any fever today, and have not taken any meds, so hopefully by monday or tuesday I will be good to go, sadly have passed it on to our teen son, I guess that was pretty much unavoidable
  • The Helper The Helper:
    hope you get to feeling better and get vaccinated my friend
  • midnight8 midnight8:
    I will at some point, but so many vaccinated people still getting it. One of the bands we watch in vegas, all 4 had been vaccinated and are now positive.
  • Ghan Ghan:
  • Ghan Ghan:
    I think the symptoms are typically less severe if previously vaccinated.
  • midnight8 midnight8:
    I have had all of the symptoms, taste is slightly starting to come back, but smell, no. Honestly, just been a little miserable, have never felt in any danger from it. Being trapped at home sucks. lol
  • midnight8 midnight8:
    meh, got a little fever again this morning, guess gonna be a few more days
  • The Helper The Helper:
    I went to Comicon this last weekend I hope I dont get it I feel fine and I am not vaccinated and did not wear a mask
  • The Helper The Helper:
    Comicon really was not packed though like it was in the past. I am not really worried though it was the most people I have been around in a year.
  • tom_mai78101 tom_mai78101:
    Still, getting vaccinated is a good idea. We're getting Delta variant spikes here in Boston.
  • The Helper The Helper:
    I am not against vaccination at all I just have a serious procrastination problem I plan on getting vaccinated soon
  • midnight8 midnight8:
    was kinda same with me, I was gonna do it, and life got in the way.
  • midnight8 midnight8:
    we wore mask in some places, but at 118 degrees outside, little rough. :)
  • The Helper The Helper:
    yeah i had another friend in Vegas talking about that heat damn
  • The Helper The Helper:
    Well I do not think I got Covid from the Comicon
  • tom_mai78101 tom_mai78101:
    Pushed out a new Pokemon Walking algorithm build. With a new system in place, I'll probably start tackling triggers and NPCs,
  • Varine Varine:
    Is it fucking hot everywhere?
  • Varine Varine:
    What's a pokemon walking algorithm?
  • jonas jonas:
    it's an engine for pokemon games that closely emulates the walking behavior of pokemon red/blue/yellow
  • jonas jonas:
    basically if you wanted to implement pokemon yellow from scratch, and you'd want it to feel as close as possible to the real thing, you'd start with that
  • Varine Varine:
    Like from the Gameboy games? I'm not at all familiar with Pokemon.
  • jonas jonas:
  • The Helper The Helper:
    I only played the Pokemon games on the Gamecube and Wii and such not on the portables my kids had all those games but I never really played on the portables. Now that I think about maybe once sooooo long ago.

    Staff online

    Members online


    Hive Workshop NUON Dome