I am trying to create a trigger that will combine two units into one.
For instance, if player 1 puts a Siege Tank and Marauder onto the point, they are removed and player 1 gets a Thor.
Currently I have a trigger that combines two Siege Tanks into a single Thor. The problem is creating a trigger that can combine units that aren't the same type. Any advice is welcome. My tank combine trigger posted below.
tank combine
Events
Unit - Any Unit Enters Region 001
Local Variables
Conditions
And
Conditions
(Count of units in Region 001 having alliance Ally with player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) > 1
(Unit type of (Triggering unit)) == Siege Tank (Tank Mode)
Actions
Unit - Create 1 Thor for player (Triggering player) at marine binding spawn using default facing (No Options)
Unit Group - Pick each unit in ((Unit type of (Triggering unit)) units in (Triggering region) owned by player (Triggering player) matching Excluded: Missile, * * Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Unit - Remove (Picked unit) from the game
Edit #1: This particular trigger works. I can put two tanks into the region and they will be removed for me to get a Thor. However, I do not know how to make this trigger work with units of different types.
That trigger does not work since as long there is any other unit type belonging to any other player in the region sending a siege tank will give you a Thor and not remove the other unit.
You need to break the problem into parts.
Resolve what units are in the region.
Determine what combination to perform (if any).
Create the resulting unit.
Clean up the appropriate units (only them, not other units).
I recommend forgetting conditions for this trigger, it is too generic and needs complex evaluations. You firstly get all units of a specific type inside the region (owned by the triggering unit's owner) and allocate them to different groups. You then use a multiple selection statement to compare the count in each unit type group to the counts required for a certain output unit in a certain pre-determined order (so that creating 1 product is higher priority than another if the unit can be used for multiple products). Once a product has been selected you create it somewhere in the region and then remove the appropriate number of units from each of the unit type groups (allow internal ordering to decide), leaving the rest intact. If only 2 unit combinations are possible then consider writing a custom action for it to reduce procedural coupling.
An alternative implementation could iterate through all units belonging to the triggering player (owner of triggering unit) and set a quantity of that unit type and checks if any matches are possible. Once a product is found the rest of the units can be skipped and the product made. Through complex data structures this would likely be more efficient, especially if you want to support a lot of unit types and output combinations.
You might also want to look at the High Templar and Dark Templar in the object editor. These units can merge with their same type or each other's type to form an Archon. This data only implementation likely is more polished and user friendly than any triggered region implementation. The reason WC3 used regions for this was because there was no such innate merge capability.
Thank you so much for the reply. The biggest issue I am running into now is finding a way to efficiently remove the units in the region. Do you have any advice for this? I can't seem to find a way to have them remove units of different types - The most I have been able to do is remove the triggering unit (of which there is only one).
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello,
I am trying to create a trigger that will combine two units into one.
For instance, if player 1 puts a Siege Tank and Marauder onto the point, they are removed and player 1 gets a Thor.
Currently I have a trigger that combines two Siege Tanks into a single Thor. The problem is creating a trigger that can combine units that aren't the same type. Any advice is welcome. My tank combine trigger posted below.
Edit #1: This particular trigger works. I can put two tanks into the region and they will be removed for me to get a Thor. However, I do not know how to make this trigger work with units of different types.
That trigger does not work since as long there is any other unit type belonging to any other player in the region sending a siege tank will give you a Thor and not remove the other unit.
You need to break the problem into parts.
I recommend forgetting conditions for this trigger, it is too generic and needs complex evaluations. You firstly get all units of a specific type inside the region (owned by the triggering unit's owner) and allocate them to different groups. You then use a multiple selection statement to compare the count in each unit type group to the counts required for a certain output unit in a certain pre-determined order (so that creating 1 product is higher priority than another if the unit can be used for multiple products). Once a product has been selected you create it somewhere in the region and then remove the appropriate number of units from each of the unit type groups (allow internal ordering to decide), leaving the rest intact. If only 2 unit combinations are possible then consider writing a custom action for it to reduce procedural coupling.
An alternative implementation could iterate through all units belonging to the triggering player (owner of triggering unit) and set a quantity of that unit type and checks if any matches are possible. Once a product is found the rest of the units can be skipped and the product made. Through complex data structures this would likely be more efficient, especially if you want to support a lot of unit types and output combinations.
You might also want to look at the High Templar and Dark Templar in the object editor. These units can merge with their same type or each other's type to form an Archon. This data only implementation likely is more polished and user friendly than any triggered region implementation. The reason WC3 used regions for this was because there was no such innate merge capability.
Thank you so much for the reply. The biggest issue I am running into now is finding a way to efficiently remove the units in the region. Do you have any advice for this? I can't seem to find a way to have them remove units of different types - The most I have been able to do is remove the triggering unit (of which there is only one).