• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Disable some units until x time

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
333
How can I disable some towers near enemy before x minutes? (but you can build towers over x range), and can I use wait and then turning off the trigger?! (on the first trigger) instead of making 2?
  • Disable structure near vampires
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • Multiple ConditionsOr - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Constructing structure)) Equal to (==) Boulder Tower
          • (Unit-type of (Constructing structure)) Equal to (==) Boulder Tower (Super)
          • (Unit-type of (Constructing structure)) Equal to (==) Boulder Tower (Ultra)
    • Actions
      • Set Point_Building = (Position of (Constructing structure))
      • Set UnitGroup = (Units within 256.00 of Point_Building matching (((Matching unit) belongs to an enemy of (Owner of (Constructing structure))) Equal to (==) True))
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: call DestroyGroup(udg_UnitGroup)
  • Enable structure near vampires
    • Events
      • Time - Elapsed game time is 1080.00 seconds
    • Conditions
    • Actions
      • Trigger - Turn off Disable structure near vampires <gen>
Also somehow this trigger doesn't work very well, sometimes the unit moves sometimes not, and when I pick that item and use again the ability then I will move back to that place without the item!
  • Random Teleport
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Random Teleport [Human]
    • Actions
      • Set Item_RandomTeleport = (Random item in (Playable map area))
      • Set Point_Item = (Position of Item_RandomTeleport)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Item-type of Item_RandomTeleport) Equal to (==) Bundle of Lumber
          • Then - Actions
            • Special Effect - Create a special effect at (Position of (Casting unit)) using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
            • Special Effect - Destroy (Last created special effect)
            • Unit - Move (Casting unit) instantly to Point_Item
            • Custom script: call RemoveLocation(udg_Point_Item)
          • Else - Actions
 
Level 9
Joined
Jul 30, 2018
Messages
445
On the first problem: use Constructed Structure, not Constructing Structure Actually yeah, it should indeed be Constructing Structure. What exactly is the problem with the triggers? Also, you are leaking a point: (Point_Building)

The second looks okay. Maybe use Triggering unit instead of Casting unit. That might conflict with some other trigger if you have other spells being cast at the same time. Also, you're leaking
(Position of (Casting unit)) and if the If-statement doesn't pass, you also leak Point_Item. Move Custom script: call RemoveLocation(udg_Point_Item) outside the if statement and use another temp point for the special effect or use Create Special Effect On Unit.
 
Last edited:
Level 7
Joined
Apr 17, 2017
Messages
316
all you need to do is, count units in your units group, if it's greater than 0 remove building:
  • cons
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to Town Hall
    • Actions
      • Set temp = (Position of (Constructing structure))
      • Set ug = (Units within 1500.00 of temp matching (((Matching unit) belongs to an enemy of (Owner of (Constructing structure))) Equal to True))
      • Custom script: call RemoveLocation(udg_temp)
      • Custom script: set bj_wantDestroyGroup = true
      • Set number = (Number of units in ug)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • number Greater than 0
        • Then - Actions
          • Unit - Kill (Constructing structure)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_ug)
      • Set number = 0
 
Level 7
Joined
Apr 17, 2017
Messages
316
The spell only works if the random item type is bundle of lumber, so if your map has a lot of other items other than bundle of lumber, it wont move the caster. To solve that you need to pick a random item with a matching condition:
  • Random Teleport
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Random Teleport [Human]
    • Actions
      • Set Item_RandomTeleport = (Random item in (Playable map area) matching ((Item-type of (Matching item)) Equal to Bundle of Lumber))
      • Set Point_Item = (Position of Item_RandomTeleport)
      • Set Point_Unit = (Position of (Triggering unit))
      • Special Effect - Create a special effect at Point_Unit using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Move (Triggering unit) instantly to Point_Item
      • Custom script: call RemoveLocation(udg_Point_Unit)
      • Custom script: call RemoveLocation(udg_Point_Item)
Note: if your map doesn't have bundle of lumber when the spell is cast, the spell wont work but I guess this is what you wanted.
 
Status
Not open for further replies.
Top