- Joined
- Dec 18, 2004
- Messages
- 148
Is it possable to have a unit drift?( faceing <90 but moveing <270( < = angle ))
// ===========================
function H2I takes handle h returns integer
return h
return 0
endfunction
// ===========================
function LocalVars takes nothing returns gamecache
// Replace InitGameCache with a global variable!!
return InitGameCache("jasslocalvars.w3v")
endfunction
function SetHandleHandle takes handle subject, string name, handle value returns nothing
if value==null then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
endif
endfunction
function SetHandleInt takes handle subject, string name, integer value returns nothing
if value==0 then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
if value==false then
call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
else
call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleReal takes handle subject, string name, real value returns nothing
if value==0 then
call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
else
call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleString takes handle subject, string name, string value returns nothing
if value==null then
call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
else
call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function GetHandleHandle takes handle subject, string name returns handle
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleUnit takes handle subject, string name returns unit
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
function UnitTurnBone takes unit whichUnit, string whichBone, real angle, real pitch, boolean fromFacing returns nothing
if ( fromFacing ) then
set angle = angle + GetUnitFacing(whichUnit)
endif
if ( pitch == 90.0 ) then
set pitch = 89
endif
call SetUnitLookAt(whichUnit, whichBone, whichUnit, 10000.0*Cos(angle*bj_DEGTORAD)*Cos(pitch*bj_DEGTORAD), 10000.0*Sin(angle*bj_DEGTORAD)*Cos(pitch*bj_DEGTORAD), 10000.0*Tan(pitch*bj_DEGTORAD)+90.0)
endfunction
function Move_Missile_Update takes nothing returns nothing
local timer t = GetExpiredTimer()
local real damage = GetHandleReal(t, "dmg")
local integer steps = GetHandleInt(t, "steps")
local unit missile = GetHandleUnit(t, "missile")
local real xvel = GetHandleReal(t, "xvel")
local real yvel = GetHandleReal(t, "yvel")
local real zvel = GetHandleReal(t, "zvel")
call SetUnitPosition(missile, GetUnitX(missile) + xvel, GetUnitY(missile) + yvel)
if ( steps <= 1 ) then
call FlushHandleLocals(t)
call DestroyTimer(t)
call RemoveUnit(missile)
return
endif
call SetHandleInt(t, "steps", steps-1)
endfunction
function Move_Missile takes unit source, unit missile, real damage, real vel, real zvel, real duration returns nothing
local timer t = CreateTimer()
local real update = 0.02
local real xvel = (update * vel * Cos(Deg2Rad(GetUnitFacing(source))))
local real yvel = (update * vel * Sin(Deg2Rad(GetUnitFacing(source))))
call SetHandleReal(t, "dmg", damage)
call SetHandleInt(t, "steps", R2I(duration/update))
call SetHandleReal(t, "xvel", xvel)
call SetHandleReal(t, "yvel", yvel)
call SetHandleReal(t, "zvel", zvel)
call SetHandleHandle(t, "missile", missile)
call TimerStart(t, update, true, function Move_Missile_Update)
endfunction
Drift
Events
Time - Every 0.01 seconds of game time
Conditions
Drift[1] Equal to True
Actions
Unit - Move Unit[1] instantly to ((Position of Unit[1]) offset by 4.00 towards ((Facing of Unit[1]) + 180.00) degrees)