• 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.

Income from units, how?

Status
Not open for further replies.
Level 4
Joined
Jun 22, 2008
Messages
62
Hey, would anyone help me with a trigger or something creating a gold rate per X sec for each of the same type of unit?

For example in the village builder gold map, it's these civillians wich generate about 3 gold per 30 sec or something.

How do i make an unending trigger that generates gold, and still stacks if you create more of those units to enlarge your income?
 
Level 4
Joined
Jun 22, 2008
Messages
62
Trigger 1 adds 1 to a counter appon unit construction.
Trigger 2 is the opposite of 1 and removed 1 from the counter on unit death.

Trigger 3 is a perodic trigger that runs every X seconds and gives a player counter * Y gold.

That is the basic layout.


So let's say this income-unit is named ... ''Darkpost'', yeah, and everytime a 'darkpost' is created, it generates 5 gold every minute for it's owned until death. I get you that far, but how exactly should i puzzle togheter my trigger? :p
 
Level 9
Joined
Apr 3, 2008
Messages
700
  • Actions
    • Set TempGroup = (Units in (Playable map area)((Unit-type of (Matching unit)) Equal to ))
    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • Player - Add (3 x (Number of units in TempGroup)) to (Owner of (Picked unit)) Current gold
    • Unit Group - Destroy unit group TempGroup
 
Level 2
Joined
Jun 26, 2005
Messages
14
Actually its alot easier than that. Or at least more straight forward...
I made the trigger when i didnt know much so its slightly archaic but it works,

Income
Events
Unit - A unit Finishes training a unit
Conditions
(Unit-type of (Trained unit)) Equal to 'Unit that you want to create Income'
((Trained unit) is alive) Equal to True
Actions
Player - Add 'gold amount' to (Owner of (Trained unit)) Current gold
Wait 'how often to occur' seconds
Trigger - Run (This trigger) (checking conditions)

You could make one of these triggers for each type of Income Unit You have or you could compack the trigger so that you can just have one for income so you wont have 20 different ones, it would play out like,

Income Multi
Events
Unit - A unit Finishes training a unit
Conditions
((Trained unit) is alive) Equal to True
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Trained unit)) Equal to 'Unit that you want to create Income #1'
Then - Actions
Player - Add 'gold amount' to (Owner of (Trained unit)) Current gold
Wait 'how often to occur' seconds
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Trained unit)) Equal to 'Unit that you want to create Income #2'
Then - Actions
Player - Add 'gold amount' to (Owner of (Trained unit)) Current gold
Wait 'how often to occur' seconds
Else - Actions
Trigger - Run (This trigger) (checking conditions)

Using this method is the way it was set up in the original village builder so each unit brought in income relative to when they were created, if instead you were looking to make it so that when you built the income units they would just pool the gold together and give it to you in one larger payment then you'd have to look toward timers and more variables but just for the basic income this works. I hope this helps.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
hunter_101, are you sure that method works? As currently I do not see how it can as you are running the trigger the second time with no units as input.

Or are you saying that event objects from one trigger carry over to an exectued trigger? As I did not know that could happen.
 
Level 2
Joined
Jun 26, 2005
Messages
14
Well not nescisarily easier, but more straightforward and easier to look at/modify... or at least for me, its just the way i trigger.

Dr. Super Good, yeah im sure that it works, its the exact trigger that i used in the VB series so i know it does. The last action works like a loop that only checks the dependencies/conditions to loop, as long as the trained unit is alive and of the same type it continues to produce income.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Dr. Super Good, yeah im sure that it works, its the exact trigger that i used in the VB series so i know it does. The last action works like a loop that only checks the dependencies/conditions to loop, as long as the trained unit is alive and of the same type it continues to produce income.

Sorry but it's 2vs1... That trigger won't work.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
He is right, it does work. It seems that triggers executed via another trigger inherit the attached event based objects of that trigger.

Basically, this is the same effect as storing the unit in a local and using a conditional loop that loops until the unit is dead. Well a slightly less efficent version as the type comparision is unnescescary after intial execute.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
No you will not be fine, your map will be ruined as every 30 seconds leaks will cause your map to use more and more system resources until the point at which it will become unplayable.

Also there are far simpler and way more efficent alternatives.

Also are you aware this thread was solved 4 months ago? Please read the site rules. . .
 
Level 4
Joined
Mar 26, 2008
Messages
100
Give your income producing unit a customized version of that ability that's used to make the goblin tinkerer robots (how is it called in english?) that produces a money unit and then a trigger:
A unit is created
if the unit created is your money unit
remove the unit
give the owner a sum of gold.

It should be leakless and simple.
 
Status
Not open for further replies.
Top