| 03-18-2007, 04:50 AM | #1 |
This trigger is for a building that you can call a bank. You don't store money in it. It is like the money farm in sheep tag, each one you have gives you x gold every x seconds. Code:
Bank
Events
Unit - A unit Finishes construction
Conditions
(Unit-type of (Constructed structure)) Equal to Bank
((Constructed structure) is alive) Equal to True - Makes it so once it is destroyed, you don't receive money anymore.
Actions
Wait 'EVERY X SECONDS YOU WANT THE GOLD DISTRIBUTED' seconds
Player - Add 'ANY NUMBER OF GOLD YOU WANT GIVEN' to (Owner of (Triggering unit)) Current gold
Trigger - Run Bank <gen> (checking conditions) |
| 03-18-2007, 05:01 AM | #2 |
Is this a contribution? ![]() |
| 03-18-2007, 07:39 AM | #3 |
Hmm...nice, never thought about doing it that way. I usually do it the complicated way and have a periodic timer. But that works. XD |
| 03-18-2007, 08:30 AM | #4 |
Ah HA! The problem with doing it this way is that it is not MUI, and will only work for 1 bank. EDIT: And please use [trigger], not [code], tags next time. |
| 03-18-2007, 09:44 AM | #5 |
Tried it. MUI for more 'banks'. Didn't check for more players though. |
| 03-18-2007, 07:05 PM | #7 |
If i had to do it i would use a variable for adding gold. Unit finishes construction Set Gold [Player Index of player constructing] equal to Gold [Player index blahblah] + Gold amount Trigger 2 Every X seconds Add Gold [Player Index blahblah] to players current gold. |
| 03-19-2007, 08:19 AM | #8 |
I jmust think that scmstrak's has a certain simplicity to it, and as long as it works in all scenarios, why bother writing 2 partially redundant triggers? It also give it every x seconds from the end of construction, instead of x clock seconds, which gives a more even gain rate. It doesn't require any player loops. If two triggers accomplish the same thing, take the simpler one. My only concern is this: I don't know enough about how WC3 handles threads. Does the first instance of this trigger ever stop running or is it constantly waiting for its "Run (this trigger) <checking conditions>" call to finish? |
| 03-19-2007, 02:30 PM | #9 |
It will essentially keep at least one thread open for the duration of the map. Because its in GUI without any custom script calls, its going to leak the player groups, OwnerOfTriggeringUnit will leak as well..etc. etc. With the construction of each additional bank, it opens another thread..so in a map with more than 1 bank for each person its going to produce hundreds of threads by the end of the map. On a side note, if the TSA function is any shorter than 15 seconds or so, the count will be innacurate (especially if the duration is shorter than 5 seconds). |
