NeuroToxin
New Member
- Reaction score
- 46
I made a leash system, and so far, it works except, it doesnt detect when the unit in question, leaves the range. heres the part of the trigger for that.
JASS:
private function IfIsElse takes nothing returns nothing
local real X = GetUnitX(GetEnumUnit())
local real Y = GetUnitY(GetEnumUnit())
local real dx = GetUnitX(GetEnumUnit()) - GetUnitX(GetTriggerUnit())
local real dy = GetUnitY(GetEnumUnit()) - GetUnitY(GetTriggerUnit())
set TempReal = SquareRoot(dx * dx + dy * dy)
if TempReal >= range then
if DoesDamage == true then
call SetUnitState(GetEnumUnit(), UNIT_STATE_LIFE, GetWidgetLife(GetEnumUnit()) - Damage )
call SetUnitX(GetEnumUnit(), X - 20)
call SetUnitY(GetEnumUnit(), Y - 20)
call IssueImmediateOrder(GetEnumUnit(), "Stop")
else
call SetUnitX(GetEnumUnit(), X - 20)
call SetUnitY(GetEnumUnit(), Y - 20)
call IssueImmediateOrder(GetEnumUnit(), "Stop")
endif
endif
endfunction