HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Leaderboard Trigger problems

11-08-2003, 10:40 PM#1
Vallian88
I have a leaderboard that shows all the players current points. You get points by killing other players units or towers. The problem is that I also have a trigger that randomly spwans a tower, 7 footmen, and 5 riflemen. I want the leaderboard to be created after everyone has had their units spwaned. Heres my triggers.

Spwan:
Event
Map Initialization
Actions
Trigger - Run Random Intiger <gen> (ignoring conditions)
Unit Group - Pick every unit in (Units in spwanregions[randomint]) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Scout Tower
Then - Actions
Wait 0.01 seconds
Trigger - Run (This trigger) (ignoring conditions)
Else - Actions
Camera - Pan camera for (Picked player) to (Center of spwanregions[randomint]) over 0.00 seconds
Unit - Create 1 Scout Tower for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees
Unit - Create 7 Footman for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees
Unit - Create 5 Rifleman for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees

Leaderboard:
Actions
Leaderboard - Create a leaderboard for (All players) titled Points
Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Leaderboard - Add (Picked player) to (Last created leaderboard) with label (Name of (Picked player)) and value 0)
Leaderboard - Show (Last created leaderboard)

Now how do I make an event of when trigger "spwan" ends. I want that to be my event for trigger "Leaderboard".
Also my leaderboard dosen't seem to change when I make kills. Heres my trigger for that:

Events
Unit - A unit owned by Player 1 (Red) Dies
Unit - A unit owned by Player 2 (Blue) Dies
Unit - A unit owned by Player 3 (Teal) Dies
Unit - A unit owned by Player 4 (Purple) Dies
Unit - A unit owned by Player 5 (Yellow) Dies
Unit - A unit owned by Player 6 (Orange) Dies
Unit - A unit owned by Player 7 (Green) Dies
Unit - A unit owned by Player 8 (Pink) Dies
Conditions
(Unit-type of (Dying unit)) Equal to Footman
(Owner of (Triggering unit)) Not equal to (Owner of (Killing unit))
Actions
Set Points[(Player number of (Owner of (Killing unit)))] = Points[((Player number of (Owner of (Killing unit))) + 1)]
Leaderboard - Change the value for (Owner of (Killing unit)) in (Last created leaderboard) to Points[(Player number of (Owner of (Killing unit)))]
Leaderboard - Sort (Last created leaderboard) by Value in Descending order

Could someone tell me whats wrong with my triggers?
11-08-2003, 11:08 PM#2
AllPainful
First off, your Spawn trigger won't work right... you might want to go back to The other board and read it, I updated it and sent you a PM...



As for making your leaderboard trigger run after the other finished, put an action at the end of the other one called "Trigger run (leaderboard)" to run the leaderboard trigger (make sure your run trigger action is not in one of your loops, otherwise it would be run multiple times.)


ALSO: (last created leaderboard) won't work right in your update trigger and thats why its not updating.

Make a variable for the leaderboard, and set the variable to "Last Created Leaderboard" RIGHT after its created (set the variable BEFORE the "Show last created leaderboard, and use the variable there instead and that way if the leaderboard shows up you know you did it right.), then use the variable instead of "Last Created Leaderboard"
11-09-2003, 03:41 AM#3
Vallian88
I did what you told me but I still have the same problems. Sometimes the towers are spawned in the same region, and the leaderboard isn't changing.
Heres my triggers for spwaning:

Actions
Set canbuild = True
Trigger - Run Random Intiger <gen> (ignoring conditions)
Unit Group - Pick every unit in (Units in spwanregions[randomint]) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Scout Tower
Then - Actions
Set canbuild = False
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
canbuild Equal to True
Then - Actions
Camera - Pan camera for (Picked player) to (Center of spwanregions[randomint]) over 0.00 seconds
Unit - Create 1 Scout Tower for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees
Unit - Create 7 Footman for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees
Unit - Create 5 Rifleman for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees
Else - Actions
Wait 0.01 seconds
Trigger - Run Spwan <gen> (checking conditions)

And heres the my trigger for the leaderboard:

Create Leaderboard
Actions
Leaderboard - Create a leaderboard for (All players) titled Points
Set leaderboard = (Last created leaderboard)
Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Leaderboard - Add (Picked player) to leaderboard with label (Name of (Picked player)) and value 0)
Leaderboard - Show leaderboard

