• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Bribe's Damage Engine questions

Status
Not open for further replies.
Level 11
Joined
Jun 2, 2004
Messages
849
So I installed this today and have a few questions.

1. How do I differentiate auto attack damage from other damage?
There's the built-in "isSpellDamage" flag but I want to differentiate between the main target and targets damaged by cleave/orb of annihilation/barrage/etc. Do I need to trigger all forms of non-spell damage, and leave auto attack damage as the only "physical" damage?

2. Should I worry about recursive damage events?
I noticed there were a lot of global variables. Do I need to worry about them being overwritten when calling a "deal damage to target" function from within a damage event, especially when I might have 4-5 layers of damage events? (an attack might cause a triggered cleave which might cause a proc which might cause a...) Or is just calling "ClearDamageEvent" after every triggered damage event sufficient?

3. Would switching over the unit indexer to hashtables/handle IDs be prohibitively bothersome?
I don't like using tables (EDIT: arrays, not tables). However, if it would be far too much of a pain to switch over then I'll make do.
 
Last edited:

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
1. How do I differentiate auto attack damage from other damage?
One option is to have auto attacks as the only physical damage, as you said.
isSpellDamage means attack type is spell, so it only comes down to the attack type.

In my map (I am not using Bribe's DDS, but it's the same for every DDS) I give all units a passive ability based on orb of corruption. If a unit is damaged and has this buff, I know the damage cam from an attack and remove the buff.

Keep in mind that this only works well with single target damage. Most aoe attacks don't work well with buff placing abilities. I guess for standard aoe you could frost breath and for artillery plague cloud could work. This a lot of work to set up, but in the end you have a good solution in my opinion.

You can as well trigger the aoe effect on top of a single target attack. Works for orb of annihilation, cleave and normal aoe attacks.
The difficulty is to know how much damage the secondary targets should take. You can't really base it on the damage the main target took, because it was modified by armor, armor type and potentially other things.

Barrage is tough, because I don't see a way how the targets can be differentiated. Either go for some kind of order/is attacked tracking so you always know which target is supposed to be the main target: You can also replace the attack with an instant single target attack. Then you detect this target and manually launch missiles to nearby targets.
Either way is a lot of work. Maybe someone has a better idea.

The general solution is to do a lot of stuff manually, because the event itself does not allow you to differentiate between attack type.

There is also some kind of aoe flag, but I don't know what it does. Haven't used Bribe's DDS for a long time.

2. Should I worry about recursive damage events?
The moment you use a damage action, the global variables will change. If you want to preserve them your best option is to use local variables.

  • Test
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Unit - Cause DamagedUnit to damage DamageSource, dealing 500.00 damage of attack type Spells and damage type Normal
      • Unit - Kill DamagedUnit
Idea: if my unit is attacked, I want to punish the attacking unit by dealing damage to it. My attacked unit will sacrifice its life for it.
What happens is, that the attacking unit dies, because after dealing damage there is a new damaged unit.

3. Would switching over the unit indexer to hashtables/handle IDs be prohibitively bothersome?
I don't understand this. You say you don't like hashtables. Why would you switch to them then?[/trigger]
 
Level 11
Joined
Jun 2, 2004
Messages
849
Oh, sorry; I meant to say I don't like using arrays. Some crossed wires when I was writing that.

Thanks for your response! I'll probably end up triggering most atypical attacks then. I'm hesitant to use buff placers since I want to avoid conflicts, though; much of the reason I'm using a DDS is to eliminate the engine limitations like "only one Orb ability" and such. But it's still worth considering for something so basic and universal.

Barrage in particular is going to be a pain of course but I was planning to remake that from the beginning, since it doesn't play nice with Critical Strike.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Oh, sorry; I meant to say I don't like using arrays. Some crossed wires when I was writing that.
I don't know in what way the DDS is connected to the indexer, but you can certainly change it. If you search in the JASS code for userdata, you should find what is connected to the indexer. I can't say if it is a lot of work.

I'm hesitant to use buff placers since I want to avoid conflicts, though; much of the reason I'm using a DDS is to eliminate the engine limitations like "only one Orb ability" and such.

In my map I have this one orb ability for every unit. Then other orb abilities are triggered.
Here is an example of one of my orb abilities.
Wurst:
OnAttack.addOnAttackFunc((unit attacker, unit target, boolean isActive) -> (begin
    if attacker.hasItemById(convertItemId(itemId)) and target.getMana() > 0 and not target.isType(UNIT_TYPE_STRUCTURE)
        let manaBurned = min(mBurn.toReal() , target.getMana())
        attacker.damageMana(target, manaBurned, ReductionType.NONE)
        attacker.dealDamage(target, manaBurned, ReductionType.MAGIC)
        target.addEffect(Abilities.spellBreakerAttack, "chest").destr()
end))
I don't know if you understand this, because it is wurst, but to put it simply it's the feedback ability.
This means: drain mana, deal damage per mana point burned and show an effect.

I think one could make a very similar approach in JASS. In GUI it's doable as well. You could use the real variable event to add orb effects.


Barrage in particular is going to be a pain of course but I was planning to remake that from the beginning, since it doesn't play nice with Critical Strike.
Remaking things is a lot of work, but in the end you will get the best result and have full control over it.
 
Status
Not open for further replies.
Top