RaiJin
New Member
- Reaction score
- 40
JASS:
scope MeatHook initializer MeatHookInit
globals
private constant integer SPELL_ID = 039;A000039;
private constant integer DUMMY_ID = 039;h001039;
private constant integer MAXHOOKS = 30
private constant real INTERVAL = 0.03
private constant real DISTANCE = 30.00
private constant real COLLISION = 60.00
endglobals
private struct hook
unit hooker
unit snagger
unit array hooks [30]
group snaggroup
location s
location h
real offset
real angle
real distance
integer hookline
boolean snagged
static hook k
method Clear takes nothing returns nothing
call DestroyGroup(.snaggroup)
call RemoveLocation(.s)
call RemoveLocation(.h)
set .snagged=false
set .offset = 0.00
set .hookline = 0
endmethod
endstruct
private function MConditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function MeatHookCondition takes nothing returns boolean
local hook h = hook.k
return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitAliveBJ(GetFilterUnit()) and GetFilterUnit() != h.hooker
endfunction
private function retract takes nothing returns nothing
local hook h = hook.k
local location oo
if h.snagged == true then
set h.offset = h.offset - DISTANCE
set oo = PolarProjectionBJ(h.h, h.offset, h.angle)
call RemoveUnit(h.hooks[h.hookline])
set h.hookline = h.hookline - 1
call SetUnitPositionLoc(h.snagger, oo)
call RemoveLocation(oo)
set oo=null
if h.hookline <= 0 then
call PauseTimer(GetExpiredTimer())
else
endif
else
endif
endfunction
private function TimerActions takes nothing returns nothing
local hook h = hook.k
local location o
set h.offset = h.offset + DISTANCE
set h.hookline = h.hookline + 1
set o=PolarProjectionBJ(h.h, h.offset, h.angle)
set h.distance = DistanceBetweenPoints(o, h.s)
set h.snaggroup = GetUnitsInRangeOfLocMatching(COLLISION, o, Condition(function MeatHookCondition))
set h.snagger = GroupPickRandomUnit(h.snaggroup)
call DestroyGroup(h.snaggroup)
if h.snagged == false then
if h.snagger == null then
set h.hooks[h.hookline] = CreateUnitAtLoc(GetOwningPlayer(h.hooker), DUMMY_ID, o, h.angle)
elseif h.distance <= COLLISION then
call PauseTimer(GetExpiredTimer())
set h.snagged = true
endif
else
endif
endfunction
private function MActions takes nothing returns nothing
local hook h = hook.create()
local timer t = CreateTimer()
local timer t2 = CreateTimer()
set h.hooker = GetTriggerUnit()
set h.s = GetSpellTargetLoc()
set h.h = GetUnitLoc(h.hooker)
set h.angle = AngleBetweenPoints(h.h, h.s)
call TimerStart(t, INTERVAL, true, function TimerActions)
call TimerStart(t2, INTERVAL, true, function retract)
endfunction
//===========================================================================
public function MeatHookInit takes nothing returns nothing
local trigger Meathook = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Meathook, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( Meathook, Condition( function MConditions ) )
call TriggerAddAction( Meathook, function MActions )
endfunction
endscope
mkay so basically he doesn't create any hooks at all nothing even happens. I really dont know why... the last time i tried this it worked O_O
why im not using x and y's ? because im still trying to learn how to use them xD AND HUGE THANKS TO PEOPLE that took there time to tell me how to use x and y's THANKS!!!<3:thup: