1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

IsUnitAliveBJ not working properly!

Discussion in 'World Editor Help Zone' started by mecatronic, Jan 14, 2010.

  1. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    "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.
     
  2. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    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.
     
  3. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Code (vJASS):
        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.
     
  4. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    what's the problem, its true so it wont really revive the hero right?
     
  5. Reaper2008

    Reaper2008

    Joined:
    Jul 27, 2008
    Messages:
    1,117
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.
    Code (vJASS):
    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?
     
  6. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    but the problem is that the function IsUnitAliveBJ sometimes returns true WHEN THE HERO IS DEAD!

    Most of the time it works, but sometimes it doesn't.
     
  7. D4RK_G4ND4LF

    D4RK_G4ND4LF

    Joined:
    Feb 4, 2009
    Messages:
    1,196
    Resources:
    20
    Models:
    3
    Spells:
    15
    Tutorials:
    2
    Resources:
    20
  8. Section

    Section

    Joined:
    Jul 23, 2008
    Messages:
    94
    Resources:
    0
    Resources:
    0
    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.
     
  9. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    instead of UnitAliveBJ use GetWidgetLife(hero) > .405