• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Quick map editor question

Status
Not open for further replies.
Level 2
Joined
Mar 17, 2021
Messages
10
Me and my friend likes to play 2v2 vs AI. I modify existing maps to help the AI out to make it more challenging. One thing i really want to try is to make the AI's town portal work an both their own units and their allies. So when they tp away from a bad fight, their ally joins them in the tp. Changing the targets allowed from the item only changes where the tp transports u to, but not units transported.
 
Level 21
Joined
Dec 4, 2007
Messages
1,481
A quick and hacky way would be, to temporarily change the units ownership to the player number of the hero using the town portal.
Just add them to a unitgroup, change ownership and after the tp reset it.
 
Level 39
Joined
Feb 27, 2007
Messages
5,031
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:
 
Level 2
Joined
Mar 17, 2021
Messages
10
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:
thank you very much!
After testing it a little bit it deffinatly works, but i noticed that sometimes the dummy is on the same team as the triggering unit. dont know how to fix this...

For now i just copy-pasted the unit and hero actions from the trigger two times so it creates 3 dummies and hopefully atleast one of them is on the allied team of the triggering unit :p
 
Level 39
Joined
Feb 27, 2007
Messages
5,031
I suppose it might be possible that a player is included in the list of its allies, but that seems bizarre to me. You can prevent this issue by adding this line right after the line that assigns TempPlayerGroup:
  • Player Group - Remove (Owner of (Triggering Unit)) from TempPlayerGroup
 
Level 2
Joined
Mar 17, 2021
Messages
10
I suppose it might be possible that a player is included in the list of its allies, but that seems bizarre to me. You can prevent this issue by adding this line right after the line that assigns TempPlayerGroup:
  • Player Group - Remove (Owner of (Triggering Unit)) from TempPlayerGroup
oh nice! thanks a lot
 
Status
Not open for further replies.
Top