• 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.

GetEventDamage () function

Status
Not open for further replies.
Yes, it responds on every damage that is dealt.

Rising Duck made an intuitive damage detection system which allows you to actually have fun triggering actions on spell-damage only or attack-damage only but it forces you to TRIGGER every damage-spell/ability yourself and furthermore you have to deal that damage ONLY via this system leaving attacks (normal hits) alone.
 
Try this snippet...

NOTE: Not fully tested
JASS:
library DDSys

globals
    private constant hashtable                  HASH = InitHashtable()
    private constant trigger                    TRIG = CreateTrigger()
endglobals

function DamageRegister takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real damtaken = GetEventDamage()
    local texttag tag = CreateTextTag()
    call SetTextTagPos(tag, GetUnitX(u), GetUnitY(u), 90)  
    call SetTextTagText(tag, I2S(R2I(damtaken)), 0.025)
    call SetTextTagPermanent(tag, false)
    call SetTextTagVelocity(tag, 0.04, 0.04)
    call SetTextTagLifespan(tag, 3)
    call SetTextTagFadepoint(tag, 0.01)
    set u = null
    set tag = null
endfunction

function TakesDamage takes unit u returns nothing
    local integer ID = GetHandleId(u)
    if not HaveSavedBoolean(HASH, ID, 1) then
        //this is used only ONE TIME per unit
        call SaveBoolean(HASH, ID, 1, true)
        call TriggerRegisterUnitEvent(TRIG, u, EVENT_UNIT_DAMAGED)
        call TriggerAddAction(TRIG, function DamageRegister)
        //===========================
    endif
endfunction

endlibrary

How it works?...
  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Custom script: call TakesDamage(GetEnumUnit())
 
I recommend you look into this:
GUI Friendly Damage Detection

It is probably the best damage detection system for GUI users. Just read the documentation and it should be very easy to implement.

The problem with mckill's snippet is that it won't register the damage events for units who come into the map after 1 second has elapsed. ;)
 
I recommend you look into this:
GUI Friendly Damage Detection

It is probably the best damage detection system for GUI users. Just read the documentation and it should be very easy to implement.

The problem with mckill's snippet is that it won't register the damage events for units who come into the map after 1 second has elapsed. ;)

Correct, and as I have mentioned >>> NOTE: Not fully tested :)
 
Status
Not open for further replies.
Top