- Joined
- Feb 20, 2015
- Messages
- 39
How do i make a unit can't cast spells if its too close to the casting unit or targeted unit.(sorry for my bad english)
+ Rep!
spell
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Banish
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Integer((Distance between (Position of (Triggering unit)) and (Position of (Target unit of ability being cast))))) Less than or equal to 300
Then - Actions
Unit - Order (Triggering unit) to Stop
Else - Actions
The condition
leaks locations. You should store locations beforehand, refer to them in the condition and then destroy them after the check.
(Integer((Distance between (Position of (Triggering unit)) and (Position of (Target unit of ability being cast))))) Less than or equal to 300
Everything is fine except the variable part,i know what is variable but I dont really know how to make it work,do the variable name need to be specified?how do i even add something to variable?Thanks for the reminder, updated.
Both variables are points.
spell
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Banish
Actions
Set Caster = (Position of (Triggering unit))
Set Target = (Position of (Target unit of ability being cast))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Integer((Distance between Caster and Target))) Less than or equal to 300
Then - Actions
Unit - Order (Triggering unit) to Stop
Else - Actions
Custom script: call RemoveLocation(udg_Caster)
Custom script: call RemoveLocation(udg_Target)
Well explained panda guyYou can press X on the top in trigger editor which allows you to make variables. As I stated, both variables are point variables, which you should be making to determine the positions of both units. I named one Caster and one Target, but you can use something like TempPoint1 and TempPoint2, whichever tickles your fancy.
If you want to set a variable, you need to use an action called Set Variable, which then you add the triggering unit to the caster and the target being targeted by a spell to the target variables. Then use custom scripts to destroy the point leaks after check.