Hello there everyone. I used to be quite adept at JASS, and left a while ago. I am taking up a new map project now, however. Trying to get back in the groove, I started with something really simple. A "if the player slot wasn't filled, remove their hero." I did a long line of if statements to solve this, with it acting on map initialization. It went from that, to finally these two functions that I have it at now.
and
* udg_character is a global array that has been preset with each corresponding player's hero. (e.g. udg_character[0] is red's hero, udg_character[11] is brown's). A variable is used because this unit _will_ change over time. Transformations and etc. are going to be applied, leaving it as a separate unit.
Two functions are used in this case, because I want to be able to call remove_player_unit in other situations (i.e. if someone is kicked, not just doing one check at the initialization).
I have one question, however. Some of the players have multiple heroes. Mainly purple and yellow. Purple's will go back and forth between one and two, and yellow will go from three to one, and remain that way. Is there any way I can efficiently write "kill all units owned by player(x)" or "kill all units in group X?" I am trying to keep the code as efficient as possible, as it is going to be quite a big map.
thanks in advance!
Travis
Code:
function remove_player_unit takes integer x returns nothing
local unit character = udg_character[x] *
call TriggerSleepAction( 120.00 )
call PingMinimap (GetUnitX(character), GetUnitY(character), 2.00)
call KillUnit( character )
set character = null
endfunction
Code:
function check_empty takes nothing returns nothing
local integer x = 0
loop
exitwhen x==12
if ( GetPlayerSlotState(Player(x)) != PLAYER_SLOT_STATE_PLAYING ) then
call remove_player_unit(x)
endif
set x = x+1
endloop
endfunction
Two functions are used in this case, because I want to be able to call remove_player_unit in other situations (i.e. if someone is kicked, not just doing one check at the initialization).
I have one question, however. Some of the players have multiple heroes. Mainly purple and yellow. Purple's will go back and forth between one and two, and yellow will go from three to one, and remain that way. Is there any way I can efficiently write "kill all units owned by player(x)" or "kill all units in group X?" I am trying to keep the code as efficient as possible, as it is going to be quite a big map.
thanks in advance!
Travis