• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help making a trade route mechanic

Status
Not open for further replies.
Level 2
Joined
Apr 16, 2008
Messages
10
Hello,

I'm working on a map and amongst other things I want to make trade routs in the sense that there is a merchant that patrols the map and when he passes nearby a player's market building that particular player earns gold.

I've been trying to make this happen with a response event to "notices a target in range", but I can't find the event response condition for that, just "targeted unit" and "acquired target".

Am I missing something? Is there an easier way I can make this mechanic happen?

thanks!

Stefan G.
 
Level 2
Joined
Apr 16, 2008
Messages
10
yeah, I adjusted it, but overall it works for me. I hope it's of some use for others as well. The Merchant unit patrols the map and is invulnerable. The point is in placing markets along the trade route.
 
Level 2
Joined
Apr 16, 2008
Messages
10
Good idea. Quick suggestion on how I might do that? Because I can only think of remaking the trigger for each player and the disabling it for a certain amount of time after the gold is given
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You could use a timer array. Every time it gives player money it starts the timer for the player for some period. If the player's timer is running then no gold is given. When the timer expires you enumerate nearby markets and give gold and restart the timer if gold was given.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You add a condition to your enter range of merchant trigger that tests that the triggering unit's owner's (array index from player id) timer has expired (remaining time 0). In the actions you start the triggering unit's owner's timer for some timeout period (maximum income rate).

You create another trigger for all the timers expiring. You resolve which player's timer expired by performing a linear search though the timer array. In the actions you search all nearby units (make sure to deal with any group leaks) and look for markets owned by the timer owner. If at least 1 is found you add more gold to the timer owner and restart the timer again.
 
Status
Not open for further replies.
Top