• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] hiding and unhiding units not working correctly

Status
Not open for further replies.
Level 29
Joined
Oct 24, 2012
Messages
6,543
can anyone tell me y this is not working its not hiding the units correctly and its not moving the units either thanks

JASS:
function Trig_Battlegrounds_Leader_Checker_Actions takes nothing returns nothing
    local real bx
    local real by
    local real array xP
    local real array yP
    set bx = GetRectCenterX( gg_rct_King_of_the_Battlegrounds )
    set bx = GetRectCenterY( gg_rct_King_of_the_Battlegrounds )
    set xP[0] = GetRectCenterX( gg_rct_P1_Battleground_Spawn )
    set yP[0] = GetRectCenterY( gg_rct_P1_Battleground_Spawn )
    set xP[1] = GetRectCenterX( gg_rct_P2_Battleground_Spawn )
    set xP[1] = GetRectCenterY( gg_rct_P2_Battleground_Spawn )
    set xP[11] = GetRectCenterX( gg_rct_P11_Battleground_Spawn )
    set yP[11] = GetRectCenterY( gg_rct_P11_Battleground_Spawn )
    
    if ( ( Battlegrounds_Counter_Player[0] > Battlegrounds_Counter_Player[1] ) and ( Battlegrounds_Counter_Player[0] > Battlegrounds_Counter_Player[11] ) ) then
        call SetUnitX( Battlegrounds_Leader_Unit_Player[0], bx )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[0], by )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[0], true ) // red
        call SetUnitX( Battlegrounds_Leader_Unit_Player[1], xP[1] )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[1], yP[1] )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[1], false ) // blue
        call SetUnitX( Battlegrounds_Leader_Unit_Player[11], xP[11] )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[11], yP[11] )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[11], false ) // green ( neutral ) player 11
    elseif ( ( Battlegrounds_Counter_Player[1] > Battlegrounds_Counter_Player[0] ) and ( Battlegrounds_Counter_Player[1] > Battlegrounds_Counter_Player[11] ) ) then
        call SetUnitX( Battlegrounds_Leader_Unit_Player[1], bx )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[1], by )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[1], true ) // blue
        call SetUnitX( Battlegrounds_Leader_Unit_Player[0], xP[0] )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[0], yP[0] )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[0], false ) // red
        call SetUnitX( Battlegrounds_Leader_Unit_Player[11], xP[11] )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[11], yP[11] )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[11], false ) // green ( neutral ) player 11
    elseif ( ( Battlegrounds_Counter_Player[11] >= Battlegrounds_Counter_Player[0] ) and ( Battlegrounds_Counter_Player[11] >= Battlegrounds_Counter_Player[1] ) ) then
        call SetUnitX( Battlegrounds_Leader_Unit_Player[11], bx )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[11], by )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[11], true ) // green ( neutral ) player 11
        call SetUnitX( Battlegrounds_Leader_Unit_Player[0], xP[0] )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[0], yP[0] )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[0], false ) // red
        call SetUnitX( Battlegrounds_Leader_Unit_Player[1], xP[1] )
        call SetUnitY( Battlegrounds_Leader_Unit_Player[1], yP[1] )
        call ShowUnit( Battlegrounds_Leader_Unit_Player[1], false ) // blue
    endif
    
endfunction

//===========================================================================
function InitTrig_Battlegrounds_Leader_Checker takes nothing returns nothing
    set gg_trg_Battlegrounds_Leader_Checker = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Battlegrounds_Leader_Checker, function Trig_Battlegrounds_Leader_Checker_Actions )
endfunction
 
Status
Not open for further replies.
Top