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.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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