The specifics of how you want it to function are important:
- Should the actual hero of the second AI player be the unit that uses the TP scroll, or is a dummy unit okay? The unit that is channeling the spell can't attack/do anything else and can be interrupted during it, but a dummy unit would be untargetable. A sub-question of this is whether it should only work if the second AI player has a hero nearby; should they be able to TP scroll if their heroes are all dead?
- Should it only work if that AI player has a hero with a TP scroll on them (thus consuming the scroll), or should it only cost the scroll for the AI that actually initiates the TP?
- Should the secondary TP happen in sync/tandem with the first TP, or is it acceptable for the second to start when the first has finished? If they should be synchronized, should the second TP cancel if the first gets interrupted before it goes off?
- Should the secondary TP happen from an advantageous location to get as many as the second AI player's units as possible, or just use the same starting location as the first TP?
- Should the second AI TP to their home base automatically, or to the same destination as the first TP?
Ignoring all of those questions, this is the simplest possible solution:
-
Cast
-

Events
-


Unit - A unit Starts the effect of an ability
-

Conditions
-


(Ability being cast) Equal to Item Town Portal
-


(Unit-type of (Triggering Unit)) not equal to DUMMY //without this line it's an infinite teleport loop
-

Actions
-


Set TempPoint = (Position of (Triggering Unit))
-


Set TempPlayerGroup = (All Allies of (Owner of (Triggering Unit)))
-


Unit - Create 1 DUMMY for (Random player from TempPlayerGroup) at TempPoint facing Default building facing degrees
-


Unit - Add a 5.00 second expiration timer to (Last created unit)
-


Hero - Create Scroll of Town Portal and give it to (Last created unit)
-


Hero - Order (Last created unit) to use (Last created item) on (Target unit of ability being cast)
-


Custom script: call RemoveLocation(udg_TempPoint) //keep the udg_ prefixes but change the names to match your variable names
-


Custom script: call DestroyForce(udg_TempPlayerGroup) //same as above
The reason a player group is involved is that it's the easiest way to get the allied AI player without having to specify which two player slots the AIs are in beforehand (so it will always work no matter the configuration). As long as they don't have a third allied player then it will never fail. The reason for the Player Group and Point variables is that they will become memory leaks if not properly cleaned up. Read this thread and the tutorial it links to if you are confused:
For a structured tutorial on the matter, read this. Hello guys! Credit to: Wolverabid, PurplePoot, Silvenon, Paskovich I want to make a list of things that leak and ways to fix them. Dynamic Unit Groups This trigger will instantly destroy dynamically generated unit groups. Trigger...
www.hiveworkshop.com