I have a question pertaining to diplomacy type triggers. It's a bit complicated so bear with me. For certain [invincible] buildings (representing large medium or small cities) I would like there to be a circular region of a particular radius (dependent on city tier) such that when an enemy unit enters this region a group of "garrison" units spawn in the region to defend the city. If you are sieging an enemy city, it would be captured [the building would be given to you] once all enemy units (excluding the city itself and factory/resource structures) have been vanquished from the city-region. After a city is captured any enemy player that enters the city-region would then retrigger the garrisons to spawn, but this time for you.
However, if you enter an enemy city-region, trigger its garrison spawn, and then leave the city region (before capturing the city) - then the spawned garrison units will be removed.
If there are no enemy units present at a given city-region any garrison units in that region should disappear. There is also the issue of garrison units being moved out of a city-region (to avoid their removal) and I am not sure if this could be addressed by simply creating a trigger that removes a garrison unit when it is not within proximity of a city.
This next bit is less of a priority (since I'm sure I could figure it out myself once the above is addressed). But I would also like for certain buildings [industry buildings] in the city-region to also be given to the conquering player, from the conquered player.
Edit: Basically whenever a city-region is entered by an enemy, I would like a defensive garrison to spawn. And when all of the defensive units or any other units the player being attacked in the location are gone, the city is lost/captured. In order to distinguish between a city that has yet to spawn its garrisons and once that has lost all its garrisons I was thinking of making the city be burning or have less HP (if that's detectable) or something along those lines whenever its under siege. It would only be capturable when under siege.
I know this is a bit complicated but I am really devoted to my current project and well, short of learning galaxy code I've tried everything. In StarCraft 1 I accomplished the above with individual regions and triggers for each city, as well as switches. Since this proves to be a much more ambitious undertaking (roughly 200 cities) I am hoping this can be accomplished in a much less tedious and time consuming manner.
Okay, first of all we have some thing to solve before we start with triggers.
The first thing, I assume each city have a central building (if not create a invisible blablabla entity with will be the center), we need a behaviour, I will call "City Tier". At the beginning of the map you need to spread this behaviour the each central building with one stack.
Now you need a formular for the range which you said depends on the tier. With this formular we create the event now. "Unit enters region of unit"
For unit we need to the following: "Closest unit to point"
Range: Your formular (There is a function to count stacks of behaviours)
Point: "Triggering Unit"(I don't know if it's work, when not this is the fail)
Group -> Unittype: "Your central building" The rest shouldn't become changed.
(You said you have different range depends on city size... either you create multiple triggers and determine each unit type for central buildungs seperatly or you create multiple events and change the unit groups to variables with the different city sizes... I would prefer the first)
With this event you maybe could do the rest alone, but like I said before not 100% sure if it will work.
Edit: With upgraded tier the behaviour stacks should also increase.
2nd Edit: The main problem here with triggers is the following: You can't use variables in events. If it won't work a lot of work will facing you. :(
@Veta20: Go
Well, I must say this sounds very interesting. Likea risk type of game? Anyways, a combination of "if then else actions" will probably let you do what you want. For example. "If: an enemy unit is in the region of player 1 (Not exact words, but you know what i'm getting at)
"Then: spawn defensive units." "Else, spawn offensive units." something like that. also, there is a trigger that trades one building off from one player to another. So that shouldn't be a problem.
Thought about using Regions?
You can store them in Variables, create or delete them via triggers and check for units within them.
The only prob would be the event, AFAIK you can't trigger region events with variables...
You can combine the data editor power and trigger editor power. Basically the data editor can be used to scan for stuff that will trigger other things. It will be pretty easy to modify some effects with some variables, then.
Example:
You can make an "enemy in range of city"-detection with a behavior with a periodic search effect that will cause a dummy effect, if the search area detected an enemy unit.
That dummy effect can be used in a trigger event which will cause some actions defined by the cities stats (e.g. spawning unit count/strength determined by city power/wealth/habitants/size/loyalty...). The city is the source of the effect.
For the periodic effect I would use something like every 2 game seconds or something different that will be less predictable (less exploitable) like 1.7 seconds).
This depends how fast your units are and how big your search area is.
If a city is captured, you need to remove other player's garrison buffs and add the new owner's garrison buff to the building.
That would avoid making 200 regions around each city or periodically checking every region (SC1 works that way) and make the spawning a bit easier to do.
Hey there SC2Mapster,
I have a question pertaining to diplomacy type triggers. It's a bit complicated so bear with me. For certain [invincible] buildings (representing large medium or small cities) I would like there to be a circular region of a particular radius (dependent on city tier) such that when an enemy unit enters this region a group of "garrison" units spawn in the region to defend the city. If you are sieging an enemy city, it would be captured [the building would be given to you] once all enemy units (excluding the city itself and factory/resource structures) have been vanquished from the city-region. After a city is captured any enemy player that enters the city-region would then retrigger the garrisons to spawn, but this time for you.
However, if you enter an enemy city-region, trigger its garrison spawn, and then leave the city region (before capturing the city) - then the spawned garrison units will be removed. If there are no enemy units present at a given city-region any garrison units in that region should disappear. There is also the issue of garrison units being moved out of a city-region (to avoid their removal) and I am not sure if this could be addressed by simply creating a trigger that removes a garrison unit when it is not within proximity of a city.
This next bit is less of a priority (since I'm sure I could figure it out myself once the above is addressed). But I would also like for certain buildings [industry buildings] in the city-region to also be given to the conquering player, from the conquered player.
Edit: Basically whenever a city-region is entered by an enemy, I would like a defensive garrison to spawn. And when all of the defensive units or any other units the player being attacked in the location are gone, the city is lost/captured. In order to distinguish between a city that has yet to spawn its garrisons and once that has lost all its garrisons I was thinking of making the city be burning or have less HP (if that's detectable) or something along those lines whenever its under siege. It would only be capturable when under siege.
I know this is a bit complicated but I am really devoted to my current project and well, short of learning galaxy code I've tried everything. In StarCraft 1 I accomplished the above with individual regions and triggers for each city, as well as switches. Since this proves to be a much more ambitious undertaking (roughly 200 cities) I am hoping this can be accomplished in a much less tedious and time consuming manner.
Thanks you for any advice or input!
Okay, first of all we have some thing to solve before we start with triggers.
The first thing, I assume each city have a central building (if not create a invisible blablabla entity with will be the center), we need a behaviour, I will call "City Tier". At the beginning of the map you need to spread this behaviour the each central building with one stack.
Now you need a formular for the range which you said depends on the tier. With this formular we create the event now. "Unit enters region of unit"
For unit we need to the following: "Closest unit to point"
Range: Your formular (There is a function to count stacks of behaviours)
Point: "Triggering Unit"(I don't know if it's work, when not this is the fail)
Group -> Unittype: "Your central building" The rest shouldn't become changed.
(You said you have different range depends on city size... either you create multiple triggers and determine each unit type for central buildungs seperatly or you create multiple events and change the unit groups to variables with the different city sizes... I would prefer the first)
With this event you maybe could do the rest alone, but like I said before not 100% sure if it will work.
Edit: With upgraded tier the behaviour stacks should also increase.
2nd Edit: The main problem here with triggers is the following: You can't use variables in events. If it won't work a lot of work will facing you. :(
@Veta20: Go Well, I must say this sounds very interesting. Likea risk type of game? Anyways, a combination of "if then else actions" will probably let you do what you want. For example. "If: an enemy unit is in the region of player 1 (Not exact words, but you know what i'm getting at) "Then: spawn defensive units." "Else, spawn offensive units." something like that. also, there is a trigger that trades one building off from one player to another. So that shouldn't be a problem.
@Veta20: Go
Thought about using Regions?
You can store them in Variables, create or delete them via triggers and check for units within them.
The only prob would be the event, AFAIK you can't trigger region events with variables...
Cheers
Then
You can combine the data editor power and trigger editor power. Basically the data editor can be used to scan for stuff that will trigger other things. It will be pretty easy to modify some effects with some variables, then.
Example: You can make an "enemy in range of city"-detection with a behavior with a periodic search effect that will cause a dummy effect, if the search area detected an enemy unit. That dummy effect can be used in a trigger event which will cause some actions defined by the cities stats (e.g. spawning unit count/strength determined by city power/wealth/habitants/size/loyalty...). The city is the source of the effect.
For the periodic effect I would use something like every 2 game seconds or something different that will be less predictable (less exploitable) like 1.7 seconds). This depends how fast your units are and how big your search area is.
If a city is captured, you need to remove other player's garrison buffs and add the new owner's garrison buff to the building.
That would avoid making 200 regions around each city or periodically checking every region (SC1 works that way) and make the spawning a bit easier to do.
If you want more detailed information and some solutions to the other problem, read the information in my answer in your staredit.net's topic because I won't copy paste the whole post between sites. I only wanted to leave a hint how to solve this here because I couldn't stand the efficiency of the provided ideas.