- Joined
- Sep 16, 2008
- Messages
- 47
Hi. I don't kow how to create units and mvoe units like in screenshot with making them face that angle instantly.
http://i.imgur.com/aBEUVH4.jpg
I have once created it as i wanted but units was facing wrong direction so this was not looking good.
at this moment i got quick made jass script for that to let you help me with it.
http://i.imgur.com/aBEUVH4.jpg
I have once created it as i wanted but units was facing wrong direction so this was not looking good.
at this moment i got quick made jass script for that to let you help me with it.
JASS:
scope MS
globals
private constant integer SPELL_CODE = 'A002'
private constant integer DUMMY_CODE = 'h001'
private constant integer AMMOUT = 7
private constant real ANGLE_ARC = 30
endglobals
private struct MS extends array
private static unit array caster
private static player array owner
private static real array distance
private static real array speed
static Table data
static Table array missiles
static Table array angles
implement CTL
local unit u
local real x
local real y
local real a
local integer k
local integer index
local integer i
implement CTLExpire
set distance[this] = distance[this] - speed[this]
set index = 0
set i = 0
loop
set u = missiles[this].unit[index]
set a = angles[this].real[index]
set x = GetUnitX(u) + speed[this] * Cos(a)
set y = GetUnitY(u) + speed[this] * Sin(a)
call SetUnitX(u, x)
call SetUnitY(u, y)
exitwhen null == u
set index = index + 1
endloop
if distance[this] <= 0 then
loop
set u = missiles[this].unit[i]
set a = angles[this].real[i]
call KillUnit(u)
set u = null
exitwhen i == AMMOUT
set i = i + 1
endloop
call missiles[this].destroy()
call angles[this].destroy()
set caster[this] = null
set owner[this] = null
call destroy()
endif
implement CTLNull
implement CTLEnd
private static method onCast takes nothing returns nothing
local thistype this = create()
local unit u
local real cx
local real cy
local real tx
local real ty
local real a
local real ainc
local integer index = 0
local integer k
set caster[this] = GetTriggerUnit()
set owner[this] = GetOwningPlayer(caster[this])
set cx = GetUnitX(caster[this])
set cy = GetUnitY(caster[this])
set tx = GetSpellTargetX()
set ty = GetSpellTargetY()
set distance[this] = 700
set speed[this] = 20
set a = Atan2(ty - cy, tx - cx) - (ANGLE_ARC / 2)
set ainc = ANGLE_ARC / AMMOUT
set missiles[this] = Table.create()
set angles[this] = Table.create()
loop
set u = CreateUnit(owner[this], DUMMY_CODE, cx, cy, a)
set k = GetHandleId(u)
set missiles[this].unit[index] = u
set angles[this].real[index] = a
set a = a + ainc
exitwhen index == AMMOUT
set index = index + 1
endloop
endmethod
private static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(SPELL_CODE,function thistype.onCast)
set data = Table.create()
endmethod
endstruct
endscope