• 🏆 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!

[Solved] Teleporting units on unfinished buildings

Status
Not open for further replies.
Level 25
Joined
Sep 26, 2009
Messages
2,387
I don't know if it can be done more efficiently than what I am about to post...

... if not, you could use a hashtable and save a boolean value in it. For example like this:


1) Creates and saves hashtable which you are going to use for this purpose

  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Check_Hash = (Last created hashtable)

2) Two triggers, which change the boolean value of each structure.

  • Construction Start
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Hashtable - Save True as (Key Constructing) of (Key (Constructing structure)) in Check_Hash
In this trigger, whenever a unit starts constructing a building, it saves value "True" for this building.


  • Construction End
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Hashtable - Save False as (Key Constructing) of (Key (Constructed structure)) in Check_Hash
This changes the bool value to "False" when the structure has been finished.


3) Now when you want to use a spell like the one you wrote about, you check the boolean value:
  • Random spell
    • Events
    • Conditions
      • (Load (Key Constructing) of (Key (Target unit of ability being cast)) from Check_Hash) Equal to True
    • Actions
      • -------- since the value of targeted unit is "True" (= is being constructed), stop trigger unit --------
      • Unit - Order (Triggering unit) to Stop
Boolean value is set to "False" by default, so even though this trigger does not check whether the target is a structure or not, the bool value of the target will be "false" if it's a normal (non-structure) unit or finished structure.


**I'm unsure if it is needed, but if it is, here is a trigger which clears child hashtables of destroyed structures:
  • Structure desroyed
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to True
    • Actions
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in Check_Hash
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
What does "it is some warcraft leak" mean?

I'm pretty sure the only way you might be able to catch if the unit i tries to TP to a unfinished structure is if you lookup the Order ID of Staff of Teleport and check when the unit tries to use it, but in order to know if the building is finished you'd probably need to index all buildings and add them to a group when they are completed.



I'm not entirely sure, but I think you should look up the Town Portal Scroll ability because I feel like it probably doesn't work on unfinished town halls. You would have to add the tag of Town Hall to the unit for it to work though.

Edit: Solution! Item Town Portal ability cannot target unfinished structures, and it looks like it has the same fields as Staff of Tele
 
Status
Not open for further replies.
Top