• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Problem with this leaderboard and alliance trigger

Status
Not open for further replies.
Level 2
Joined
May 25, 2016
Messages
15
Hi! I'm trying to make a dying player switch alliances to ally with player12(brown) and brown's allies, and unally everyone else. I'd also like to remove the dying player from the human leaderboard, and add them to an undead leaderboard.

Both triggers run when they are supposed to, so the problem isn't in events or conditions, its in the actions.

When in game the first leaderboard for humans works, but when a human dies they aren't removed from the human leaderboard, they aren't added to the undead leaderboard, and player12(undead) gives control, and then instantly removes control.

Can anyone help please?

This is the starting resources/leaderboard trigger at the beginning of the game:
  • Set Starting Resources and leaderboard
    • Events
      • Time - Elapsed game time is 3.00 seconds
    • Conditions
    • Actions
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Leaderboard - Create a leaderboard for Player Group - Player 12 (Brown) titled Undead Kills
      • Leaderboard - Add Player 12 (Brown) to (Last created leaderboard) with label Brown and value 0
      • Leaderboard - Create a leaderboard for (All players) titled Human Income (Every...
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (((Picked player) controller) Equal to User) then do (Leaderboard - Add (Picked player) to (Last created leaderboard) with label (Name of (Picked player)) and value 0) else do (Do nothing)
      • Player Group - Pick every player in (All enemies of Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Player - Set (Picked player) Current gold to 50
          • Unit - Create 3 Peasant for (Picked player) at (Random point in Human Playable area <gen>) facing Default building facing degrees
          • Unit - Create 1 Davos (wielding Frostmourne) for (Picked player) at (Position of (Last created unit)) facing Default building facing degrees
      • Game - Display to (All players) for 60.00 seconds the text: You have 60 seconds...
      • Leaderboard - Show (Last created leaderboard)
And here is the trigger that runs when a player "dies":
  • Humandeath
    • Events
      • Unit - A unit Dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Number of living Town Hall units owned by (Owner of (Triggering unit))) Equal to 0
          • (Number of living Peasant units owned by (Owner of (Triggering unit))) Equal to 0
          • (Number of living Davos (wielding Frostmourne) units owned by (Owner of (Triggering unit))) Equal to 0
          • (Unit-type of (Triggering unit)) Not equal to Wight
          • (Unit-type of (Triggering unit)) Not equal to White Walker
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Triggering player)) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Leaderboard - Remove (Triggering player) from (Leaderboard of (Triggering player))
      • Leaderboard - Add (Triggering player) to (Leaderboard of Player 12 (Brown)) with label (Name of (Triggering player)) and value 0
      • Leaderboard - Show (Leaderboard of (Triggering player))
      • Player Group - Remove (Triggering player) from (All players controlled by a User player)
      • Player - Make (Triggering player) treat Player 12 (Brown) as an Ally with shared vision
      • Player - Make Player 12 (Brown) treat (Triggering player) as an Ally with shared vision
      • Player - For Player 12 (Brown), turn Shared units On toward (Triggering player)
      • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
      • Player - Make (Triggering player) treat Player 2 (Blue) as an Enemy
      • Player - Make (Triggering player) treat Player 3 (Teal) as an Enemy
      • Player - Make (Triggering player) treat Player 4 (Purple) as an Enemy
      • Player - Make (Triggering player) treat Player 5 (Yellow) as an Enemy
      • Player - Make (Triggering player) treat Player 6 (Orange) as an Enemy
      • Player - Make (Triggering player) treat Player 7 (Green) as an Enemy
      • Player - Make (Triggering player) treat Player 8 (Pink) as an Enemy
      • Player - Make (Triggering player) treat Player 9 (Gray) as an Enemy
      • Player - Make (Triggering player) treat Player 10 (Light Blue) as an Enemy
      • Player - Make (Triggering player) treat Player 11 (Dark Green) as an Enemy
      • Wait 0.02 seconds
      • Player Group - Pick every player in (All allies of Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Player Group - Make (All allies of Player 12 (Brown)) treat (All allies of Player 12 (Brown)) as an Ally with shared vision
      • Unit - Create 1 White Walker for (Owner of (Triggering unit)) at (Random point in zombie spawn <gen>) facing Default building facing degrees
      • Trigger - Run Undead Victory <gen> (checking conditions)
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I think this might be the issue for the removal part:

  • Leaderboard - Remove (Triggering player) from (Leaderboard of (Triggering player))
I think, you just created one leadedboard for the force "all players". Try saving this leader board in a variable in the init trigger and refer to this variable in the death trigger. I think, like you do it know, there is no Leaderboard of Triggering Player. I might be wrong, because I dont know how this function creates the board.

  • Leaderboard - Show (Leaderboard of (Triggering player))
THis as well might be the problem for the adding part. Try to create the undead leaderboard not for player 12 only, rather create it for a whole player group (force). then show the leaderboard to the force, you can add p 12 to it. Upon death, add the dying player to this force, and it should work. Maybe you have to use Show Leaderboard for Undead Force again to refresh the board. Save the board to a variable in init trigger as suggested above.
 

Ash

Ash

Level 22
Joined
Aug 27, 2005
Messages
1,684
SuperScruffy,

I noticed this has been posted in a few different places. I've deleted all the other copies, and now only this thread remains. Be sure to take a read through our rules, and good luck fixing your issue! :)
 
Level 2
Joined
May 25, 2016
Messages
15
@Ash Oops, sorry. As a sidenote would this go under triggers and scripts or world editor help zone?

@Emm-A- ooooh there are leaderboard variables. That helps a ton, thanks.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
As a sidenote would this go under triggers and scripts or world editor help zone?
This would be appropriate for Triggers & Scripts since you have a trigger you need help fixing. On the other hand, if you needed help getting started on it or needed clarification for something trigger related, that would be more appropriate for the World Editor Help Zone.
 
Level 2
Joined
May 25, 2016
Messages
15
At this point, I've got the leaderboard stuff figured out. Just need a clarification on alliance stuff. Can I have force 1 contain user players 1-11, and force 2 be a computer player, and partway through a game use the trigger action "Player - Make X treat Player 12(Brown) as an ally with shared vision" to make that player effectively switch sides?

Basically - can players on different "forces" be "allied"? If not, how do map makers get around that? I need to have 1 player be on force 2 to be able to start the game.

Also - how do I set the thread to solved?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I am pretty sure, that this is possible. I cant try it atm, but you can easily test that in a simple map.

By the way, players can be in more than one force in trigger editor, so you have to remove players when using forces. Just in case, you create custom forces.

In case of allying players from different preset player-editor-forces, dont forget, that you have to make every single player treat every single player as an ally, that you want them to ally.
So in your case, you would have to make p 2 treat every other player as an ally and vise versa.
 
Level 2
Joined
May 25, 2016
Messages
15
Either there is something wrong with the following trigger actions, or there is something I'm missing (Like computer players won't ally and won't share control?)

  • Actions
    • Player - Make (Triggering player) treat Player 12 (Brown) as an Ally with shared vision
    • Player - Make Player 12 (Brown) treat (Triggering player) as an Ally with shared vision
    • Player - For Player 12 (Brown), turn Full shared units On toward (Triggering player)
    • Player - For (Triggering player), turn Full shared units On toward Player 12 (Brown)
    • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
    • Player - Make (Triggering player) treat Player 2 (Blue) as an Enemy
    • Player - Make (Triggering player) treat Player 3 (Teal) as an Enemy
    • Player - Make (Triggering player) treat Player 4 (Purple) as an Enemy
    • Player - Make (Triggering player) treat Player 5 (Yellow) as an Enemy
    • Player - Make (Triggering player) treat Player 6 (Orange) as an Enemy
    • Player - Make (Triggering player) treat Player 7 (Green) as an Enemy
    • Player - Make (Triggering player) treat Player 8 (Pink) as an Enemy
    • Player - Make (Triggering player) treat Player 9 (Gray) as an Enemy
    • Player - Make (Triggering player) treat Player 10 (Light Blue) as an Enemy
    • Player Group - Pick every player in (All allies of Player 12 (Brown)) and do (Actions)
      • Loop - Actions
        • Player Group - Make (All allies of Player 12 (Brown)) treat (All allies of Player 12 (Brown)) as an Ally with shared vision
    • Unit - Create 1 White Walker for (Triggering player) at (Random point in zombie spawn <gen>) facing Default building facing degrees
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
This looks a bit messed up. For example I do not understand, why you add that player group enumeration. There is only one player left, which is player 11 .. Also: What is your event? Is player 11 triggering player? If there is no player tirggering, then nothing will happen in your trigger.

You can ally computer players with shared units, I actually tried this.

Can you maybe simply explain again, what you are trying to do? Like what is your starting conditions and what do you want to do?
 
Level 2
Joined
May 25, 2016
Messages
15
This looks a bit messed up. For example I do not understand, why you add that player group enumeration. There is only one player left, which is player 11 .. Also: What is your event? Is player 11 triggering player? If there is no player tirggering, then nothing will happen in your trigger.

You can ally computer players with shared units, I actually tried this.

Can you maybe simply explain again, what you are trying to do? Like what is your starting conditions and what do you want to do?

That last post was just a more focused section of the original trigger "human death". My forces include force 1 with players 1-10+12 and force 2 with player 11. Player 11 is entirely missing/removed from the game. Force 1 players are not allied at the start of the game, and for scenario properties "use custom forces" and "fixed player settings" are both checked.

The triggering player is whichever player owns the unit that dies. I know the events and conditions aren't the problem because the leaderboard section of actions from the same trigger work correctly.

I'll include the full trigger and an explanation of what I expect the trigger to do:
  • Humandeath
    • Events
      • Unit - A unit Dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Number of living Town Hall units owned by (Owner of (Triggering unit))) Equal to 0
          • (Number of living Peasant units owned by (Owner of (Triggering unit))) Equal to 0
          • (Number of living Davos (wielding Frostmourne) units owned by (Owner of (Triggering unit))) Equal to 0
          • (Unit-type of (Triggering unit)) Not equal to Wight
          • (Unit-type of (Triggering unit)) Not equal to White Walker
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Triggering player)) and do (Actions)
        • Loop - Actions
          • If ((Unit-type of (Picked unit)) Equal to White Walker) then do (Do nothing) else do (Unit - Remove (Picked unit) from the game)
      • Wait 3.00 game-time seconds
      • Leaderboard - Remove (Triggering player) from HumanLeaderboard
      • Leaderboard - Add (Triggering player) to HumanLeaderboard with label (White Walker + (Name of (Triggering player))) and value 0
      • Leaderboard - Show (Leaderboard of (Triggering player))
      • Player - Make (Triggering player) treat Player 12 (Brown) as an Ally with shared vision
      • Player - Make Player 12 (Brown) treat (Triggering player) as an Ally with shared vision
      • Player - For Player 12 (Brown), turn Full shared units On toward (Triggering player)
      • Player - For (Triggering player), turn Full shared units On toward Player 12 (Brown)
      • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
      • Player - Make (Triggering player) treat Player 2 (Blue) as an Enemy
      • Player - Make (Triggering player) treat Player 3 (Teal) as an Enemy
      • Player - Make (Triggering player) treat Player 4 (Purple) as an Enemy
      • Player - Make (Triggering player) treat Player 5 (Yellow) as an Enemy
      • Player - Make (Triggering player) treat Player 6 (Orange) as an Enemy
      • Player - Make (Triggering player) treat Player 7 (Green) as an Enemy
      • Player - Make (Triggering player) treat Player 8 (Pink) as an Enemy
      • Player - Make (Triggering player) treat Player 9 (Gray) as an Enemy
      • Player - Make (Triggering player) treat Player 10 (Light Blue) as an Enemy
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Trigger - Turn off Ally RedAA <gen>
          • Trigger - Turn off Ally RedNA <gen>
          • Trigger - Turn off Unally Red <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Trigger - Turn off Ally BlueAA <gen>
          • Trigger - Turn off Ally BlueNA <gen>
          • Trigger - Turn off Unally Blue <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • Trigger - Turn off Ally TealAA <gen>
          • Trigger - Turn off Ally TealNA <gen>
          • Trigger - Turn off Unally Teal <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 4 (Purple)
        • Then - Actions
          • Trigger - Turn off Ally PurpleAA <gen>
          • Trigger - Turn off Ally PurpleNA <gen>
          • Trigger - Turn off Unally Purple <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
        • Then - Actions
          • Trigger - Turn off Ally YellowAA <gen>
          • Trigger - Turn off Ally YellowNA <gen>
          • Trigger - Turn off Unally Yellow <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 6 (Orange)
        • Then - Actions
          • Trigger - Turn off Ally OrangeAA <gen>
          • Trigger - Turn off Ally OrangeNA <gen>
          • Trigger - Turn off Unally Orange <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 7 (Green)
        • Then - Actions
          • Trigger - Turn off Ally GreenAA <gen>
          • Trigger - Turn off Ally GreenNA <gen>
          • Trigger - Turn off Unally Green <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 8 (Pink)
        • Then - Actions
          • Trigger - Turn off Ally PinkAA <gen>
          • Trigger - Turn off Ally PinkNA <gen>
          • Trigger - Turn off Unally Pink <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 9 (Gray)
        • Then - Actions
          • Trigger - Turn off Ally GrayAA <gen>
          • Trigger - Turn off Ally GrayNA <gen>
          • Trigger - Turn off Unally Gray <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 10 (Light Blue)
        • Then - Actions
          • Trigger - Turn off Ally LightBlueAA <gen>
          • Trigger - Turn off Ally LightBlueNA <gen>
          • Trigger - Turn off Unally LightBlue <gen>
        • Else - Actions
          • Do nothing
      • Player Group - Pick every player in (All allies of Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Player Group - Make (All allies of Player 12 (Brown)) treat (All allies of Player 12 (Brown)) as an Ally with shared vision
      • Unit - Create 1 White Walker for (Triggering player) at (Random point in zombie spawn <gen>) facing Default building facing degrees
Explanation:
Whenever a unit dies, if that unit was the last effective unit owned by a human player (they can no longer create new units or use their hero as determined by the conditions) then:

-pick all remaining units in the map owned by that player and remove them.(if this wasn't there the trigger could unintentionally run multiple times for the same player)[works]

-remove them from the human leaderboard and add them back as a white walker with value 0[works]

-make brown ally the "dead" player w/ shared vision and control

-make all players except brown unally the player

-turn off the alliance system for the dead player (all the if then else's)[works]

-pick every dead player(allies of P12 Brown) and make them allies with all dead players (allies of P12 Brown).

-create a white walker unit for the dead player[works]


Thank you for trying to help, I'm sorry I wasn't too clear with the first posts.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
So first of all, are you sure triggering player always works for "A unit dies" events? I would change it always to Owner of Triggering Unit, just to be sure, there is no way this can go wrong.

I am very suspicious of the line, where you show the leadboard of that player. Are you sure, you need that? Seems useless to me. You can also just change player label and value by a GUI function, you dont have to remove and re-add the dying player.

The same for these "Set aspect of alliance" lines. You dont need it, just set the shared units control in the lines above, where you define them as allies.

Next for the player-pick at the bottom of the trigger, did you check, if All allies of player 12 is editor-based or not? Maybe this is only the ones, that you set in world editor and not the actual allies. Could be that this is always not true or strange. Just add all players to a playergroup ("dead players group") at the beginning of this trigger. Then just loop through this group instead of All allies of player 12, unless you are sure that this works, like you do it.

Now, to the problem, just think of player 1 dying. Then you can see, that this has to go wrong in some parts, e.g. p1 would treat itself as enemy and so on.

Delete this:

  • Player - For Player 12 (Brown), turn Full shared units On toward (Triggering player)
  • Player - For (Triggering player), turn Full shared units On toward Player 12 (Brown)
  • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
  • Player - Make (Triggering player) treat Player 2 (Blue) as an Enemy
  • Player - Make (Triggering player) treat Player 3 (Teal) as an Enemy
  • Player - Make (Triggering player) treat Player 4 (Purple) as an Enemy
  • Player - Make (Triggering player) treat Player 5 (Yellow) as an Enemy
  • Player - Make (Triggering player) treat Player 6 (Orange) as an Enemy
  • Player - Make (Triggering player) treat Player 7 (Green) as an Enemy
  • Player - Make (Triggering player) treat Player 8 (Pink) as an Enemy
  • Player - Make (Triggering player) treat Player 9 (Gray) as an Enemy
  • Player - Make (Triggering player) treat Player 10 (Light Blue) as an Enemy
and add this instead:

  • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal (==) Playing)) and do (Actions)
    • Loop - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • Multiple ConditionsAnd - All (Conditions) are true
            • Conditions
              • (Owner of (Triggering unit)) Not Equal (!=) (Picked player)
  • Player 11 Not Equal (!=) (Picked player)
    • Player 12 (Brown) Not Equal (!=) (Picked player)
    • 'THEN'-Actions
      • Player - Make (Picked player) treat (Owner of (Triggering unit)) as an enemy
      • Player - Make (Owner of (Triggering unit)) treat (Picked player) as an enemy
    • 'ELSE'-Actions
 
Level 2
Joined
May 25, 2016
Messages
15
Not sure which of these parts did it, but ITS FIXED! Thank you!

#ThreadClosed
#FixedTrigger
#Solved

So first of all, are you sure triggering player always works for "A unit dies" events? I would change it always to Owner of Triggering Unit, just to be sure, there is no way this can go wrong.

I am very suspicious of the line, where you show the leadboard of that player. Are you sure, you need that? Seems useless to me. You can also just change player label and value by a GUI function, you dont have to remove and re-add the dying player.

The same for these "Set aspect of alliance" lines. You dont need it, just set the shared units control in the lines above, where you define them as allies.

Next for the player-pick at the bottom of the trigger, did you check, if All allies of player 12 is editor-based or not? Maybe this is only the ones, that you set in world editor and not the actual allies. Could be that this is always not true or strange. Just add all players to a playergroup ("dead players group") at the beginning of this trigger. Then just loop through this group instead of All allies of player 12, unless you are sure that this works, like you do it.

Now, to the problem, just think of player 1 dying. Then you can see, that this has to go wrong in some parts, e.g. p1 would treat itself as enemy and so on.

Delete this:

  • Player - For Player 12 (Brown), turn Full shared units On toward (Triggering player)
  • Player - For (Triggering player), turn Full shared units On toward Player 12 (Brown)
  • Player - Make (Triggering player) treat Player 1 (Red) as an Enemy
  • Player - Make (Triggering player) treat Player 2 (Blue) as an Enemy
  • Player - Make (Triggering player) treat Player 3 (Teal) as an Enemy
  • Player - Make (Triggering player) treat Player 4 (Purple) as an Enemy
  • Player - Make (Triggering player) treat Player 5 (Yellow) as an Enemy
  • Player - Make (Triggering player) treat Player 6 (Orange) as an Enemy
  • Player - Make (Triggering player) treat Player 7 (Green) as an Enemy
  • Player - Make (Triggering player) treat Player 8 (Pink) as an Enemy
  • Player - Make (Triggering player) treat Player 9 (Gray) as an Enemy
  • Player - Make (Triggering player) treat Player 10 (Light Blue) as an Enemy
and add this instead:

  • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal (==) Playing)) and do (Actions)
    • Loop - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • Multiple ConditionsAnd - All (Conditions) are true
            • Conditions
              • (Owner of (Triggering unit)) Not Equal (!=) (Picked player)
  • Player 11 Not Equal (!=) (Picked player)
    • Player 12 (Brown) Not Equal (!=) (Picked player)
    • 'THEN'-Actions
      • Player - Make (Picked player) treat (Owner of (Triggering unit)) as an enemy
      • Player - Make (Owner of (Triggering unit)) treat (Picked player) as an enemy
    • 'ELSE'-Actions
 
Status
Not open for further replies.
Top