HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problem with Auto-Revive

12-23-2009, 02:08 AM#1
FootysMaXeD
Hey, i have a little bug with my Auto-Revive trigger. I only use GUI atm, so maybe you can consider that in your responses. The revival works fine, but the only problem is that the Timer Window doesn't show any numbers for some players and works for others. It will just say "Hero will revive in: " and no number.

Here is the converted code:
Collapse JASS:
function Trig_Revive_Heroes_Copy_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    if ( not ( IsPlayerInForce(GetOwningPlayer(GetTriggerUnit()), GetPlayersAll()) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Revive_Heroes_Copy_Func009C takes nothing returns boolean
    if ( not ( TimerGetRemaining(udg_HeroReviveTimer[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]) > 0.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Revive_Heroes_Copy_Func010001 takes nothing returns boolean
    return ( udg_RevivingNow[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] == false )
endfunction

function Trig_Revive_Heroes_Copy_Func018C takes nothing returns boolean
    if ( not ( IsPlayerInForce(GetOwningPlayer(GetTriggerUnit()), GetPlayersAll()) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Revive_Heroes_Copy_Actions takes nothing returns nothing
    local timerdialog WINDOW
    local integer HEROWAIT
    local unit OURHERO
    set OURHERO = GetTriggerUnit()
    set HEROWAIT = ( GetHeroLevel(OURHERO) * 3 ) + 27
    set udg_AA = GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit()))
    call DisplayTextToForce( udg_AA, ( "Your hero will be revived in: " + ( I2S(( 27 + ( GetHeroLevel(GetTriggerUnit()) * 3 ) )) + " seconds!" ) ) )
    call DestroyForce(udg_AA)
    if ( Trig_Revive_Heroes_Copy_Func009C() ) then
        set udg_WaitingHeros[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = ( GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) + 1 )
        call TriggerSleepAction( ( TimerGetRemaining(udg_HeroReviveTimer[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]) + I2R(udg_WaitingHeros[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]) ) )
        set udg_WaitingHeros[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = ( GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1 )
    else
    endif
    loop
        exitwhen ( Trig_Revive_Heroes_Copy_Func010001() )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 1))
    endloop
    set udg_RevivingNow[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = true
    call StartTimerBJ( udg_HeroReviveTimer[GetConvertedPlayerId(GetOwningPlayer(OURHERO))], false, I2R(HEROWAIT) )
    call CreateTimerDialogBJ( udg_HeroReviveTimer[GetConvertedPlayerId(GetOwningPlayer(OURHERO))], "Hero Revive in:" )
    set WINDOW = GetLastCreatedTimerDialogBJ()
    call TimerDialogDisplayBJ( false, WINDOW )
    call TimerDialogDisplayForPlayerBJ( true, WINDOW, GetOwningPlayer(OURHERO) )
    call PolledWait( HEROWAIT )
    if ( Trig_Revive_Heroes_Copy_Func018C() ) then
        call ReviveHeroLoc(OURHERO, GetPlayerStartLocationLoc(GetOwningPlayer(OURHERO)), true )
    else
    endif
    call DestroyTimerDialog(WINDOW)
    set udg_RevivingNow[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = false
endfunction

//===========================================================================
function InitTrig_Revive_Heroes_Copy takes nothing returns nothing
    set gg_trg_Revive_Heroes_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Revive_Heroes_Copy, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Revive_Heroes_Copy, Condition( function Trig_Revive_Heroes_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Revive_Heroes_Copy, function Trig_Revive_Heroes_Copy_Actions )
endfunction

Thank you
12-23-2009, 06:51 AM#2
DioD
Try to debug yourself.

I see no debug messages at all.
12-23-2009, 06:59 AM#3
MysticGeneral
I prefer to see GUI work posted back in GUI. I do not code anything like the converted versions. Please send the original GUI version.
12-23-2009, 07:11 AM#4
MysticGeneral
Collapse JASS:
call CreateTimerDialogBJ( udg_HeroReviveTimer[GetConvertedPlayerId(GetOwningPlayer(OURHERO))], "Hero Revive in:" )


Is where your problem lies in. It is a simple error. You never even put a number after "revive in:"
12-23-2009, 08:07 AM#5
DioD
Quote:
works for others

Magic?
12-24-2009, 04:39 AM#6
TheWye
Quote:
Is where your problem lies in. It is a simple error. You never even put a number after "revive in:"
No its not. This is supposed to be just the window title. You are not supposed to put any number there.

Collapse JASS:
call CreateTimerDialogBJ( udg_HeroReviveTimer[GetConvertedPlayerId(GetOwningPlayer(OURHERO))], "Hero Revive in:" )
I'm pretty suspicious of this line. Aren't you supposed to put a -1 after you convert the player Id because of the array index? I mean array index goes from 0 to LAST_PLAYER_NUMBER - 1 while player Id goes from 1 to LAST_PLAYER_NUMBER. If you don't want to put a -1 then you need to use GetPlayerId instead of GetConvertedPlayerId. There are actually a number of this cases in your entire code where array index does not match player index. Maybe you try fixing this first and see what happens.

@DioD
Have you ever considered giving an actually helpful comment for once in your post? :p
12-24-2009, 08:32 AM#7
Tot
Quote:
Originally Posted by TheWye
No its not. This is supposed to be just the window title. You are not supposed to put any number there.

Collapse JASS:
call CreateTimerDialogBJ( udg_HeroReviveTimer[GetConvertedPlayerId(GetOwningPlayer(OURHERO))], "Hero Revive in:" )
I'm pretty suspicious of this line. Aren't you supposed to put a -1 after you convert the player Id because of the array index? I mean array index goes from 0 to LAST_PLAYER_NUMBER - 1 while player Id goes from 1 to LAST_PLAYER_NUMBER. If you don't want to put a -1 then you need to use GetPlayerId instead of GetConvertedPlayerId. There are actually a number of this cases in your entire code where array index does not match player index. Maybe you try fixing this first and see what happens.

@DioD
Have you ever considered giving an actually helpful comment for once in your post? :p

player 1 (red) has the id 0
player 2 (blue) has the id 1
...

putting an -1 there should only crash the game if player 1 is used
12-24-2009, 08:35 AM#8
DioD
array size?
12-24-2009, 09:19 AM#9
TheWye
Quote:
If you don't want to put a -1 then you need to use GetPlayerId instead of GetConvertedPlayerId

GetConvertedPlayerId(player) is a blizzard function which calls GetPlayerId(player) + 1. So:

player 1 will have Converted id 1
player 2 will have Converted id 2
player 3 will have Converted id 3
etc..
12-27-2009, 09:43 PM#10
FootysMaXeD
Quote:
Originally Posted by TheWye
No its not. This is supposed to be just the window title. You are not supposed to put any number there.

Collapse JASS:
call CreateTimerDialogBJ( udg_HeroReviveTimer[GetConvertedPlayerId(GetOwningPlayer(OURHERO))], "Hero Revive in:" )
I'm pretty suspicious of this line. Aren't you supposed to put a -1 after you convert the player Id because of the array index? I mean array index goes from 0 to LAST_PLAYER_NUMBER - 1 while player Id goes from 1 to LAST_PLAYER_NUMBER. If you don't want to put a -1 then you need to use GetPlayerId instead of GetConvertedPlayerId. There are actually a number of this cases in your entire code where array index does not match player index. Maybe you try fixing this first and see what happens.

@DioD
Have you ever considered giving an actually helpful comment for once in your post? :p

I replaced the 2 instances of "GetConvertedPlayerId" to "GetPlayerId", and the display timer seems to be working for all players now.

Thank you for the help. I'll make another post if anything goes wrong lol.
Sorry, it's not letting me +rep you TheWye because i already did it recently lol.