HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Building Income Trigger

07-17-2008, 09:21 PM#1
FarsalanSX
if anyone can help please do this is my current trigger i got from another thread somewhere in this site...
Trigger:
Income-
event: periodic event: every 5 secs
Condition: Player owns a (insert unit here)
Action: Give player gold

i cant find the condition so i was wondering if someone else could help find or they make their own i don't care if its in jass since all i'd have to do is set it to custom script and then copy and paste but i really need this and i may be able to finally set my map out into the open....
07-17-2008, 10:59 PM#2
SeruK
Please copy the triggers directly from WE. :P It's Player Comparison.
07-17-2008, 11:00 PM#3
FarsalanSX
i cant i told you in my post i cant find the condition part i have that in notepad
07-17-2008, 11:06 PM#4
the-thingy
Have you tried "Pick every unit of type <insert unit type> and do action: Add X gold to Owner of Picked Unit"? Or do you just want to give the gold once, regardless of how many units of that type exist for the player?

EDIT: Here's two triggers, first is for gold on a per unit basis (each unit will result in X gold for the owner), second is for gold on a per player basis (player will result X gold if they have at least 1 unit, but additional gold will not be received for more than 1 unit)

Trigger:
Per unit basis
Collapse Events
Time - Every 5.00 seconds of game time
Conditions
Collapse Actions
Set SomeGroup = (Units of type Footman)
Collapse Unit Group - Pick every unit in SomeGroup and do (Actions)
Collapse Loop - Actions
Player - Add 50 to (Owner of (Picked unit)) Current gold
Custom script: call DestroyGroup (udg_SomeGroup)

Trigger:
Per player basis
Collapse Events
Time - Every 5.00 seconds of game time
Conditions
Collapse Actions
Collapse Player Group - Pick every player in (All players) and do (Actions)
Collapse Loop - Actions
Set SomeGroup = (Units of type Footman)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in SomeGroup) Greater than 0
Collapse Then - Actions
Player - Add 50 to (Picked player) Current gold
Else - Actions
Custom script: call DestroyGroup (udg_SomeGroup)

Just edit the unit type to whatever you need
07-17-2008, 11:24 PM#5
SeruK
Quote:
Originally Posted by FarsalanSX
i cant i told you in my post i cant find the condition part i have that in notepad
Oh, sorry I misunderstood you. Well the-thingy should have solved it for you.
07-18-2008, 12:44 AM#6
FarsalanSX
bah late reply but i cant find the
Set SomeGroup = (Units of type Footman)

thx for the all the help guys
07-18-2008, 01:11 AM#7
SeruK
SomeGroup is just the name of a variable, and the action itself is called "Set Variable".
07-19-2008, 02:51 AM#8
FarsalanSX
ok um i cant get the type part of the trigger i can get the set variable action but nothing after that and my friend right now is afk prolly for the night
07-19-2008, 08:02 AM#9
the-thingy
Did you create a variable in the Variable Editor of type Unit Group?
07-19-2008, 10:51 PM#10
FarsalanSX
no thx for the reply... i think i have it =)
Trigger:
undead i
Collapse Events
Time - Every 15.00 seconds of game time
Conditions
Collapse Actions
Set SomeGroup[3] = Graveyard
Collapse Unit Group - Pick every unit in (Units of type Graveyard) and do (Actions)
Collapse Loop - Actions
Player - Add 9 to (Owner of (Triggering unit)) Current gold

if this is wrong please tell me
07-19-2008, 11:35 PM#11
Anitarf
First of all, your "SomeGroup" variable seems to be a unit type variable, not unit group variable, because you're setting it to "graveyard" instead of "Units of type Graveyard". Furthermore, you made it an array for no adequately explained reason, untick the "array" checkbox in the variable edit window, it is not needed for this purpose. The rest seems ok, of course once you have a proper unit group variable you'll want to be using that for your unit group loop instead of creating a new group in that line, and you'll want to clean up the variable after the loop.

Either that, or just remove the set variable action and keep the rest as is. You'll have a small memory leak in there but I've seen worse.

Actually, no, you can't keep the rest as is, you need to replace "triggering unit" with "picked unit", triggering unit makes no sense there.
07-20-2008, 06:02 PM#12
FarsalanSX
Quote:
Originally Posted by From an Xfire chat
[11:56] -KSSM- Blood_Rayven: well its only an array cuz u have to do other buildings to
[11:56] -KSSM- Blood_Rayven: diferent races
[11:56] Phoenix Overlord: yea
[11:56] Phoenix Overlord: thats why theres different races
[11:56] Phoenix Overlord: i mean
[11:56] -KSSM- Blood_Rayven: lol
[11:56] Phoenix Overlord: triggers
[11:56] -KSSM- Blood_Rayven: ok u lost me
[11:56] Phoenix Overlord: x.x
[11:56] Phoenix Overlord: thats why theres different triggers
[11:56] -KSSM- Blood_Rayven: yea
[11:56] -KSSM- Blood_Rayven: but u need a variable for each one
[11:57] -KSSM- Blood_Rayven: so there's ur ARRAY
[11:57] Phoenix Overlord: but the guy sounded so smart! =(
[11:57] -KSSM- Blood_Rayven: lol
[11:57] Phoenix Overlord: i'll change it back if this doesnt work
[11:57] -KSSM- Blood_Rayven: tell him that


my friend says i need the variable im getting confused =(
07-20-2008, 06:59 PM#13
Anitarf
That's what you get for not explaining in more detail what you need. You never mentioned up until now you needed this to work for multiple building types.

Even so, you can do this with a single group variable, it doesn't need to be an array. Even if you have multiple triggers they can all use the same variable because each of them only needs it while it's running, you store a unit group to it at the start of the trigger and destroy that group at the end.

Heck, as long as the income comes at the same time for all races you can use a single trigger to do all the incomes:

Trigger:
Income trigger
Collapse Events
Time - Every 15.00 seconds of game time
Conditions
Collapse Actions
Set TempGroup = (Units of type Graveyard)
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Player - Add 9 to (Owner of (Picked unit)) Current gold
Custom script: call DestroyGroup(udg_TempGroup)
Set TempGroup = (Units of type Income building 2)
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Player - Add 9 to (Owner of (Picked unit)) Current gold
Custom script: call DestroyGroup(udg_TempGroup)
Set TempGroup = (Units of type Income building 3)
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Player - Add 9 to (Owner of (Picked unit)) Current gold
Custom script: call DestroyGroup(udg_TempGroup)
...
07-20-2008, 07:23 PM#14
FarsalanSX
wow thx and thx again for the trigger uh so then this should be right?
Trigger:
undead i
Collapse Events
Time - Every 15.00 seconds of game time
Conditions
Collapse Actions
Set SomeGroup = (Units of type Graveyard)
Collapse Unit Group - Pick every unit in (Units of type Graveyard) and do (Actions)
Collapse Loop - Actions
Player - Add 20 to (Owner of (Picked unit)) Current gold
Custom script: call DestroyGroup(udg_SomeGroup)

and wow i didnt know they could all be in one trigger O.o
p.s. this is just a beta for the first release the income for all races will be set to one income until later advancment
07-20-2008, 10:09 PM#15
Anitarf
What you have there should work, however you didn't write it correctly so you have a memory leak in there. As I explained before and wrote in my example triggers, you're supposed to use your unit group variable in the unit loop. Instead, you're using "(Units of type Graveyard)" again, which creates another unit group object. That defeats the purpose of us having the variable in the first place; we store the unit group to a variable for the sole purpose of being able to destroy it with that last line of the trigger after we're done using it.