hi, i'm using katana's handles and made a function called Missile to be used with a timer. So here's the function
I hope this works for you guys... it rocks for me... I fixed the leaaks purple poot talks about in his post below XD.
The MissileUL function is missile from Unit to Location. HOMEWORK: Make MissileLL, MissileUU,MissileLU on your own
oh, and if you want to make them homming just enable homming by adding
call SetHandleBoolean(t,"Hom",true)
in the missile XU (it should always target a unit to be homming... or else... it will crash in an unknown way we all fear
By the way:
local unit u is the missile unit with locust
local boolean FF is for friendly fire on or off[/code]
JASS:
function Missile takes nothing returns nothing
//===================IMPORTED VARS===========================
local timer t = GetExpiredTimer()
local integer ExploType = GetHandleInt(t,"ExploID")
local unit u = GetHandleUnit(t,"u")
local unit cast = GetHandleUnit(t,"cast")
local unit targ = null
local real dmg = GetHandleReal(t,"dmg")
local real radius = GetHandleReal(t,"rad")
local real sense = GetHandleReal(t,"sns")
local boolean homing = GetHandleBoolean(t,"Hom")
local boolean FF = GetHandleBoolean(t,"FF")
local location target = GetHandleLocation(t,"targloc")
local real speed = GetHandleReal(t,"Speed")
local real maxdist = GetHandleReal(t,"MxDist")
local real dist = GetHandleReal(t,"Dist")
local sound explode = GetHandleSound (t,"Sonido")
//===================NOT IMPORTED VARS===========================
local boolean ReachesRegion=false
local boolean NOW=false
local boolean multit = true
local unit U
local group g
local real x = GetUnitX( u ) + (speed) * Cos( GetUnitFacing( u )*bj_DEGTORAD )
local real y = GetUnitY( u ) + (speed) * Sin( GetUnitFacing( u )*bj_DEGTORAD)
local location locazo
if (homing) then
set targ = GetHandleUnit(t,"target")
set target = GetUnitLoc(targ)
set x = GetUnitX( u ) + (speed) * Cos( AngleBetweenPoints(GetUnitLoc(u),GetUnitLoc(targ))*bj_DEGTORAD )
set y = GetUnitY( u ) + (speed) * Sin( AngleBetweenPoints(GetUnitLoc(u),GetUnitLoc(targ))*bj_DEGTORAD )
endif
if(maxdist==0)then
set ReachesRegion=true
endif
if(radius==0)then
set multit=false
endif
//================= moves the projectile =================
if x < GetRectMaxX( bj_mapInitialPlayableArea ) and x > GetRectMinX( bj_mapInitialPlayableArea ) and y < GetRectMaxY( bj_mapInitialPlayableArea ) and y > GetRectMinY( bj_mapInitialPlayableArea ) then
call SetUnitX( u, x )
call SetUnitY( u, y )
endif
set dist=dist+speed
call SetHandleReal(t,"Dist",dist)
//================== should it explode?===================
set locazo = GetUnitLoc(u)
set g = GetUnitsInRangeOfLocAll(sense,locazo)
set U = FirstOfGroup(g)
if(homing)then
loop
set U = FirstOfGroup(g)
exitwhen (U==null)or(NOW)
if(U==targ)then
set NOW=true
endif
call GroupRemoveUnit( g, U)
set U=null
endloop
else
if(FF)then
loop
set U = FirstOfGroup(g)
exitwhen(U==null)or(NOW)
if(U!=cast)and(U!=u)and(IsUnitAliveBJ(U))then
set NOW = true
set targ=U
endif
call GroupRemoveUnit( g, U)
set U=null
endloop
else
loop
set U = FirstOfGroup(g)
exitwhen(U==null)or(NOW)
if(IsUnitAliveBJ(U))and(IsUnitEnemy(U,GetOwningPlayer(cast)))then
set NOW = true
set targ=U
endif
call GroupRemoveUnit( g, U)
set U=null
endloop
endif
endif
if(ReachesRegion)then
if(DistanceBetweenPoints(locazo,target)<=30)then
set NOW = true
endif
elseif(dist>=maxdist)then
set NOW = true
endif
//=============== did it explode? ========================
if(NOW)then
if(explode!=null)then
call PlaySoundAtPointBJ(gg_snd_FBTarg,100,GetUnitLoc(u),0.00)
endif
if(ExploType!=0)then
call CreateNUnitsAtLoc( 1, ExploType, GetOwningPlayer(u), GetUnitLoc(u), bj_UNIT_FACING )
call KillUnit( GetLastCreatedUnit() )
endif
call KillUnit( u )
if(multit)then
set g = GetUnitsInRangeOfLocAll(radius,locazo)
if(FF)then
call UnitDamagePointLoc( cast, 0, radius, locazo, dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
else
loop
set U = FirstOfGroup(g)
exitwhen(U==null)
if(IsUnitEnemy(U,GetOwningPlayer(cast)))then
call UnitDamageTargetBJ(cast,U,dmg,ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
endif
call GroupRemoveUnit(g,U)
set U=null
endloop
endif
else
call UnitDamageTargetBJ(cast,targ,dmg,ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
endif
call RemoveLocation (target)
call PauseTimer( t )
call FlushHandleLocals( t )
call DestroyTimer( t )
endif
call RemoveLocation (locazo)
set target = null
set u = null
call DestroyGroup( g )
set g = null
endfunction
function MissileUL takes integer MisID, integer ExploID, unit caster, location target, real damage, real radius, real speed, real sensibilidad, real maxdist, boolean friendlyfire, sound sonidoC, sound sonidoT returns nothing
local timer t = CreateTimer()
local location LC = GetUnitLoc( caster )
if (sonidoC!=null) then
call PlaySoundAtPointBJ(sonidoC,100,LC,0)
endif
call SetHandleHandle(t,"sonido",sonidoT)
call SetHandleInt(t,"ExploID",ExploID)
call SetHandleHandle(t,"cast",caster)
call SetHandleHandle( t, "u", CreateUnit( GetOwningPlayer(caster),MisID, GetUnitX( caster ), GetUnitY( caster ), AngleBetweenPoints( LC, target )) )
call SetHandleReal(t, "Speed", speed)
call SetHandleReal(t, "MxDist", maxdist)
call SetHandleReal(t, "Dist", 0)
call SetHandleBoolean(t,"Hom",false)
call SetHandleBoolean(t,"FF",friendlyfire)
call SetHandleHandle(t,"targloc",target)
call SetHandleReal(t,"dmg",damage)
call SetHandleReal(t,"rad",radius)
call SetHandleReal(t,"sns",sensibilidad)
call TimerStart(t,0.01,true,function Missile)
set t = null
call RemoveLocation ( LC )
set target = null
set LC = null
endfunction
I hope this works for you guys... it rocks for me... I fixed the leaaks purple poot talks about in his post below XD.
The MissileUL function is missile from Unit to Location. HOMEWORK: Make MissileLL, MissileUU,MissileLU on your own
oh, and if you want to make them homming just enable homming by adding
call SetHandleBoolean(t,"Hom",true)
in the missile XU (it should always target a unit to be homming... or else... it will crash in an unknown way we all fear
By the way:
local unit u is the missile unit with locust
local boolean FF is for friendly fire on or off[/code]