• 🏆 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] Can you help me with Ice Trap Spell?

Status
Not open for further replies.
When I cast it it makes the trap, but when unit enter the trap nothing happens?
  • Ice Trap cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ice Trap
    • Actions
      • Set Hunter_tempIceTrapPoint = ((Position of Hero_units[3]) offset by 50.00 towards (Facing of Hero_units[3]) degrees)
      • Region - Center Ice Trap <gen> on Hunter_tempIceTrapPoint
      • Unit - Create 1 Dummy_Ice_trap for Neutral Passive at (Center of Ice Trap <gen>) facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Hunter_tempIceTrapPoint)
      • Trigger - Turn on Ice Trap Triggering <gen>
  • Ice Trap Triggering
    • Events
      • Unit - A unit enters Ice Trap <gen>
    • Conditions
      • ((Entering unit) belongs to an enemy of (Owner of Hero_units[3])) Equal to True
    • Actions
      • Sound - Play IceBarrirerState <gen>
      • Special Effect - Create a special effect attached to the feet of (Entering unit) using war3mapImported\ice cube.mdx
      • Set Hunter_Ice_trap_effect = (Last created special effect)
      • Unit - Set (Entering unit) movement speed to 0.00
      • Unit Group - Add (Entering unit) to Hunter_IceTrappedGroup
      • Custom script: call IssueTargetOrderById( udg_Dummy1, 'ANsi', GetEnteringUnit() )
      • Countdown Timer - Start Timer_Hunter_Ice_Trap as a One-shot timer that will expire in 10.00 seconds
      • Trigger - Turn off (This trigger)
  • Ice Trap Timer off
    • Events
      • Time - Timer_Hunter_Ice_Trap expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Hunter_IceTrappedGroup and do (Actions)
        • Loop - Actions
          • Unit - Set (Picked unit) movement speed to (Default movement speed of (Picked unit))
          • Unit Group - Remove (Picked unit) from Hunter_IceTrappedGroup
      • Special Effect - Destroy Hunter_Ice_trap_effect
 
Level 18
Joined
May 11, 2012
Messages
2,103
This is so very inefficient.
In cast trigger, set the Hero_units[3] in a variable.
  • Set Hunter_tempIceTrapPoint = ((Position of Hero_units[3]) offset by 50.00 towards (Facing of Hero_units[3]) degrees)
leaks point (Position of Hero_units[3]). Set that point into variable.
The thing why this doesn't works is because you never create the "dummy1" unit. Create that unit in cast trigger, set it into variable "dummy1" and then in issue order refer to it.
There is easier way to make this.
 
1. How can it leak when I destroy the location later in the same trigger....?
2. Hunter_tempIceTrapPoint is the variable point o_O
3. the "dummy1" stays in the map from the beginning....
4. the ISSUE ORDER IS SILENCE< SILENCE IS NOT ON TRIGGER UNIT ORDER OPTIONS THAT'S WHY I NEED ID
5. I'm telling you that not only some of the "triggering" triggers don't work, but all, mean sound, special effect, movement.
6. How is the easier way?
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
"position offset by range r towards angle a" creates 2 locations: one location which serves as the center and the other as one which is offset from the center by range r and angle a.

You save only the latter in variable.

Also, I believe that the problem is in the "region" itself. The event "Unit enters region" is registered only upon map initialization and it means that if unit get inside rectangle of 2 points (A[x1, y1] and B[x2, y2]), it fires the trigger. However these two points do not move when you move the region.
What does that mean: The unit will most likely get captured when it enter the area where the region is during map initialization, not later.


Edit: Also, the spell is not MUI. Unless you want to make it MUI, there is no need to have unit group variable when you can use unit variable.
 
"position offset by range r towards angle a" creates 2 locations: one location which serves as the center and the other as one which is offset from the center by range r and angle a.

You save only the latter in variable.

