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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top