1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Bribe's Damage Engine questions

Discussion in 'Triggers & Scripts' started by Kaijyuu, May 11, 2018.

  1. Kaijyuu

    Kaijyuu

    Joined:
    Jun 2, 2004
    Messages:
    848
    Resources:
    0
    Resources:
    0
    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: May 11, 2018
  2. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    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.

    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.

    I don't understand this. You say you don't like hashtables. Why would you switch to them then?[/trigger]
     
  3. Kaijyuu

    Kaijyuu

    Joined:
    Jun 2, 2004
    Messages:
    848
    Resources:
    0
    Resources:
    0
    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.
     
  4. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    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.

    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.
    Code (WurstScript):

    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.


    Remaking things is a lot of work, but in the end you will get the best result and have full control over it.