I would to switch control of the buildings (in a region) based on who has units in the region (like zone control). What would be the easiest way (I'd assume using triggers) to implement this?
Edit: Found a good example once I looked around a little more (and switched search terms)
Events
Unit - Any Unit Enters (SomeRegion)
Local Variables
CurrentOwner = 0 <Integer>
Conditions
Actions
Variable - Set CurrentOwner = (Owner of (Unit 1 from (Any units in (SomeRegion) owned by player Any Player matching Required: Structure; Excluded: Missile, Dead, Hidden, with at most Any Amount)))
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in (Any units in (SomeRegion) owned by player (Owner of (Triggering unit)) matching Excluded: Structure, Missile, Dead, Hidden, with at most Any Amount)) > (Number of Living units in (Any units in (SomeRegion) owned by player CurrentOwner matching Excluded: Structure, Missile, Dead, Hidden, with at most Any Amount))
Then
Unit Group - Pick each unit in (Any units in (SomeRegion) owned by player Any Player matching Required: Structure; Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Unit - Change ownership of (Picked unit) to player (Owner of (Triggering unit)) and Change Color
Else
Unit enters region.
Find out who currently owns buildings.
Compare unit count for player whose unit entered to owner of buildings.
If player whose unit entered has more, give all buildings in region to that player.
Doesn't quite seem to be working, not 100% sure why. Not giving me any errors, just doesn't seem to be switching unit control at all (it remains neutral regardless of original unit placement/unit movement).
Edit: Got it working, not really sure what was going wrong. Thanks.
I would to switch control of the buildings (in a region) based on who has units in the region (like zone control). What would be the easiest way (I'd assume using triggers) to implement this?
Edit: Found a good example once I looked around a little more (and switched search terms)
Events
Unit - Any Unit Enters (SomeRegion)
Local Variables
CurrentOwner = 0 <Integer>
Conditions
Actions
Variable - Set CurrentOwner = (Owner of (Unit 1 from (Any units in (SomeRegion) owned by player Any Player matching Required: Structure; Excluded: Missile, Dead, Hidden, with at most Any Amount)))
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in (Any units in (SomeRegion) owned by player (Owner of (Triggering unit)) matching Excluded: Structure, Missile, Dead, Hidden, with at most Any Amount)) > (Number of Living units in (Any units in (SomeRegion) owned by player CurrentOwner matching Excluded: Structure, Missile, Dead, Hidden, with at most Any Amount))
Then
Unit Group - Pick each unit in (Any units in (SomeRegion) owned by player Any Player matching Required: Structure; Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Unit - Change ownership of (Picked unit) to player (Owner of (Triggering unit)) and Change Color
Else
Unit enters region.
Find out who currently owns buildings.
Compare unit count for player whose unit entered to owner of buildings.
If player whose unit entered has more, give all buildings in region to that player.
@Nashadun: Go
Would that reset the variable current owner to whoever last entered the region?
The variable is reset whenever the trigger runs. The variable is not important, it just makes the trigger less messy.
Doesn't quite seem to be working, not 100% sure why. Not giving me any errors, just doesn't seem to be switching unit control at all (it remains neutral regardless of original unit placement/unit movement).
Edit: Got it working, not really sure what was going wrong. Thanks.