• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Condition Evaluation

Status
Not open for further replies.
Level 20
Joined
May 16, 2012
Messages
635
hey guys! In my map i've created a function that change the ownership of a hero in a region to a player if the slot occupied belongs to a user player and the number of heroes owned by that user player is equal to 0, part of the code below:

JASS:
loop
            exitwhen bj_forLoopAIndex > 8
            if ((CountUnitsInGroup(GetUnitsOfPlayerMatching(Player(bj_forLoopAIndex - 1), Condition(function Filter_Func))) == 0) and (GetPlayerController(Player(bj_forLoopAIndex - 1)) == MAP_CONTROL_USER)) then
                set u = GroupPickRandomUnit(GetUnitsInRectMatching(gg_rct_Hero_Selection_Region, Condition(function Filter_Func)))
                set l = Location(GetRectCenterX(udg_Final_Wave_Player_Region[bj_forLoopAIndex]), GetRectCenterY(udg_Final_Wave_Player_Region[bj_forLoopAIndex]))
                call SetUnitOwner( u, Player(bj_forLoopAIndex - 1), true )
                call SetUnitPositionLoc(u, l)
                call PauseUnit( u, false )
                set bj_lastCreatedItem = CreateItem('ankh', GetUnitX(u), GetUnitY(u))
                call UnitAddItem( u, bj_lastCreatedItem)
                set bj_lastCreatedItem = CreateItem('pghe', GetUnitX(u), GetUnitY(u))
                call UnitAddItem( u, bj_lastCreatedItem)
                call SmartCameraPanBJModified(Player(bj_forLoopAIndex - 1), l, 0.00)
                call SetUnitInvulnerable( u, false )
                call SetPlayerState(Player(bj_forLoopAIndex - 1), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(bj_forLoopAIndex - 1), PLAYER_STATE_RESOURCE_GOLD) + 1000000)
                set udg_Alredy_Owned[bj_forLoopAIndex] = 1
                set udg_Hero_Selected[bj_forLoopAIndex] = u
                call DestroyTrigger( gg_trg_SelectionPlayer1 )
                call DestroyTrigger( gg_trg_SelectionPlayer2 )
                call DestroyTrigger( gg_trg_SelectionPlayer3 )
                call DestroyTrigger( gg_trg_SelectionPlayer4 )
                call DestroyTrigger( gg_trg_SelectionPlayer5 )
                call DestroyTrigger( gg_trg_SelectionPlayer6 )
                call DestroyTrigger( gg_trg_SelectionPlayer7 )
                call DestroyTrigger( gg_trg_SelectionPlayer8 )
                call RemoveLocation(l)
                set l = null
                set u = null
            endif
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop

The problem is, when this code is required, all slots with Open status also get a hero, and i dont understand why, because im checking if the player controller is a user, and i've tried to add one more condition that checked if the controller was None and still it didnt work. How to solve this?
 
Status
Not open for further replies.
Top