• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

Problem with my trigger.

Status
Not open for further replies.
Level 2
Joined
Oct 2, 2010
Messages
12
Could someone explain me, what's the problem whit this event?

  • Time - Every (5.00 - (1.00 x (Real((Number of living farm units owned by Player 1 (Red)))))) seconds of game time
It should increase the food cap by 1 every (5-1*number of farms) seconds. But in this case, food cap always rises in every 5 seconds, no matter how many farms i have.
 
Last edited by a moderator:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Create an action in map initialization trigger that adds all farms into a group like farm_group.
Remember to create a trigger that has event Unit ends building structure - or smth like this (got no Eng editor) and add the buidling being contructed into farm_group if the given building type is farm.
Egzample:
  • init
    • Events
      • Unit - A unit ends building structure
    • Conditions
      • (Unit-type of (Constructed structure)) equal to Farm
    • Actions
      • Unit group - Add (Constructed structure) to farm_group
If you want to remove units from this group when it dies do similar trigger with event - Unit dies and action: Remove unit from unit group.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You could make it run every 1 seconds and keep track of the times it has looped with an integer. If the integer matches the count then increase food cap and calculate a new value.

Something like this:

Every 1 seconds
if value = 0 then
Value = number of units
set food cap
else
value = value - 1
endif
 
Level 2
Joined
Oct 2, 2010
Messages
12
Thank you guys for the replys!

I tryed both of them, and unfortunately neither of them worked. But it's probably because of my noobism.

However i came up with solution:

I used a countdown timer instead of a periodic one, with the same values. When ever the timer expires, it fires it self again.

  • Events
  • Time - timer1 expires
  • Conditions
  • Actions
  • Player - Add 1 to Player 1 (Red) Food cap
  • Countdown Timer - Start timer 1 as a One-shot timer that will expire in (5.00 - (1.00 x (Real((Number of living farm units owned by Player 1 (Red)))))) seconds
Is it good, or it may cause somekind of leak or anything?
 
Status
Not open for further replies.
Top