I am new to this site so you'll have to forgive me if this has already been covered. I did a search for about 5-10 min but didn't seem to find anything related to what I am wanting to do. If it has already been covered a link to the thread would be appreciated.
Here is my concept: I have a map divided into areas containing structures with upgrades (new structures allowing for new units as well as upgrades for units). What I am wanting to do to have two teams of three battling for control of these areas in order to get the units and upgrades they want/need to beat the other team. As they enter the areas they gain control of the structure and as long as they have a unit presence they will have control but as soon as the other team destroys all the their units in the area the control of the area will switch to the other team. I hope that makes sense. My thinking is that this will sort of be like a tug of war game with a twist (only the units will be controlled directly).
My problem is figuring out the triggers for this. Though, I have been messing with the editor for over a year now I am still relatively new to the triggers. Any help would be appreciated.
Use a trigger with 2 types of events: Unit Enters Region and Unit Leaves Region, setting "Unit" to the preset "Any Unit."
You don't necessarily have to use pre-placed regions to make this work, although it would probably be much simpler. I'm going to assume that's what you will want to do. Use a Unit Enters Region and a Unit Leaves Region event for each territory you want to be contestable.
Next you need to operate a switch based on the triggering region. You'll need a case for each region you have. Then it's just a matter of setting up the proper conditions and actions:
General-Switch(Actions)dependingon(Triggeringregion)CasesGeneral-If(Barracks1)ActionsUnitGroup-Pickeachunitin(AnyunitsinBarracks1ownedbyplayerAnyPlayermatchingExcluded:Structure,Missile,Dead,Hidden,withatmost1)anddo(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(NumberofLivingunitsin(UnitsinBarracks1havingallianceEnemywithplayer(Ownerof(Pickedunit))matchingExcluded:Structure,Missile,Dead,Hidden,withatmostAnyAmount))==0(OwnerofBarracks1Unit)!=(Ownerof(Pickedunit))ThenUnit-ChangeownershipofBarracks1Unittoplayer(Ownerof(Pickedunit))andChangeColorUI-Display"You tooked it overz LOLOLOL:):):)"for(Playergroup((Ownerof(Pickedunit))))toChatareaElseDefault
This code basically picks 1 random unit from within the region (excluding structures - that's very important) and checks to see if the owner of that unit has any enemies. If there are enemies, nothing happens. If not, the ownership of the structure changes to the owner of that unit and a message is displayed. Make sure you set it to "At Most 1" or it might cause lag with a lot of units present.
You'll also need a trigger to handle a unit death within a region, which will look almost the same with a few key changes:
Contest(Death)EventsUnit-AnyUnitdiesLocalVariablesConditionsActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If((Positionof(Triggeringunit))isinBarracks1)==TrueThenUnitGroup-Pickeachunitin(AnyunitsinBarracks1ownedbyplayerAnyPlayermatchingExcluded:Structure,Missile,Dead,Hidden,withatmost1)anddo(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(NumberofLivingunitsin(UnitsinBarracks1havingallianceEnemywithplayer(Ownerof(Pickedunit))matchingExcluded:Structure,Missile,Dead,Hidden,withatmostAnyAmount))==0(OwnerofBarracks1Unit)!=(Ownerof(Pickedunit))ThenUnit-ChangeownershipofBarracks1Unittoplayer(Ownerof(Pickedunit))andChangeColorUI-Display"You tooked it overz LOLOLOL:):):)"for(Playergroup((Ownerof(Pickedunit))))toChatareaGeneral-BreakElseElse
Here I use the Unit Dies event and an If/Then/Else function instead of a Switch function. This is because there isn't a simple function I can use when determining different cases for the switch. Anyway, you'll need to use a different If/Then/Else function for each territory. The trigger basically checks which region the dying unit is in and runs the same actions as the first trigger.
That should do it. Let me know if you have any further questions.
Sorry, for not responding months ago. I started on this custom game and then life got busy. But, now I am finally having some time to devote to this custom. I have not tried your triggers yet but I am going to do so either tonight or tomorrow. Not sure if you still want feedback on the triggers you posted so long after your response but I'll let you know how it works for me anyway. I really appreciate the effort you went to to helping me.
Thanks much,
-muse
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I am new to this site so you'll have to forgive me if this has already been covered. I did a search for about 5-10 min but didn't seem to find anything related to what I am wanting to do. If it has already been covered a link to the thread would be appreciated.
Here is my concept: I have a map divided into areas containing structures with upgrades (new structures allowing for new units as well as upgrades for units). What I am wanting to do to have two teams of three battling for control of these areas in order to get the units and upgrades they want/need to beat the other team. As they enter the areas they gain control of the structure and as long as they have a unit presence they will have control but as soon as the other team destroys all the their units in the area the control of the area will switch to the other team. I hope that makes sense. My thinking is that this will sort of be like a tug of war game with a twist (only the units will be controlled directly).
My problem is figuring out the triggers for this. Though, I have been messing with the editor for over a year now I am still relatively new to the triggers. Any help would be appreciated.
Use a trigger with 2 types of events: Unit Enters Region and Unit Leaves Region, setting "Unit" to the preset "Any Unit."
You don't necessarily have to use pre-placed regions to make this work, although it would probably be much simpler. I'm going to assume that's what you will want to do. Use a Unit Enters Region and a Unit Leaves Region event for each territory you want to be contestable.
Here's an example of what I mean so far:
Next you need to operate a switch based on the triggering region. You'll need a case for each region you have. Then it's just a matter of setting up the proper conditions and actions:
This code basically picks 1 random unit from within the region (excluding structures - that's very important) and checks to see if the owner of that unit has any enemies. If there are enemies, nothing happens. If not, the ownership of the structure changes to the owner of that unit and a message is displayed. Make sure you set it to "At Most 1" or it might cause lag with a lot of units present.
You'll also need a trigger to handle a unit death within a region, which will look almost the same with a few key changes:
Here I use the Unit Dies event and an If/Then/Else function instead of a Switch function. This is because there isn't a simple function I can use when determining different cases for the switch. Anyway, you'll need to use a different If/Then/Else function for each territory. The trigger basically checks which region the dying unit is in and runs the same actions as the first trigger.
That should do it. Let me know if you have any further questions.
Was my response helpful? I'm thinking about making it into a mini-tutorial. Please let me know :)
@BasharTeg: Go
Sorry, for not responding months ago. I started on this custom game and then life got busy. But, now I am finally having some time to devote to this custom. I have not tried your triggers yet but I am going to do so either tonight or tomorrow. Not sure if you still want feedback on the triggers you posted so long after your response but I'll let you know how it works for me anyway. I really appreciate the effort you went to to helping me.
Thanks much,
-muse