| 01-27-2004, 02:25 PM | #1 |
Alright, this one trigger is giving me a serious headache. :( What it's supposed to do is... basically, divide players' heroes into 2 teams (as even as possible), randomly. I then set alliance settings in another trigger, but that's not the point. This trigger works fine... most of the time. The woes usually start once players leave. I don't know if it has anything to do with it, but it never happend before players left. The problem is that sometimes, the trigger will change the color of the wrong hero, and transport it to the wrong rect. However, when it sets the alliance settings (based on whatever random heroes it picked), it seems to work the way it should work, and the hero transported to the wrong rect will be attacked by the other team. Here's the trigger: Code:
Random Teams
Events
Time - PickHeroes expires
Time - NextBattle expires
Conditions
Actions
Set PlayerNumber = 0
Set Thingy1 = 0
Set Thingy2 = 0
Unit Group - Remove all units from UnitGroup
Player Group - Remove all players from Team1
Player Group - Remove all players from Team2
Wait 0.00 seconds
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Player((Integer A))) slot status) Equal to (==) Is playing
((Player((Integer A))) slot status) Not equal to (!=) Has left the game
Then - Actions
Set PlayerNumber = (PlayerNumber + 1)
Unit Group - Pick every unit in (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to (==) True)) and do (Unit Group - Add (Picked unit) to UnitGroup)
Else - Actions
Unit Group - Pick every unit in (Random (PlayerNumber / 2) units from UnitGroup) and do (Actions)
Loop - Actions
Set Thingy1 = (Thingy1 + 1)
Player Group - Add (Owner of (Picked unit)) to Team1
Set Team1Array[Thingy1] = (Owner of (Picked unit))
Unit - Change color of (Picked unit) to Gray
Unit Group - Remove (Picked unit) from UnitGroup
Unit Group - Pick every unit in UnitGroup and do (Actions)
Loop - Actions
Set Thingy2 = (Thingy2 + 1)
Player Group - Add (Owner of (Picked unit)) to Team2
Set Team2Array[Thingy2] = (Owner of (Picked unit))
Unit - Change color of (Picked unit) to Orange
Unit Group - Remove (Picked unit) from UnitGroupI know I'm probably not making much sense, I'm not very good at explaining myself... but if anyone can find what's wrong with this trigger, I'd be forever grateful. ;) And if not, just say so and I'll try to explain myself better. Thanks in advance! Edit: by Lord Vexorian, Use [code] not [quote] ! |
| 01-28-2004, 08:23 AM | #2 |
Alright... since no one is helping, and I *am* desperate, I'll throw in a little motivator... 100 points will go to the person who helps me figure this out. Sounds good enough? :P If you can't find anything wrong with this trigger, I'll post my other ones, since the problem could be there. Thanks. |
| 01-28-2004, 08:49 AM | #3 |
One error, you need only one condition to check if the player is playing or not, if he "Is playing", he is, else he's not in the game OR have left the game. "Unit Group - Pick every unit in (Random (PlayerNumber / 2) units from UnitGroup) and do (Actions)" - What's this good for?? Why random unit with half of the player number in the unit group? I really don't get it? What are you SUPOSE to do with this line? I'm sensing this is your problem... It only picks half of the units, thus you get decolorations and stuff like that :P. Regards Dead-Inside |
| 01-28-2004, 09:04 AM | #4 |
Yeah, at first I only had one condition, but I thought this might be the problem, so I tried adding the other one... needless to say it didn't work. I'll try to explain better. Each player gets to pick ONE hero. So, I check for player slot status, if player is playing, it adds his hero to UnitGroup, which is a unit group variable. Then, I need to assign players to 2 teams randomly. So, my trigger picks [Amount of Players / 2] random heroes from UnitGroup, changes their color, and removes them from UnitGroup. (a different trigger then sets their alliance status as well as teleport them to a region) Then it picks whatever heroes are left in UnitGroup, and does the same thing for them. It works fine until a player leaves, and even then it only sometimes messes up. Hope it's clearer now, if not, I'll just post my map so you can see all the triggers. Thanks. :) |
| 01-29-2004, 08:39 AM | #5 |
I think I know what's causing it now. My Team1Array and Team2Array weren't being cleared. Which means that when players leave, and it assigned, for example, Team2Array[6] to a person which is still in game, another trigger could teleport it to a different rect. :P Okay... so now my question is, how do I clear/destroy player arrays/variables? Is there any way to do it other than to set the array/variable to equal to a blank player variable? And would that even work? Thanks. :P |
| 01-29-2004, 10:38 AM | #6 | |
Quote:
Edit: NM, i was wrong about one being able to set a player-variable to null with the "set variable". However, you can do it the following way: Code:
Events
Whatever you want
Conditions
Whatever you want
Actions
For each (Integer i) from 1 to N, do (Actions)
Loop - Actions
Set Players[i] = PlayerBlankPlayers is your players-array, and PlayerBlank is a player-variable which has not been set ( = it's still default; null/blank) Other than that, i cant spot any other flaws in your trigger than what Dead-Inside pointed out. My advice would be to add debugging text-outputs in the trigger, so you can see if there's anything messed up with the variables. |
