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

City Income?

Status
Not open for further replies.
Level 5
Joined
Apr 8, 2007
Messages
116
*Sigh*, I knew how to do this once, but I forgot, having not used world editor in about 2 years.....how do you make a trigger that gives, say, 200 gold for every city you have every 2 minutes? (I don't want to do the long way, where you do the income of each city individually - my map has probably 80 cities!)
 
Level 5
Joined
Apr 8, 2007
Messages
116
Well just create an Trigger with the Periodic Timer, and add Property to the Player.


No, thats not what I mean, I meant income PER EVERY CITY a person controls.... XD

Say a guy has 10 cities, he gets 2000 income, and a second guy has 20 cities, gets 4000 income. Guy A captures 2 cities from guy B. Now guy A has 2400 income, while guy B has 3600 income...get what I'm saying?
 
Level 12
Joined
Feb 1, 2007
Messages
1,092
Do you build the cities or what? Ok, first make Integer Variables for Red City, Blue City, ect. Event: Finishes Construction, COndition: Built Unit= City, Building Player=Red, Action: Set Red City+1. THen do a periodic timer for each two minutes, you can figure that out I think. I dont know how you would do it if you didnt build the cities though. IF you need to capture them, then your in trouble I think. =)
 
Level 5
Joined
Apr 8, 2007
Messages
116
Do you build the cities or what? Ok, first make Integer Variables for Red City, Blue City, ect. Event: Finishes Construction, COndition: Built Unit= City, Building Player=Red, Action: Set Red City+1. THen do a periodic timer for each two minutes, you can figure that out I think. I dont know how you would do it if you didnt build the cities though. IF you need to capture them, then your in trouble I think. =)


Oh dear, thats what I thought =(...My map involves capturing. And though I know a way, it would be REALLLY long, since I'd have to do individual triggers for cities, and I have mroe than 80 cities..
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
you'll need a few triggers:

Trigger 1: City Counter
The event/condition depends on how you capture a city: let's say that you build a city, and everytime someone destroys it, the city respawns but for the player who destroyed it (very lame, but this is just an example)

Event: unit finishes constructing a building
Condition: unit comparison - constructed building = City
Action: set CityCounter [Player Number of owner of constructed building] (Integer variable with an Array of 12) = CityCounter [Player Number of owner of constructed building] + 1

Trigger 2: Whenever a city is destroyed, it should respawn and change ownership to the destroying unit
Event: a unit dies
condition: unit type of dying unit = City
Action:
set CityCounter [Player Number of owner of dying unit] (Integer variable with an Array of 12) = CityCounter [Player Number of owner of dying unit] - 1
revive unit instantly
change ownership of last revived unit to owner of killing unit
set CityCounter [Player Number of owner of killing unit] (Integer variable with an Array of 12) = CityCounter [Player Number of owner of killing unit] + 1

Trigger 3: The actual income
Event: Every X seconds of game time
action:
loop - for each integer A from 1 to 12:
do:
Player - Add 200*Citycounter [Integer A] to player [Integer A]'s gold

didn't use world edit to create these triggers, so the exact trigger might look slightly different, but basically, this is what you should do.
if you capture a city in a different way, ofcourse the events of trigger 1 and 2 should change, or nothing will work.

EDIT: you replied before I posted... didn't know.
tell me how capturing a city works, and I'll see what could be done
 
Level 7
Joined
Dec 26, 2006
Messages
303
Either way for trigger 2 and 3:
Trigger 2: Whenever a city is destroyed, it should respawn and change ownership to the destroying unit
Event:
a unit dies
condition:
unit type of dying unit = City
Action:
revive unit instantly
change ownership of last revived unit to owner of killing unit

Trigger 3: The actual income
Event:
Every X seconds of game time
Action:
Player - Add 200 to player [owner of unit type of city]'s gold

Looks more simple don't it?? SOme of it doesn't work but I forget which one.. Sorry, gotta fix some bugs
 
Level 9
Joined
Jul 27, 2006
Messages
652
One trigger

You could do it with one trigger?
Event - Periodic Timer 120 seconds
Actions -
For each integer a between 1 and 12
set TempInt = Count units of type City, owned by player(for loop a).
Add Player property - add 200*TempInt
Not exactly right but its just a guideline.
 
Level 7
Joined
Dec 26, 2006
Messages
303
Still I beginner... When the pro say it it will be even more simple from 3 trigger becoming 1, My heart get stomped by you kixer
 
Level 9
Joined
Jul 27, 2006
Messages
652
Hahaha

Hahahaha, im no where near pro :smile:!
Yours was fine? And mine was only one trigger because i left it up to the creator to do the building conversion trigger!
 
Level 5
Joined
Apr 8, 2007
Messages
116
Either way for trigger 2 and 3:
Trigger 2: Whenever a city is destroyed, it should respawn and change ownership to the destroying unit
Event:
a unit dies
condition:
unit type of dying unit = City
Action:
revive unit instantly
change ownership of last revived unit to owner of killing unit

Trigger 3: The actual income
Event:
Every X seconds of game time
Action:
Player - Add 200 to player [owner of unit type of city]'s gold

Looks more simple don't it?? SOme of it doesn't work but I forget which one.. Sorry, gotta fix some bugs

Yeah, this was the way I knew how to do it, but seeing as how I have about 80-some cities placed (whioch are the same unit), an individual trigger for 80 places would be a bit difficult :emote_grin: ...thanks for the tips, hope I'll be able to do em =)
 
Level 5
Joined
Apr 8, 2007
Messages
116
you'll need a few triggers:

Trigger 1: City Counter
The event/condition depends on how you capture a city: let's say that you build a city, and everytime someone destroys it, the city respawns but for the player who destroyed it (very lame, but this is just an example)

Event: unit finishes constructing a building
Condition: unit comparison - constructed building = City
Action: set CityCounter [Player Number of owner of constructed building] (Integer variable with an Array of 12) = CityCounter [Player Number of owner of constructed building] + 1

Trigger 2: Whenever a city is destroyed, it should respawn and change ownership to the destroying unit
Event: a unit dies
condition: unit type of dying unit = City
Action:
set CityCounter [Player Number of owner of dying unit] (Integer variable with an Array of 12) = CityCounter [Player Number of owner of dying unit] - 1
revive unit instantly
change ownership of last revived unit to owner of killing unit
set CityCounter [Player Number of owner of killing unit] (Integer variable with an Array of 12) = CityCounter [Player Number of owner of killing unit] + 1

Trigger 3: The actual income
Event: Every X seconds of game time
action:
loop - for each integer A from 1 to 12:
do:
Player - Add 200*Citycounter [Integer A] to player [Integer A]'s gold

didn't use world edit to create these triggers, so the exact trigger might look slightly different, but basically, this is what you should do.
if you capture a city in a different way, ofcourse the events of trigger 1 and 2 should change, or nothing will work.

EDIT: you replied before I posted... didn't know.
tell me how capturing a city works, and I'll see what could be done

Oh, sorry, didn't notice that last thing you typed. Capturing is by "killing" the building (which is replaced and becomes the capturer's XD)
 