Update Scoreboard Footman
Events
Unit - A unit owned by Player 1 (Red) Dies
Unit - A unit owned by Player 2 (Blue) Dies
Unit - A unit owned by Player 3 (Teal) Dies
Unit - A unit owned by Player 4 (Purple) Dies
Unit - A unit owned by Player 5 (Yellow) Dies
Unit - A unit owned by Player 6 (Orange) Dies
Unit - A unit owned by Player 7 (Green) Dies
Unit - A unit owned by Player 8 (Pink) Dies
Conditions
(Unit-type of (Dying unit)) Equal to Footman
(Owner of (Triggering unit)) Not equal to (Owner of (Killing unit))
Actions
Set Points[(Player number of (Owner of (Killing unit)))] = Points[((Player number of (Owner of (Killing unit))) + 1)]
Leaderboard - Change the value for (Owner of (Killing unit)) in leaderboard to Points[(Player number of (Owner of (Killing unit)))]
Leaderboard - Sort leaderboard by Value in Descending order
11-09-2003, 05:17 AM#4
AllPainful
Ok... well your first trigger:

Actions
Set canbuild = True
Trigger - Run Random Intiger <gen> (ignoring conditions)
Unit Group - Pick every unit in (Units in spwanregions[randomint]) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Scout Tower
Then - Actions
Set canbuild = False
Else - Actions
Everything below this point is NOT in the pick units loop, Right? because its not supposed to be. Everything below this point is supposed to run AFTER the pick all units loop is done.
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
canbuild Equal to True
Then - Actions
Camera - Pan camera for (Picked player) to (Center of spwanregions[randomint]) over 0.00 seconds
Unit - Create 1 Scout Tower for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees
Unit - Create 7 Footman for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees
Unit - Create 5 Rifleman for (Picked player) at (Random point in spwanregions[randomint]) facing Default building facing degrees
Else - Actions
Wait 0.01 seconds
Trigger - Run Spwan <gen> (checking conditions)

Your create board looks fine.. Update trigger:

Update Scoreboard Footman
Events
Unit - A unit owned by Player 1 (Red) Dies
Unit - A unit owned by Player 2 (Blue) Dies
Unit - A unit owned by Player 3 (Teal) Dies
Unit - A unit owned by Player 4 (Purple) Dies
Unit - A unit owned by Player 5 (Yellow) Dies
Unit - A unit owned by Player 6 (Orange) Dies
Unit - A unit owned by Player 7 (Green) Dies
Unit - A unit owned by Player 8 (Pink) Dies
Conditions
(Unit-type of (Dying unit)) Equal to Footman
(Owner of (Triggering unit)) Not equal to (Owner of (Killing unit))
Actions
Set Points[(Player number of (Owner of (Killing unit)))] = Points[((Player number of (Owner of (Killing unit))) + 1)] That +1 should be OUTSIDE the ] and not inside because inside is the array number, so essencially what this action is doing is, if player 1 killes a unit the action would read "Set Points[1] = Points[2]" and because all the points are 0 you get no change...
Leaderboard - Change the value for (Owner of (Killing unit)) in leaderboard to Points[(Player number of (Owner of (Killing unit)))]
Leaderboard - Sort leaderboard by Value in Descending order


And last but not least, your "Ranomint" is a variable right? Well, the problem is if in mid trigger another trigger runs and resets the Randomint variable to another number your going to have problems... So you should prolly make your randomint an array so each player will have their own "randomint" variable to make it less likely that 2 triggers using the same variable might run at the same time...
11-09-2003, 05:41 AM#5
Vallian88
I made canbuild and randomint into arrays so they dosen't get mixed up. This is my trigger as it stands:

The returns seperate different parts of the trigger.

Spwan
Events
Conditions
Actions
Set canbuild[(Player number of (Picked player))] = True

Trigger - Run Random Intiger <gen> (ignoring conditions)

Unit Group - Pick every unit in (Units in spwanregions[randomint[(Player number of (Picked player))]]) and do (Actions)
Loop - Actions

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Scout Tower
Then - Actions
Set canbuild[(Player number of (Picked player))] = False
Else - Actions
Do nothing

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
canbuild[randomint[(Player number of (Picked player))]] Equal to True
Then - Actions
Camera - Pan camera for (Picked player) to (Center of spwanregions[randomint[(Player number of (Picked player))]]) over 0.00 seconds
Unit - Create 1 Scout Tower for (Picked player) at (Center of spwanregions[randomint[(Player number of (Picked player))]]) facing Default building facing degrees
Unit - Create 7 Footman for (Picked player) at (Center of spwanregions[randomint[(Player number of (Picked player))]]) facing Default building facing degrees
Unit - Create 5 Rifleman for (Picked player) at (Center of spwanregions[randomint[(Player number of (Picked player))]]) facing Default building facing degrees
Else - Actions
Wait 0.01 seconds
Trigger - Run Spwan <gen> (checking conditions)

Could someone please tell me whats wrong?
11-09-2003, 06:41 AM#6
AllPainful
Picked player???

You don't have a "Pick All Players" in the trigger, so picked player doesn't work...

I suggest making the trigger an all "Player 1" trigger, and then copying it and changing the copy to player 2 and so on.. otherwise your going to end up making your triggers VERY complicated...

UNLESS.. Is this a 1 time run trigger? If it is then you can do a pick all players, but if it needs to run when a player dies, and only run for that player, then you can't use a pick all players..
11-09-2003, 04:10 PM#7
Vallian88
I do have a pick all players this is my initilization trigger:

