• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

IsUnitAliveBJ not working properly!

Status
Not open for further replies.
Level 6
Joined
Jun 20, 2005
Messages
108
"Unit is Alive" not working properly!

Hi to everyone,

In my map I use a revive system that always worked, but recently I added a cheat pack for beta testing, and I had to update my revive system to check if the Hero is already alive (brought back with these cheats).

The problem is that sometimes now it doesn't revive the Hero at all! I've added a few debug messages to be sure where the bug was, and I'm pretty positive that the "Unit is Alive" is returning true BEFORE the hero gets revived.

Any clues?

Thanks in advance.
 
Hi to everyone,

In my map I use a revive system that always worked, but recently I added a cheat pack for beta testing, and I had to update my revive system to check if the Hero is already alive (brought back with these cheats).

The problem is that sometimes now it doesn't revive the Hero at all! I've added a few debug messages to be sure where the bug was, and I'm pretty positive that the "Unit is Alive" is returning true BEFORE the hero gets revived.

Any clues?

Thanks in advance.

what's the code? anyways if you do this...

  • Condition
    • Boolean - Unit is alive equal to true
  • Action
    • Revive unit
then it would definitely not revive the hero because the hero is dead before you revive it... if I misunderstood it its because you didnt post your code. Its easier to understand the problems if you post the code.
 
Level 6
Joined
Jun 20, 2005
Messages
108
JASS:
    if ( IsUnitAliveBJ(L_UNIT) == false ) then
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Unit Alive: false")
    else
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Unit Alive: true")
    endif    
    if ( IsPlayerInForce(L_PLAYER, udg_GROUP_CurrentPlayers[team]) == true ) then
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Player in Force: true")
    else
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Player in Force: false")
    endif    
    if (udg_FLAG_Victory == false) then
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Flag_Victory: false")
    else
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Flag_Victory: true")
    endif
    if ( ( IsUnitAliveBJ(L_UNIT) == false ) and ( IsPlayerInForce(L_PLAYER, udg_GROUP_CurrentPlayers[team]) == true )  ) then
        if (udg_FLAG_Victory == false) then
            call ReviveHeroLoc( L_UNIT, L_POINT2, true )
            call SetUnitManaPercentBJ( L_UNIT, 15.00 )
            call SetUnitInvulnerable( L_UNIT, true )
            call TriggerSleepAction( 3.00 )
            call SetUnitInvulnerable( L_UNIT, false )
        endif
    endif

the first displaytext functions are just debug, and the IsUnitAlive returned true according to the debug msg.
 
JASS:
    if ( IsUnitAliveBJ(L_UNIT) == false ) then
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Unit Alive: false")
    else
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Unit Alive: true")
    endif    
    if ( IsPlayerInForce(L_PLAYER, udg_GROUP_CurrentPlayers[team]) == true ) then
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Player in Force: true")
    else
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Player in Force: false")
    endif    
    if (udg_FLAG_Victory == false) then
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Flag_Victory: false")
    else
        call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Flag_Victory: true")
    endif
    if ( ( IsUnitAliveBJ(L_UNIT) == false ) and ( IsPlayerInForce(L_PLAYER, udg_GROUP_CurrentPlayers[team]) == true )  ) then
        if (udg_FLAG_Victory == false) then
            call ReviveHeroLoc( L_UNIT, L_POINT2, true )
            call SetUnitManaPercentBJ( L_UNIT, 15.00 )
            call SetUnitInvulnerable( L_UNIT, true )
            call TriggerSleepAction( 3.00 )
            call SetUnitInvulnerable( L_UNIT, false )
        endif
    endif

the first displaytext functions are just debug, and the IsUnitAlive returned true according to the debug msg.

what's the problem, its true so it wont really revive the hero right?
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
First off, it can't hurt to have faster code. Plus, more easy to debug, as it has 3 if's less, and returns directly on failure.
JASS:
if ( IsUnitAliveBJ(L_UNIT) == false ) then
    call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Unit Alive: false")
else
    call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Unit Alive: true")
    return
endif
if ( IsPlayerInForce(L_PLAYER, udg_GROUP_CurrentPlayers[team]) == true ) then
    call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Player in Force: true")
else
    call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Is Player in Force: false")
    return
endif
if (udg_FLAG_Victory == false) then
    call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Flag_Victory: false")
else
    call DisplayTimedTextToForce( udg_GROUP_Debug, 10, "Flag_Victory: true")
    return
endif
    
call ReviveHeroLoc( L_UNIT, L_POINT2, true )
call SetUnitManaPercentBJ( L_UNIT, 15.00 )
call SetUnitInvulnerable( L_UNIT, true )
call TriggerSleepAction( 3.00 )
call SetUnitInvulnerable( L_UNIT, false )

I don't see the problem here, maybe the location is uninitialized?
 
Level 4
Joined
Jul 23, 2008
Messages
99
BJ functions may result error because BJ works for GUI purposes (they use global bj_ vars to do). If you are JASS, better to use native codes and starts from now, replace BJ to natives.
 
Status
Not open for further replies.
Top