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

[Trigger] Basic Income Trigger

Status
Not open for further replies.
Level 11
Joined
Dec 13, 2008
Messages
1,047
Hello everyone, I need help creating an income trigger than will give 15gold per capital. A capital is any building that has the ability "Income - Capital" which gives off a buff of the same type. For each of these buildings that the player would own, 15 gold would be received.
I attempted creating this trigger on my own, however, it did not work. This is what I made:

  • Capitals
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
      • ((Triggering unit) has buff Income - Capital ) Equal to True
    • Actions
      • Player - Add 15 to (Owner of (Triggering unit)) Current gold
Would anyone know how i can fix my trigger so that it does what I'd like it to do? If you have any questions, let me know, thanks!
 
Last edited:
Level 6
Joined
Nov 24, 2012
Messages
218
Make actions like, pick all units with buff, then do actions. Inside the actions, make an if then else statement (multiple), move the condition into this one, and add gold action into it. Remove unit group leak. Change triggering unit to picked unit. I would show you but im typing this on my cellphone.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
I guess you want only user-players receive gold right? So here it is the solution:
  • Income
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Owner of (Matching unit)) controller) Equal to User)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Income - Capital for (Picked unit)) Greater than 0
            • Then - Actions
              • Player - Add 15 to (Owner of (Picked unit)) Current gold
            • Else - Actions
      • Custom script: call DestroyGroup(GetLastCreatedGroup())
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
:vw_wtf:
  • ((Triggering unit) has buff Income - Capital ) Equal to True
You have no triggering unit.
If the unit is a building and is preset in yourmap just do

  • Set Capital = Capital 001gen
And replace triggering unit in your trigger with the variabe.


Edit//
If its not preset or unique:
use a unit group
3triggers:
1st-When an income building is created add it to unit group.
2nd-Evry xx seconds add yy gold depending on the number of units in yhe unit group.
3rd-When an income building dies remove it from the unit group
 
Last edited:

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
:vw_wtf:
  • ((Triggering unit) has buff Income - Capital ) Equal to True
You have no triggering unit.
If the unit is a building and is preset in yourmap just do

  • Set Capital = Capital 001gen
And replace triggering unit in your trigger with the variabe.


Edit//
If its not preset or unique:
3triggers:
1st-When an income building is created add it to unit group.
2nd-Evry xx seconds add yy gold depending on the number of units in yhe unit group.
3rd-When an income building dies remove it from the unit group

LOL.
That would be done slower than setting a unit group with 3 conditions, unit is a building, it is alive and has capital ability. Your coding knowledge should be improved nedio...
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,544
LOL.
That would be done slower than setting a unit group with 3 conditions, unit is a building, it is alive and has capital ability. Your coding knowledge should be improved nedio...

Actually, it shouldn't be slower. Enumerating all the units in the whole map and then checking if each one matches 3 conditions is just as slow.

A better method would be to store player incomes as an integer array and then increment/decrement values when income buildings are created/destroyed.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
I thought the Hive was friendly? Why are you here? Be gone demon spawn!
This
Your coding knowledge should be improved nedio...
is supposed to be an advice, not an inflamatory post.
Actually, it shouldn't be slower. Enumerating all the units in the whole map and then checking if each one matches 3 conditions is just as slow.

A better method would be to store player incomes as an integer array and then increment/decrement values when income buildings are created/destroyed.
It doesn't enumerate all the units in the map, it enumerates the units in map who match the conditions. Anyway it doesn't slow.
 
Last edited:

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,544
It doesn't enumerate all the units in the map, it enumerates the units in map who match the conditions. Anyway it doesn't slow.

While that would be nice, it does actually have to check all units in the whole map (enumerating them) and checking each one individually if it matches the condition before storing it in the group.

Sorry!
 
Level 11
Joined
Dec 13, 2008
Messages
1,047
Thanks for the help everyone! I am definitely not a coder, so all the help is much appreciated. I am going to first try the system that -Kobas- suggested and then the others if that one doesn't work the way I wish it to.
Thanks again!
 
Status
Not open for further replies.
Top