• 🏆 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] Problem when unit get outside the map bounds

Status
Not open for further replies.
Level 4
Joined
Dec 16, 2013
Messages
84
now i get confused with this problem
i made jump strike ability (not really), means that your unit jump to x location and upon landing dealing damage.

problem is, i can always cast that spell to make a unit landing on outside the map. Like out of map bounds

how to solve this problem?
i was thinking about, when the unit cast jump strike to that map bounds, it will get yellow error message "unable to target there"

or when the unit land on that map bounds, it wll return to the position before the unit casted spell.

if im not wrong, dota map has this system:
when x hero target spell to the map bounds, it will give error message like " unable to get or target there"

how do i make trigger like that? pls teach me
or how do i solve this problem
 
Level 7
Joined
Jun 15, 2010
Messages
218
Post the trigger of the ability and i can tell you exacly what to do.
In most jumping abilities there are 2 location:
location 1 = position of the unit
location 2 = location 1 with polar offset of like 30 range towards units facing angle
now what you have to do is to check if location 2 is flyable. (this is a boleean condition)
if flyability is off then dont move the unit towards location 2
 
Level 4
Joined
Dec 16, 2013
Messages
84
Post the trigger of the ability and i can tell you exacly what to do.
In most jumping abilities there are 2 location:
location 1 = position of the unit
location 2 = location 1 with polar offset of like 30 range towards units facing angle
now what you have to do is to check if location 2 is flyable. (this is a boleean condition)
if flyability is off then dont move the unit towards location 2

here sir
  • Jump Strike
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Jump Strike
    • Actions
      • Set Hero[1] = (Casting unit)
      • Special Effect - Create a special effect attached to the weapon of Hero[1] using Abilities\Weapons\PhoenixMissile\Phoenix_Missile.mdl
      • Set Specialeffect[3] = (Last created special effect)
      • Unit - Turn collision for Hero[1] Off
      • Set Point[1] = (Position of Hero[1])
      • Set Point[2] = (Target point of ability being cast)
      • Set Real[1] = (Distance between Point[1] and Point[2])
      • Set Real[2] = Real[1]
      • Unit - Pause Hero[1]
      • Unit - Add Crow Form to Hero[1]
      • Unit - Remove Crow Form from Hero[1]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Real[1] Less than or equal to 100.00
        • Then - Actions
        • Else - Actions
          • Animation - Change Hero[1] flying height to 400.00 at (Real[2] / 2.00)
      • Animation - Change Hero[1]'s animation speed to (1200.00 / (Real[2] / 40.00))% of its original speed
      • Animation - Play Hero[1]'s attack slam animation
      • Custom script: call RemoveLocation(udg_Point[1])
      • Trigger - Turn on Jump Strike loop <gen>

  • Jump Strike loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Set Point[1] = (Position of Hero[1])
      • Set Point[3] = (Point[1] offset by 10.00 towards (Angle from Point[1] to Point[2]) degrees)
      • Unit - Move Hero[1] instantly to Point[3]
      • Set Real[1] = (Real[1] - 10.00)
      • Custom script: call RemoveLocation(udg_Point[1])
      • Custom script: call RemoveLocation(udg_Point[3])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Real[1] Less than or equal to 50.00
        • Then - Actions
          • Trigger - Turn off Jump Strike loop <gen>
          • Unit - Create 1 Dummy Caster for Player 1 (Red) at Point[2] facing (Target point of ability being cast)
          • Unit - Add Dummy Stomp to (Last created unit)
          • Unit - Add a 0.01 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Orc Tauren Chieftain - War Stomp
          • Custom script: call RemoveLocation(udg_Point[2])
          • Set Real[1] = 0.00
          • Set Real[2] = 0.00
          • Unit - Turn collision for Hero[1] On
          • Special Effect - Destroy Specialeffect[3]
          • Animation - Change Hero[1]'s animation speed to 100.00% of its original speed
          • Animation - Reset Hero[1]'s animation
          • Unit - Unpause Hero[1]
          • Set Hero[1] = No unit
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Real[1] Less than or equal to (Real[2] / 2.00)
            • Then - Actions
              • Animation - Change Hero[1] flying height to 0.00 at (Real[2] / 2.10)
            • Else - Actions
 
The above method will work (similarly you can check if the target point it within the playable map area, if not then you simply do not start an instance of the jump) though this will cause the ability to go on cooldown and consume the mana needed to cast the ability even though nothing will occur.

If you run this check in a seperate trigger which runs when a "unit starts casting an ability" rather than when they start the effect (you should still do everything else in a trigger which does that) then you can quickly order the unit to stop (or to carry out whatever it's previous order was if you can be bothered with building all the code for that but it'll be very tiresome) and the unit will not carry out the ability, you can then text a game message to the player who tried to cast the ability keep its mana and cooldown, setting it up so that it looks like an error message like with other things (though how you do that specifically I do not remember) I believe there's an "ErrorSim" snippet for it, or was.
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,266
You turn of the collision of the unit, and when you turn if on again, if its a ground unit it will automatically move to nearest area where it can move, if the closest area happens to the over the edge of the map bounds, it will do so. Worse if you can target that area.

You need to make a seperate trigger and make regions on the edges of map bounds which actually moves the unit inside the map again. If a unit enters region, move it a bit off edge instantly.


Another solution is also if target point is in region (make one region which goes along the edge of the map), -> stop remaining actions.
 
Level 4
Joined
Dec 16, 2013
Messages
84
The above method will work (similarly you can check if the target point it within the playable map area, if not then you simply do not start an instance of the jump) though this will cause the ability to go on cooldown and consume the mana needed to cast the ability even though nothing will occur.

If you run this check in a seperate trigger which runs when a "unit starts casting an ability" rather than when they start the effect (you should still do everything else in a trigger which does that) then you can quickly order the unit to stop (or to carry out whatever it's previous order was if you can be bothered with building all the code for that but it'll be very tiresome) and the unit will not carry out the ability, you can then text a game message to the player who tried to cast the ability keep its mana and cooldown, setting it up so that it looks like an error message like with other things (though how you do that specifically I do not remember) I believe there's an "ErrorSim" snippet for it, or was.

You turn of the collision of the unit, and when you turn if on again, if its a ground unit it will automatically move to nearest area where it can move, if the closest area happens to the over the edge of the map bounds, it will do so. Worse if you can target that area.

You need to make a seperate trigger and make regions on the edges of map bounds which actually moves the unit inside the map again. If a unit enters region, move it a bit off edge instantly.


Another solution is also if target point is in region (make one region which goes along the edge of the map), -> stop remaining actions.

THANK YOU GUYS i made it
i use event
if unit enter region
region = map bounds
actions: turn entering unit collision on
 
Status
Not open for further replies.
Top