Initialization
Events
Map initialization
Conditions
Actions
Player Group - Pick every player in Player Group - Player 1 (Red) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 2 (Blue) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 3 (Teal) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 4 (Purple) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 5 (Yellow) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 6 (Orange) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 7 (Green) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 8 (Pink) and do (Trigger - Run Spwan <gen> (checking conditions))
Wait 0.01 seconds
Trigger - Run Create Leaderboard <gen> (ignoring conditions)

I want this trigger to go off consecutively, waiting for each trigger it starts to finish before it continues.
11-09-2003, 05:46 PM#8
AllPainful
I do not believe that will fuction properly...

Picked Player will not transfer across triggers...

But I could be wrong...
11-09-2003, 05:58 PM#9
Vallian88
Well when I test it, it does work but I still have the problem of people spwaning in the same area. But lately it hasn't been happening... I'll keep testing.
11-09-2003, 06:36 PM#10
AllPainful
Cool, glad to hear its not happening right now...

If the problem does persist, then perhaps you might want to break your "Spawn" trigger into separate triggers, and put a wait between them.

Also, I have a question:


Player Group - Pick every player in Player Group - Player 1 (Red) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 2 (Blue) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 3 (Teal) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 4 (Purple) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 5 (Yellow) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 6 (Orange) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 7 (Green) and do (Trigger - Run Spwan <gen> (checking conditions))
Player Group - Pick every player in Player Group - Player 8 (Pink) and do (Trigger - Run Spwan <gen> (checking conditions))

Are all those players users?

If so then all you need is 1 pick player.

Player Group - Pick all players matching condition player controller (matching player) is equal to User and do do (Trigger - Run Spwan <gen> (checking conditions))

And that will pick each player individually and run the "Spawn" trigger for them...

Or you can just do:

Player Group - Pick every player in Player Group - (All Players) and do (Trigger - Run Spwan <gen> (checking conditions))

But that one would do the spawn for computer players too...
11-09-2003, 08:04 PM#11
Vallian88
Ok it still happens. I can't figure out the problem. Heres a copy of what I have gotten done so far, if you can fix it you will have the credit.
11-10-2003, 02:03 AM#12
AllPainful
Found the problem.

This wasn't in the Loop, it was AFTER the loop, its supposed to be in the loop:
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Unit-type of (Picked unit)) Equal to Scout Tower
    Then - Actions
        Set canbuild[(Player number of (Picked player))] = False
    Else - Actions
        Set canbuild[(Player number of (Picked player))] = True

I fixed it and attached it.

It had another problem too.. Your else actions, they shouldn't be there. Because what if the it picks another unit after it picks the scout tower? It would set the variable back to true even though it should be false.

If the problem still persists let me know and I will take another look at it, but it should be fine now.
11-10-2003, 02:47 AM#13
Vallian88
I think my initialization has a problem because none of my units are spwaning. How do I get it to run as many times as there are players in the game(this is a multiplayer game) for each of those players?
This is what it looks like right now:

Initialization
Events
Map initialization
Conditions
Actions
Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Trigger - Run Spwan <gen> (checking conditions))
Wait 0.01 seconds
Trigger - Run Create Leaderboard <gen> (ignoring conditions)
11-10-2003, 03:48 AM#14
AllPainful
My suggestion, copy everything that is in the "Spawn" trigger, and paste it in the loop (after the "Loop" and before your "run trigger") and then delete your "Run Trigger(Spawn)" from the init.
11-10-2003, 01:35 PM#15
Vallian88
Initialization
Events
Map initialization
Conditions
Actions
Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Do nothing)
Trigger - Run Random Integer <gen> (ignoring conditions)
Unit Group - Pick every unit in (Units in spwanregions[randomint[(Player number of (Picked player))]]) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Scout Tower
Then - Actions
Set canbuild[(Player number of (Picked player))] = False
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
canbuild[randomint[(Player number of (Picked player))]] Equal to True
Then - Actions
Camera - Pan camera for (Picked player) to (Center of spwanregions[randomint[(Player number of (Picked player))]]) over 0.00 seconds
Unit - Create 1 Scout Tower for (Picked player) at (Center of spwanregions[randomint[(Player number of (Picked player))]]) facing Default building facing degrees
Unit - Create 7 Footman for (Picked player) at (Center of spwanregions[randomint[(Player number of (Picked player))]]) facing Default building facing degrees
Unit - Create 5 Rifleman for (Picked player) at (Center of spwanregions[randomint[(Player number of (Picked player))]]) facing Default building facing degrees
Else - Actions
Wait 0.01 seconds
Trigger - Run Spwan <gen> (checking conditions)
Wait 0.01 seconds
Trigger - Run Create Leaderboard <gen> (ignoring conditions)

Because my units still arn't spwaning.