Somebody help me please! I need to move a unit through map and keep it's animations playing. I need it to be able to make triggers that allow units to move much faster then it's possible by simply modifying it's movespeed. Somebody help please!
function UnitMoveToAsProjectile takes unit m, real arc, real x2, real y2, real z2 returns nothing
call UnitMoveToAsProjectileGen(m, arc,x2,y2,null,z2)
endfunction
function UnitMoveToAsProjectileAnySpeed_Move takes gamecache H, unit m, string k returns boolean
local boolean tounit = GetStoredBoolean(H,k,"unit")
local unit tg
local real x2
local real y2
local real z2
local real x1=GetUnitX(m)
local real y1=GetUnitY(m)
local real z1=GetUnitFlyHeight(m)
local real g
local real d
local real od
local real v
local real time
local integer n
local boolean done=false
if tounit then
set tg=UnitMoveToAsProjectileAnySpeed_Target(H,k,"tg")
if (GetWidgetLife(tg)<=0.405) then
set tounit=false
call StoreBoolean(H,k,"unit",false)
else
set x2=GetUnitX(tg)
set y2=GetUnitY(tg)
set z2=GetUnitFlyHeight(tg)+GetStoredReal(H,k,"z2o")
set n=GetStoredInteger(H,k,"N")
set n=n+1
if (n==0) then
//I have the tilt writing on gamecache is slower than reading, in that case I prevent writting
// these 3 reals, but use a counter so each second they are backuped.
// They are needed because if the unit dies or is removed, they would otherwise go to the
// center of the map, and that is not something nice.
call StoreReal(H,k,"z2",z2)
call StoreReal(H,k,"x2",x2) // Backup stuff just in case
call StoreReal(H,k,"y2",y2)
elseif (n==25) then
set n=0
endif
call StoreInteger(H,k,"N",n)
endif
set tg=null
endif
if not(tounit) then
set z2=GetStoredReal(H,k,"z2")
set x2=GetStoredReal(H,k,"x2")
set y2=GetStoredReal(H,k,"y2")
endif
set g=Atan2(y2-y1,x2-x1)
call SetUnitFacing(m,g*bj_RADTODEG)
set v=GetStoredReal(H,k,"speed")
set d= v * CS_Cycle()
set od=SquareRoot(Pow(x1-x2,2) + Pow(y1-y2,2))
if( od <=d )then
call CS_MoveUnit(m , x2, y2 )
set done=true
else
call CS_MoveUnit(m , x1+d*Cos(g), y1+d*Sin(g) )
endif
set g=GetStoredReal(H,k,"acel")
set time= od / v
set v=(z2-z1+0.5*g*time*time)/time //z speed
call SetUnitFlyHeight(m,z1+v*CS_Cycle(),0)
set d=( Pow(GetUnitX(m)-x2,2) + Pow(GetUnitY(m)-y2,2) )
if (done or (d<=400)) then //So the actual distance is less than or equal to 20
set done=true
call StoreBoolean(H,k,"done",true)
endif
return done
endfunction
I'm sorry, this isn't a solution to his problem at all. You said you found it with JassCraft, therein lies the problem. Jasscraft doesn't just list natives, it also lists functions of Vexorian's Caster System. So if you try to use that in-game without the caster system, it won't work.simple create a new trigger and then
Edit->Convert to custom text and now you can paste that there
but i found this
this function is better
JASS:function UnitMoveToAsProjectileAnySpeed_Move takes gamecache H, unit m, string k returns boolean local boolean tounit = GetStoredBoolean(H,k,"unit") local unit tg local real x2 local real y2 local real z2 local real x1=GetUnitX(m) local real y1=GetUnitY(m) local real z1=GetUnitFlyHeight(m) local real g local real d local real od local real v local real time local integer n local boolean done=false if tounit then set tg=UnitMoveToAsProjectileAnySpeed_Target(H,k,"tg") if (GetWidgetLife(tg)<=0.405) then set tounit=false call StoreBoolean(H,k,"unit",false) else set x2=GetUnitX(tg) set y2=GetUnitY(tg) set z2=GetUnitFlyHeight(tg)+GetStoredReal(H,k,"z2o") set n=GetStoredInteger(H,k,"N") set n=n+1 if (n==0) then //I have the tilt writing on gamecache is slower than reading, in that case I prevent writting // these 3 reals, but use a counter so each second they are backuped. // They are needed because if the unit dies or is removed, they would otherwise go to the // center of the map, and that is not something nice. call StoreReal(H,k,"z2",z2) call StoreReal(H,k,"x2",x2) // Backup stuff just in case call StoreReal(H,k,"y2",y2) elseif (n==25) then set n=0 endif call StoreInteger(H,k,"N",n) endif set tg=null endif if not(tounit) then set z2=GetStoredReal(H,k,"z2") set x2=GetStoredReal(H,k,"x2") set y2=GetStoredReal(H,k,"y2") endif set g=Atan2(y2-y1,x2-x1) call SetUnitFacing(m,g*bj_RADTODEG) set v=GetStoredReal(H,k,"speed") set d= v * CS_Cycle() set od=SquareRoot(Pow(x1-x2,2) + Pow(y1-y2,2)) if( od <=d )then call CS_MoveUnit(m , x2, y2 ) set done=true else call CS_MoveUnit(m , x1+d*Cos(g), y1+d*Sin(g) ) endif set g=GetStoredReal(H,k,"acel") set time= od / v set v=(z2-z1+0.5*g*time*time)/time //z speed call SetUnitFlyHeight(m,z1+v*CS_Cycle(),0) set d=( Pow(GetUnitX(m)-x2,2) + Pow(GetUnitY(m)-y2,2) ) if (done or (d<=400)) then //So the actual distance is less than or equal to 20 set done=true call StoreBoolean(H,k,"done",true) endif return done endfunction
after you paste it just replace the first function settings with what you want: arc,speed etc.
when you done then just create another trigger
you can use what event and conditions you want and voila you are done
- Events -
- Map Initialization
- Conditions -
- Actions -
- Custom Script - call UnitMoveToAsProjectileAnySpeed_Move()
I'm sorry, this isn't a solution to his problem at all. You said you found it with JassCraft, therein lies the problem. Jasscraft doesn't just list natives, it also lists functions of Vexorian's Caster System. So if you try to use that in-game without the caster system, it won't work.
Caster System:
http://www.wc3campaigns.net/showthread.php?t=80534
Open it up, look through the documentation. You should find the function your looking for (fully documented)