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

[General] Buildable Traps

Status
Not open for further replies.
Level 3
Joined
Jan 4, 2009
Messages
45
Hello. I am trying to make buildable traps. I have a worker called security master, who can build circle of power, which is invisible, and when an enemy unit steps on it it should trigger the trap. But I don't know how to make it work. I need help.
 
Level 6
Joined
Jan 29, 2010
Messages
213
make a trap with damage.
  • trap
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Unit - Create 1 "dummy unit" for (Owner of (Attacking unit)) at (Position of (Attacking unit)) facing Default building facing degrees
      • Unit - Order (Last created unit) to "ability" (Attacked unit)
      • Unit - Remove (Last created unit) from the game
      • Unit - Remove (Attacking unit) from the game
This trigger goes on trap attacking range.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
I would prefer much differend thing. Btw D0W3R, your triger leaks location.
Things that leaks

@Wolwy5 Trap triggers when enemy approaches it yes? Basically is means that unit is really close to the trap.

When you build a trap, add it to TrapGroup.
  • get trap
    • Events
      • Unit - A unit finishes construction
    • Conditions
      • (Unit-type of (Constructed unit)) Equals to <trap-unit here>
    • Actions
      • Unit Group - Add (Constructed unit) to TrapGroup
      • Trigger - Turn on loop <gen>
Loop trigger:
  • loop
    • Events
      • Time - Every 0.2 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TrapGroup and do Actions
        • Loop - Actions
          • Set tempu = (Picked unit)
          • Set p = (Position of tempu)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 25 of p matching (<condtions here, like if (Matching unit) isn't Building type, if it's alive and ofcourse if it's enemy ;) >)
            • Loop - Actions
              • If (All conditions are true) then do (Then - Actions) else do (Else - Actions)
                • If - Conditions
                  • (Picked unit) Not equal to No unit
                  • (tempu is in TrapGroup) Equal to True
                • Then - Actions
                  • // stuff here refered to traping target
                  • Unit - Kill tempu
                  • Unit Group - Remove tempu from TrapGroup
                  • If (All conditions are true) then do (Then - Actions) else do (Else - Actions)
                    • If - Conditions
                      • (TrapGroup is Empty) Equal to True
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
          • Custom script: call RemoveLocation(udg_p)
 
Status
Not open for further replies.
Top