Snippet GUI-Friendly Damage Detection

Discussion in 'Systems and Snippets' started by Weep, Oct 2, 2009.

  1. DuelPlayer

    DuelPlayer Member

    Ratings:
    +21 / 0 / -0
    This methods arent good...
    And i tried once, i set the damage of cripple to 0
    But the unit get knockback which is another trigger when it is casted
     
  2. Weep

    Weep Godspeed to the sound of the pounding

    Ratings:
    +400 / 0 / -0
    Well, not being able to use a variable in a hashtable seems to be a World Editor shortcoming.

    It's not a bug that you can use Event Response - Triggering Unit in place of GDD_DamagedUnit (though unless you want it for a hashtable or after a wait, using the variable might be marginally faster :rolleyes:); I just haven't documented it. Also, FYI, Event Response - Damaged Unit doesn't work with GDD.
     
  3. Inflicted

    Inflicted Currently inactive

    Ratings:
    +63 / 0 / -0
    nvm figured it out.
     
  4. Weep

    Weep Godspeed to the sound of the pounding

    Ratings:
    +400 / 0 / -0
    Updated to 1.2.1, with two user-configuration functions, minor code cleanup, and expanded documentation. Happy users of 1.2.0 don't really need to update.
     
  5. mapguy

    mapguy New Member

    Ratings:
    +46 / 0 / -0
    I just have to copy + paste it in trigger editor?

    that jass code box?
    just it?

    how to enable my locusts to DEAL damage.
     
  6. HeX.16

    HeX.16 Isn't Trollin You Right Now

    Ratings:
    +131 / 0 / -0
    Download the test map and the instructions are REALLY easy.
     
  7. hgkjfhfdsj

    hgkjfhfdsj Active Member

    Ratings:
    +55 / 0 / -0
    question(s) (more learning purposes.)
    JASS:
    function GDD_LeaveMap takes nothing returns boolean
        local boolean cached = bj_slotControlUsed[5063]
        if(udg_GDD__Integers[2] < 64) then
            set udg_GDD__Integers[2] = udg_GDD__Integers[2]+1
        else
            set bj_slotControlUsed[5063] = true
            call ForGroup(udg_GDD__LeftMapGroup, function GDD_GroupRefresh)
            set udg_GDD__Integers[2] = 0
        endif
        call GroupAddUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
        set bj_slotControlUsed[5063] = cached
        return false
    endfunction


    why set cached as bj_slotControlUsed instead of using bj_slotControlUsed directly, ie
    JASS:
    
    function GDD_GroupRefresh takes nothing returns nothing
        if (bj_slotControlUsed[5063] == true) then
            call GroupClear(udg_GDD__LeftMapGroup)
            set bj_slotControlUsed[5063] = false
        endif
        call GroupAddUnit(udg_GDD__LeftMapGroup, GetEnumUnit())
    endfunction
    // . .
    function GDD_LeaveMap takes nothing returns boolean
        //local boolean cached = bj_slotControlUsed[5063]
        if(udg_GDD__Integers[2] < 64) then
            set udg_GDD__Integers[2] = udg_GDD__Integers[2]+1
        else
            set bj_slotControlUsed[5063] = true
            call ForGroup(udg_GDD__LeftMapGroup, function GDD_GroupRefresh)
            set udg_GDD__Integers[2] = 0
        endif
        call GroupAddUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
        //set bj_slotControlUsed[5063] = cached  //why set it to original bj_slotControlUsed?
        return false
    endfunction



    ty:)
     
  8. Weep

    Weep Godspeed to the sound of the pounding

    Ratings:
    +400 / 0 / -0
    It's because I'm co-opting a Blizzard global array instead of having to create my own global variable (it only matters without vJASS, which gives the freedom to declare globals in the code), and because I don't know whether some other system or spell might happen to use that exact same array variable (unlikely, but you never know ;)), I make sure to save its original value and put it back when I'm done.
     
  9. the Immortal

    the Immortal I know, I know...

    Ratings:
    +51 / 0 / -0
    Setting a (surely empty) array's 5063rd member should allocate at least 5062 (surely empty) booleans in the game's memory from what I understand? Since arrays are consecutive in memory and blahblahblahboringtalk, my point is: you reset it anyway, so simply use the 0 index of the array. It is highly improbable that someone could use a 'variable changed value' event on this array member, so why waste these few bytes of memory creating 5k useless booleans! =D


    It's a pointless optimization.. but hey, it is something!
     
  10. Weep

    Weep Godspeed to the sound of the pounding

    Ratings:
    +400 / 0 / -0
    As far as I've read other people mention, WC3 allocates the entire array when declared, so this shouldn't make any difference. [edit] I guess it does...
     
  11. Opa

    Opa New Member

    Ratings:
    +3 / 0 / -0
    and this really doesnt leak?
     
  12. Laiev

    Laiev Hey Listen!!

    Ratings:
    +187 / 0 / -0
    100% leakless because this allow to add the event just one time, not 14923849273984 times for the same unit
     
  13. Sevion

    Sevion The DIY Ninja

    Ratings:
    +423 / 0 / -0
    There is no leakless.

    But as far as you're concerned (and any users of this system) you'll be fine.
     
  14. Opa

    Opa New Member

    Ratings:
    +3 / 0 / -0
    nice system is nice...
     
  15. Sajin

    Sajin User title under construction.

    Ratings:
    +57 / 0 / -0
    Would this system have a problem is the damage source and damaged unit are owned by the same player?
     
  16. Weep

    Weep Godspeed to the sound of the pounding

    Ratings:
    +400 / 0 / -0
    Nope, that works fine.
     
  17. Sajin

    Sajin User title under construction.

    Ratings:
    +57 / 0 / -0
    ok thank you :)
     
  18. dianamod27

    dianamod27 Member

    Ratings:
    +1 / 0 / -0
    Are there any conditions I can use to determine whether the damage taken by GDD_DamagedUnit is caused by a spell?
    The problem is that I want certain triggers to fire only when a unit takes damage from a regular attack. I already have direct damage spells covered with

    Trigger:
    • Or - Any (Conditions) are true
      • Conditions
        • (Current order of GDD_DamageSource) Equal to (Order(<Empty String>))
        • (Current order of GDD_DamageSource) Equal to (Order(smart))


    but said triggers still fire when a unit takes periodic damage from Acid Bomb and similar spells.
    I have this feeling that I'm overlooking something really obvious here but I just can't figure it out.
     
  19. Ayanami

    Ayanami 칼리

    Ratings:
    +287 / 0 / -0
    I believe this System is only for detecting damage, and not damage type. You'd need to make your own damage system. For example, if you trigger all your spell-based damage, you can easily differentiate a physical attack and a spell attack.
     
  20. dianamod27

    dianamod27 Member

    Ratings:
    +1 / 0 / -0
    I was thinking about that as a measure of last resort but I guess I have to.
     

Share This Page