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

minimum range spell

Status
Not open for further replies.
Level 4
Joined
Oct 18, 2007
Messages
99
I want to make a skill that has minimum range to cast (if enemy too close it will not work and make the hero just keep attack, a ranged hero)
Any suggestions?
( a throw knife that will be cast only if the enemy is very far , I saw it is able in "blink" but I need other skills)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Try enhancing the ability with this trigger:

  • Untitled Trigger 017
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Holy Light
    • Actions
      • Set Temp_Loc_1 = (Position of (Triggering unit))
      • Set Temp_Loc_2 = (Position of (Target unit of ability being cast))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between Temp_Loc_1 and Temp_Loc_2) Less than 400.00
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
          • Wait 0.01 seconds
          • Animation - Play (Triggering unit)'s stand animation
        • Else - Actions
With or without the animation thingy.
 
Level 8
Joined
Dec 8, 2007
Messages
312
  • Untitled Trigger 002
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to <<Your ability>>
    • Actions
      • Set Point1 = (Position of (Triggering unit))
      • Set Point2 = (Target point of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between Point1 and Point2) Less than 500.00
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
      • Custom script: call RenoveLocation(udg_Point1)
      • Custom script: call RenoveLocation(udg_Point2)
Edit:
I was too slow :cry:
 
Level 7
Joined
Aug 29, 2007
Messages
336
  • Events
  • Unit - A unit Begins casting an ability
  • Conditions
  • (Ability being cast) Egual to [Your Spell]
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Condtions
  • (Distance between (Position of (Casting Unit)) and (Position of (Target unit of ability being cast))) greater than or equal to 100
  • Then - Actions
  • [Your actions here]
  • Else - Actions
  • Do nothing
Edit: Waaaaaaaay to slow xD + mine sucks considering the others sugestions :p
 
Level 4
Joined
Oct 18, 2007
Messages
99
make the variable "Point" an array so you wont have to make multiple variables when it isnt necessary. You can just do TempLoc[0] and TempLoc[1] for your 2 points. Thats what i always do

Everyone , thanks a lot for help but I need more hints about this X and Y into integer, can you be more specific?
And will it work for any player considering all players has the same ability?
(point1 = place of caster one then the next second point 1 = place of second caster?)
note : RemoveLocation(udg_Point1) is a bug
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
If you create a point array, you can set

Loc[0] = Position of triggering unit
Loc[1] = Position of target unit of ability being cast

It doesn't really matter if you do it like this or with two separate point variables. Using an array results in less variable in the list of variables, which is just a comfortability factor. It does not affect your spell or anything. However I don't like using arrays too much since you first have to select the variable, and then the "slot" [0], [1] or whatever.

The trigger is multi unit instanceable. It works even if there are more than one unit casting the spell. The trigger first runs for the first unit to cast, then for the second and so on.
 
Level 11
Joined
May 31, 2008
Messages
698
to remove a location you do "call RemoveLocation(udg_point1)"
If point is an array and you used point[1] then you must do "call RemoveLocation(udg_point[1])"
Using capitals does count btw, so Point is different from point.

Also as far as the variable array thing goes, arrays are sometimes better with more advanced triggers where you need more than just 1 or 2 points. For example i have a trigger that uses up to 12 locations, and it is easier to just use arrays rather than having 12 different variables. I guess its just a personal prefference.
 
Level 7
Joined
Aug 29, 2007
Messages
336
Set the mana cost to 0 and deal with the mana through triggers, might be one way of doing it.
 
Level 11
Joined
May 31, 2008
Messages
698
It shouldnt cost any mana because if you use the event "Unit begins casting ability", that should trigger before mana cost and before setting the cooldown. But if there is still a problem just trigger the mana restore, like everyone else said.
 
Status
Not open for further replies.
Top