- Joined
- Oct 16, 2010
- Messages
- 680
okay , so I've already done this with globals worked properly
but I'm gone use it in my orpg so i have to make it MUI
I don't really familiar with structs atm , so I'm not sure about how to do it.
This is what i've done so far but don't know how to use
methods with timer
call TimerStart(as.tmr,0.03,false,as.RekLoop) fails:/
Or should i do it in another way?
but I'm gone use it in my orpg so i have to make it MUI
I don't really familiar with structs atm , so I'm not sure about how to do it.
JASS:
library AimedShot initializer begin
struct aimedshot
unit arrow
unit castunit
unit targunit
real clocx
real clocy
real tlocx
real tlocy
real alocx
real alocy
timer tmr
method Distance takes real x1, real y1, real x2, real y2 returns real
return SquareRoot(Pow(x2-x1,2)+Pow(y2-y1,2))
endmethod
method GetX takes nothing returns real
set .alocx = .alocx - ((.clocx-.tlocx)/((.Distance(.clocx,.clocy,.tlocx,.tlocy)/2500.)/0.03))
return .alocx
endmethod
method GetY takes nothing returns real
set .alocy = .alocy - ((.clocy-.tlocy)/((.Distance(.clocx,.clocy,.tlocx,.tlocy)/2500.)/0.03))
return .alocy
endmethod
method RekLoop takes nothing returns nothing
local location loc = Location(GetX(),GetY())
call SetUnitPositionLoc(.arrow,loc)
call RemoveLocation(loc)
set loc = null
if .Distance(.clocx,.clocy,.tlocx,.tlocy) > .Distance(.clocx,.clocy,.alocx,.alocy) then
//... this should be the part when the method calls itself
else
endif
endmethod
method Init takes integer pn returns nothing
set .castunit = GetTriggerUnit()
set .targunit = GetSpellTargetUnit()
set .clocx = GetUnitX(.castunit)
set .clocy = GetUnitY(.castunit)
set .tlocx = GetUnitX(.targunit)
set .tlocy = GetUnitY(.targunit)
set .alocx = .clocx
set .alocy = .clocy
set .tmr = CreateTimer()
endmethod
endstruct
private function kilo takes nothing returns nothing
local integer x = 0
local unit arrow = CreateUnitAtLoc(GetLocalPlayer(),'h001',GetUnitLoc(GetTriggerUnit()),GetUnitFacing(GetTriggerUnit()))
local aimedshot as = aimedshot.create()
call SetUnitUserData(arrow,as)
loop
exitwhen GetLocalPlayer() == Player(x)
set x = x + 1
endloop
call as.Init(x)
call TimerStart(as.tmr,0.03,false,as.RekLoop)
endfunction
private function ft takes nothing returns boolean
return GetSpellAbilityId() == 'A00U'
endfunction
private function begin takes nothing returns nothing
local trigger t = CreateTrigger()
local integer a = 0
loop
call TriggerRegisterPlayerUnitEvent(t,Player(a),EVENT_PLAYER_UNIT_SPELL_CAST,null)
set a = a + 1
exitwhen a > 7
endloop
call TriggerAddAction(t,function kilo)
call TriggerAddCondition(t,Condition(function ft))
endfunction
endlibrary
This is what i've done so far but don't know how to use
methods with timer
call TimerStart(as.tmr,0.03,false,as.RekLoop) fails:/
Or should i do it in another way?