Discussion Theory/Engine for Attack/Spell System

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
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!
 

Laiev

Hey Listen!!
Reaction score
188
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:

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


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
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
wow, thanks for the reply, that opened my mind (a bit :p)

I'm still waiting for other replies :)
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
[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?
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
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 :)
 

Laiev

Hey Listen!!
Reaction score
188
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 Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top