• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Condition Evaluation

Status
Not open for further replies.
Level 21
Joined
May 16, 2012
Messages
644
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