• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Teleport Item

Level 6
Joined
Mar 28, 2018
Messages
132
I have an idea for an item and I don't know if it's possible or how to do it :(
I would like to make an item called Boots of Evasion and have the passive ability to teleport 500 distance behind only when surrounded by enemies and after the ability is activated, the item goes on cooldown for 30 seconds and so on.
If there is a wall/obstacle behind me, teleport me to another place nearby.
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,296
Fundamentally you need to break the problem down into 2 parts.
  • Detect if the unit is surrounded. You need to define what "surrounded" means, such as what the minimum number of units and their positions would be for you to consider the unit surrounded. A simple meaning might be to check if there are 3 or more units very close to the units collision radius. This can be done by sampling units in a max collision radius * 2 circle around the item user and filtering them using the unit in range of position native with the range being based on the item user's collision radius, or max collision radius + some small amount.
  • Find a suitable teleport location. This is the very hard part to implement. In newer games like StarCraft II, you can perform some pathfinding tests from the item user to some sampled locations to test if a path exists and if so teleport the unit. Warcraft III lacks native support for this functionality, so you instead need to try and implement your own logic for this. A simple approach might be to test every map cell distance between the item user's origin and the desired teleport point as defined by a polar offset with 500 distance, passing (allowing teleport) if no blocked tiles exist. Should such a test fail, you then iteratively choose another point, possibly another polar offset with 500 distance but instead with angle offset by a constant such as 30 degrees. While doing this track the furthest away reachable point that was encountered so that can be used as a fall back should all 12 tests fail to extend to 500 range.
Ideally for the second part some sort of path finder logic should be used as this will likely end up a lot more efficient or producing significantly better results than sampling. However, these are very complex to implement, especially in a way that runs fast.
 
Top