Also, I believe that the problem is in the "region" itself. The event "Unit enters region" is registered only upon map initialization and it means that if unit get inside rectangle of 2 points (A[x1, y1] and B[x2, y2]), it fires the trigger. However these two points do not move when you move the region.
What does that mean: The unit will most likely get captured when it enter the area where the region is during map initialization, not later.


Edit: Also, the spell is not MUI. Unless you want to make it MUI, there is no need to have unit group variable when you can use unit variable.

1. Ok. I will make second point
2. You are wrong. Moving regions works fine!
3. I don't need it to be MUI, I make it only for one and only hero.
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
1. Ok. I will make second point
2. You are wrong. Moving regions works fine!
3. I don't need it to be MUI, I make it only for one and only hero.
You misunderstand in points #2 and #3.


#2 Moving regions
While moving regions does indeed work and you can still use it as a reference for some things - like using it for "center of (region)" when you want to create special effect there, it does not change where the event "Unit enters regions" fires.

To explain better I will use this situation:
Code:
   x
    A
(A is location where region is upon map initialization)



   .    ----------> x
    A                 B
(Region is moved to location B)



   .                      .   --------------> x
    A                      B                   C
(Region is moved somewhere else, to some location C)
The event will still fire only when unit enters location A, even when the region is actually at location B or C at that moment. Why? Because the event was registered at location A upon map initialization.

Look at the map attached at the bottom of this post.


-----------

#3 MUI
Just because the spell is used by 1 unit only does not necessarily mean that the spell shouldn't be MUI.
What is important is how many instances of that spell can run at a time.
E.g. if the trap stuns some unit and in that 10 second interval you can cast another trap which will stun another unit, then your spell will bug out, because the first trapped unit will be stunned for at least [10 + remaining time] seconds.

If only 1 instance of the spell can run at a time, then as I've said, you don't need unit group at all, because why create unit group when it will be filled by 1 unit max?



______
Attached test map:
 

Attachments

  • MovingRegions.w3x
    17.7 KB · Views: 46
#3 MUI
Just because the spell is used by 1 unit only does not necessarily mean that the spell shouldn't be MUI.
What is important is how many instances of that spell can run at a time.
E.g. if the trap stuns some unit and in that 10 second interval you can cast another trap which will stun another unit, then your spell will bug out, because the first trapped unit will be stunned for at least [10 + remaining time] seconds.

If only 1 instance of the spell can run at a time, then as I've said, you don't need unit group at all, because why create unit group when it will be filled by 1 unit max?
I told you I don't need it to be MUI because only one unit will use it at all times. the cooldown is more than the duration, so there won't be more than one trap. I will see your attachment.

edit: Hmm I see. what do I do then?

edit2: I had a topic before in the help forum and one user helped me to make game mode king of the hill, qhwre a region moves from place to place every 3 min and staying in this region gives you points. right now it is on the big development map I'm working on, this spell is for other map.
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
If you move region to some location without saving that location inside variable, you will leak that location that's why I saved the location beforehand and move region to saved location.

He may have used the action "Event - Add new event"
 
