• 🏆 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!

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:
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