[Trigger] How to make this Trigger once per player.

Level 12
Joined
Apr 9, 2013
Messages
762
Hello, I have these triggers that activates when someone builds a barracks. There are 4 races and 20 players, how can I make it trigger only once per player?
Also I think my trigger will make it so the text appears to everyone, how to make it appear only to the triggering player?

  • Quest WE Faction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Barracks
    • Actions
      • Sound - Play QuestNew <gen>
      • Quest - Create a Required quest titled Western European Cu... with the description Commands in Game. ..., using icon path ReplaceableTextures\CommandButtons\BTNFootman.blp
      • Quest - Display to (All players matching (((Triggering unit) is A structure) Equal to True).) the Quest Discovered message: |cffffcc00Western E...
      • Cinematic - Ping minimap for (All players matching (((Unit-type of (Triggering unit)) is A structure) Equal to True).) at (Center of CITY ME JERUSALEM <gen>) for 10.00 seconds
1724096497247.png

1724096509901.png

1724096521848.png
 
Level 30
Joined
Aug 29, 2012
Messages
1,382
You can use a boolean variable with an array as a simple yes/no to keep track of each player's advancement
  • Events
    • Unit - A unit Finishes construction
  • Conditions
    • (Unit-type of (Constructed structure)) Equal to Barracks
    • Bool_Player[(Player number of (Owner of (Triggering unit)))] Equal to False
  • Actions
    • Set VariableSet Bool_Player[(Player number of (Owner of (Triggering unit)))] = True
    • -------- Your actions --------
To display the message only for the concerned player, you can use this function

1724098701650.png
 
Level 12
Joined
Apr 9, 2013
Messages
762
You can use a boolean variable with an array as a simple yes/no to keep track of each player's advancement
  • Events
    • Unit - A unit Finishes construction
  • Conditions
    • (Unit-type of (Constructed structure)) Equal to Barracks
    • Bool_Player[(Player number of (Owner of (Triggering unit)))] Equal to False
  • Actions
    • Set VariableSet Bool_Player[(Player number of (Owner of (Triggering unit)))] = True
    • -------- Your actions --------
To display the message only for the concerned player, you can use this function

View attachment 483624

Sorry, I am very bad with triggers, I only got this far
1724168220409.png


I don't know what to do next.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
When you click on any blue underlined words in an Action (or Event/Condition) you'll see these three categories on the left side.

() Preset:
() Variable:
() Function:

Note how in Chaosium's picture the Function category is highlighted blue. That tells you that he chose something from the list of available Functions. So you should do the same.
 
Last edited:
Level 12
Joined
Apr 9, 2013
Messages
762
When you click on any blue underlined words in an Action (or Event/Condition) you'll see these three categories on the left side.

() Preset:
() Variable:
() Function:

Note how in Chaosium's picture the Function category is highlighted blue. That tells you that he chose something from the list of available Functions. So you should do the same.
I don't know how to get this.
1724170027723.png


I did this
1724170135891.png
 
Level 14
Joined
Jan 10, 2023
Messages
247
I don't know how to get this.
View attachment 483780

I did this
View attachment 483781
That will be in the "Conditions" menu when you make a new condition, the first (default selected) option is 'boolean comparison', then select from the Variables list (as Uncle's post shows).

Make a boolean variable array for your players and then use that variable, using the 'Convert Player # to integer' function as the array index integer (like how Chaosium's trigger showed in the second trigger condition).
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I don't know how to get this.

You've already created the Variable so now you just need to reference it in the Conditions section of your trigger:
  • Conditions
    • (Unit-type of (Constructed structure)) Equal to Barracks
    • (FactionQuestBarracks[(Player number of (Owner of (Triggering unit))) Equal to False
So you would click the ((Triggering unit) is A structure) part of your second condition and change it to use your new FactionQuestBarracks variable. Then change True to False.


Understand that triggers are broken up into 3 categories:
  • Events
  • Conditions
  • Actions
Events = Something has happened. For example, a unit died.
Conditions = Ask questions related to what happened. What type of unit died?
Actions = Do something special if your questions have been answered. Respawn the dying unit.

Then you have Event Responses which are like Variables that get set based on what has happened. These allow you to interact with the Units/Players/Items/Destructables that are related to the Event (if any).

Also, the (Triggering unit) Event Response always refers to the Unit mentioned in your Event:
Unit - A unit Finishes construction
In this situation the (Triggering unit) is the same exact thing as the (Constructed structure). It's recommended to use (Triggering unit) whenever possible but using both here won't cause any problems.
 
Last edited:
Level 12
Joined
Apr 9, 2013
Messages
762
Okay I did it, my problem was that I didn't understand how to make the variable work, so it was not showing up in the clickable tag.

But I have a few concerns now (notes: my map is for 20 players, with 4 races, they pick their races after the game starts, this whole trigger is to just give them information about their race specific victory condition):
  1. How do I make sure the quest is only created for that specific player?
  2. I don't have any good way to test if this works for other players, so can you assure me the trigger does what it does.
  • Quest ME Faction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Barracks (ME)
      • FactionQuest[(Player number of (Owner of (Triggering unit)))] Equal to False
    • Actions
      • Sound - Play QuestNew <gen>
      • Quest - Create a Required quest titled Culture Information with the description |cffffcc00Saracens|..., using icon path ReplaceableTextures\CommandButtons\BTNCastle.blp
      • Quest - Display to (Player group((Owner of (Triggering unit)))) the Quest Discovered message: |cffffcc00Saracens|...
      • Cinematic - Ping minimap for (Player group((Owner of (Triggering unit)))) at (Center of CITY WE Paris <gen>) for 30.00 seconds
      • Cinematic - Ping minimap for (Player group((Owner of (Triggering unit)))) at (Center of CITY WE Vienna <gen>) for 30.00 seconds
      • Set VariableSet FactionQuest[(Player number of (Owner of (Triggering unit)))] = True
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
1. Having Player-specific Quests is tricky because the game doesn't support it natively.

Instead, you have to use GetLocalPlayer() which can cause desyncs IF you don't use it properly:

2. The logic is very simple and will not fail:
  • FactionQuest is a Boolean variable. All Boolean variables are set to FALSE by default.
  • When you finish building a Barracks (ME) the Conditions check to see if FactionQuest is equal to FALSE.
  • If it's FALSE then we proceed to the Actions which set it to TRUE.
  • This prevents the trigger from ever getting past the Conditions once FactionQuest has been set to TRUE.
  • This works for each Player because we utilize the [index] of the FactionQuest array variable to give each Player their own copy of the variable. This method is called Player Indexing and can be used with any type of variable.
 
Last edited:
Level 12
Joined
Apr 9, 2013
Messages
762
1. Having Player-specific Quests is tricky because the game doesn't support it natively.

Instead, you have to use GetLocalPlayer() which can cause desyncs IF you don't use it properly:

2. The logic is very simple and will not fail:
  • FactionQuest is a Boolean variable. All Boolean variables are set to FALSE by default.
  • When you finish building a Barracks (ME) the Conditions check to see if FactionQuest is equal to FALSE.
  • If it's FALSE then we proceed to the Actions which set it to TRUE.
  • This prevents the trigger from ever getting past the Conditions once FactionQuest has been set to TRUE.
  • This works for each Player because we utilize the [index] of the FactionQuest array variable to give each Player their own copy of the variable. This method is called Player Indexing and can be used with any type of variable.

What about if I set the quest to undiscovered? Will it then only discover for that specific player?

EDIT: I ask because I can't test it in singleplayer.
 
Last edited:
Top