do you want to compare and tell me? i will give you the trigger. I made it, he guided me.
This here is working fine.

  • king locations
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set king_points[1] = king 1 <gen>
      • Set king_points[2] = king 2 <gen>
      • Set king_points[3] = king 3 <gen>
      • Set king_points[4] = king 4 <gen>
      • Set king_points[5] = king 5 <gen>
      • Set king_points[6] = king 6 <gen>
      • Set king_points[7] = king 7 <gen>
      • Set king_points[8] = king 8 <gen>
      • Set king_points[9] = king 9 <gen>
      • Set king_points[10] = king 10 <gen>
      • Set king_points[11] = king 11 <gen>
      • Set king_points[12] = king 12 <gen>
      • Set king_points[13] = king 13 <gen>
      • Set king_points[14] = king 14 <gen>
      • Set king_points[15] = king 15 <gen>
      • Set king_points[16] = king 16 <gen>
  • relocate
    • Events
      • Time - Every 180.00 seconds of game time
    • Conditions
    • Actions
      • Region - Center king <gen> on (Center of king_points[(Random integer number between 1 and 16)])
      • Unit - Move king_circle instantly to (Center of king <gen>)
      • Cinematic - Ping minimap for (All players) at (Center of king <gen>) for 3.00 seconds
      • Sound - Play MapPing <gen>
  • king integer
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: call DestroyGroup(udg_King_alliance_in)
      • Custom script: call DestroyGroup(udg_King_horde_in)
      • Set King_alliance_in = (Units in king <gen> matching (((Race of (Matching unit)) Equal to Human) and ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True))))
      • Set King_horde_in = (Units in king <gen> matching (((Race of (Matching unit)) Equal to Orc) and ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Number of units in King_alliance_in) Greater than 0
              • (Number of units in King_horde_in) Equal to 0
        • Then - Actions
          • Set king_ally_points = (king_ally_points + ((Number of units in King_alliance_in) x 2))
          • Multiboard - Set the text for (Last created multiboard) item in column 1, row 1 to ((String(king_ally_points)) + ( / + (String(king_cap))))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Number of units in King_alliance_in) Equal to 0
              • (Number of units in King_horde_in) Greater than 0
        • Then - Actions
          • Set king_horde_points = (king_horde_points + ((Number of units in King_horde_in) x 2))
          • Multiboard - Set the text for (Last created multiboard) item in column 1, row 2 to ((String(king_horde_points)) + ( / + (String(king_cap))))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • king_ally_points Equal to king_cap
        • Then - Actions
          • Game - Pause the game
          • Dialog - Show Victory for Player 1 (Red)
          • Dialog - Show Victory for Player 2 (Blue)
          • Dialog - Show Victory for Player 3 (Teal)
          • Dialog - Show Victory for Player 4 (Purple)
          • Dialog - Show Victory for Player 5 (Yellow)
          • Dialog - Show Victory for Player 6 (Orange)
          • Dialog - Show Defeat for Player 7 (Green)
          • Dialog - Show Defeat for Player 8 (Pink)
          • Dialog - Show Defeat for Player 9 (Gray)
          • Dialog - Show Defeat for Player 10 (Light Blue)
          • Dialog - Show Defeat for Player 11 (Dark Green)
          • Dialog - Show Defeat for Player 12 (Brown)
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • king_horde_points Equal to king_cap
        • Then - Actions
          • Game - Pause the game
          • Dialog - Show Defeat for Player 1 (Red)
          • Dialog - Show Defeat for Player 2 (Blue)
          • Dialog - Show Defeat for Player 3 (Teal)
          • Dialog - Show Defeat for Player 4 (Purple)
          • Dialog - Show Defeat for Player 5 (Yellow)
          • Dialog - Show Defeat for Player 6 (Orange)
          • Dialog - Show Victory for Player 7 (Green)
          • Dialog - Show Victory for Player 8 (Pink)
          • Dialog - Show Victory for Player 9 (Gray)
          • Dialog - Show Victory for Player 10 (Light Blue)
          • Dialog - Show Victory for Player 11 (Dark Green)
          • Dialog - Show Victory for Player 12 (Brown)
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Also he should learn how to code a little better.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
You notice how both say all conditions are true.

You only ever need and all condition block inside an or condition block. Other than that never use it again.

Using last created multiboard in that trigger is both inefficient and prone to bugs as who know what the last created multiboard is.

Also note that 3 seconds is a long time. If a unit is in the region and dies that event will not catch that unit. So the person that should have won would not win.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
what do I do then, the trap can be put anywhere..?

It helps if we know what you are referring to.

If it is about moving the region then using a unit enters region event with a trigger is the best option. You would also need to destroy and create the trigger whenever the region is moved to keep it efficient and working correctly.

@deathismyfriend there is only one multiboard, I don't need to put it in variable.

Anything used twice or more should always be stored into a variable. So for efficiency and speed yes it should be in a variable. This has been said many times.
 
Status
Not open for further replies.
Top