HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Death System only working sometimes?

08-10-2009, 12:16 PM#1
thehellman
Collapse JASS:
function Trig_Death_System_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true  and GetPlayerSlotState(GetOwningPlayer(GetTriggerUnit())) == PLAYER_SLOT_STATE_PLAYING
endfunction

function ReviveTimer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = LoadUnitHandle( udg_GameCore, GetHandleId(t), 0 )
    local timerdialog td = LoadTimerDialogHandle( udg_GameCore, GetHandleId(t), 1 )
    if( IsUnitAlly( u, Player(0) ) ) then
        call PanCameraToTimedForPlayer( GetOwningPlayer(u), -780, 6256, 0 )
        call ReviveHero( u,-780, 6256, true )
    elseif  IsUnitAlly( u, Player(6)) then
        call PanCameraToTimedForPlayer( GetOwningPlayer(u), 90, -7200, 0 )
        call ReviveHero( u, 90, -7200, true )
    endif
    call PauseTimer(t)
    call DestroyTimer(t)
    call DestroyTimerDialog( td )
    call FlushChildHashtable( udg_GameCore, GetHandleId(t) )    
endfunction

function Trig_Death_System_Actions takes nothing returns nothing
    local unit killer = GetKillingUnit()
    local unit u = GetTriggerUnit()
    local real duration = GetUnitLevel( u )*5    
    local timer t = CreateTimer()
    local timerdialog td = CreateTimerDialog(t)
    
    if( killer != null and GetPlayerController( GetOwningPlayer(killer) ) == MAP_CONTROL_USER and udg_FirstKill == FALSE) then
        set udg_FirstKill = TRUE
        call DisplayTextToForce( bj_FORCE_ALL_PLAYERS, "|cffFF0000FIRST BLOOD!|r +200 big dollaz!" )
        call AdjustPlayerStateBJ( 200, GetOwningPlayer(killer), PLAYER_STATE_RESOURCE_GOLD )
    endif
    
    call AdjustPlayerStateBJ( -200, GetOwningPlayer(u), PLAYER_STATE_RESOURCE_GOLD )
    
    call SaveUnitHandle( udg_GameCore, GetHandleId(t), 0, u )
    call SaveTimerDialogHandle( udg_GameCore, GetHandleId(t), 1, td )
    call TimerStart(t, duration, false, function ReviveTimer )
    call TimerDialogSetTitle( td, GetUnitName( u ) )
    call TimerDialogDisplay( td, true ) 
    set udg_PlayerDeath[ GetPlayerId(GetOwningPlayer(u)) ] = udg_PlayerDeath[ GetPlayerId(GetOwningPlayer(u)) ] + 1
    call ChangePlayerValue( GetOwningPlayer(u), 2, udg_PlayerDeath[ GetPlayerId(GetOwningPlayer(u)) ] )
endfunction

//===========================================================================
function InitTrig_Death_System takes nothing returns nothing
    set gg_trg_Death_System = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventNL( gg_trg_Death_System, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Death_System, Condition( function Trig_Death_System_Conditions ) )
    call TriggerAddAction( gg_trg_Death_System, function Trig_Death_System_Actions )
endfunction

I was just wondering if someone could sift through this and point out any obivous failure or mistakes coding-wise. Right now the system only works 90% of the time, which makes it very strange.
08-10-2009, 07:19 PM#2
Pyrogasm
What do you mean by "only works 90% of the time"? What exactly is going wrong?

Try placing some Debug messages to make sure all of the parts of your script are running properly. If nothing seems apparent, it could just be an inherent Hashtable bug that nobody's reported yet.