• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[DDS Plugin] Damage Event

Edit: Basically there's a bug in your system which makes GetUnitState(u,UNIT_STATE_LIFE) unsafe by sometimes returning the value of the unit's health + the offset of the maximum life ability.

I haven't had time to look at what might be causing this, but somehow lfh's script circumvents this issue.

On the bright side, after attacks stop occurring, this script proves the correctness of all 3 scripts (10,000 attacks dealing 1 damage each will deal 10,000 damage, regardless of whether or not the attacks occur simultaneously - this is good news for scripts that use the ITEM_MAX_HEALTH ability)
 

Attachments

  • lfhCorrectness001.w3x
    34.9 KB · Views: 67
  • nestharusCorrectness001.w3x
    65 KB · Views: 85
  • sDDcorrectness001.w3x
    26.6 KB · Views: 104
Last edited:
Level 14
Joined
Dec 12, 2012
Messages
1,007
Its not an accuracy thing.

1.) You don't have acces to life from everywhere, so you can't use scopes:


JASS:
struct Test extends array
    private static method onDamage takes nothing returns nothing
        set damage = 0.0001*damage
    endmethod

    implement DDS
endstruct

scope test initializer Init
    private function slowCallback takes nothing returns nothing
        call UnitDamageTarget(gg_unit_hkni_0000, gg_unit_hkni_0000, 0.5*GetUnitState(gg_unit_hkni_0000, UNIT_STATE_MAX_LIFE), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
    endfunction
    
    private function fastCallback takes nothing returns nothing
        call UnitDamageTarget(gg_unit_hkni_0000, gg_unit_hkni_0000, 10000.0, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
    endfunction

    private function Init takes nothing returns nothing
        call TimerStart(CreateTimer(), 0.01, true, function fastCallback)
        call TimerStart(CreateTimer(), 1.00, true, function slowCallback)
    endfunction
endscope


So this will break all spells that use GetWidgetLife/GetUnitState from scopes/libraries that are not implemented into DDS.

2.) Even if you have access, it then may not contain anything (only zero):


JASS:
struct Test extends array
    private static method onDamage takes nothing returns nothing
        set damage = 0.0001*damage
    endmethod

    implement DDS
endstruct

struct test extends array
    private static method slowCallback takes nothing returns nothing
        call BJDebugMsg(R2S(life))
        call UnitDamageTarget(gg_unit_hkni_0000, gg_unit_hkni_0000, 0.5*GetUnitState(gg_unit_hkni_0000, UNIT_STATE_MAX_LIFE), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
    endmethod
    
    private static method fastCallback takes nothing returns nothing
        call UnitDamageTarget(gg_unit_hkni_0000, gg_unit_hkni_0000, 10000.0, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
    endmethod

    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(), 0.01, true, function thistype.fastCallback)
        call TimerStart(CreateTimer(), 1.00, true, function thistype.slowCallback)
    endmethod
    
    implement DDS
endstruct
 
Huh? The variable isn't empty.

If a damage event is up, the variable has something in it.

Unless you mean for a general function working with unit life that takes a unit and is called within a damage event? Or code that runs in between that has nothing to do with the damage event stuff. I see what you mean now : ).

edit
A lot of overhead is added to maintain the correct health of a unit from event to event. The logic gets very complicated too : |. However, now that I see this issue, it might be worth it to look into that.

I'm also looking into figuring out some way to disable all of DDS so that spell damage doesn't run 2 triggers every time.
 
Level 10
Joined
May 28, 2011
Messages
455
Hai. I have a problem. I use dummy to cast flame strike. The damaged units seem to kill themselves. I think this is the cause.

In Damage Event Modification DDS Plugin trigger
JASS:
call RemoveAfterDamage(targetId_p)
                    if (actualDamage < 0) then
                        set DDS[targetId_p].enabled = false
                        call SetWidgetLife(u, damageOriginal)
                        call UnitDamageTarget(u, u, damageOriginal*100, true, false, null, DAMAGE_TYPE_UNIVERSAL, null)
                        call UnitDamageTarget(u, u, damageOriginal*100, true, false, null, DAMAGE_TYPE_NORMAL, null)
                        set DDS[targetId_p].enabled = true
                    else
                        call SetWidgetLife(u, actualDamage)
                    endif

I don't want them to kill themselves. What am i suppose to do?
 
That's not the cause, look above it

JASS:
                if (life - damage_p < .4051) then
                    call RemoveAfterDamage(targetId_p)
                    if (actualDamage < 0) then
                        set DDS[targetId_p].enabled = false
                        call SetWidgetLife(u, damageOriginal)
                        call UnitDamageTarget(u, u, damageOriginal*100, true, false, null, DAMAGE_TYPE_UNIVERSAL, null)
                        call UnitDamageTarget(u, u, damageOriginal*100, true, false, null, DAMAGE_TYPE_NORMAL, null)
                        set DDS[targetId_p].enabled = true
                    else
                        call SetWidgetLife(u, actualDamage)
                    endif

if (life - damage_p < .4051) then

This says that if the unit is going to die from the damage, then kill that unit. The unit will either die from UnitDamageTarget if the actual damage is negative (spell damage is negative, it has to be accounted for) or set the unit's life to the actual damage if it's not negative to ensure that it dies.

I've never run into this issue. It sounds like Flame Strike is hitting the stuff that is killing itself. If Flame Strike is doing damage to them, that explains it ;o.
 
Top