Hi! I'm currently creating a map that has debris towers that block the ramps of the main bases when torn down. However, I want only the player that spawns in a particular main base to be able to destroy the towers in that main base (so opponents can't destroy it). It seems easy enough to do this by having the player that spawns in the main base own the towers in that base, and then only making them targetable/attackable by the owner.
However, I'm running into a roadblock trying to figure out how to assign the towers to the owner. I played with triggers some with no luck (not saying it can't be done), but at the moment I'm trying a Search Area effect approach. I'm trying to give the towers an ability with an effect that searches for a player-owned unit within a certain radius and then uses a behavior to change ownership (looking at Neural Parasite as a reference) to the player permanently and then disable the ability (so it stops casting after a player owns it).
But I'm having a lot of trouble with the details -- I know how to create and assign an ability, I know how to add an effect to the ability, and I know how to add behaviors to effects. The other details I'm having trouble with, like actually making the towers cast the ability and give themselves to the players. Does anyone have any ideas on how to accomplish this? Is this even a correct approach?
(Note: locking player spawns and simply assigning the towers to players 1 and 2 isn't an option because it's a 3-player map with random spawn positions)
I would probably go the trigger route. I would loop through the players and compare the distance between two points. Whichever is shortest is the player I would assign ownership to. The two points would be position of unit (the debris tower) and starting location of player.
Thank you! I ended up looking at triggers again based on your suggestion and came up with this:
----Unit -Any Unit Enters (Entire map)
----Region of Triggering Player = (Region((Start location of player (Triggering player)), 50.0)) <Region> [this is enough range to find the structures but avoid grabbing structures from the other bases]
----(Owner of (Triggering unit)) != 0 [don't want neutral players grabbing the structures]
----(Elapsed time of Game Started Timer) < 0.1 [possibly unnecessary, but I want to make sure no bugs happen and unowned towers get cleared seamlessly with a separate trigger after 0.1 seconds]
----Unit Group -Pick each unit in ([the debris towers] units in Region of Triggering Player owned by player 0 matching (No Value), with at most Any Amount) and do (Actions)
------------Unit -Change onwership of (Picked unit) to player (Triggering player) and Change Color