I've created a simple trigger that, when a unit enters Region 001 its controlling player gets ownership of all structures in Region 002. Another trigger reverts control to Player 0 when a unit leaves Region 001. And... well, that's kind of the problem. A direct but unintended result of this is, if you ask more than 1 unit to go stand on Region 001, and one of them passes through it, control will revert to Player 0 even if other units are standing on Region 001. Furthermore, there's no 'ownership' state where the FIRST player to put a unit in Region 001 has preference until they no longer have units there.
Additionally, Region 002 has 5 structures, each of which are enumerated in the Trigger. To clarify:
Event: Any Unit Enters Region 001
Actions: Change Ownership of Unit 1 from (Power Station 01 Unit Group) to Owner of Triggering Unit and Change Color; Change Ownership of Unit 2 from (Power Station 01 Unit Group) to Owner of Triggering Unit and Change Color, etc
and there's a trigger that's Any Unit Leaves Region 001 that does the opposite.
The actual desired behavior would be for the to control Region 002 via Region 001 as long as they have any units in Region 001. Other players don't get control of Region 002 so long as the initial player has any unit in Region 001
I'm not looking for anyone to write a trigger for me. Something like "use Player Groups to do X" or "Use Data Tables to do Y" would at least point me in the right direction.
add a condition to only change ownership if no other unit is in the region (count number of unit in unitgroup <= 0). so whenever a unit leaves, all buildings wil only change if it was the last unit.
Ok that makes sense! How would I determing owning player? Is a simple way to check the unit group for which player has more units in the group?
So, any time a unit enters region 001, add it to unit group 001, then check to see which player has more units in unit group 001 and set all structures in region 002 to the resulting player.
Then, any time a unit leaves region 001, remove it from unit group 001... something like that?
you dont need to. you said the initial player keeps control aslong as he has units in region.
so whenever a unit enters region and the region is not empty (except buildings) nothing happens and whenever a unit leaves region and there are still units of himself in that region nothing happens. if it was the last unit of player X but player Y is there you have to change ownership by checking which player has most units there (count units in unitgroup by player). loop through all human players, have 2 local variables (current max player and max unit count; if number of units > max_unit_count then set current max player = loop player and set max_unit_count = units in region) and change ownership then.
Hey y'all, hopefully this will be easy.
I've created a simple trigger that, when a unit enters Region 001 its controlling player gets ownership of all structures in Region 002. Another trigger reverts control to Player 0 when a unit leaves Region 001. And... well, that's kind of the problem. A direct but unintended result of this is, if you ask more than 1 unit to go stand on Region 001, and one of them passes through it, control will revert to Player 0 even if other units are standing on Region 001. Furthermore, there's no 'ownership' state where the FIRST player to put a unit in Region 001 has preference until they no longer have units there.
Additionally, Region 002 has 5 structures, each of which are enumerated in the Trigger. To clarify:
Event: Any Unit Enters Region 001 Actions: Change Ownership of Unit 1 from (Power Station 01 Unit Group) to Owner of Triggering Unit and Change Color; Change Ownership of Unit 2 from (Power Station 01 Unit Group) to Owner of Triggering Unit and Change Color, etc
and there's a trigger that's Any Unit Leaves Region 001 that does the opposite.
The actual desired behavior would be for the to control Region 002 via Region 001 as long as they have any units in Region 001. Other players don't get control of Region 002 so long as the initial player has any unit in Region 001
I'm not looking for anyone to write a trigger for me. Something like "use Player Groups to do X" or "Use Data Tables to do Y" would at least point me in the right direction.
Thanks!
My current project: SCRAP (Scavenge, Collect, Reclaim, Attack, Prevail)
add a condition to only change ownership if no other unit is in the region (count number of unit in unitgroup <= 0). so whenever a unit leaves, all buildings wil only change if it was the last unit.
Ok that makes sense! How would I determing owning player? Is a simple way to check the unit group for which player has more units in the group?
So, any time a unit enters region 001, add it to unit group 001, then check to see which player has more units in unit group 001 and set all structures in region 002 to the resulting player.
Then, any time a unit leaves region 001, remove it from unit group 001... something like that?
My current project: SCRAP (Scavenge, Collect, Reclaim, Attack, Prevail)
you dont need to. you said the initial player keeps control aslong as he has units in region.
so whenever a unit enters region and the region is not empty (except buildings) nothing happens and whenever a unit leaves region and there are still units of himself in that region nothing happens. if it was the last unit of player X but player Y is there you have to change ownership by checking which player has most units there (count units in unitgroup by player). loop through all human players, have 2 local variables (current max player and max unit count; if number of units > max_unit_count then set current max player = loop player and set max_unit_count = units in region) and change ownership then.
I got it working! Thanks for your help!
My current project: SCRAP (Scavenge, Collect, Reclaim, Attack, Prevail)