Warcraft III resources & community, 2003–2006 · archived

problem with changing unit control

21 posts
#1

problem with changing unit control

i want it so that when a player leaves, his units change control, but i want it so they only change control to his allies that are still playing the game, because sometimes it is changing it to his allies that have left the game already, and sometimes it doesnt change control all all..

this is my code

Unit Group - Pick every unit in (Units owned by nextpersondoom) and do (If (((Random player from (All allies of (Triggering player))) slot status) Equal to Is playing) then do (Unit - Change ownership of (Picked unit) to (Matching player) and Change color) else do (Do nothing))


tell me what is wrong please.
#2
Try this:

Event:
Map initialization
Conditions:
(player1) is playing equal to false / Player slot 1 is equal to not playing/unused
Action:
if/then/else
If (Player2) is equal to playing, then Player- make player 2 treat player 1 as an ally with full shared unit control or else Do nothing
(repeat action until all players are covered...make sure "do nothing" is inputted in the "or else" section or further actions will not spring. Repeat entire trigger until all players are covered at map start)

-VGsatomi
#3
You could make that ever so slightly slicker by doing a For loop encompassing the player numbers of all the players and putting the actions inside that, referring to Player (Integer A) and the player that's left, instead of pasting the code in several times.
#4
i dont think you understood right. this doesnt have to do with map initialization. i am trying to change unit control to an ally of a player when he leaves in the middle of the game. ....so theres 3 allys, one of them leaves, i want his units to go to split between the remaining 2 allys. see?
#5
It shouldn't take a whole lot of creative energy for you to change the trigger that he gave you into one that fires when a player leaves the game and changes control of just that player's units.
#6
it may be easy for you but i am a new map maker and i dont know anything about for loop a fuctions thats why i came to this forum. if someone can tell me the exact trigger or spend a minute or 2 and make a test map with the trigger on it and link me to it i will appreciate it a lot.
#7

Re: problem with changing unit control

drumminforevi want it so that when a player leaves, his units change control, but i want it so they only change control to his allies that are still playing the game, because sometimes it is changing it to his allies that have left the game already, and sometimes it doesnt change control all all..

this is my code

Unit Group - Pick every unit in (Units owned by nextpersondoom) and do (If (((Random player from (All allies of (Triggering player))) slot status) Equal to Is playing) then do (Unit - Change ownership of (Picked unit) to (Matching player) and Change color) else do (Do nothing))


1. To your trigger: You used "Matching Player", but I can't see a matching-condition anywhere, and without the events/conditions I can't help there.

2. To Panto's last: It's not that difficult. There's an event called "Player - [SpecificPlayerHere] leaves the game". From here you should be able to build an action like VGsatomi said that checks whos playing and who not and give the units to the active players. Do this for every player.
#8
Make a Player group, that's including all players playing from start, and remove them from the group if they leave and change control to a random player from the Player group.
#9
to the last guy that said player group. that would not work since it would throw control to enemy units since there are 4 teams of 3

to darky. i dont have any matching player conditions, i just am not that good with triggers so i thought matching player was supposed to go right there.
#10
OK, post your current whole trigger here and I'll correct it. But be patient, I'm currently working on some stuff for two guys here.

btw, darkshadow, not darky (else darky28 would wonder :wink: )
#11
drumminforevto the last guy that said player group. that would not work since it would throw control to enemy units since there are 4 teams of 3

to darky. i dont have any matching player conditions, i just am not that good with triggers so i thought matching player was supposed to go right there.


i'd do it with player groups personally, just make one for each team... but if u want to use ur current trigger it would be fixed to something like (i don't have the editor open right now so this is coming from the top of my head)

set up a int variable, nTemp (could use player too, but i use ints all the time)

event -
player leaves the game
cond -
none
action -
pick every unit in (units owned by triggering player) and do
+ set nTemp = player number of (random player from (allies of triggering player) matching (matching player slot status equal to playing))
unit - change ownership of (picked unit) to (convert player number to player (nTemp) ) and change color

if u wanted it to give every unit to a random player instead of distrubuting hte units randomly u would put the set nTemp thing before the pick every units
#12
drumminforevto the last guy that said player group. that would not work since it would throw control to enemy units since there are 4 teams of 3


Well, use array then, 1-4 for each player group, sort them into that from beginning and fix the rest with some if/then/else's
#13
my map is havening major issues. the triggers only work half of the time, so i am including a link to download my map if anyone can help correct the code.

several problems i have (this is a footmen wars type map)
1) when a player leaves the game, all his units chang ownership to a random ally that is playing, that work, and he begins to spawn zombies no matter what unit he was previously spawning, and half of the time it continues spawning regular units, which isnt what it supposed to do after he left , but i dont know how to get the units to spawn in ownership of the chosen ally, because they are still concidered the left players units which makes them useless

2) when a player gets his town hall kill, it should create a visibility modifier so he can see whole map, and that works, but when he leaves , since it is sharing changing unit ownership, the visibiility chances also, but i want it to be removed for the specific player.

3)when a player is defeated it should also spawn zombies, but somtimes it spawns zombies, sometimes regular units

4) left players or defated players should have their name removed from the scored board, but it does not always remove them...why?


here is the map
http://www.angelfire.com/vamp/out/problemed_map.w3x
#14
why do people always use the crappy loops and if statements that don't allow u to put multiple things in it? + they're 5x harder to read and 10x harder to edit
#15
ok well i just don't have the patience right now to go through ur stuff and correct it, but ur player choosing system is very strange, that would prob be the largest problem, and remove some waits, since inbetween waits variables can change and mess up things

if noone has solved it by tommorow i'll fix it for u, but i'm just lazy right now