HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problem with GetEventDamage()

08-12-2007, 03:39 AM#1
grupoapunte
hey, well i suppose this is one of those known bugs, and its the first time it happends to me, i made a trigger that captures (or at least should) the dmg taken by a unit and gives an item if the dmg is higher than X, the function GetEventDamage() is returning 0.00 but the unit is in fact taking damage, is there a way to fix this?

By the way this is the trigger if you want to take a look:
Collapse JASS:
function Trig_Iceberg_Conditions takes nothing returns boolean
    
    if (GetUnitTypeId(GetTriggerUnit()) == rcIceberg()) then
        return true
    endif
    
    return false
endfunction

function Trig_Iceberg_Actions takes nothing returns nothing
    local real rDamage = GetEventDamage()
    local location l = GetUnitLoc(GetAttacker())
    
    call DisplayTextToPlayer(Player(0), 0, 0, "Dmg: " + R2S(rDamage))
    
    loop
        exitwhen rDamage < 3.00
        call DisplayTextToPlayer(Player(0), 0, 0, "Dmg: " + R2S(rDamage))
        call UnitAddItem(GetAttacker(), CreateItemLoc(rcIce(), l))
        set rDamage = rDamage - 3.00
    endloop
    
    call RemoveLocation(l)
    set l = null
endfunction

//===========================================================================
function InitTrig_Iceberg takes nothing returns nothing
    set gg_trg_Iceberg = CreateTrigger()
    call TriggerRegisterPlayerUnitEventSimple(gg_trg_Iceberg, Player(PLAYER_NEUTRAL_PASSIVE), EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_Iceberg, Condition(function Trig_Iceberg_Conditions))
    call TriggerAddAction(gg_trg_Iceberg, function Trig_Iceberg_Actions)
endfunction

I added the "Displays" just to make sure that the trigger was actualy triggering.

Thanks!
08-12-2007, 03:41 AM#2
Rising_Dusk
You're using the EVENT_PLAYER_UNIT_ATTACKED event, of course it's returning 0.00 for GetEventDamage().
GetEventDamage() only returns anything for the EVENT_UNIT_DAMAGED event.
08-12-2007, 04:35 AM#3
grupoapunte
wow, thanks! hehe