Level 7
Joined
Dec 26, 2006
Messages
303
You must use trigger (If {condition} true run {action} else {action}) after picked every units in playable area those unit:
C-
Picked unit is type of Townhall
A-
Add 200 to owner of picked unit's gold.
Else A-
DO nothing

Should work
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
You could do it with one trigger?
Event - Periodic Timer 120 seconds
Actions -
For each integer a between 1 and 12
set TempInt = Count units of type City, owned by player(for loop a).
Add Player property - add 200*TempInt
Not exactly right but its just a guideline.

that would be the best trigger, in case the "cities" are buildings... otherwise you'd have to split the trigger into 3 anyway
 
Level 3
Joined
Aug 15, 2006
Messages
41
All of you peoples trigger functions are a bit messy. A single trigger would work, provided that each city is not its own unit. (If they are all the same unit it is so simple it isn't even funny).

Event: Periodic event, ever 120 seconds (for your two minutes).

Action: Player - Add property: Add (do not use value, go to function, then arithmetic). Then go to unit count - living units owned by player. Select the unit, then the player. Then clear out of all of that and choose the resource type added and to what player it gets added to.

This allows you to use a single trigger for each player's income. There is no lag because there is almost no calculation. Enjoy.
 
Level 7
Joined
Dec 26, 2006
Messages
303
Llama is very lucky, one give him trigger and others make it as short as it can be... Any1 can make it shorter??
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
yeah you should loop HisdivineShadow's trigger if you have more than 1 player in the map

here's *the* final trigger

Event: Periodic Event: Every 120 Seconds
Action:
Loop - For each integer A from 1 to 12 do:
Player - Add property: Add 200*(count "cities" owned by player Integer A) gold to Player Integer A's current gold
 
Status
Not open for further replies.
Top