//TESH.scrollpos=0
//TESH.alwaysfold=0
// ****************************************************************************
// **
// ** CALIBRATION FUNCTIONS
// **
// ****************************************************************************
constant function ScriptSystemPeriod takes nothing returns real
return 0.02
endfunction
constant function ParticlePeriod takes nothing returns real
return 0.02
endfunction
constant function CameraPeriod takes nothing returns real
return 0.02
endfunction
constant function FadeFilterUnit takes nothing returns integer
return 'e000'
endfunction
// ****************************************************************************
// **
// ** GENERAL AND MISCELANEOUS FUNCTIONS
// **
// ****************************************************************************
function H2S takes handle h returns string
return I2S(GetHandleId(h))
endfunction
function GC takes nothing returns gamecache
if udg_cinS_GC == null then
call FlushGameCache(InitGameCache( "CinemaCache" ))
set udg_cinS_GC = InitGameCache( "CinemaCache" )
endif
return udg_cinS_GC
endfunction
function MakeUnitFlyable takes unit u returns nothing
call UnitAddAbility(u, 'Amrf')
call UnitRemoveAbility(u, 'Amrf')
endfunction
function ActorAssign takes unit u, integer actID returns nothing
call SetUnitUserData(u, actID)
call MakeUnitFlyable(u)
set udg_cinS_actor[actID] = u
set udg_cinS_act_colourR[actID] = 100.0
set udg_cinS_act_colourG[actID] = 100.0
set udg_cinS_act_colourB[actID] = 100.0
set udg_cinS_act_colourA[actID] = 100.0
endfunction
function ActorCreate takes player p, integer actID, integer unitType returns unit
local unit u = CreateUnit(p, unitType, 0.0, 0.0, 0.0)
call ActorAssign(u, actID)
return u
endfunction
function InitCinematicSystem takes nothing returns nothing
set udg_cinS_tempPoint=Location(0.0,0.0)
call ExecuteFunc("ScriptSystemInit")
call ExecuteFunc("CameraSystemInit")
call ExecuteFunc("ParticleInit")
call ExecuteFunc("SubtitlesInit")
endfunction
// ****************************************************************************
// **
// ** CAMERA SYSTEM
// **
// ****************************************************************************
function CinematicCameraEnable takes nothing returns nothing
call EnableTrigger(udg_cinS_cam_trigger)
endfunction
function CinematicCameraDisable takes nothing returns nothing
call DisableTrigger(udg_cinS_cam_trigger)
endfunction
function SetCameraZ takes real z returns nothing
//thanks to ToadCop for this function
set z = GetCameraField(CAMERA_FIELD_ZOFFSET)+z-GetCameraTargetPositionZ()
call SetCameraField(CAMERA_FIELD_ZOFFSET,z,- 0.01)
call SetCameraField(CAMERA_FIELD_ZOFFSET,z,0.01)
endfunction
function CameraMainLoop takes nothing returns nothing
local real array s
local location stupid = udg_cinS_tempPoint
local integer i = 0
local real ovrFactor
// camera motion
loop
exitwhen i == 18
set i = i + 1
set udg_cinS_cam_time[i] = udg_cinS_cam_time[i] + CameraPeriod()
set s[i] = udg_cinS_cam_startval[i] + ( udg_cinS_cam_startvel[i] * udg_cinS_cam_time[i] ) + ( udg_cinS_cam_accprim[i] * udg_cinS_cam_time[i] * udg_cinS_cam_time[i] / 2 )
if i > 3 and i < 7 then
loop
if s[i] > 360 then
set s[i] = s[i] - 360
elseif s[i] < 0 then
set s[i] = s[i] + 360
else
exitwhen true
endif
endloop
endif
if udg_cinS_cam_time[i] + CameraPeriod() >= udg_cinS_cam_endtime[i] then
if udg_cinS_cam_accsec[i] != 0 then
set udg_cinS_cam_startvel[i] = udg_cinS_cam_startvel[i] + ( udg_cinS_cam_accprim[i] * udg_cinS_cam_time[i] )
set udg_cinS_cam_accprim[i] = udg_cinS_cam_accsec[i]
set udg_cinS_cam_startval[i] = s[i]
set udg_cinS_cam_time[i] = 0.0
set udg_cinS_cam_accsec[i] = 0.0
else
if i>9 then
set udg_cinS_cam_startvel[i] = 0.0
set udg_cinS_cam_startval[i] = s[i]
set udg_cinS_cam_time[i] = 0.0
endif
endif
endif
endloop
// camera lock-to-unit override
if udg_cinS_cam_OvRxyzUnitPrim!=null or udg_cinS_cam_OvRxyzUnitSec!=null then
set udg_cinS_cam_OvRxyzTime = udg_cinS_cam_OvRxyzTime + CameraPeriod()
if udg_cinS_cam_OvRxyzTime > udg_cinS_cam_OvRxyzEndtime then
set udg_cinS_cam_OvRxyzTime = udg_cinS_cam_OvRxyzEndtime
endif
set ovrFactor = udg_cinS_cam_OvRxyzTime/udg_cinS_cam_OvRxyzEndtime
if udg_cinS_cam_OvRxyzSmooth then
set ovrFactor = (1.0 - Cos(ovrFactor*bj_PI)) / 2
endif
call MoveLocation(stupid, GetUnitX(udg_cinS_cam_OvRxyzUnitPrim),GetUnitY(udg_cinS_cam_OvRxyzUnitPrim))
set s[19] = GetLocationZ(stupid)
call MoveLocation(stupid, GetUnitX(udg_cinS_cam_OvRxyzUnitSec),GetUnitY(udg_cinS_cam_OvRxyzUnitSec))
set s[20] = GetLocationZ(stupid)
if udg_cinS_cam_OvRxyzUnitSec==null then //going from null to unit
set s[1] = s[1]*(1-ovrFactor) + (GetUnitX(udg_cinS_cam_OvRxyzUnitPrim)+udg_cinS_cam_OvRoffset[1])*ovrFactor
set s[2] = s[2]*(1-ovrFactor) + (GetUnitY(udg_cinS_cam_OvRxyzUnitPrim)+udg_cinS_cam_OvRoffset[2])*ovrFactor
set s[3] = s[3]*(1-ovrFactor) + (s[19]+GetUnitFlyHeight(udg_cinS_cam_OvRxyzUnitPrim)+udg_cinS_cam_OvRoffset[3])*ovrFactor
elseif udg_cinS_cam_OvRxyzUnitPrim==null then //going from unit to null
set s[1] = s[1]*ovrFactor + (GetUnitX(udg_cinS_cam_OvRxyzUnitSec)+udg_cinS_cam_OvRoffset[7])*(1.0-ovrFactor)
set s[2] = s[2]*ovrFactor + (GetUnitY(udg_cinS_cam_OvRxyzUnitSec)+udg_cinS_cam_OvRoffset[8])*(1.0-ovrFactor)
set s[3] = s[3]*ovrFactor + (s[20]+GetUnitFlyHeight(udg_cinS_cam_OvRxyzUnitSec)+udg_cinS_cam_OvRoffset[9])*(1.0-ovrFactor)
else //going from unit to unit
set s[1] = (GetUnitX(udg_cinS_cam_OvRxyzUnitSec)+udg_cinS_cam_OvRoffset[7])*(1-ovrFactor) + (GetUnitX(udg_cinS_cam_OvRxyzUnitPrim)+udg_cinS_cam_OvRoffset[1])*ovrFactor
set s[2] = (GetUnitY(udg_cinS_cam_OvRxyzUnitSec)+udg_cinS_cam_OvRoffset[8])*(1-ovrFactor) + (GetUnitY(udg_cinS_cam_OvRxyzUnitPrim)+udg_cinS_cam_OvRoffset[2])*ovrFactor
set s[3] = (s[20]+GetUnitFlyHeight(udg_cinS_cam_OvRxyzUnitSec)+udg_cinS_cam_OvRoffset[9])*(1-ovrFactor) + (s[19]+GetUnitFlyHeight(udg_cinS_cam_OvRxyzUnitPrim)+udg_cinS_cam_OvRoffset[3])*ovrFactor
endif
if udg_cinS_cam_OvRxyzTime == udg_cinS_cam_OvRxyzEndtime then
if udg_cinS_cam_OvRxyzUnitPrim==null then
set udg_cinS_cam_OvRxyzUnitSec = null
endif
endif
endif
// camera face-to-unit override
if udg_cinS_cam_OvRangUnitPrim!=null or udg_cinS_cam_OvRangUnitSec!=null then
set udg_cinS_cam_OvRangTime = udg_cinS_cam_OvRangTime + CameraPeriod()
if udg_cinS_cam_OvRangTime > udg_cinS_cam_OvRangEndtime then
set udg_cinS_cam_OvRangTime = udg_cinS_cam_OvRangEndtime
endif
set ovrFactor = udg_cinS_cam_OvRangTime/udg_cinS_cam_OvRangEndtime
if udg_cinS_cam_OvRangSmooth then
set ovrFactor = (1.0 - Cos(ovrFactor*bj_PI)) / 2
endif
call MoveLocation(stupid, GetUnitX(udg_cinS_cam_OvRangUnitPrim),GetUnitY(udg_cinS_cam_OvRangUnitPrim))
set s[19] = GetLocationZ(stupid)
call MoveLocation(stupid, GetUnitX(udg_cinS_cam_OvRangUnitSec),GetUnitY(udg_cinS_cam_OvRangUnitSec))
set s[20] = GetLocationZ(stupid)
if udg_cinS_cam_OvRangUnitPrim!=null then
set s[21]=(GetUnitX(udg_cinS_cam_OvRangUnitPrim)+udg_cinS_cam_OvRoffset[4])-s[1]
set s[22]=(GetUnitY(udg_cinS_cam_OvRangUnitPrim)+udg_cinS_cam_OvRoffset[5])-s[2]
set s[23]=(s[19]+GetUnitFlyHeight(udg_cinS_cam_OvRangUnitPrim)+udg_cinS_cam_OvRoffset[6])-s[3]
set s[24]=Atan2(s[22], s[21]) * bj_RADTODEG
set s[25]=Atan2(s[23], SquareRoot(s[21]*s[21]+s[22]*s[22])) * bj_RADTODEG
else
set s[24]=s[4]
set s[25]=s[5]
endif
if udg_cinS_cam_OvRangUnitSec!=null then
set s[21]=(GetUnitX(udg_cinS_cam_OvRangUnitSec)+udg_cinS_cam_OvRoffset[10])-s[1]
set s[22]=(GetUnitY(udg_cinS_cam_OvRangUnitSec)+udg_cinS_cam_OvRoffset[11])-s[2]
set s[23]=(s[20]+GetUnitFlyHeight(udg_cinS_cam_OvRangUnitSec)+udg_cinS_cam_OvRoffset[12])-s[3]
set s[26]=Atan2(s[22], s[21]) * bj_RADTODEG
set s[27]=Atan2(s[23], SquareRoot(s[21]*s[21]+s[22]*s[22])) * bj_RADTODEG
else
set s[26]=s[4]
set s[27]=s[5]
endif
if (s[26] - s[24]) > 180 then
set s[24] = s[24] + 360
elseif (s[26] - s[24]) < -180 then
set s[24] = s[24] - 360
endif
set s[4] = ovrFactor * s[24] + (1-ovrFactor) * s[26]
if (s[27] - s[25]) > 180 then
set s[25] = s[25] + 360
elseif (s[27] - s[25]) < -180 then
set s[25] = s[25] - 360
endif
set s[5] = ovrFactor * s[25] + (1-ovrFactor) * s[27]
if udg_cinS_cam_OvRangTime == udg_cinS_cam_OvRangEndtime then
if udg_cinS_cam_OvRangUnitPrim==null then
set udg_cinS_cam_OvRangUnitSec = null
endif
endif
endif
if s[9]<100.0 then
set s[9]=100.0
endif
// camera fade filter unit
if s[18]>0 then
set s[23]=Sin(s[5]*bj_DEGTORAD)
set s[20]=Cos(s[5]*bj_DEGTORAD)
set s[21]=Cos(s[4]*bj_DEGTORAD)*s[20]
set s[22]=Sin(s[4]*bj_DEGTORAD)*s[20]
set s[19]=(s[9]-128.0)
set s[20]=Tan(s[7]*bj_DEGTORAD/2) *40
set s[21]=s[1]-s[19]*s[21]
set s[22]=s[2]-s[19]*s[22]
set s[23]=s[3]-s[19]*s[23]
call MoveLocation(stupid, s[21], s[22])
set s[23]=s[23]-GetLocationZ(stupid)
call SetUnitX(udg_cinS_cam_fadeUnit, s[21])
call SetUnitY(udg_cinS_cam_fadeUnit, s[22])
call SetUnitFlyHeight(udg_cinS_cam_fadeUnit, s[23], 0.0)
call SetUnitScale(udg_cinS_cam_fadeUnit, s[20],s[20],s[20])
endif
call PanCameraToTimed( s[1], s[2], 0.0 )
call MoveLocation(stupid, s[1], s[2])
if udg_cinS_cam_ignoreTerrain then
call SetCameraZ(s[3])
else
call SetCameraField( CAMERA_FIELD_ZOFFSET, s[3]-GetLocationZ(stupid), 0.00 )
endif
call SetCameraField( CAMERA_FIELD_ROTATION, s[4], 0.00 )
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, s[5], 0.00 )
call SetCameraField( CAMERA_FIELD_ROLL, s[6], 0.00 )
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, s[7], 0.00 )
call SetCameraField( CAMERA_FIELD_FARZ, s[8], 0.00 )
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, s[9], 0.00 )
call SetUnitVertexColor(udg_cinS_cam_fadeUnit, R2I(s[15]*256), R2I(s[16]*256), R2I(s[17]*256), R2I(s[18]*256))
call SetTerrainFogEx(0, s[10], s[11], 0.0, s[12], s[13], s[14])
set stupid = null
endfunction
function CameraStatChangeLin takes integer stat, real endvalue, real time returns nothing
local real startvalue = udg_cinS_cam_startval[stat] + ( udg_cinS_cam_startvel[stat] * udg_cinS_cam_time[stat] ) + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] * udg_cinS_cam_time[stat] / 2 )
set udg_cinS_cam_startval[stat] = startvalue
set udg_cinS_cam_startvel[stat] = (endvalue - startvalue)/time
set udg_cinS_cam_accprim[stat] = 0.0
set udg_cinS_cam_accsec[stat] = 0.0
set udg_cinS_cam_time[stat] = 0.0
set udg_cinS_cam_endtime[stat] = time
endfunction
function CameraStatChangeLinRad takes integer stat, real endvalue, real time returns nothing
local real startvalue = udg_cinS_cam_startval[stat] + ( udg_cinS_cam_startvel[stat] * udg_cinS_cam_time[stat] ) + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] * udg_cinS_cam_time[stat] / 2 )
local real distance = endvalue - startvalue
local real velocity1 = distance/time
local real velocity2 = -( RSignBJ(distance) * (360 - RAbsBJ(distance)) )/time
set udg_cinS_cam_startval[stat] = startvalue
if RAbsBJ(velocity1) < RAbsBJ(velocity2) then
set udg_cinS_cam_startvel[stat] = velocity1
else
set udg_cinS_cam_startvel[stat] = velocity2
endif
set udg_cinS_cam_accprim[stat] = 0.0
set udg_cinS_cam_accsec[stat] = 0.0
set udg_cinS_cam_time[stat] = 0.0
set udg_cinS_cam_endtime[stat] = time
endfunction
function CameraStatChange takes integer stat, real endvalue, real time returns nothing
local real startvalue = udg_cinS_cam_startval[stat] + ( udg_cinS_cam_startvel[stat] * udg_cinS_cam_time[stat] ) + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] * udg_cinS_cam_time[stat] / 2 )
local real startvelocity = udg_cinS_cam_startvel[stat] + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] )
local real distance = endvalue - startvalue
local real accel = 2 * ( distance - startvelocity * time ) / ( time * time )
set udg_cinS_cam_startval[stat] = startvalue
set udg_cinS_cam_startvel[stat] = startvelocity
set udg_cinS_cam_accprim[stat] = accel
set udg_cinS_cam_accsec[stat] = 0.0
set udg_cinS_cam_time[stat] = 0.0
set udg_cinS_cam_endtime[stat] = time
endfunction
function CameraStatChangeRad takes integer stat, real endvalue, real time returns nothing
local real startvalue = udg_cinS_cam_startval[stat] + ( udg_cinS_cam_startvel[stat] * udg_cinS_cam_time[stat] ) + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] * udg_cinS_cam_time[stat] / 2 )
local real startvelocity = udg_cinS_cam_startvel[stat] + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] )
local real distance = endvalue - startvalue
local real accel1 = 2 * ( distance - startvelocity * time ) / ( time * time )
local real accel2 = 2 * ( -( RSignBJ(distance) * (360 - RAbsBJ(distance)) ) - startvelocity * time ) / ( time * time )
set udg_cinS_cam_startval[stat] = startvalue
set udg_cinS_cam_startvel[stat] = startvelocity
if RAbsBJ(accel1) < RAbsBJ(accel2) then
set udg_cinS_cam_accprim[stat] = accel1
else
set udg_cinS_cam_accprim[stat] = accel2
endif
set udg_cinS_cam_accsec[stat] = 0.0
set udg_cinS_cam_time[stat] = 0.0
set udg_cinS_cam_endtime[stat] = time
endfunction
function CameraStatChangeAdv takes integer stat, real endvalue, real endvelocity, real time returns nothing
local real startvalue = udg_cinS_cam_startval[stat] + ( udg_cinS_cam_startvel[stat] * udg_cinS_cam_time[stat] ) + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] * udg_cinS_cam_time[stat] / 2 )
local real startvelocity = udg_cinS_cam_startvel[stat] + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] )
local real distance = endvalue - startvalue
local real accel1 = 4 * ( distance ) / ( time * time ) - ( endvelocity + 3 * startvelocity ) / time
local real accel2 = ( 3 * endvelocity + startvelocity ) / time - 4 * ( distance ) / ( time * time )
set udg_cinS_cam_startval[stat] = startvalue
set udg_cinS_cam_startvel[stat] = startvelocity
set udg_cinS_cam_accprim[stat] = accel1
set udg_cinS_cam_accsec[stat] = accel2
set udg_cinS_cam_time[stat] = 0.0
set udg_cinS_cam_endtime[stat] = time/2
endfunction
function CameraStatChangeAdvRad takes integer stat, real endvalue, real endvelocity, real time returns nothing
local real startvalue = udg_cinS_cam_startval[stat] + ( udg_cinS_cam_startvel[stat] * udg_cinS_cam_time[stat] ) + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] * udg_cinS_cam_time[stat] / 2 )
local real startvelocity = udg_cinS_cam_startvel[stat] + ( udg_cinS_cam_accprim[stat] * udg_cinS_cam_time[stat] )
local real distance = endvalue - startvalue
local real accel1 = 4 * ( distance ) / ( time * time ) - ( endvelocity + 3 * startvelocity ) / time
local real accel2 = ( 3 * endvelocity + startvelocity ) / time - 4 * ( distance ) / ( time * time )
local real accel3 = 4 * ( -( RSignBJ(distance) * (360 - RAbsBJ(distance)) ) ) / ( time * time ) - ( endvelocity + 3 * startvelocity ) / time
local real accel4 = ( 3 * endvelocity + startvelocity ) / time - 4 * ( -( RSignBJ(distance) * (360 - RAbsBJ(distance)) ) ) / ( time * time )
set udg_cinS_cam_startval[stat] = startvalue
set udg_cinS_cam_startvel[stat] = startvelocity
if (RAbsBJ(accel3) + RAbsBJ(accel4)) > (RAbsBJ(accel1) + RAbsBJ(accel2)) then
set udg_cinS_cam_accprim[stat] = accel1
set udg_cinS_cam_accsec[stat] = accel2
else
set udg_cinS_cam_accprim[stat] = accel3
set udg_cinS_cam_accsec[stat] = accel4
endif
set udg_cinS_cam_time[stat] = 0.0
set udg_cinS_cam_endtime[stat] = time/2
endfunction
function CameraLockToUnitOverride takes unit u, real xoff, real yoff, real zoff, boolean smooth, real duration returns nothing
if duration < CameraPeriod() then
set duration = CameraPeriod()
endif
set udg_cinS_cam_OvRxyzUnitSec = udg_cinS_cam_OvRxyzUnitPrim
set udg_cinS_cam_OvRxyzUnitPrim = u
set udg_cinS_cam_OvRxyzSmooth = smooth
set udg_cinS_cam_OvRoffset[7]=udg_cinS_cam_OvRoffset[1]
set udg_cinS_cam_OvRoffset[8]=udg_cinS_cam_OvRoffset[2]
set udg_cinS_cam_OvRoffset[9]=udg_cinS_cam_OvRoffset[3]
set udg_cinS_cam_OvRoffset[1]=xoff
set udg_cinS_cam_OvRoffset[2]=yoff
set udg_cinS_cam_OvRoffset[3]=zoff
set udg_cinS_cam_OvRxyzTime = 0.0
set udg_cinS_cam_OvRxyzEndtime = duration
endfunction
function CameraLockToUnitReset takes boolean smooth, real duration returns nothing
call CameraLockToUnitOverride(null, 0.0,0.0,0.0, smooth, duration)
endfunction
function CameraFaceToUnitOverride takes unit u, real xoff, real yoff, real zoff, boolean smooth, real duration returns nothing
if duration < CameraPeriod() then
set duration = CameraPeriod()
endif
set udg_cinS_cam_OvRangUnitSec = udg_cinS_cam_OvRangUnitPrim
set udg_cinS_cam_OvRangUnitPrim = u
set udg_cinS_cam_OvRangSmooth = smooth
set udg_cinS_cam_OvRoffset[10]=udg_cinS_cam_OvRoffset[4]
set udg_cinS_cam_OvRoffset[11]=udg_cinS_cam_OvRoffset[5]
set udg_cinS_cam_OvRoffset[12]=udg_cinS_cam_OvRoffset[6]
set udg_cinS_cam_OvRoffset[4]=xoff
set udg_cinS_cam_OvRoffset[5]=yoff
set udg_cinS_cam_OvRoffset[6]=zoff
set udg_cinS_cam_OvRangTime = 0.0
set udg_cinS_cam_OvRangEndtime = duration
endfunction
function CameraFaceToUnitReset takes boolean smooth, real duration returns nothing
call CameraFaceToUnitOverride(null, 0.0,0.0,0.0, smooth, duration)
endfunction
function ApplyCameraInstantly takes camerasetup whichSetup returns nothing
local integer i = 0
set udg_cinS_cam_startval[1] = CameraSetupGetDestPositionX( whichSetup )
set udg_cinS_cam_startval[2] = CameraSetupGetDestPositionY( whichSetup )
call MoveLocation(udg_cinS_tempPoint, CameraSetupGetDestPositionX( whichSetup ), CameraSetupGetDestPositionY( whichSetup ))
set udg_cinS_cam_startval[3] = CameraSetupGetField( whichSetup, CAMERA_FIELD_ZOFFSET) + GetLocationZ(udg_cinS_tempPoint)
set udg_cinS_cam_startval[4] = CameraSetupGetField( whichSetup, CAMERA_FIELD_ROTATION )
set udg_cinS_cam_startval[5] = CameraSetupGetField( whichSetup, CAMERA_FIELD_ANGLE_OF_ATTACK )
set udg_cinS_cam_startval[6] = CameraSetupGetField( whichSetup, CAMERA_FIELD_ROLL )
set udg_cinS_cam_startval[7] = CameraSetupGetField( whichSetup, CAMERA_FIELD_FIELD_OF_VIEW )
set udg_cinS_cam_startval[8] = CameraSetupGetField( whichSetup, CAMERA_FIELD_FARZ )
set udg_cinS_cam_startval[9] = CameraSetupGetField( whichSetup, CAMERA_FIELD_TARGET_DISTANCE )
loop
set i = i + 1
exitwhen i > 9
set udg_cinS_cam_startvel[i] = 0.0
set udg_cinS_cam_accprim[i] = 0.0
set udg_cinS_cam_accsec[i] = 0.0
set udg_cinS_cam_time[i] = 0.0
set udg_cinS_cam_endtime[i] = 0.0
endloop
endfunction
function ApplyCameraLinear takes camerasetup whichSetup, real duration returns nothing
if duration < CameraPeriod() then
set duration = CameraPeriod()
endif
call CameraStatChangeLin(1, CameraSetupGetDestPositionX( whichSetup ), duration)
call CameraStatChangeLin(2, CameraSetupGetDestPositionY( whichSetup ), duration)
call MoveLocation(udg_cinS_tempPoint, CameraSetupGetDestPositionX( whichSetup ), CameraSetupGetDestPositionY( whichSetup ))
call CameraStatChangeLin(3, CameraSetupGetField( whichSetup, CAMERA_FIELD_ZOFFSET ) + GetLocationZ(udg_cinS_tempPoint), duration)
call CameraStatChangeLinRad(4, CameraSetupGetField( whichSetup, CAMERA_FIELD_ROTATION ), duration)
call CameraStatChangeLinRad(5, CameraSetupGetField( whichSetup, CAMERA_FIELD_ANGLE_OF_ATTACK ), duration)
call CameraStatChangeLinRad(6, CameraSetupGetField( whichSetup, CAMERA_FIELD_ROLL ), duration)
call CameraStatChangeLin(7, CameraSetupGetField( whichSetup, CAMERA_FIELD_FIELD_OF_VIEW ), duration)
call CameraStatChangeLin(8, CameraSetupGetField( whichSetup, CAMERA_FIELD_FARZ ), duration)
call CameraStatChangeLin(9, CameraSetupGetField( whichSetup, CAMERA_FIELD_TARGET_DISTANCE ), duration)
endfunction
function ApplyCameraSmooth takes camerasetup whichSetup, real duration returns nothing
if duration < CameraPeriod() then
set duration = CameraPeriod()
endif
call CameraStatChange(1, CameraSetupGetDestPositionX( whichSetup ), duration)
call CameraStatChange(2, CameraSetupGetDestPositionY( whichSetup ), duration)
call MoveLocation(udg_cinS_tempPoint, CameraSetupGetDestPositionX( whichSetup ), CameraSetupGetDestPositionY( whichSetup ))
call CameraStatChange(3, CameraSetupGetField( whichSetup, CAMERA_FIELD_ZOFFSET ) + GetLocationZ(udg_cinS_tempPoint), duration)
call CameraStatChangeRad(4, CameraSetupGetField( whichSetup, CAMERA_FIELD_ROTATION ), duration)
call CameraStatChangeRad(5, CameraSetupGetField( whichSetup, CAMERA_FIELD_ANGLE_OF_ATTACK ), duration)
call CameraStatChangeRad(6, CameraSetupGetField( whichSetup, CAMERA_FIELD_ROLL ), duration)
call CameraStatChange(7, CameraSetupGetField( whichSetup, CAMERA_FIELD_FIELD_OF_VIEW ), duration)
call CameraStatChange(8, CameraSetupGetField( whichSetup, CAMERA_FIELD_FARZ ), duration)
call CameraStatChange(9, CameraSetupGetField( whichSetup, CAMERA_FIELD_TARGET_DISTANCE ), duration)
endfunction
function ApplyCameraSmoothStop takes camerasetup whichSetup, real duration returns nothing
if duration < CameraPeriod() then
set duration = CameraPeriod()
endif
call CameraStatChangeAdv(1, CameraSetupGetDestPositionX( whichSetup ), 0.00, duration)
call CameraStatChangeAdv(2, CameraSetupGetDestPositionY( whichSetup ), 0.00, duration)
call MoveLocation(udg_cinS_tempPoint, CameraSetupGetDestPositionX( whichSetup ), CameraSetupGetDestPositionY( whichSetup ))
call CameraStatChangeAdv(3, CameraSetupGetField( whichSetup, CAMERA_FIELD_ZOFFSET ) + GetLocationZ(udg_cinS_tempPoint), 0.00, duration)
call CameraStatChangeAdvRad(4, CameraSetupGetField( whichSetup, CAMERA_FIELD_ROTATION ), 0.00, duration)
call CameraStatChangeAdvRad(5, CameraSetupGetField( whichSetup, CAMERA_FIELD_ANGLE_OF_ATTACK ), 0.00, duration)
call CameraStatChangeAdvRad(6, CameraSetupGetField( whichSetup, CAMERA_FIELD_ROLL ), 0.00, duration)
call CameraStatChangeAdv(7, CameraSetupGetField( whichSetup, CAMERA_FIELD_FIELD_OF_VIEW ), 0.00, duration)
call CameraStatChangeAdv(8, CameraSetupGetField( whichSetup, CAMERA_FIELD_FARZ ), 0.00, duration)
call CameraStatChangeAdv(9, CameraSetupGetField( whichSetup, CAMERA_FIELD_TARGET_DISTANCE ), 0.00, duration)
endfunction
function ApplyFog takes real startZ, real endZ, real red, real green, real blue, real duration returns nothing
if duration < CameraPeriod() then
set duration = CameraPeriod()
endif
call CameraStatChangeLin(10,startZ,duration)
call CameraStatChangeLin(11,endZ, duration)
call CameraStatChangeLin(12,red*0.01, duration)
call CameraStatChangeLin(13,green*0.01, duration)
call CameraStatChangeLin(14,blue*0.01, duration)
endfunction
function ApplyFade takes real red, real green, real blue, real opacity, real duration returns nothing
if duration < CameraPeriod() then
set duration = CameraPeriod()
endif
call CameraStatChangeLin(15,red*0.01, duration)
call CameraStatChangeLin(16,green*0.01, duration)
call CameraStatChangeLin(17,blue*0.01, duration)
call CameraStatChangeLin(18,opacity*0.01, duration)
endfunction
function CameraSystemInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventPeriodic( t, CameraPeriod() )
call TriggerAddAction( t, function CameraMainLoop )
set udg_cinS_cam_trigger = t
set t = null
call ApplyCameraInstantly( GetCurrentCameraSetup() )
call ApplyFog( 10000.0, 10000.0, 0.0,0.0,0.0, 0.0 )
set udg_cinS_cam_fadeUnit = CreateUnit(Player(12), FadeFilterUnit(), 0,0,0)
call MakeUnitFlyable(udg_cinS_cam_fadeUnit)
set udg_cinS_cam_ignoreTerrain = false
endfunction
// ****************************************************************************
// **
// ** PARTICLE SYSTEM
// **
// ****************************************************************************
function ParticleMove takes nothing returns nothing
local unit u = GetEnumUnit()
local integer i = GetUnitUserData(u)
local real h
local location stupid = udg_cinS_tempPoint
set udg_cinS_act_moveTime[i] = udg_cinS_act_moveTime[i] - ParticlePeriod()
set udg_cinS_act_moveX[i]=udg_cinS_act_moveX[i]+udg_cinS_act_moveVX[i]
set udg_cinS_act_moveY[i]=udg_cinS_act_moveY[i]+udg_cinS_act_moveVY[i]
if udg_cinS_act_moveAZ[i] != 0 then
set udg_cinS_act_moveVZ[i] = udg_cinS_act_moveVZ[i] + udg_cinS_act_moveAZ[i]
set udg_cinS_act_moveZ[i] = udg_cinS_act_moveZ[i] + udg_cinS_act_moveVZ[i]
call MoveLocation(stupid, udg_cinS_act_moveX[i],udg_cinS_act_moveY[i])
set h=udg_cinS_act_moveZ[i]-GetLocationZ(stupid)
call SetUnitFlyHeight( u, h, 0 )
if h <= 0.0 then
call GroupRemoveUnit(udg_cinS_act_groups[0], u)
set udg_cinS_act_moveZ[i] = 0.0
endif
elseif udg_cinS_act_moveTime[i]<=0.0 then
call GroupRemoveUnit(udg_cinS_act_groups[0], u)
endif
call SetUnitX(u,udg_cinS_act_moveX[i])
call SetUnitY(u,udg_cinS_act_moveY[i])
set stupid=null
set u = null
endfunction
function ParticleTurn takes nothing returns nothing
local unit u = GetEnumUnit()
local integer i = GetUnitUserData(u)
set udg_cinS_act_turnTime[i] = udg_cinS_act_turnTime[i] - ParticlePeriod()
set udg_cinS_act_turnFi[i] = udg_cinS_act_turnFi[i] + udg_cinS_act_turnVFi[i]
call SetUnitFacing( u, udg_cinS_act_turnFi[i] )
if udg_cinS_act_turnTime[i]<=0.0 then
call GroupRemoveUnit(udg_cinS_act_groups[1], u)
endif
set u = null
endfunction
function ParticleColour takes nothing returns nothing
local unit u = GetEnumUnit()
local integer i = GetUnitUserData(u)
set udg_cinS_act_colourTime[i] = udg_cinS_act_colourTime[i] - ParticlePeriod()
set udg_cinS_act_colourR[i] = udg_cinS_act_colourR[i] + udg_cinS_act_colourVR[i]
set udg_cinS_act_colourG[i] = udg_cinS_act_colourG[i] + udg_cinS_act_colourVG[i]
set udg_cinS_act_colourB[i] = udg_cinS_act_colourB[i] + udg_cinS_act_colourVB[i]
set udg_cinS_act_colourA[i] = udg_cinS_act_colourA[i] + udg_cinS_act_colourVA[i]
call SetUnitVertexColor(u, PercentTo255(udg_cinS_act_colourR[i]), PercentTo255(udg_cinS_act_colourG[i]), PercentTo255(udg_cinS_act_colourB[i]), PercentTo255(udg_cinS_act_colourA[i]))
if udg_cinS_act_colourTime[i]<=0.0 then
call GroupRemoveUnit(udg_cinS_act_groups[2], u)
endif
set u = null
endfunction
function ParticleSize takes nothing returns nothing
local unit u = GetEnumUnit()
local integer i = GetUnitUserData(u)
set udg_cinS_act_sizeTime[i] = udg_cinS_act_sizeTime[i] - ParticlePeriod()
set udg_cinS_act_sizeS[i] = udg_cinS_act_sizeS[i] + udg_cinS_act_sizeVS[i]
call SetUnitScale(u,udg_cinS_act_sizeS[i],udg_cinS_act_sizeS[i],udg_cinS_act_sizeS[i])
if udg_cinS_act_sizeTime[i]<=0.0 then
call GroupRemoveUnit(udg_cinS_act_groups[3], u)
endif
set u = null
endfunction
function ParticleMain takes nothing returns nothing
call GroupAddUnit(udg_cinS_act_groups[0], null)
call ForGroup(udg_cinS_act_groups[0], function ParticleMove )
call GroupAddUnit(udg_cinS_act_groups[1], null)
call ForGroup(udg_cinS_act_groups[1], function ParticleTurn )
call GroupAddUnit(udg_cinS_act_groups[2], null)
call ForGroup(udg_cinS_act_groups[2], function ParticleColour )
call GroupAddUnit(udg_cinS_act_groups[3], null)
call ForGroup(udg_cinS_act_groups[3], function ParticleSize )
endfunction
function UnitMove takes unit u, real destX, real destY, real duration, real g returns nothing
local real x = GetUnitX( u )
local real y = GetUnitY( u )
local integer i = GetUnitUserData( u )
local location stupid = udg_cinS_tempPoint
local real z
if duration < ParticlePeriod() then
set duration = ParticlePeriod()
endif
if g != 0 then
if udg_cinS_act_moveZ[i] == 0.0 then
call MoveLocation(stupid, x,y)
set z = GetLocationZ(stupid)
set udg_cinS_act_moveZ[i] = z
else
set z = udg_cinS_act_moveZ[i]
endif
call MoveLocation(stupid, destX, destY)
set z = GetLocationZ(stupid)-z
set udg_cinS_act_moveVZ[i] = ((g*duration/2)+(z/duration))*ParticlePeriod()
set udg_cinS_act_moveAZ[i] = (-g*ParticlePeriod()*ParticlePeriod())
else
set udg_cinS_act_moveAZ[i] = 0.0
endif
set udg_cinS_act_moveX[i] = x
set udg_cinS_act_moveY[i] = y
set udg_cinS_act_moveVX[i] = (destX - x)/duration*ParticlePeriod()
set udg_cinS_act_moveVY[i] = (destY - y)/duration*ParticlePeriod()
set udg_cinS_act_moveTime[i] = duration
call GroupAddUnit( udg_cinS_act_groups[0], u )
set stupid = null
endfunction
function UnitTurn takes unit u, real destAng, real duration, integer clockwise returns nothing
// input angle between 0.00 and 360.00 please
local real angle = GetUnitFacing(u)
local integer i = GetUnitUserData(u)
local real turnspeed
if duration < ParticlePeriod() then
set duration = ParticlePeriod()
endif
if clockwise > 0 and angle > destAng then
set destAng = destAng + 360.0
elseif clockwise < 0 and angle < destAng then
set destAng = destAng - 360.0
elseif clockwise == 0 then
if (angle - destAng) > 180 then
set destAng = destAng + 360
elseif (angle - destAng) < -180 then
set destAng = destAng - 360
endif
endif
set turnspeed = (destAng - angle)/duration*ParticlePeriod()
set udg_cinS_act_turnFi[i] = angle
set udg_cinS_act_turnVFi[i] = turnspeed
set udg_cinS_act_turnTime[i] = duration
call GroupAddUnit( udg_cinS_act_groups[1], u )
endfunction
function UnitColour takes unit u, real red, real green, real blue, real opacity, real duration returns nothing
local integer i = GetUnitUserData(u)
if duration < ParticlePeriod() then
set duration = ParticlePeriod()
endif
set red = red - udg_cinS_act_colourR[i]
set udg_cinS_act_colourVR[i] = red / duration * ParticlePeriod()
set green = green - udg_cinS_act_colourG[i]
set udg_cinS_act_colourVG[i] = green / duration * ParticlePeriod()
set blue = blue - udg_cinS_act_colourB[i]
set udg_cinS_act_colourVB[i] = blue / duration * ParticlePeriod()
set opacity = opacity - udg_cinS_act_colourA[i]
set udg_cinS_act_colourVA[i] = opacity / duration * ParticlePeriod()
set udg_cinS_act_colourTime[i] = duration
call GroupAddUnit( udg_cinS_act_groups[2], u )
endfunction
function UnitSize takes unit u, real size, real duration returns nothing
local integer i = GetUnitUserData(u)
if duration < ParticlePeriod() then
set duration = ParticlePeriod()
endif
set size = size - udg_cinS_act_sizeS[i]
set udg_cinS_act_sizeVS[i] = size / duration * ParticlePeriod()
set udg_cinS_act_sizeTime[i] = duration
call GroupAddUnit( udg_cinS_act_groups[3], u )
endfunction
function ParticleInit takes nothing returns nothing
local trigger t = CreateTrigger()
set udg_cinS_act_groups[0]=CreateGroup()
set udg_cinS_act_groups[1]=CreateGroup()
set udg_cinS_act_groups[2]=CreateGroup()
set udg_cinS_act_groups[3]=CreateGroup()
call TriggerRegisterTimerEventPeriodic( t, ParticlePeriod() )
call TriggerAddAction( t, function ParticleMain )
set t = null
endfunction
// ****************************************************************************
// **
// ** SUBTITLE ENGINE
// **
// ****************************************************************************
constant function DefaultCharWidth takes nothing returns real
return 1.56
endfunction
function DisplaySubtitle takes string line1 returns nothing
local string char
local integer i
local real charwidth
local real totalwidth
local gamecache g = GC()
set i = 0
set totalwidth = 0
loop
set char = SubString(line1, i, i+1)
exitwhen char == ""
if StringCase(char, false)==char then
set charwidth = GetStoredReal(g, "subtitles", "low"+char)
else
set charwidth = GetStoredReal(g, "subtitles", "upp"+char)
endif
if charwidth == 0.0 then
set charwidth = DefaultCharWidth()
endif
set totalwidth=totalwidth+charwidth
set i = i + 1
endloop
set i = R2I((50.0-totalwidth/2)/GetStoredReal(g, "subtitles", "low "))
set char = ""
loop
exitwhen i <= 3
set char=char+" "
set i = i-1
endloop
set line1=char+line1
// call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.25,0.0, 1000.0, line1)
call DisplayTimedTextToPlayer( GetLocalPlayer(), 0.25, 0.0, 1000.0, "\n\n\n\n\n\n" + line1 + "\n\n\n\n\n\n\n\n\n\n\n\n")
set g = null
endfunction
function ClearSubtitles takes nothing returns nothing
call ClearTextMessages()
endfunction
function SubtitlesInit takes nothing returns nothing
local gamecache g=GC()
call StoreReal(g, "subtitles", "uppa", 2.06)
call StoreReal(g, "subtitles", "uppb", 1.62)
call StoreReal(g, "subtitles", "uppc", 1.83)
call StoreReal(g, "subtitles", "uppd", 1.93)
call StoreReal(g, "subtitles", "uppe", 1.53)
call StoreReal(g, "subtitles", "uppf", 1.22)
call StoreReal(g, "subtitles", "uppg", 2.04)
call StoreReal(g, "subtitles", "upph", 2.00)
call StoreReal(g, "subtitles", "uppi", 0.77)
call StoreReal(g, "subtitles", "uppj", 0.80)
call StoreReal(g, "subtitles", "uppk", 1.83)
call StoreReal(g, "subtitles", "uppl", 1.48)
call StoreReal(g, "subtitles", "uppm", 2.64)
call StoreReal(g, "subtitles", "uppn", 2.00)
call StoreReal(g, "subtitles", "uppo", 2.25)
call StoreReal(g, "subtitles", "uppp", 1.56)
call StoreReal(g, "subtitles", "uppq", 2.37)
call StoreReal(g, "subtitles", "uppr", 1.79)
call StoreReal(g, "subtitles", "upps", 1.56)
call StoreReal(g, "subtitles", "uppt", 1.51)
call StoreReal(g, "subtitles", "uppu", 1.87)
call StoreReal(g, "subtitles", "uppv", 1.83)
call StoreReal(g, "subtitles", "uppw", 2.82)
call StoreReal(g, "subtitles", "uppx", 2.04)
call StoreReal(g, "subtitles", "uppy", 1.79)
call StoreReal(g, "subtitles", "uppz", 1.79)
call StoreReal(g, "subtitles", "lowa", 1.51)
call StoreReal(g, "subtitles", "lowb", 1.59)
call StoreReal(g, "subtitles", "lowc", 1.47)
call StoreReal(g, "subtitles", "lowd", 1.62)
call StoreReal(g, "subtitles", "lowe", 1.59)
call StoreReal(g, "subtitles", "lowf", 0.98)
call StoreReal(g, "subtitles", "lowg", 1.76)
call StoreReal(g, "subtitles", "lowh", 1.59)
call StoreReal(g, "subtitles", "lowi", 0.65)
call StoreReal(g, "subtitles", "lowj", 0.77)
call StoreReal(g, "subtitles", "lowk", 1.47)
call StoreReal(g, "subtitles", "lowl", 0.68)
call StoreReal(g, "subtitles", "lowm", 2.27)
call StoreReal(g, "subtitles", "lown", 1.56)
call StoreReal(g, "subtitles", "lowo", 1.66)
call StoreReal(g, "subtitles", "lowp", 1.62)
call StoreReal(g, "subtitles", "lowq", 1.62)
call StoreReal(g, "subtitles", "lowr", 0.98)
call StoreReal(g, "subtitles", "lows", 1.26)
call StoreReal(g, "subtitles", "lowt", 1.00)
call StoreReal(g, "subtitles", "lowu", 1.59)
call StoreReal(g, "subtitles", "lowv", 1.59)
call StoreReal(g, "subtitles", "loww", 2.29)
call StoreReal(g, "subtitles", "lowx", 1.59)
call StoreReal(g, "subtitles", "lowy", 1.59)
call StoreReal(g, "subtitles", "lowz", 1.47)
call StoreReal(g, "subtitles", "low.", 0.51)
call StoreReal(g, "subtitles", "low,", 0.55)
call StoreReal(g, "subtitles", "low ", 0.80)
call StoreReal(g, "subtitles", "low-", 1.04)
set g = null
endfunction
// ****************************************************************************
// **
// ** SOUND ENGINE
// **
// ****************************************************************************
function AllocateSound takes string path, integer id, integer volume, real pitch returns nothing
endfunction
// ****************************************************************************
// **
// ** SCRIPT SYSTEM
// **
// ****************************************************************************
function PlayScene takes integer scene returns nothing
call StoreInteger( GC(), "Interpreter", "Scene", scene )
call StoreReal( GC(), "Interpreter", "SceneTime", 0.00 )
call StoreInteger( GC(), "Interpreter", "PendingAction", GetStoredInteger( GC(), "Scene"+I2S(scene), "FirstSpot" ) )
endfunction
function PlaySceneFromTime takes integer scene, real time returns nothing
local string s
local integer previous = GetStoredInteger( GC(), "Scene"+I2S(scene), "LastSpot" )
if time < 0.00 then
call BJDebugMsg( "User error: negative action time" )
return
endif
loop
set s = "S"+I2S(scene)+"A"+I2S(previous)
exitwhen time > GetStoredReal( GC(), s, "Time" )
set previous = GetStoredInteger( GC(), s, "PrevAction" )
endloop
call StoreInteger( GC(), "Interpreter", "Scene", scene )
call StoreReal( GC(), "Interpreter", "SceneTime", time )
call StoreInteger( GC(), "Interpreter", "PendingAction", GetStoredInteger( GC(), s, "NextAction" ) )
endfunction
function ScriptInterpreter takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local real time = GetStoredReal( g, "Interpreter", "SceneTime" ) + ScriptSystemPeriod()
local string s
if scene == 0 then
return
endif
loop
set s = "S"+I2S(scene)+"A"+I2S(action)
exitwhen time < GetStoredReal( g, s, "Time" )
if action == 0 then
return
endif
call ExecuteFunc( GetStoredString( g, s, "ActionType" ) )
if scene != GetStoredInteger( g, "Interpreter", "Scene" ) then
return
endif
set action = GetStoredInteger( g, s, "NextAction" )
call StoreInteger( g, "Interpreter", "PendingAction", action )
endloop
call StoreReal( g, "Interpreter", "SceneTime", time )
endfunction
function WriteToScene takes integer scene returns nothing
call StoreInteger( GC(), "Scripter", "Scene", scene )
endfunction
function GetActionSpot takes integer scene, real time returns integer
local gamecache g = GC()
local string s
local integer previous = GetStoredInteger( g, "Scene"+I2S(scene), "LastSpot" )
local integer length = GetStoredInteger( g, "Scene"+I2S(scene), "Length" ) + 1
local integer next = 0
if time < 0.00 then
call BJDebugMsg( "User error: negative action time" )
return -1
endif
call StoreInteger( g, "Scene"+I2S(scene), "Length", length )
loop
if previous == 0 then
call StoreInteger( g, "Scene"+I2S(scene), "FirstSpot", length )
endif
set s = "S"+I2S(scene)+"A"+I2S(previous)
exitwhen time >= GetStoredReal( g, s, "Time" )
set previous = GetStoredInteger( g, s, "PrevAction" )
endloop
if previous == GetStoredInteger( g, "Scene"+I2S(scene), "LastSpot" ) then
call StoreInteger( g, "Scene"+I2S(scene), "LastSpot", length )
call StoreInteger( g, s, "NextAction", length )
else
set next = GetStoredInteger(g, s, "NextAction" )
call StoreInteger( g, s, "NextAction", length )
set s = "S"+I2S(scene)+"A"+I2S(next)
call StoreInteger( g, s, "PrevAction", length )
endif
set s = "S"+I2S(scene)+"A"+I2S(length)
call StoreInteger( g, s, "PrevAction", previous )
call StoreInteger( g, s, "NextAction", next )
return length
endfunction
// next scene
function NextScene takes nothing returns nothing
local integer scene = GetStoredInteger( GC(), "Interpreter", "Scene" )
call PlayScene(scene+1)
endfunction
function ScriptNextScene takes real time returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "NextScene" )
call StoreReal( g, s, "Time", time )
set g = null
endfunction
// external function
function ScriptExternalFunc takes real time, string funcName returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", funcName )
call StoreReal( g, s, "Time", time )
set g = null
endfunction
// special effect
function SpecialEffectDestroy takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = GetStoredInteger( GC(), H2S(t), "effect" )
call DestroyEffect( udg_cinS_effect[i] )
set udg_cinS_effect[i]=null
set udg_cinS_effectFree[i]=udg_cinS_effectCount
set udg_cinS_effectCount=i
call FlushStoredMission( GC(), H2S(t) )
call DestroyTimer( t )
set t = null
endfunction
function SpecialEffectDestroyOverTime takes effect eff, real duration returns nothing
local timer t = CreateTimer()
local integer i=udg_cinS_effectCount
if udg_cinS_effectFree[i]!=0 then
set udg_cinS_effectCount=udg_cinS_effectFree[i]
set udg_cinS_effectFree[i]=0
else
set udg_cinS_effectCount=udg_cinS_effectCount+1
endif
set udg_cinS_effect[i]=eff
call StoreInteger( GC(), H2S(t), "effect", i )
call TimerStart(t, duration, false, function SpecialEffectDestroy)
set t = null
endfunction
function SpecialEffectPoint takes nothing returns nothing
local gamecache g = GC()
local effect eff = null
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local real x = GetStoredReal( g, s, "real1" )
local real y = GetStoredReal( g, s, "real2" )
local real z = GetStoredReal( g, s, "real3" )
local real duration = GetStoredReal( g, s, "real4" )
local string path = GetStoredString( g, s, "str1" )
local destructable d = CreateDestructableZ( 'OTip', x, y, z, 0.00, 1, 0 )
set eff = AddSpecialEffect(path, x, y)
call RemoveDestructable( d )
call SpecialEffectDestroyOverTime(eff, duration)
set d = null
set eff = null
set g = null
endfunction
function ScriptPointEffect takes real time, real x, real y, real z, string path, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "SpecialEffectPoint" )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", x )
call StoreReal( g, s, "real2", y )
call StoreReal( g, s, "real3", z )
call StoreReal( g, s, "real4", duration )
call StoreString( g, s, "str1", path )
set g = null
endfunction
function SpecialEffectActor takes nothing returns nothing
local gamecache g = GC()
local effect eff = null
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real duration = GetStoredReal( g, s, "real1" )
local string path = GetStoredString( g, s, "str1" )
local string attPoint = GetStoredString( g, s, "str2" )
set eff = AddSpecialEffectTarget(path, udg_cinS_actor[actID], attPoint)
call SpecialEffectDestroyOverTime(eff, duration)
set eff = null
set g = null
endfunction
function ScriptActEffect takes real time, integer actor, string path, string attachpoint, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "SpecialEffectActor" )
call StoreReal( g, s, "Time", time )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "real1", duration )
call StoreString( g, s, "str1", path )
call StoreString( g, s, "str2", attachpoint )
set g = null
endfunction
// play sound
function PlaySoundPath takes nothing returns nothing
local gamecache g = GC()
local sound snd = null
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer volume = GetStoredInteger( g, s, "int1" )
local real pitch = GetStoredReal( g, s, "real1" )
local string path = GetStoredString( g, s, "str1" )
set snd = CreateSound(path, false, false, false, 10, 10, "")
call SetSoundPitch(snd, pitch)
call SetSoundVolume(snd, volume)
call StartSound(snd)
call KillSoundWhenDone(snd)
set snd = null
set g = null
endfunction
function PreloadSoundPath takes nothing returns nothing
local gamecache g = GC()
local timer t = GetExpiredTimer()
local string path = GetStoredString( g, H2S(t), "path" )
local sound snd = CreateSound(path, false, false, false, 10, 10, "")
call SetSoundVolume(snd, 0)
call StartSound(snd)
call KillSoundWhenDone(snd)
set snd = null
call FlushStoredMission( g, H2S(t) )
call DestroyTimer(t)
set t = null
set g = null
endfunction
function ScriptPlaySound takes real time, string path, real pitch, integer volume returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local timer t
if not(GetStoredBoolean(g, "preloading", path)) then
set t = CreateTimer()
call StoreString( g, H2S(t), "path", path )
call TimerStart(t, 1.00, false, function PreloadSoundPath)
call StoreBoolean(g, "preloading", path, true)
set t = null
endif
call StoreString( g, s, "ActionType", "PlaySoundPath" )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", pitch )
call StoreInteger( g, s, "int1", volume )
call StoreString( g, s, "str1", path )
set g = null
endfunction
// ability level
function ActorAbilityLevel takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local integer abilityID = GetStoredInteger( g, s, "int1" )
local integer level = GetStoredInteger( g, s, "int2" )
call UnitRemoveAbility( udg_cinS_actor[actID], abilityID )
call UnitAddAbility( udg_cinS_actor[actID], abilityID )
call SetUnitAbilityLevel( udg_cinS_actor[actID], abilityID, level )
set g = null
endfunction
function ScriptActAbilityLvl takes real time, integer actor, integer abilityID, integer level returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorAbilityLevel" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreInteger( g, s, "int1", abilityID )
call StoreInteger( g, s, "int2", level )
set g = null
endfunction
// play animation
function ActorPlayAnimation takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local integer animationID = GetStoredInteger( g, s, "int1" )
local real animationBlend = GetStoredReal( g, s, "real1" )
call SetUnitBlendTime(udg_cinS_actor[actID], animationBlend)
call SetUnitAnimationByIndex( udg_cinS_actor[actID], animationID )
set g = null
endfunction
function ScriptActAnimPlay takes real time, integer actor, integer animationID, real animationBlend returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorPlayAnimation" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreInteger( g, s, "int1", animationID )
call StoreReal( g, s, "real1", animationBlend )
set g = null
endfunction
function ActorResetAnimation takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
call ResetUnitAnimation( udg_cinS_actor[actID] )
set g = null
endfunction
function ScriptActAnimReset takes real time, integer actor returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorResetAnimation" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
set g = null
endfunction
// animation speed
function ActorSpeedAnimation takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real animationSpeed = GetStoredReal( g, s, "real1" )
call SetUnitTimeScale( udg_cinS_actor[actID], animationSpeed )
set g = null
endfunction
function ScriptActAnimSpeed takes real time, integer actor, real speed returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorSpeedAnimation" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", speed )
set g = null
endfunction
// slide unit
function ActorSlide takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real destX = GetStoredReal( g, s, "real1" )
local real destY = GetStoredReal( g, s, "real2" )
local real duration = GetStoredReal( g, s, "real3" )
local real gr = GetStoredReal( g, s, "real4" )
call UnitMove( udg_cinS_actor[actID], destX, destY, duration, gr )
set g = null
endfunction
function ScriptActSlide takes real time, integer actor, real x, real y, real duration, real gr returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorSlide" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", x )
call StoreReal( g, s, "real2", y )
call StoreReal( g, s, "real3", duration )
call StoreReal( g, s, "real4", gr )
set g = null
endfunction
// walk unit
function ActorWalkProperties takes integer unitID, integer walkAnimID, real walkAnimDuration, real walkSpeed returns nothing
local real speed = walkSpeed / walkAnimDuration
local string s = "ActorStats "+I2S(unitID)
call StoreReal( GC(), s, "speed", speed )
call StoreInteger( GC(), s, "animation", walkAnimID )
endfunction
function ActorWalk takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real destX = GetStoredReal( g, s, "real1" )
local real destY = GetStoredReal( g, s, "real2" )
local real duration = GetStoredReal( g, s, "real3" )
local real animationBlend = GetStoredReal( g, s, "real4" )
call UnitMove( udg_cinS_actor[actID], destX, destY, duration, 0 )
set s = "ActorStats "+I2S(GetUnitTypeId(udg_cinS_actor[actID]))
set destX=destX-GetUnitX(udg_cinS_actor[actID])
set destY=destY-GetUnitY(udg_cinS_actor[actID])
call UnitTurn( udg_cinS_actor[actID], bj_RADTODEG * Atan2(destY , destX), animationBlend, 0 )
call SetUnitBlendTime(udg_cinS_actor[actID], animationBlend)
call SetUnitTimeScale( udg_cinS_actor[actID], (SquareRoot(destX*destX+destY*destY) / (duration+0.01) / (GetStoredReal(GC(), s, "speed"))+0.01) )
call SetUnitAnimationByIndex( udg_cinS_actor[actID], GetStoredInteger(GC(), s, "animation") )
set g = null
endfunction
function ScriptActWalk takes real time, integer actor, real x, real y, real duration, real animationBlend returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorWalk" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", x )
call StoreReal( g, s, "real2", y )
call StoreReal( g, s, "real3", duration )
call StoreReal( g, s, "real4", animationBlend )
set g = null
endfunction
// turn unit
function ActorTurn takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real destAng = GetStoredReal( g, s, "real1" )
local real duration = GetStoredReal( g, s, "real2" )
local integer clockwise = GetStoredInteger( g, s, "int1" )
call UnitTurn( udg_cinS_actor[actID], destAng, duration, clockwise )
set g = null
endfunction
function ScriptActTurn takes real time, integer actor, real destAng, real duration, integer clockwise returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorTurn" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", destAng )
call StoreReal( g, s, "real2", duration )
call StoreInteger( g, s, "int1", clockwise )
set g = null
endfunction
function ActorFace takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local integer targetID = GetStoredInteger( g, s, "int1" )
local integer headORchest = GetStoredInteger( g, s, "int2" )
local real x = GetStoredReal( g, s, "real1" )
local real y = GetStoredReal( g, s, "real2" )
local real z = GetStoredReal( g, s, "real3" )
local real animationBlend = GetStoredReal( g, s, "real4" )
if headORchest == 0 then
set s = "Bone_Head"
else
set s = "Bone_Chest"
endif
call SetUnitBlendTime(udg_cinS_actor[actID], animationBlend)
call SetUnitLookAt( udg_cinS_actor[actID], s, udg_cinS_actor[targetID], x,y,z )
set g = null
endfunction
function ScriptActFace takes real time, integer actor, integer destActor, integer headORchest, real xoff, real yoff, real zoff, real animationBlend returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorFace" )
call StoreInteger( g, s, "actor", actor )
call StoreInteger( g, s, "int1", destActor )
call StoreInteger( g, s, "int2", headORchest )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", xoff )
call StoreReal( g, s, "real2", yoff )
call StoreReal( g, s, "real3", zoff )
call StoreReal( g, s, "real4", animationBlend )
set g = null
endfunction
function ActorFaceReset takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real animationBlend = GetStoredReal( g, s, "real1" )
call SetUnitBlendTime(udg_cinS_actor[actID], animationBlend)
call ResetUnitLookAt( udg_cinS_actor[actID] )
set g = null
endfunction
function ScriptActFaceReset takes real time, integer actor, real animationBlend returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorFaceReset" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", animationBlend )
set g = null
endfunction
// vertex colouring
function ActorColour takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real red = GetStoredReal( g, s, "real1" )
local real green = GetStoredReal( g, s, "real2" )
local real blue = GetStoredReal( g, s, "real3" )
local real opacity = GetStoredReal( g, s, "real4" )
local real duration = GetStoredReal( g, s, "real5" )
call UnitColour( udg_cinS_actor[actID], red, green, blue, opacity, duration )
set g = null
endfunction
function ScriptActColour takes real time, integer actor, real red, real green, real blue, real opacity, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorColour" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", red )
call StoreReal( g, s, "real2", green )
call StoreReal( g, s, "real3", blue )
call StoreReal( g, s, "real4", opacity )
call StoreReal( g, s, "real5", duration )
set g = null
endfunction
// size unit
function ActorSize takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real size = GetStoredReal( g, s, "real1" )
local real duration = GetStoredReal( g, s, "real2" )
call UnitSize( udg_cinS_actor[actID], size, duration )
set g = null
endfunction
function ScriptActSize takes real time, integer actor, real size, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorSize" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", size )
call StoreReal( g, s, "real2", duration )
set g = null
endfunction
// camera scripting
function CameraAction takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer camID = GetStoredInteger( g, s, "actor" )
local integer changeType = GetStoredInteger( g, s, "int1" )
local real duration = GetStoredReal( g, s, "real1" )
if changeType == 1 then
call ApplyCameraInstantly( udg_cinS_camera[camID] )
elseif changeType == 2 then
call ApplyCameraLinear( udg_cinS_camera[camID], duration )
elseif changeType == 3 then
call ApplyCameraSmooth( udg_cinS_camera[camID], duration )
elseif changeType == 4 then
call ApplyCameraSmoothStop( udg_cinS_camera[camID], duration )
endif
set g = null
endfunction
function ScriptCamera takes real time, integer camera, real duration, integer changeType returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "CameraAction" )
call StoreInteger( g, s, "actor", camera )
call StoreInteger( g, s, "int1", changeType )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", duration )
set g = null
endfunction
function CameraStatChangeInst takes integer stat, real endvalue returns nothing
set udg_cinS_cam_startval[stat] = endvalue
set udg_cinS_cam_startvel[stat] = 0.0
set udg_cinS_cam_accprim[stat] = 0.0
set udg_cinS_cam_accsec[stat] = 0.0
set udg_cinS_cam_time[stat] = 0.0
set udg_cinS_cam_endtime[stat] = 0.0
endfunction
function CameraStatAction takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer statID = GetStoredInteger( g, s, "actor" )
local integer changeType = GetStoredInteger( g, s, "int1" )
local real duration = GetStoredReal( g, s, "real1" )
local real endValue = GetStoredReal( g, s, "real2" )
local real endSpeed = GetStoredReal( g, s, "real3" )
if statID==4 or statID==5 or statID==6 then
if changeType == 1 then
call CameraStatChangeInst( statID, endValue )
elseif changeType == 2 then
call CameraStatChangeLinRad( statID, endValue, duration )
elseif changeType == 3 then
call CameraStatChangeRad( statID, endValue, duration )
elseif changeType == 4 then
call CameraStatChangeAdvRad( statID, endValue, endSpeed, duration )
endif
else
if changeType == 1 then
call CameraStatChangeInst( statID, endValue )
elseif changeType == 2 then
call CameraStatChangeLin( statID, endValue, duration )
elseif changeType == 3 then
call CameraStatChange( statID, endValue, duration )
elseif changeType == 4 then
call CameraStatChangeAdv( statID, endValue, endSpeed, duration )
endif
endif
set g = null
endfunction
function ScriptCameraStat takes real time, integer statID, real duration, real endValue, real endSpeed, integer changeType returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "CameraStatAction" )
call StoreInteger( g, s, "actor", statID )
call StoreInteger( g, s, "int1", changeType )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", duration )
call StoreReal( g, s, "real2", endValue )
call StoreReal( g, s, "real3", endSpeed )
set g = null
endfunction
// camera statID list
// 1 - x coordinate; 2 - y coordinate; 3 - z coordinate;
// 4 - facing angle; 5 - angle of attack; 6 - roll angle;
// 7 - field ov view; 8 - far z; 9 - distance to target
function CameraIgnoreTerrain takes nothing returns nothing
set udg_cinS_cam_ignoreTerrain = true
endfunction
function CameraUnignoreTerrain takes nothing returns nothing
set udg_cinS_cam_ignoreTerrain = false
endfunction
function ScriptCameraIgnoreTerrain takes real time, boolean ignore returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
if ignore then
call StoreString( g, s, "ActionType", "CameraIgnoreTerrain" )
else
call StoreString( g, s, "ActionType", "CameraUnignoreTerrain" )
endif
set g = null
endfunction
function ActorCameraLock takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real duration = GetStoredReal( g, s, "real1" )
local real xoff = GetStoredReal( g, s, "real2" )
local real yoff = GetStoredReal( g, s, "real3" )
local real zoff = GetStoredReal( g, s, "real4" )
local boolean smooth = GetStoredInteger( g, s, "int1" )==1
call CameraLockToUnitOverride(udg_cinS_actor[actID], xoff, yoff, zoff, smooth, duration )
set g = null
endfunction
function ScriptActCameraLock takes real time, integer actor, real xoff, real yoff, real zoff, boolean smooth, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorCameraLock" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "real2", xoff )
call StoreReal( g, s, "real3", yoff )
call StoreReal( g, s, "real4", zoff )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", duration )
if smooth then
call StoreInteger( g, s, "int1", 1 )
else
call StoreInteger( g, s, "int1", 0 )
endif
set g = null
endfunction
function ActorCameraLockReset takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local real duration = GetStoredReal( g, s, "real1" )
local boolean smooth = GetStoredInteger( g, s, "int1" )==1
call CameraLockToUnitReset( smooth, duration )
set g = null
endfunction
function ScriptActCameraLockReset takes real time, boolean smooth, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorCameraLockReset" )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", duration )
if smooth then
call StoreInteger( g, s, "int1", 1 )
else
call StoreInteger( g, s, "int1", 0 )
endif
set g = null
endfunction
function ActorCameraFace takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local integer actID = GetStoredInteger( g, s, "actor" )
local real duration = GetStoredReal( g, s, "real1" )
local real xoff = GetStoredReal( g, s, "real2" )
local real yoff = GetStoredReal( g, s, "real3" )
local real zoff = GetStoredReal( g, s, "real4" )
local boolean smooth = GetStoredInteger( g, s, "int1" )==1
call CameraFaceToUnitOverride(udg_cinS_actor[actID], xoff, yoff, zoff, smooth, duration )
set g = null
endfunction
function ScriptActCameraFace takes real time, integer actor, real xoff, real yoff, real zoff, boolean smooth, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorCameraFace" )
call StoreInteger( g, s, "actor", actor )
call StoreReal( g, s, "real2", xoff )
call StoreReal( g, s, "real3", yoff )
call StoreReal( g, s, "real4", zoff )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", duration )
if smooth then
call StoreInteger( g, s, "int1", 1 )
else
call StoreInteger( g, s, "int1", 0 )
endif
set g = null
endfunction
function ActorCameraFaceReset takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local real duration = GetStoredReal( g, s, "real1" )
local boolean smooth = GetStoredInteger( g, s, "int1" )==1
call CameraFaceToUnitReset( smooth, duration )
set g = null
endfunction
function ScriptActCameraFaceReset takes real time, boolean smooth, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "ActorCameraFaceReset" )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", duration )
if smooth then
call StoreInteger( g, s, "int1", 1 )
else
call StoreInteger( g, s, "int1", 0 )
endif
set g = null
endfunction
function FogChange takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local real duration = GetStoredReal( g, s, "real1" )
local real startZ = GetStoredReal( g, s, "real2" )
local real endZ = GetStoredReal( g, s, "real3" )
local real red = GetStoredReal( g, s, "real4" )
local real green = GetStoredReal( g, s, "real5" )
local real blue = GetStoredReal( g, s, "real6" )
call ApplyFog(startZ, endZ, red, green, blue, duration)
endfunction
function ScriptFog takes real time, real startZ, real endZ, real red, real green, real blue, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "FogChange" )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", duration )
call StoreReal( g, s, "real2", startZ )
call StoreReal( g, s, "real3", endZ )
call StoreReal( g, s, "real4", red )
call StoreReal( g, s, "real5", green )
call StoreReal( g, s, "real6", blue )
set g = null
endfunction
function FadeChange takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local real duration = GetStoredReal( g, s, "real1" )
local real red = GetStoredReal( g, s, "real2" )
local real green = GetStoredReal( g, s, "real3" )
local real blue = GetStoredReal( g, s, "real4" )
local real opacity = GetStoredReal( g, s, "real5" )
call ApplyFade(red, green, blue, opacity, duration)
endfunction
function ScriptFade takes real time, real red, real green, real blue, real opacity, real duration returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "FadeChange" )
call StoreReal( g, s, "Time", time )
call StoreReal( g, s, "real1", duration )
call StoreReal( g, s, "real2", red )
call StoreReal( g, s, "real3", green )
call StoreReal( g, s, "real4", blue )
call StoreReal( g, s, "real5", opacity )
set g = null
endfunction
function SubtitleDisplay takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
local string line = GetStoredString( g, s, "string1" )
if udg_cinS_displaySubtitles then
call DisplaySubtitle(line)
endif
set g = null
endfunction
function ScriptSubtitleLine takes real time, string line returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "SubtitleDisplay" )
call StoreReal( g, s, "Time", time )
call StoreString( g, s, "string1", line )
set g = null
endfunction
function SubtitleClear takes nothing returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Interpreter", "Scene" )
local integer action = GetStoredInteger( g, "Interpreter", "PendingAction" )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call ClearSubtitles()
set g = null
endfunction
function ScriptSubtitleClear takes real time returns nothing
local gamecache g = GC()
local integer scene = GetStoredInteger( g, "Scripter", "Scene" )
local integer action = GetActionSpot( scene, time )
local string s = "S"+I2S(scene)+"A"+I2S(action)
call StoreString( g, s, "ActionType", "SubtitleClear" )
call StoreReal( g, s, "Time", time )
set g = null
endfunction
function ScriptSystemInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventPeriodic( t, ScriptSystemPeriod() )
call TriggerAddAction( t, function ScriptInterpreter )
set t = null
endfunction
Name | Type | is_array | initial_value |
cinS_act_colourA | real | Yes | |
cinS_act_colourB | real | Yes | |
cinS_act_colourG | real | Yes | |
cinS_act_colourR | real | Yes | |
cinS_act_colourTime | real | Yes | |
cinS_act_colourVA | real | Yes | |
cinS_act_colourVB | real | Yes | |
cinS_act_colourVG | real | Yes | |
cinS_act_colourVR | real | Yes | |
cinS_act_groups | group | Yes | |
cinS_act_moveAZ | real | Yes | |
cinS_act_moveTime | real | Yes | |
cinS_act_moveVX | real | Yes | |
cinS_act_moveVY | real | Yes | |
cinS_act_moveVZ | real | Yes | |
cinS_act_moveX | real | Yes | |
cinS_act_moveY | real | Yes | |
cinS_act_moveZ | real | Yes | |
cinS_act_sizeS | real | Yes | |
cinS_act_sizeTime | real | Yes | |
cinS_act_sizeVS | real | Yes | |
cinS_act_turnFi | real | Yes | |
cinS_act_turnTime | real | Yes | |
cinS_act_turnVFi | real | Yes | |
cinS_actor | unit | Yes | |
cinS_cam_accprim | real | Yes | |
cinS_cam_accsec | real | Yes | |
cinS_cam_endtime | real | Yes | |
cinS_cam_fadeUnit | unit | No | |
cinS_cam_ignoreTerrain | boolean | No | |
cinS_cam_OvRangEndtime | real | No | |
cinS_cam_OvRangSmooth | boolean | No | |
cinS_cam_OvRangTime | real | No | |
cinS_cam_OvRangUnitPrim | unit | No | |
cinS_cam_OvRangUnitSec | unit | No | |
cinS_cam_OvRoffset | real | Yes | |
cinS_cam_OvRxyzEndtime | real | No | |
cinS_cam_OvRxyzSmooth | boolean | No | |
cinS_cam_OvRxyzTime | real | No | |
cinS_cam_OvRxyzUnitPrim | unit | No | |
cinS_cam_OvRxyzUnitSec | unit | No | |
cinS_cam_startval | real | Yes | |
cinS_cam_startvel | real | Yes | |
cinS_cam_time | real | Yes | |
cinS_cam_trigger | trigger | No | |
cinS_camera | camerasetup | Yes | |
cinS_displaySubtitles | boolean | No | |
cinS_effect | effect | Yes | |
cinS_effectCount | integer | No | |
cinS_effectFree | integer | Yes | |
cinS_GC | gamecache | No | |
cinS_tempPoint | location | No |