• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Convoy trigger for alot of players

Level 7
Joined
Sep 10, 2023
Messages
112
Hello, I want to make a convoy system to make players send resources through convoys. So far the convoy system works but I wanted to see if someone got experience with something like that to make it more effective on the implementation.

So far Ive managed to do it like this

  • Convoy player 4 1
    • Events
      • Unit - A unit owned by Player 4 (Purple) Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to |cffff0000Send 200g to Solarguardia|r
    • Actions
      • Unit - Remove (Trained unit) from the game
      • Set VariableSet wagon4 = Wagon (team)
      • Unit - Create 1 Wagon (team) for Neutral Passive at (Center of W4 P1 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Move To (Center of W1 DELIVER <gen>)

  • Convoy arrival red1
    • Events
      • Unit - A unit enters W1 DELIVER <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Wagon (team)
    • Actions
      • Player - Add 200 to Player 1 (Red).Current gold
      • Game - Display to HumanPlayers the text: A convoy has arrive...
      • Unit - Remove (Triggering unit) from the game
For every trading post Ive separated regions to spawn wagons for neutral player. Then send them to each destination based on the region where it spawns.

1755666838975.png

I have 10 players so it would mean 100 of these triggers more or less. Any tips ?
 
I think you will want to have a heartbeat-kind of trigger. Such trigger would order all wagons to move to their target locations every ~3 seconds. It works as a safe mechanism if wagons ever get stuck. Right now, if wagon got stunned, it would then stay in place even after stun expired, as there is nothing else ordering it to move to target location again.

You don't need hundreds of triggers for this, just abstract your triggers and use variables/arrays.
For example instead of the first trigger running only for Player 4 (Purple), make it generic so it runs any time for any player whenever given unit-type has been trained. Store reference to triggering player in an array or hashtable so that you know which wagon was created by which player.
In your second trigger don't add 200 gold to specific player, instead load the player from array/hashtable that you stored in previous trigger and add gold to that player.

You also don't need copies of second trigger. Just use multiple events in that trigger - one event for each "Wx Deliever" region.

Finally, you may want to keep track of wagon's targeted region in an array/hashtable and check in your second trigger if wagon entered its target region. As I look at the picture you've provided, I can see that the right/east side has two columns of regions. If those are the target regions, then a wagon would disappear/finish route when it passed through the outer-most regions, even if its targeted region was the inner-most one.
 
I think you will want to have a heartbeat-kind of trigger. Such trigger would order all wagons to move to their target locations every ~3 seconds. It works as a safe mechanism if wagons ever get stuck. Right now, if wagon got stunned, it would then stay in place even after stun expired, as there is nothing else ordering it to move to target location again.

You don't need hundreds of triggers for this, just abstract your triggers and use variables/arrays.
For example instead of the first trigger running only for Player 4 (Purple), make it generic so it runs any time for any player whenever given unit-type has been trained. Store reference to triggering player in an array or hashtable so that you know which wagon was created by which player.
In your second trigger don't add 200 gold to specific player, instead load the player from array/hashtable that you stored in previous trigger and add gold to that player.

You also don't need copies of second trigger. Just use multiple events in that trigger - one event for each "Wx Deliever" region.

Finally, you may want to keep track of wagon's targeted region in an array/hashtable and check in your second trigger if wagon entered its target region. As I look at the picture you've provided, I can see that the right/east side has two columns of regions. If those are the target regions, then a wagon would disappear/finish route when it passed through the outer-most regions, even if its targeted region was the inner-most one.
Ill try with arrays, it seems it can help me make triggers faster. Thanks for your response!
 
Back
Top