//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//x >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< x
//x^ Dragonblood Creations' Camera System ^x
//x^ Copyright Waldbaer@Dragonblood Creations, March 25th, 2007 ^x
//x^ ^x
//x^ Version 1.01 ^x
//x^ Credits to eGust for the Tool JassShopPro partly used for development ^x
//x^ Check www.dragonblood-creations.de for the latest update ^x
//x^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>^x
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//
//___________________________________________________________________________
//|You have to give credits, if you use anything of this system for your |
//|map, either whole functions or only parts of them. You are allowed to |
//|change this system, if you still give credits to Dragonblood Creations. |
//|If you think that changes by you are so useful in a way that they should |
//|be implemented in the official version for everybody's use, send an |
//|e-mail to |
//|[email protected] |
//|and write us your changes in it, as well as a description of what their |
//|exact effect is. If we decide to implement them really, you will of |
//|course also be credited. |
//|_________________________________________________________________________|
//===========================================================================
// Constant Functions for easy editing of basic preferences
//===========================================================================
constant function DCCamSystem_LoopFrequence takes nothing returns real
return 0.05 //The time period, the system is based on. You can
endfunction //change this to a higher value to save performance.
constant function DCCamSystem_TargetCurveAngleStep takes nothing returns real
return 5.00 //This is the number of degrees every step is big
endfunction //when the target is making a curve.
constant function DCCamSystem_TargetMinSpeed takes nothing returns real
return 10.00 //This is the speed the target is braked to if it
endfunction //is braked automatically in a shorter than the
//input smoothtime.
constant function DCCamSystem_ZOffMinSpeed takes nothing returns real
return 2.00 //This is the speed the Z-Offset is braked to if it
endfunction //is braked automatically in a shorter than the
//input smoothtime.
constant function DCCamSystem_DistMinSpeed takes nothing returns real
return 3.00 //This is the speed the distance is braked to if it
endfunction //is braked automatically in a shorter than the
//input smoothtime.
constant function DCCamSystem_FieldMinSpeed takes nothing returns real
return 0.02 //This is the speed the field of view is braked to
endfunction //if it is braked automatically in a shorter than
//the input smoothtime.
constant function DCCamSystem_AngleMinSpeed takes nothing returns real
return 0.01 //This is the speed the angle is braked to if it is
endfunction //braked automatically in a shorter than the input
//smoothtime.
constant function DCCamSystem_RotaMinSpeed takes nothing returns real
return 0.01 //This is the speed the rotation is braked to if it
endfunction //is braked automatically in a shorter than the
//input smoothtime.
constant function DCCamSystem_RollMinSpeed takes nothing returns real
return 0.02 //This is the speed the roll is braked to if it is
endfunction //braked automatically in a shorter than the input
//smoothtime.
//===========================================================================
// Error messages
//===========================================================================
//You can translate these error messages here, if you want, to the language
//of your choice.
constant function DCCamSystem_Error takes nothing returns string
return "|cffff0000DCCamSystem Error: |r"
endfunction
constant function DCCamSystem_NegativeTimeValue takes nothing returns string
return "|cffff9900An input time value is smaller than null. Function canceled.|r"
endfunction
constant function DCCamSystem_SmoothGreaterTotal takes nothing returns string
return "|cffff9900The input smoothtime is greater or equal to the totaltime of the sway. Function canceled.|r"
endfunction
constant function DCCamSystem_ErrorBrakePointV takes nothing returns string
return "|cffff9900The velocity is equal to null so the Brake to Point function will not work. Function canceled.|r"
endfunction
constant function DCCamSystem_ErrorBrakeZOffsetPoint takes nothing returns string
return "|cffff9900The input z-Offset for the Brake to Point function will never be reached braking from the current z-Offset velocity and direction. Function canceled.|r"
endfunction
constant function DCCamSystem_ErrorBrakeDistancePoint takes nothing returns string
return "|cffff9900The input target distance for the Brake to Point function will never be reached braking from the current target distance velocity and direction. Function canceled.|r"
endfunction
constant function DCCamSystem_ErrorBrakeFieldOfViewPoint takes nothing returns string
return "|cffff9900The input target field of view for the Brake to Point function will never be reached braking from the current field of view velocity and direction. Function canceled.|r"
endfunction
constant function DCCamSystem_ErrorBrakeAnglePoint takes nothing returns string
return "|cffff9900The input target angle for the Brake to Point function will not be reached braking from the current angle velocity and direction. Function canceled.|r"
endfunction
constant function DCCamSystem_ErrorBrakeRollPoint takes nothing returns string
return "|cffff9900The input target roll for the Brake to Point function will not be reached braking from the current roll velocity and direction. Function canceled.|r"
endfunction
constant function DCCamSystem_ErrorBrakeRotationPoint takes nothing returns string
return "|cffff9900The input target rotation for the Brake to Point function will not be reached braking from the current rotation velocity and direction. Function canceled.|r"
endfunction
constant function DCCamSystem_ErrorTargetCurve takes nothing returns string
return "|cffff9900The target point of the target curve is the same as the start point. In this case the curve cannot be generated. Function canceled."
endfunction
constant function DCCamSystem_ErrorBrakeFieldOfViewTime takes nothing returns string
return "The target field of view needed by the Brake Time function to brake during the input time is outside the allowed range (20 to 120). A Brake Point with the best possible value was started instead."
endfunction
constant function DCCamSystem_ErrorFieldOfViewInput takes nothing returns string
return "The input value for a Field Of View function is outside the allowed range (20 to 120). Target value was set to the nearest possible."
endfunction
constant function DCCamSystem_ErrorSmoothBrakeTarget takes nothing returns string
return "The current target velocity is too high to brake during the smoothtime to the target location. Smoothtime was shortened to make the sway possible. " + " |cff66ff66 => Brake the target before starting this smooth sway|r"
endfunction
constant function DCCamSystem_ErrorSmoothTarget takes nothing returns string
return "The distance to the target location is in relation to its velocity so small that even shortening smoothtime did not work. Normal pan started instead."
endfunction
constant function DCCamSystem_ErrorSmoothBrakeZOff takes nothing returns string
return "The current z-offset velocity is too high to brake during the smoothtime to the target z-offset. Smoothtime was shortened to make the sway possible." + " |cff66ff66 => Brake the z-offset before starting this smooth sway|r"
endfunction
constant function DCCamSystem_ErrorSmoothZOff takes nothing returns string
return "The distance to the target z-offset is in relation to its velocity so small that even shortening smoothtime did not work. Normal zoffset set started instead."
endfunction
constant function DCCamSystem_ErrorSmoothBrakeDist takes nothing returns string
return "The current distance velocity is too high to brake during the smoothtime to the target distance. Smoothtime was shortened to make the sway possible." + " |cff66ff66 => Brake the distance before starting this smooth sway|r"
endfunction
constant function DCCamSystem_ErrorSmoothDist takes nothing returns string
return "The distance to the target distance is in relation to its velocity so small that even shortening smoothtime did not work. Normal distance set started instead."
endfunction
constant function DCCamSystem_ErrorSmoothBrakeField takes nothing returns string
return "The current field of view velocity is too high to brake during the smoothtime to the target field of view. Smoothtime was shortened to make the sway possible." + " |cff66ff66 => Brake the field of view before starting this smooth sway|r"
endfunction
constant function DCCamSystem_ErrorSmoothField takes nothing returns string
return "The distance to the target field of view is in relation to its velocity so small that even shortening smoothtime did not work. Normal field of view set started instead."
endfunction
constant function DCCamSystem_ErrorSmoothBrakeAngle takes nothing returns string
return "The current angle velocity is too high to brake during the smoothtime to the target angle. Smoothtime was shortened to make the sway possible." + " |cff66ff66 => Brake the angle before starting this smooth sway|r"
endfunction
constant function DCCamSystem_ErrorSmoothAngle takes nothing returns string
return "The distance to the target angle is in relation to its velocity so small that even shortening smoothtime did not work. Normal angle set started instead."
endfunction
constant function DCCamSystem_ErrorSmoothBrakeRota takes nothing returns string
return "The current rotation velocity is too high to brake during the smoothtime to the target rotation. Smoothtime was shortened to make the sway possible." + " |cff66ff66 => Brake the rotation before starting this smooth sway|r"
endfunction
constant function DCCamSystem_ErrorSmoothRota takes nothing returns string
return "The distance to the target rotation is in relation to its velocity so small that even shortening smoothtime did not work. Normal rotation set started instead."
endfunction
constant function DCCamSystem_ErrorSmoothBrakeRoll takes nothing returns string
return "The current roll velocity is too high to brake during the smoothtime to the target roll. Smoothtime was shortened to make the sway possible." + " |cff66ff66 => Brake the roll before starting this smooth sway|r"
endfunction
constant function DCCamSystem_ErrorSmoothRoll takes nothing returns string
return "The distance to the target roll is in relation to its velocity so small that even shortening smoothtime did not work. Normal roll set started instead."
endfunction
//===========================================================================
// Working Functions Of The Camera System
//===========================================================================
// Mathematical functions needed by the system
//--------------------------------------------
function DistanceBetweenAnglesRad takes real angle1, real angle2 returns real
local real distance
set distance = angle2 - angle1
if distance > bj_PI then
set distance = - 2 * bj_PI + distance
elseif distance < - bj_PI then
set distance = 2 * bj_PI + distance
endif
return distance
endfunction
function DistanceBetweenAnglesDeg takes real angle1, real angle2 returns real
local real distance
set distance = angle2 - angle1
if distance > 180 then
set distance = - 360 + distance
elseif distance < - 180 then
set distance = 360 + distance
endif
return distance
endfunction
function DistanceBetweenPointsLocXY takes location locA, real locBX, real locBY returns real
local real dx = locBX - GetLocationX(locA)
local real dy = locBY - GetLocationY(locA)
return SquareRoot(dx * dx + dy * dy)
endfunction
function DistanceBetweenPointsXYXY takes real locAX, real locAY, real locBX, real locBY returns real
local real dx = locBX - locAX
local real dy = locBY - locAY
return SquareRoot(dx * dx + dy * dy)
endfunction
function AngleBetweenPointsXYXY takes real locAX, real LocAY, real locBX, real locBY returns real
return bj_RADTODEG * Atan2(locBY - LocAY, locBX - locAX)
endfunction
function AngleBetweenPointsXYXYRad takes real locAX, real LocAY, real locBX, real locBY returns real
return Atan2(locBY - LocAY, locBX - locAX)
endfunction
function DCCamSystem_CurveDistance takes real targetX, real targetY returns real
local real distance
local real point1X
local real point1Y
local real point2X
local real point2Y
local real point3X
local real point3Y
local real CamTargetX = GetCameraTargetPositionX()
local real CamTargetY = GetCameraTargetPositionY()
local real anglefactor
local real targetangle = AngleBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY )
local real r = DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY ) / 2 * udg_DCCamSystem_CurveRadius
local real distancefactor = r * 1.85 * Sin( Deg2Rad( DCCamSystem_TargetCurveAngleStep() / 2 ) )
local real angle
local real curveanglestep = DCCamSystem_TargetCurveAngleStep() * bj_DEGTORAD
if DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY ) < 10 then
return 0
endif
if udg_zz_DCCamSystem_TargetDir == -1 or RAbsBJ( DistanceBetweenAnglesDeg( udg_zz_DCCamSystem_TargetDir, targetangle ) ) < DCCamSystem_TargetCurveAngleStep() then
//Curve not necessary
set distance = DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY )
else
//Curve necessary
//Set the angle at the optimal direction to make the curve as short as possible
if DistanceBetweenAnglesDeg( udg_zz_DCCamSystem_TargetDir, targetangle ) > 0 then
set anglefactor = DCCamSystem_TargetCurveAngleStep()
else
set anglefactor = - DCCamSystem_TargetCurveAngleStep()
endif
set anglefactor = anglefactor * bj_DEGTORAD
//Calculate distance of curve to target
set point2X = CamTargetX
set point2Y = CamTargetY
set point3X = CamTargetX + distancefactor * Cos(anglefactor)
set point3Y = CamTargetY + distancefactor * Sin(anglefactor)
set distance = DistanceBetweenPointsXYXY( point2X, point2Y, point3X, point3Y )
set angle = AngleBetweenPointsXYXYRad( point2X, point2Y, point3X, point3Y )
loop
exitwhen RAbsBJ(DistanceBetweenAnglesRad( angle, AngleBetweenPointsXYXYRad( point3X, point3Y, targetX, targetY ) ) ) <= curveanglestep
set point1X = point2X
set point1Y = point2Y
set point2X = point3X
set point2Y = point3Y
set angle = angle + anglefactor
set point3X = point2X + distancefactor * Cos(angle)
set point3Y = point2Y + distancefactor * Sin(angle)
set distance = distance + distancefactor
endloop
set distance = distance + DistanceBetweenPointsXYXY( point3X, point3Y, targetX, targetY )
endif
return distance
endfunction
// Timer Functions With Forward References
//----------------------------------------
function DCCamSystem_DirChangeZOffsetTimer takes nothing returns nothing //DirectionChangeTimer Index 1
if udg_zz_DCCamSystem_ZOffSmooth2 != -1 then
call ExecuteFunc( "DCCamSystem_DirChangeZOffset" )
endif
endfunction
function DCCamSystem_DirChangeDistanceTimer takes nothing returns nothing //DirectionChangeTimer Index 2
if udg_zz_DCCamSystem_DistSmooth2 != -1 then
call ExecuteFunc( "DCCamSystem_DirChangeDistance" )
endif
endfunction
function DCCamSystem_DirChangeFieldOfViewTimer takes nothing returns nothing //DirectionChangeTimer Index 3
if udg_zz_DCCamSystem_FieldSmooth2 != -1 then
call ExecuteFunc( "DCCamSystem_DirChangeFieldOfView" )
endif
endfunction
function DCCamSystem_DirChangeAngleTimer takes nothing returns nothing //DirectionChangeTimer Index 4
if udg_zz_DCCamSystem_AngleSmooth2 != -1 then
call ExecuteFunc( "DCCamSystem_DirChangeAngle" )
endif
endfunction
function DCCamSystem_DirChangeRotationTimer takes nothing returns nothing //DirectionChangeTimer Index 5
if udg_zz_DCCamSystem_RotaSmooth2 != -1 then
call ExecuteFunc( "DCCamSystem_DirChangeRotation" )
endif
endfunction
function DCCamSystem_DirChangeRollTimer takes nothing returns nothing //DirectionChangeTimer Index 6
if udg_zz_DCCamSystem_RollSmooth2 != -1 then
call ExecuteFunc( "DCCamSystem_DirChangeRoll" )
endif
endfunction
// Timer Functions - Long Angle Sway functions
//--------------------------------------------
function DCCamSystem_LongAngleAngleTimer takes nothing returns nothing //Long Angle Timer Index 4
if udg_zz_DCCamSystem_AngleSmooth2 != -1 then
set udg_zz_DCCamSystem_AngleTarget = udg_zz_DCCamSystem_AngleTarget2
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( udg_zz_DCCamSystem_AngleTarget ), DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), udg_zz_DCCamSystem_AngleTarget ) / udg_zz_DCCamSystem_AngleV )
endif
endfunction
function DCCamSystem_LongAngleRotationTimer takes nothing returns nothing //Long Angle Timer Index 5
if udg_zz_DCCamSystem_RotaSmooth2 != -1 then
set udg_zz_DCCamSystem_RotaTarget = udg_zz_DCCamSystem_RotaTarget2
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( udg_zz_DCCamSystem_RotaTarget ), DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), udg_zz_DCCamSystem_RotaTarget ) / udg_zz_DCCamSystem_RotaV )
endif
endfunction
function DCCamSystem_LongAngleRollTimer takes nothing returns nothing //Long Angle Timer Index 6
if udg_zz_DCCamSystem_RollSmooth2 != -1 then
set udg_zz_DCCamSystem_RollTarget = udg_zz_DCCamSystem_RollTarget2
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( udg_zz_DCCamSystem_RollTarget ), DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), udg_zz_DCCamSystem_RollTarget ) / udg_zz_DCCamSystem_RollV )
endif
endfunction
// Timer Functions - Stop motion functions
//----------------------------------------
function DCCamSystem_StopTarget takes nothing returns nothing //StopTimer Index 0
if udg_zz_DCCamSystem_TargetVEnd == 0 then
call PanCameraToTimed( GetCameraTargetPositionX(), GetCameraTargetPositionY(), 0 )
set udg_zz_DCCamSystem_TargetDir = -1
set udg_zz_DCCamSystem_TargetV = 0
set udg_zz_DCCamSystem_TargetAccelOn = false
endif
endfunction
function DCCamSystem_StopZOffset takes nothing returns nothing //StopTimer Index 1
if udg_zz_DCCamSystem_ZOffVEnd == 0 then
call SetCameraField( CAMERA_FIELD_ZOFFSET, GetCameraField( CAMERA_FIELD_ZOFFSET ), 0 )
set udg_zz_DCCamSystem_ZOffV = 0
set udg_zz_DCCamSystem_ZOffAccelOn = false
endif
endfunction
function DCCamSystem_StopDistance takes nothing returns nothing //StopTimer Index 2
if udg_zz_DCCamSystem_DistVEnd == 0 then
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, GetCameraField( CAMERA_FIELD_TARGET_DISTANCE ), 0 )
set udg_zz_DCCamSystem_DistV = 0
set udg_zz_DCCamSystem_DistAccelOn = false
endif
endfunction
function DCCamSystem_StopFieldOfView takes nothing returns nothing //StopTimer Index 3
if udg_zz_DCCamSystem_FieldVEnd == 0 then
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( GetCameraField( CAMERA_FIELD_FIELD_OF_VIEW ) ), 0 )
set udg_zz_DCCamSystem_FieldV = 0
set udg_zz_DCCamSystem_FieldAccelOn = false
endif
endfunction
function DCCamSystem_StopAngle takes nothing returns nothing //StopTimer Index 4
if udg_zz_DCCamSystem_AngleVEnd == 0 then
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ) ), 0 )
set udg_zz_DCCamSystem_AngleV = 0
set udg_zz_DCCamSystem_AngleAccelOn = false
endif
endfunction
function DCCamSystem_StopRotation takes nothing returns nothing //StopTimer Index 5
if udg_zz_DCCamSystem_RotaVEnd == 0 then
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( GetCameraField( CAMERA_FIELD_ROTATION ) ), 0 )
set udg_zz_DCCamSystem_RotaV = 0
set udg_zz_DCCamSystem_RotaAccelOn = false
endif
endfunction
function DCCamSystem_StopRoll takes nothing returns nothing //StopTimer Index 6
if udg_zz_DCCamSystem_RollVEnd == 0 then
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( GetCameraField( CAMERA_FIELD_ROLL ) ), 0 )
set udg_zz_DCCamSystem_RollV = 0
set udg_zz_DCCamSystem_RollAccelOn = false
endif
endfunction
// Camera movement functions concerning the target's movement
//-----------------------------------------------------------
function DCCamSystem_NormalTarget takes location target, real swaytime returns nothing
local real CamTargetX = GetCameraTargetPositionX()
local real CamTargetY = GetCameraTargetPositionY()
if swaytime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_TargetAccelOn = false
if udg_zz_DCCamSystem_CamTarIncorrect then
//This is to correct the movement in case that a NormalTarget function follows directly a NormalTarget function with swaytime null
set CamTargetX = udg_zz_DCCamSystem_TargetReserveX
set CamTargetY = udg_zz_DCCamSystem_TargetReserveY
endif
set udg_zz_DCCamSystem_TargetX = GetLocationX( target )
set udg_zz_DCCamSystem_TargetY = GetLocationY( target )
if swaytime == 0 then
set udg_zz_DCCamSystem_TargetV = 0
call SetCameraPosition( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY )
set udg_zz_DCCamSystem_CamTarIncorrect = true
set udg_zz_DCCamSystem_TargetReserveX = udg_zz_DCCamSystem_TargetX
set udg_zz_DCCamSystem_TargetReserveY = udg_zz_DCCamSystem_TargetY
set udg_zz_DCCamSystem_TargetDir = -1
else
set udg_zz_DCCamSystem_TargetV = DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / swaytime
set udg_zz_DCCamSystem_TargetDir = AngleBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY )
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, swaytime )
if udg_DCCamSystem_DebugModeOn then
call AddLightning( "CLSB", true, CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY )
endif
endif
set udg_zz_DCCamSystem_TargetVBegin = udg_zz_DCCamSystem_TargetV
set udg_zz_DCCamSystem_TargetVEnd = udg_zz_DCCamSystem_TargetV
set udg_zz_DCCamSystem_TargetCurve = false
endfunction
function DCCamSystem_TargetCurve takes real targetX, real targetY returns real
local real CamTargetX = GetCameraTargetPositionX()
local real CamTargetY = GetCameraTargetPositionY()
local real anglefactor
local real targetangle
local real r
local real distancefactor
local real completedistance
local integer curvelevel = 1
local real angle = udg_zz_DCCamSystem_TargetDir * bj_DEGTORAD
local real curveanglestep = DCCamSystem_TargetCurveAngleStep() * bj_DEGTORAD
if udg_zz_DCCamSystem_CamTarIncorrect then
//This is to correct the movement in case that a NormalTarget function follows directly a NormalTarget function with swaytime null
set CamTargetX = udg_zz_DCCamSystem_TargetReserveX
set CamTargetY = udg_zz_DCCamSystem_TargetReserveY
endif
set targetangle = AngleBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY )
set r = DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY ) / 2 * udg_DCCamSystem_CurveRadius
set distancefactor = r * 1.85 * Sin( DCCamSystem_TargetCurveAngleStep() / 2 * bj_DEGTORAD )
//Set the angle at the optimal direction to make the curve as short as possible
if DistanceBetweenAnglesDeg( udg_zz_DCCamSystem_TargetDir, targetangle ) > 0 then
set anglefactor = DCCamSystem_TargetCurveAngleStep()
else
set anglefactor = - DCCamSystem_TargetCurveAngleStep()
endif
set anglefactor = anglefactor * bj_DEGTORAD
//Set the key points of the curve
set udg_zz_DCCamSystem_TargetPointsXY [ 0 ] = CamTargetX
set udg_zz_DCCamSystem_TargetPointsXY [ 1 ] = CamTargetY
set angle = angle + anglefactor
set udg_zz_DCCamSystem_TargetPointsXY [ 2 ] = CamTargetX + distancefactor * Cos(angle)
set udg_zz_DCCamSystem_TargetPointsXY [ 3 ] = CamTargetY + distancefactor * Sin(angle)
if udg_DCCamSystem_DebugModeOn then
call AddLightning( "CLSB", true, udg_zz_DCCamSystem_TargetPointsXY [ 0 ], udg_zz_DCCamSystem_TargetPointsXY[ 1 ], udg_zz_DCCamSystem_TargetPointsXY [ 2 ], udg_zz_DCCamSystem_TargetPointsXY[ 3 ] )
endif
loop
exitwhen RAbsBJ( DistanceBetweenAnglesRad( angle, AngleBetweenPointsXYXYRad( udg_zz_DCCamSystem_TargetPointsXY[ curvelevel * 2 ], udg_zz_DCCamSystem_TargetPointsXY[ curvelevel * 2 + 1], targetX, targetY ) ) ) <= curveanglestep or curvelevel == 127
set curvelevel = curvelevel + 1
set angle = angle + anglefactor
set udg_zz_DCCamSystem_TargetPointsXY[ curvelevel * 2 ] = udg_zz_DCCamSystem_TargetPointsXY[ curvelevel * 2 - 2 ] + distancefactor * Cos(angle)
set udg_zz_DCCamSystem_TargetPointsXY[ curvelevel * 2 + 1 ] = udg_zz_DCCamSystem_TargetPointsXY[ curvelevel * 2 - 1 ] + distancefactor * Sin(angle)
endloop
set udg_zz_DCCamSystem_TargetPointsXY [ curvelevel * 2 + 2 ] = targetX
set udg_zz_DCCamSystem_TargetPointsXY [ curvelevel * 2 + 3 ] = targetY
set completedistance = distancefactor * curvelevel
set completedistance = completedistance + DistanceBetweenPointsXYXY( udg_zz_DCCamSystem_TargetPointsXY [ curvelevel * 2 ], udg_zz_DCCamSystem_TargetPointsXY [ curvelevel * 2 + 1 ], targetX, targetY )
//Set additional variables needed by the system
set udg_zz_DCCamSystem_TargetDir = udg_zz_DCCamSystem_TargetDir + anglefactor * bj_RADTODEG
set udg_zz_DCCamSystem_TargetX = udg_zz_DCCamSystem_TargetPointsXY[ 2 ]
set udg_zz_DCCamSystem_TargetY = udg_zz_DCCamSystem_TargetPointsXY[ 3 ]
set udg_zz_DCCamSystem_CurveFinalX = targetX
set udg_zz_DCCamSystem_CurveFinalY = targetY
set udg_zz_DCCamSystem_CurveLevel = 1
set udg_zz_DCCamSystem_TargetCurve = true
return completedistance
endfunction
function DCCamSystem_BrakeTargetPoint takes location targetpoint, boolean linear returns real
local real CamTargetX = GetCameraTargetPositionX()
local real CamTargetY = GetCameraTargetPositionY()
local real targetX = GetLocationX( targetpoint )
local real targetY = GetLocationY( targetpoint )
local real distance = DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY )
if udg_zz_DCCamSystem_TargetV == 0 then
if distance <= 1 then
return 0
endif
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakePointV() )
endif
return 0
endif
if udg_zz_DCCamSystem_CamTarIncorrect then
//This is to correct the movement in case that a NormalTarget function follows directly a NormalTarget function with swaytime null
set CamTargetX = udg_zz_DCCamSystem_TargetReserveX
set CamTargetY = udg_zz_DCCamSystem_TargetReserveY
set distance = DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY )
endif
set udg_zz_DCCamSystem_TargetAccelOn = false
if udg_zz_DCCamSystem_TargetDir == -1 or RAbsBJ( DistanceBetweenAnglesDeg( udg_zz_DCCamSystem_TargetDir, AngleBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY ) ) ) <= DCCamSystem_TargetCurveAngleStep() then
//Curve not necessary
set udg_zz_DCCamSystem_TargetCurve = false
set udg_zz_DCCamSystem_TargetX = targetX
set udg_zz_DCCamSystem_TargetY = targetY
if udg_DCCamSystem_DebugModeOn then
call AddLightning( "CLSB", true, CamTargetX, CamTargetY, targetX, targetY )
endif
else
//Curve necessary
set distance = DCCamSystem_TargetCurve( targetX, targetY )
endif
set udg_zz_DCCamSystem_TargetVEnd = 0
set udg_zz_DCCamSystem_TargetVBegin = udg_zz_DCCamSystem_TargetV
set udg_zz_DCCamSystem_LinearTarget = linear
if linear then
set udg_zz_DCCamSystem_TargetVNullTime = distance / udg_zz_DCCamSystem_TargetV * 2
else
set udg_zz_DCCamSystem_TargetVNullTime = distance * 3 / udg_zz_DCCamSystem_TargetV / 2
endif
if udg_zz_DCCamSystem_TargetVNullTime < 0.1 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothTarget() )
endif
call PanCameraToTimed( targetX, targetY, udg_zz_DCCamSystem_TargetVNullTime )
return 0
endif
set udg_zz_DCCamSystem_TargetAccelTime = udg_zz_DCCamSystem_TargetVNullTime
set udg_zz_DCCamSystem_TargetAccelNull = udg_zz_DCCamSystem_Time
call TimerStart( udg_zz_DCCamSystem_StopTimer0, udg_zz_DCCamSystem_TargetVNullTime, false, function DCCamSystem_StopTarget )
if linear then
set udg_zz_DCCamSystem_TargetFactor = - udg_zz_DCCamSystem_TargetVBegin / udg_zz_DCCamSystem_TargetVNullTime
else
set udg_zz_DCCamSystem_TargetFactor = udg_zz_DCCamSystem_TargetVBegin / SquareRoot( udg_zz_DCCamSystem_TargetVNullTime )
endif
set udg_zz_DCCamSystem_TargetAccelOn = true
return udg_zz_DCCamSystem_TargetVNullTime
endfunction
function DCCamSystem_BrakeTargetTime takes real brakingtime, boolean linear returns nothing
local real CamTargetX = GetCameraTargetPositionX()
local real CamTargetY = GetCameraTargetPositionY()
local real distance
local real angle
local integer i
if udg_DCCamSystem_DebugModeOn then
if brakingtime < 0 then //Errors
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
return
endif
endif
set udg_zz_DCCamSystem_TargetAccelOn = false
if brakingtime < 0.01 or udg_zz_DCCamSystem_TargetV == 0 then
set udg_zz_DCCamSystem_TargetV = 0
set udg_zz_DCCamSystem_TargetDir = -1
call PanCameraToTimed( GetCameraTargetPositionX(), GetCameraTargetPositionY(), 0 )
return
endif
call TimerStart( udg_zz_DCCamSystem_StopTimer0, brakingtime, false, function DCCamSystem_StopTarget )
if udg_zz_DCCamSystem_CamTarIncorrect then
//This is to correct the movement in case that a NormalTarget function follows directly a NormalTarget function with swaytime null
set CamTargetX = udg_zz_DCCamSystem_TargetReserveX
set CamTargetY = udg_zz_DCCamSystem_TargetReserveY
endif
set udg_zz_DCCamSystem_TargetVEnd = 0
set udg_zz_DCCamSystem_TargetVBegin = udg_zz_DCCamSystem_TargetV
set udg_zz_DCCamSystem_TargetV = udg_zz_DCCamSystem_TargetVBegin
set udg_zz_DCCamSystem_TargetVNullTime = brakingtime
set udg_zz_DCCamSystem_LinearTarget = linear
if linear then
set distance = udg_zz_DCCamSystem_TargetVBegin * udg_zz_DCCamSystem_TargetVNullTime / 2
set udg_zz_DCCamSystem_TargetAccelTime = brakingtime
else
set distance = 2 * udg_zz_DCCamSystem_TargetVBegin * udg_zz_DCCamSystem_TargetVNullTime / 3
endif
if udg_zz_DCCamSystem_TargetCurve then //Curve is currently running
set i = udg_zz_DCCamSystem_CurveLevel
set udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 2 ] = CamTargetX
set udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 1 ] = CamTargetY
if distance - DistanceBetweenPointsXYXY( udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 2 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 1 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 + 1 ] ) > 0 then
loop
exitwhen distance - DistanceBetweenPointsXYXY( udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 2 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 1 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 + 1 ] ) < 0 or udg_zz_DCCamSystem_TargetPointsXY[ i * 2 ] == udg_zz_DCCamSystem_CurveFinalX and udg_zz_DCCamSystem_TargetPointsXY[ i * 2 + 1 ] == udg_zz_DCCamSystem_CurveFinalY
set distance = distance - DistanceBetweenPointsXYXY( udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 2 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 1 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 + 1 ] )
set i = i + 1
endloop
set angle = AngleBetweenPointsXYXY( udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 2 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 1 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 ], udg_zz_DCCamSystem_TargetPointsXY[ i * 2 + 1 ] ) * bj_DEGTORAD
set udg_zz_DCCamSystem_TargetPointsXY[ i * 2 ] = udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 2 ] + distance * Cos(angle)
set udg_zz_DCCamSystem_TargetPointsXY[ i * 2 + 1 ] = udg_zz_DCCamSystem_TargetPointsXY[ i * 2 - 1 ] + distance * Sin(angle)
set udg_zz_DCCamSystem_CurveFinalX = udg_zz_DCCamSystem_TargetPointsXY [ i * 2 ]
set udg_zz_DCCamSystem_CurveFinalY = udg_zz_DCCamSystem_TargetPointsXY [ i * 2 + 1 ]
else
set udg_zz_DCCamSystem_TargetX = CamTargetX + distance * Cos( udg_zz_DCCamSystem_TargetDir * bj_DEGTORAD )
set udg_zz_DCCamSystem_TargetY = CamTargetY + distance * Sin( udg_zz_DCCamSystem_TargetDir * bj_DEGTORAD )
set udg_zz_DCCamSystem_TargetCurve = false
endif
else //No Curve is currently running
set udg_zz_DCCamSystem_TargetX = CamTargetX + distance * Cos( udg_zz_DCCamSystem_TargetDir * bj_DEGTORAD )
set udg_zz_DCCamSystem_TargetY = CamTargetY + distance * Sin( udg_zz_DCCamSystem_TargetDir * bj_DEGTORAD )
endif
set udg_zz_DCCamSystem_TargetAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_TargetFactor = - udg_zz_DCCamSystem_TargetVBegin / brakingtime
else
set udg_zz_DCCamSystem_TargetFactor = udg_zz_DCCamSystem_TargetVBegin / SquareRoot( brakingtime )
endif
set udg_zz_DCCamSystem_TargetAccelOn = true
endfunction
function DCCamSystem_SmoothTarget takes location targetpoint, real totaltime, real smoothtime, boolean linear returns nothing
local real CamTargetX = GetCameraTargetPositionX()
local real CamTargetY = GetCameraTargetPositionY()
local real targetX = GetLocationX( targetpoint )
local real targetY = GetLocationY( targetpoint )
local real distance
local integer Power = 0
local real vnulltime = 0
if udg_DCCamSystem_DebugModeOn then
if smoothtime < 0 or totaltime < 0 then //Errors
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
if (smoothtime >= totaltime) then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
return
elseif (smoothtime >= totaltime) then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
return
endif
endif
if udg_zz_DCCamSystem_CamTarIncorrect then
//This is to correct the movement in case that a NormalTarget function follows directly a NormalTarget function with swaytime null
set CamTargetX = udg_zz_DCCamSystem_TargetReserveX
set CamTargetY = udg_zz_DCCamSystem_TargetReserveY
endif
set distance = DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY )
if distance <= 1 then
return
endif
set udg_zz_DCCamSystem_TargetAccelOn = false
set udg_zz_DCCamSystem_TargetVBegin = udg_zz_DCCamSystem_TargetV
call PauseTimer( udg_zz_DCCamSystem_StopTimer0 )
if smoothtime < DCCamSystem_LoopFrequence() then
//No accelleration necessary
call DCCamSystem_NormalTarget( targetpoint, totaltime )
else
//Set accelleration values
if udg_zz_DCCamSystem_TargetV == 0 then
//Acceleration from null
if linear then
set udg_zz_DCCamSystem_TargetVEnd = distance / ( smoothtime / 2 + totaltime - smoothtime )
else
set udg_zz_DCCamSystem_TargetVEnd = distance / ( smoothtime * 2 / 3 + totaltime - smoothtime )
endif
//Curve not necessary
set udg_zz_DCCamSystem_TargetCurve = false
set udg_zz_DCCamSystem_TargetX = targetX
set udg_zz_DCCamSystem_TargetY = targetY
set udg_zz_DCCamSystem_TargetDir = AngleBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY )
if udg_DCCamSystem_DebugModeOn then
call AddLightning( "CLSB", true, CamTargetX, CamTargetY, targetX, targetY )
endif
else
//Accelleration from current speed, if it is greater than null
if RAbsBJ( DistanceBetweenAnglesDeg( udg_zz_DCCamSystem_TargetDir, AngleBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY ) ) ) < DCCamSystem_TargetCurveAngleStep() then
//Curve not necessary
set udg_zz_DCCamSystem_TargetCurve = false
set udg_zz_DCCamSystem_TargetX = targetX
set udg_zz_DCCamSystem_TargetY = targetY
set udg_zz_DCCamSystem_TargetDir = AngleBetweenPointsXYXY( CamTargetX, CamTargetY, targetX, targetY )
if udg_DCCamSystem_DebugModeOn then
call AddLightning( "CLSB", true, CamTargetX, CamTargetY, targetX, targetY )
endif
else
//Initialize Curve
set distance = DCCamSystem_TargetCurve( targetX, targetY )
endif
if linear then
if udg_zz_DCCamSystem_TargetV * totaltime > distance and udg_zz_DCCamSystem_TargetV * smoothtime / 2 > distance then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeTarget() )
endif
if DCCamSystem_TargetMinSpeed() * totaltime + 0.05 * ( udg_zz_DCCamSystem_TargetV - DCCamSystem_TargetMinSpeed() ) > distance then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothTarget() )
endif
call DCCamSystem_NormalTarget( targetpoint, totaltime )
return
endif
//shortening smoothtime to make sway possible
set udg_zz_DCCamSystem_TargetVEnd = DCCamSystem_TargetMinSpeed()
set distance = distance - udg_zz_DCCamSystem_TargetVEnd * totaltime
loop
exitwhen Power < -2
loop
set smoothtime = smoothtime - Pow( 10, Power )
exitwhen (udg_zz_DCCamSystem_TargetVBegin - udg_zz_DCCamSystem_TargetVEnd) * smoothtime / 2 < distance
endloop
set smoothtime = smoothtime + Pow( 10, Power )
set Power = Power - 1
endloop
else
set udg_zz_DCCamSystem_TargetVEnd = ( distance - udg_zz_DCCamSystem_TargetVBegin * smoothtime / 2 ) / ( totaltime - smoothtime / 2 )
endif
else
//Calculate approximate value of VNullTime
if udg_zz_DCCamSystem_TargetV * totaltime < distance then
//Accelleration
loop
exitwhen Power < -3
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_TargetVEnd = ( distance + udg_zz_DCCamSystem_TargetV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
exitwhen udg_zz_DCCamSystem_TargetVEnd / SquareRoot( smoothtime + vnulltime ) * SquareRoot( vnulltime ) > udg_zz_DCCamSystem_TargetV
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_TargetVEnd = ( distance + udg_zz_DCCamSystem_TargetV * vnulltime * 2 /3 ) / ( ( smoothtime + vnulltime ) * 2 / 3 + totaltime - smoothtime )
else
//Decelleration
if 2 * udg_zz_DCCamSystem_TargetV * smoothtime / 3 > distance then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeTarget() )
endif
if DCCamSystem_TargetMinSpeed() * totaltime + 0.07 * ( udg_zz_DCCamSystem_TargetV - DCCamSystem_TargetMinSpeed() ) > distance then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothTarget() )
endif
call DCCamSystem_NormalTarget( targetpoint, totaltime )
return
endif
set vnulltime = 0
set udg_zz_DCCamSystem_TargetVEnd = DCCamSystem_TargetMinSpeed()
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
exitwhen udg_zz_DCCamSystem_TargetVBegin / SquareRoot( vnulltime ) * 2 / 3 * Pow( vnulltime, 1.5 ) + udg_zz_DCCamSystem_TargetVEnd * ( totaltime - vnulltime ) > distance
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set smoothtime = - Pow( udg_zz_DCCamSystem_TargetVEnd, 2 ) * vnulltime / Pow( udg_zz_DCCamSystem_TargetVBegin, 2 ) + vnulltime
else
set vnulltime = smoothtime
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_TargetVEnd = udg_zz_DCCamSystem_TargetVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
exitwhen udg_zz_DCCamSystem_TargetVBegin / SquareRoot( vnulltime ) * 2 / 3 * ( Pow( vnulltime, 1.5 ) - Pow( vnulltime - smoothtime, 1.5 ) ) + udg_zz_DCCamSystem_TargetVEnd * ( totaltime - smoothtime ) >= distance
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_TargetVEnd = udg_zz_DCCamSystem_TargetVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
endif
endif
endif
endif
endif
set udg_zz_DCCamSystem_TargetVNullTime = vnulltime
set udg_zz_DCCamSystem_TargetAccelTime = smoothtime
set udg_zz_DCCamSystem_TargetAccelNull = udg_zz_DCCamSystem_Time
set udg_zz_DCCamSystem_LinearTarget = linear
if linear then
set udg_zz_DCCamSystem_TargetFactor = ( udg_zz_DCCamSystem_TargetVEnd - udg_zz_DCCamSystem_TargetVBegin ) / smoothtime
elseif udg_zz_DCCamSystem_TargetVEnd < udg_zz_DCCamSystem_TargetV then
set udg_zz_DCCamSystem_TargetFactor = udg_zz_DCCamSystem_TargetVBegin / SquareRoot( vnulltime )
else
set udg_zz_DCCamSystem_TargetFactor = udg_zz_DCCamSystem_TargetVEnd / SquareRoot( vnulltime + smoothtime )
endif
set udg_zz_DCCamSystem_TargetAccelOn = true
endfunction
// Camera movement functions concerning the Z-Offset's movement
//-------------------------------------------------------------
function DCCamSystem_NormalZOffset takes real target, real swaytime returns nothing
if swaytime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_ZOffAccelOn = false
if swaytime > 0 then
set udg_zz_DCCamSystem_ZOffV = ( target - GetCameraField( CAMERA_FIELD_ZOFFSET ) ) / swaytime
else
set udg_zz_DCCamSystem_ZOffV = 0
endif
set udg_zz_DCCamSystem_ZOffVBegin = udg_zz_DCCamSystem_ZOffV
set udg_zz_DCCamSystem_ZOffVEnd = udg_zz_DCCamSystem_ZOffV
call PauseTimer( udg_zz_DCCamSystem_DirChange1 )
call SetCameraField( CAMERA_FIELD_ZOFFSET, target, swaytime )
endfunction
function DCCamSystem_BrakeZOffsetPoint takes real targetzoffset, boolean linear returns real
local real distance = targetzoffset - GetCameraField(CAMERA_FIELD_ZOFFSET)
if udg_zz_DCCamSystem_ZOffV == 0 then //Errors
if RAbsBJ(distance) <= 1 then
return 0
endif
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakePointV() )
endif
return 0
endif
if (distance > 0 and udg_zz_DCCamSystem_ZOffV < 0) or (distance < 0 and udg_zz_DCCamSystem_ZOffV > 0) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeZOffsetPoint() )
endif
return 0
endif
set udg_zz_DCCamSystem_ZOffAccelOn = false
set udg_zz_DCCamSystem_ZOffTarget = targetzoffset
set udg_zz_DCCamSystem_LinearZOffset = linear
set udg_zz_DCCamSystem_ZOffVEnd = 0
set udg_zz_DCCamSystem_ZOffVBegin = udg_zz_DCCamSystem_ZOffV
if linear then
set udg_zz_DCCamSystem_ZOffVNullTime = RAbsBJ( distance * 2 / udg_zz_DCCamSystem_ZOffV )
else
set udg_zz_DCCamSystem_ZOffVNullTime = RAbsBJ( distance * 3 / udg_zz_DCCamSystem_ZOffV ) / 2
endif
if udg_zz_DCCamSystem_ZOffVNullTime < 0.1 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothZOff() )
endif
call SetCameraField( CAMERA_FIELD_ZOFFSET, targetzoffset, udg_zz_DCCamSystem_ZOffVNullTime )
call PauseTimer( udg_zz_DCCamSystem_DirChange1 )
return 0
endif
set udg_zz_DCCamSystem_ZOffAccelTime = udg_zz_DCCamSystem_ZOffVNullTime
set udg_zz_DCCamSystem_ZOffAccelNull = udg_zz_DCCamSystem_Time
call PauseTimer( udg_zz_DCCamSystem_DirChange1 )
call TimerStart( udg_zz_DCCamSystem_StopTimer1, udg_zz_DCCamSystem_ZOffVNullTime, false, function DCCamSystem_StopZOffset )
if linear then
set udg_zz_DCCamSystem_ZOffFactor = - udg_zz_DCCamSystem_ZOffVBegin / udg_zz_DCCamSystem_ZOffVNullTime
else
set udg_zz_DCCamSystem_ZOffFactor = udg_zz_DCCamSystem_ZOffVBegin / SquareRoot( udg_zz_DCCamSystem_ZOffVNullTime )
endif
set udg_zz_DCCamSystem_ZOffAccelOn = true
return udg_zz_DCCamSystem_ZOffVNullTime
endfunction
function DCCamSystem_BrakeZOffsetTime takes real brakingtime, boolean linear returns nothing
local real distance
if brakingtime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_ZOffAccelOn = false
call PauseTimer( udg_zz_DCCamSystem_DirChange1 )
if brakingtime < 0.01 or udg_zz_DCCamSystem_ZOffV == 0 then
set udg_zz_DCCamSystem_ZOffV = 0
call SetCameraField( CAMERA_FIELD_ZOFFSET, GetCameraField( CAMERA_FIELD_ZOFFSET ), 0 )
return
endif
call TimerStart( udg_zz_DCCamSystem_StopTimer1, brakingtime, false, function DCCamSystem_StopZOffset )
set udg_zz_DCCamSystem_ZOffVEnd = 0
set udg_zz_DCCamSystem_ZOffVBegin = udg_zz_DCCamSystem_ZOffV
set udg_zz_DCCamSystem_ZOffVNullTime = brakingtime
if linear then
set distance = 2 * udg_zz_DCCamSystem_ZOffVBegin * udg_zz_DCCamSystem_ZOffVNullTime / 3
else
set distance = udg_zz_DCCamSystem_ZOffVBegin * udg_zz_DCCamSystem_ZOffVNullTime / 2
endif
set udg_zz_DCCamSystem_ZOffAccelTime = udg_zz_DCCamSystem_ZOffVNullTime
set udg_zz_DCCamSystem_ZOffTarget = GetCameraField( CAMERA_FIELD_ZOFFSET ) + distance
set udg_zz_DCCamSystem_LinearZOffset = linear
set udg_zz_DCCamSystem_ZOffAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_ZOffFactor = - udg_zz_DCCamSystem_ZOffVBegin / brakingtime
else
set udg_zz_DCCamSystem_ZOffFactor = udg_zz_DCCamSystem_ZOffVBegin / SquareRoot( brakingtime )
endif
set udg_zz_DCCamSystem_ZOffAccelOn = true
endfunction
function DCCamSystem_SmoothZOffset takes real targetzoffset, real totaltime, real smoothtime, boolean linear returns nothing
local real distance = targetzoffset - GetCameraField( CAMERA_FIELD_ZOFFSET )
local integer Power = 1
local real localbrake
local real vnulltime = 0
if RAbsBJ(distance) < 1 then
return
endif
if smoothtime < 0 or totaltime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
if (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
endif
return
elseif (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
return
endif
set udg_zz_DCCamSystem_ZOffAccelOn = false
call PauseTimer( udg_zz_DCCamSystem_DirChange1 )
set udg_zz_DCCamSystem_ZOffAccelNull = udg_zz_DCCamSystem_Time
set udg_zz_DCCamSystem_ZOffVBegin = udg_zz_DCCamSystem_ZOffV
set udg_zz_DCCamSystem_LinearZOffset = linear
if (smoothtime == 0) then
//No accelleration necessary
call DCCamSystem_NormalZOffset( targetzoffset, totaltime )
return
else
//Set accelleration values
if udg_zz_DCCamSystem_ZOffV == 0 then
//Acceleration from null
if linear then
set udg_zz_DCCamSystem_ZOffVEnd = distance / ( smoothtime / 2 + totaltime - smoothtime )
else
set udg_zz_DCCamSystem_ZOffVEnd = distance / ( smoothtime * 2 / 3 + totaltime - smoothtime )
endif
else
//Accelleration from current speed, if it is greater than null
if (udg_zz_DCCamSystem_ZOffV < 0 and distance > 0) or (udg_zz_DCCamSystem_ZOffV > 0 and distance < 0) then
//Brake and change of direction necessary
if linear then
set localbrake = smoothtime / ( RAbsBJ( distance / ( totaltime - smoothtime ) / udg_zz_DCCamSystem_ZOffV ) + 1 )
else
set localbrake = smoothtime / ( Pow( distance / ( totaltime - smoothtime ), 2 ) / Pow( udg_zz_DCCamSystem_ZOffV, 2 ) + 1 )
endif
set udg_zz_DCCamSystem_ZOffTarget2 = targetzoffset
set udg_zz_DCCamSystem_ZOffTotal2 = totaltime - localbrake
set udg_zz_DCCamSystem_ZOffSmooth2 = smoothtime - localbrake
call DCCamSystem_BrakeZOffsetTime( localbrake, linear )
call TimerStart( udg_zz_DCCamSystem_DirChange1, localbrake, false, function DCCamSystem_DirChangeZOffsetTimer )
return
endif
if linear then
if RAbsBJ( udg_zz_DCCamSystem_ZOffV * smoothtime / 2 ) > RAbsBJ( distance ) then
//shortening smoothtime to make sway possible
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeZOff() )
endif
if DCCamSystem_ZOffMinSpeed() * totaltime + 0.05 * ( udg_zz_DCCamSystem_ZOffV - DCCamSystem_ZOffMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothZOff() )
endif
call DCCamSystem_NormalZOffset( targetzoffset, totaltime )
return
endif
if distance > 0 then
set udg_zz_DCCamSystem_ZOffVEnd = DCCamSystem_ZOffMinSpeed()
else
set udg_zz_DCCamSystem_ZOffVEnd = - DCCamSystem_ZOffMinSpeed()
endif
set distance = distance - udg_zz_DCCamSystem_ZOffVEnd * totaltime
loop
exitwhen Power < -2
loop
set smoothtime = smoothtime - Pow( 10, Power )
exitwhen RAbsBJ(udg_zz_DCCamSystem_ZOffVBegin - udg_zz_DCCamSystem_ZOffVEnd) * smoothtime / 2 < RAbsBJ( distance )
endloop
set smoothtime = smoothtime + Pow( 10, Power )
set Power = Power - 1
endloop
else
//normal, possible smooth sway
set udg_zz_DCCamSystem_ZOffVEnd = ( distance - udg_zz_DCCamSystem_ZOffVBegin * smoothtime / 2 ) / ( totaltime - smoothtime / 2 )
endif
else
//Calculate approximate value of VNullTime
if RAbsBJ( udg_zz_DCCamSystem_ZOffV * totaltime ) < RAbsBJ( distance ) then
//Accelleration
loop
exitwhen Power < -3
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_ZOffVEnd = ( distance + udg_zz_DCCamSystem_ZOffV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_ZOffVEnd / SquareRoot( smoothtime + vnulltime ) * SquareRoot( vnulltime ) ) > RAbsBJ( udg_zz_DCCamSystem_ZOffV )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_ZOffVEnd = ( distance + udg_zz_DCCamSystem_ZOffV * vnulltime * 2 /3 ) / ( ( smoothtime + vnulltime ) * 2 / 3 + totaltime - smoothtime )
else
//Decelleration
if RAbsBJ( 2 * udg_zz_DCCamSystem_ZOffV * smoothtime / 3 ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeZOff() )
endif
if DCCamSystem_ZOffMinSpeed() * totaltime + 0.07 * ( RAbsBJ( udg_zz_DCCamSystem_ZOffV ) - DCCamSystem_ZOffMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothZOff() )
endif
call DCCamSystem_NormalZOffset( targetzoffset, totaltime )
return
endif
set vnulltime = 0
if distance > 0 then
set udg_zz_DCCamSystem_ZOffVEnd = DCCamSystem_ZOffMinSpeed()
else
set udg_zz_DCCamSystem_ZOffVEnd = - DCCamSystem_ZOffMinSpeed()
endif
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set smoothtime = vnulltime
exitwhen RAbsBJ( udg_zz_DCCamSystem_ZOffVBegin / SquareRoot( vnulltime ) * 2 / 3 * Pow( vnulltime, 1.5 ) + udg_zz_DCCamSystem_ZOffVEnd * ( totaltime - vnulltime ) ) > RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set smoothtime = - Pow( udg_zz_DCCamSystem_ZOffVEnd, 2 ) * vnulltime / Pow( udg_zz_DCCamSystem_ZOffVBegin, 2 ) + vnulltime
else
set vnulltime = smoothtime
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_ZOffVEnd = udg_zz_DCCamSystem_ZOffVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_ZOffVBegin ) / SquareRoot( vnulltime ) * 2 / 3 * ( Pow( vnulltime, 1.5 ) - Pow( vnulltime - smoothtime, 1.5 ) ) + RAbsBJ( udg_zz_DCCamSystem_ZOffVEnd ) * ( totaltime - smoothtime ) >= RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_ZOffVEnd = udg_zz_DCCamSystem_ZOffVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
endif
endif
endif
endif
endif
set udg_zz_DCCamSystem_ZOffVNullTime = vnulltime
set udg_zz_DCCamSystem_ZOffAccelTime = smoothtime
set udg_zz_DCCamSystem_ZOffTarget = targetzoffset
set udg_zz_DCCamSystem_ZOffAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_ZOffFactor = ( udg_zz_DCCamSystem_ZOffVEnd - udg_zz_DCCamSystem_ZOffVBegin ) / smoothtime
elseif RAbsBJ( udg_zz_DCCamSystem_ZOffVEnd ) < RAbsBJ( udg_zz_DCCamSystem_ZOffV ) then
set udg_zz_DCCamSystem_ZOffFactor = udg_zz_DCCamSystem_ZOffVBegin / SquareRoot( vnulltime )
else
set udg_zz_DCCamSystem_ZOffFactor = udg_zz_DCCamSystem_ZOffVEnd / SquareRoot( vnulltime + smoothtime )
endif
set udg_zz_DCCamSystem_ZOffAccelOn = true
endfunction
// Camera movement functions concerning the Target Distance's movement
//--------------------------------------------------------------------
function DCCamSystem_NormalDistance takes real target, real swaytime returns nothing
if swaytime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_DistAccelOn = false
if swaytime > 0 then
set udg_zz_DCCamSystem_DistV = ( target - GetCameraField( CAMERA_FIELD_TARGET_DISTANCE ) ) / swaytime
else
set udg_zz_DCCamSystem_DistV = 0
endif
set udg_zz_DCCamSystem_DistVBegin = udg_zz_DCCamSystem_DistV
set udg_zz_DCCamSystem_DistVEnd = udg_zz_DCCamSystem_DistV
call PauseTimer( udg_zz_DCCamSystem_DirChange2 )
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, target, swaytime )
endfunction
function DCCamSystem_BrakeDistancePoint takes real targetdistance, boolean linear returns real
local real distance = targetdistance - GetCameraField( CAMERA_FIELD_TARGET_DISTANCE )
if udg_zz_DCCamSystem_DistV == 0 then
if RAbsBJ(distance) <= 1 then
return 0
endif
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakePointV() )
endif
return 0
endif
if (distance > 0 and udg_zz_DCCamSystem_DistV < 0) or (distance < 0 and udg_zz_DCCamSystem_DistV > 0) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeDistancePoint() )
endif
return 0
endif
set udg_zz_DCCamSystem_DistAccelOn = false
set udg_zz_DCCamSystem_DistTarget = targetdistance
set udg_zz_DCCamSystem_LinearDistance = linear
set udg_zz_DCCamSystem_DistVEnd = 0
set udg_zz_DCCamSystem_DistVBegin = udg_zz_DCCamSystem_DistV
if linear then
set udg_zz_DCCamSystem_DistVNullTime = RAbsBJ( distance * 2 / udg_zz_DCCamSystem_DistV )
else
set udg_zz_DCCamSystem_DistVNullTime = RAbsBJ( distance * 3 / udg_zz_DCCamSystem_DistV ) / 2
endif
if udg_zz_DCCamSystem_DistVNullTime < 0.1 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothDist() )
endif
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, targetdistance, udg_zz_DCCamSystem_DistVNullTime )
call PauseTimer( udg_zz_DCCamSystem_DirChange2 )
return 0
endif
set udg_zz_DCCamSystem_DistAccelTime = udg_zz_DCCamSystem_DistVNullTime
set udg_zz_DCCamSystem_DistAccelNull = udg_zz_DCCamSystem_Time
call PauseTimer( udg_zz_DCCamSystem_DirChange2 )
call TimerStart( udg_zz_DCCamSystem_StopTimer2, udg_zz_DCCamSystem_DistVNullTime, false, function DCCamSystem_StopDistance )
if linear then
set udg_zz_DCCamSystem_DistFactor = - udg_zz_DCCamSystem_DistVBegin / udg_zz_DCCamSystem_DistVNullTime
else
set udg_zz_DCCamSystem_DistFactor = udg_zz_DCCamSystem_DistVBegin / SquareRoot( udg_zz_DCCamSystem_DistVNullTime )
endif
set udg_zz_DCCamSystem_DistAccelOn = true
return udg_zz_DCCamSystem_DistVNullTime
endfunction
function DCCamSystem_BrakeDistanceTime takes real brakingtime, boolean linear returns nothing
local real distance
if brakingtime < 0 then //Errors
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
return
endif
set udg_zz_DCCamSystem_DistAccelOn = false
call PauseTimer( udg_zz_DCCamSystem_DirChange2 )
if brakingtime < 0.01 or udg_zz_DCCamSystem_DistV == 0 then
set udg_zz_DCCamSystem_DistV = 0
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, GetCameraField( CAMERA_FIELD_TARGET_DISTANCE ), 0 )
return
endif
call TimerStart( udg_zz_DCCamSystem_StopTimer2, brakingtime, false, null )
set udg_zz_DCCamSystem_DistVEnd = 0
set udg_zz_DCCamSystem_DistVBegin = udg_zz_DCCamSystem_DistV
set udg_zz_DCCamSystem_DistVNullTime = brakingtime
if linear then
set distance = udg_zz_DCCamSystem_DistVBegin * udg_zz_DCCamSystem_DistVNullTime / 2
else
set distance = 2 * udg_zz_DCCamSystem_DistVBegin * udg_zz_DCCamSystem_DistVNullTime / 3
endif
set udg_zz_DCCamSystem_DistAccelTime = udg_zz_DCCamSystem_DistVNullTime
set udg_zz_DCCamSystem_DistTarget = GetCameraField( CAMERA_FIELD_TARGET_DISTANCE ) + distance
set udg_zz_DCCamSystem_LinearDistance = linear
set udg_zz_DCCamSystem_DistAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_DistFactor = - udg_zz_DCCamSystem_DistVBegin / brakingtime
else
set udg_zz_DCCamSystem_DistFactor = udg_zz_DCCamSystem_DistVBegin / SquareRoot( brakingtime )
endif
set udg_zz_DCCamSystem_DistAccelOn = true
endfunction
function DCCamSystem_SmoothDistance takes real targetdistance, real totaltime, real smoothtime, boolean linear returns nothing
local real distance = targetdistance - GetCameraField( CAMERA_FIELD_TARGET_DISTANCE )
local integer Power = 1
local real localbrake
local real vnulltime = 0
if RAbsBJ(distance) < 2 then
return
endif
if smoothtime < 0 or totaltime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
if (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
endif
return
elseif (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
return
endif
set udg_zz_DCCamSystem_DistAccelOn = false
call PauseTimer( udg_zz_DCCamSystem_DirChange2 )
set udg_zz_DCCamSystem_DistAccelNull = udg_zz_DCCamSystem_Time
set udg_zz_DCCamSystem_DistVBegin = udg_zz_DCCamSystem_DistV
set udg_zz_DCCamSystem_LinearDistance = linear
if (smoothtime == 0) then
//No accelleration necessary
call DCCamSystem_NormalDistance( targetdistance, totaltime )
return
else
//Set accelleration values
if udg_zz_DCCamSystem_DistV == 0 then
//Acceleration from null
if linear then
set udg_zz_DCCamSystem_DistVEnd = distance / ( smoothtime / 2 + totaltime - smoothtime )
else
set udg_zz_DCCamSystem_DistVEnd = distance / ( smoothtime * 2 / 3 + totaltime - smoothtime )
endif
else
//Accelleration from current speed, if it is greater than null
if ( udg_zz_DCCamSystem_DistV < 0 and distance > 0 ) or ( udg_zz_DCCamSystem_DistV > 0 and distance < 0 ) then
//Brake and change of direction necessary
if linear then
set localbrake = smoothtime / ( RAbsBJ( distance / ( totaltime - smoothtime ) / udg_zz_DCCamSystem_DistV ) + 1 )
else
set localbrake = smoothtime / ( Pow( distance / ( totaltime - smoothtime ), 2 ) / Pow( udg_zz_DCCamSystem_DistV, 2 ) + 1 )
endif
set udg_zz_DCCamSystem_DistTarget2 = targetdistance
set udg_zz_DCCamSystem_DistTotal2 = totaltime - localbrake
set udg_zz_DCCamSystem_DistSmooth2 = smoothtime - localbrake
call DCCamSystem_BrakeDistanceTime( localbrake, linear )
call TimerStart( udg_zz_DCCamSystem_DirChange2, localbrake, false, function DCCamSystem_DirChangeDistanceTimer )
return
endif
if linear then
if RAbsBJ( udg_zz_DCCamSystem_DistV * smoothtime / 2 ) > RAbsBJ( distance ) then
//shortening smoothtime to make sway possible
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeDist() )
endif
if DCCamSystem_DistMinSpeed() * totaltime + 0.05 * ( RAbsBJ( udg_zz_DCCamSystem_DistV ) - DCCamSystem_DistMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothDist() )
endif
call DCCamSystem_NormalDistance( targetdistance, totaltime )
return
endif
if distance > 0 then
set udg_zz_DCCamSystem_DistVEnd = DCCamSystem_DistMinSpeed()
else
set udg_zz_DCCamSystem_DistVEnd = - DCCamSystem_DistMinSpeed()
endif
set distance = distance - udg_zz_DCCamSystem_DistVEnd * totaltime
loop
exitwhen Power < -2
loop
set smoothtime = smoothtime - Pow( 10, Power )
exitwhen RAbsBJ(udg_zz_DCCamSystem_DistVBegin - udg_zz_DCCamSystem_DistVEnd) * smoothtime / 2 < RAbsBJ( distance )
endloop
set smoothtime = smoothtime + Pow( 10, Power )
set Power = Power - 1
endloop
else
//normal, possible smooth sway
set udg_zz_DCCamSystem_DistVEnd = ( distance - udg_zz_DCCamSystem_DistVBegin * smoothtime / 2 ) / ( totaltime - smoothtime / 2 )
endif
else
//Calculate approximate value of VNullTime
if RAbsBJ( udg_zz_DCCamSystem_DistV * totaltime ) < RAbsBJ( distance ) then
//Accelleration
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_DistVEnd = ( distance + udg_zz_DCCamSystem_DistV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_DistVEnd / SquareRoot( smoothtime + vnulltime ) * SquareRoot( vnulltime ) ) > RAbsBJ( udg_zz_DCCamSystem_DistV )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_DistVEnd = ( distance + udg_zz_DCCamSystem_DistV * vnulltime * 2 /3 ) / ( ( smoothtime + vnulltime ) * 2 / 3 + totaltime - smoothtime )
else
//Decelleration
if RAbsBJ( 2 * udg_zz_DCCamSystem_DistV * smoothtime / 3 ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeDist() )
endif
if DCCamSystem_DistMinSpeed() * totaltime + 0.07 * ( RAbsBJ( udg_zz_DCCamSystem_DistV ) - DCCamSystem_DistMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothDist() )
endif
call DCCamSystem_NormalDistance( targetdistance, totaltime )
return
endif
set vnulltime = 0
if distance > 0 then
set udg_zz_DCCamSystem_DistVEnd = DCCamSystem_DistMinSpeed()
else
set udg_zz_DCCamSystem_DistVEnd = - DCCamSystem_DistMinSpeed()
endif
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set smoothtime = vnulltime
exitwhen RAbsBJ( udg_zz_DCCamSystem_DistVBegin / SquareRoot( vnulltime ) * 2 / 3 * Pow( vnulltime, 1.5 ) + udg_zz_DCCamSystem_DistVEnd * ( totaltime - vnulltime ) ) > RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set smoothtime = - Pow( udg_zz_DCCamSystem_DistVEnd, 2 ) * vnulltime / Pow( udg_zz_DCCamSystem_DistVBegin, 2 ) + vnulltime
else
set vnulltime = smoothtime
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_DistVEnd = udg_zz_DCCamSystem_DistVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_DistVBegin / SquareRoot( vnulltime ) * 2 / 3 * ( Pow( vnulltime, 1.5 ) - Pow( vnulltime - smoothtime, 1.5 ) ) ) + RAbsBJ( udg_zz_DCCamSystem_DistVEnd * ( totaltime - smoothtime ) ) >= RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_DistVEnd = udg_zz_DCCamSystem_DistVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
endif
endif
endif
endif
endif
set udg_zz_DCCamSystem_DistVNullTime = vnulltime
set udg_zz_DCCamSystem_DistAccelTime = smoothtime
set udg_zz_DCCamSystem_DistTarget = targetdistance
set udg_zz_DCCamSystem_DistAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_DistFactor = ( udg_zz_DCCamSystem_DistVEnd - udg_zz_DCCamSystem_DistVBegin ) / smoothtime
elseif RAbsBJ( udg_zz_DCCamSystem_DistVEnd ) < RAbsBJ( udg_zz_DCCamSystem_DistV ) then
set udg_zz_DCCamSystem_DistFactor = udg_zz_DCCamSystem_DistVBegin / SquareRoot( vnulltime )
else
set udg_zz_DCCamSystem_DistFactor = udg_zz_DCCamSystem_DistVEnd / SquareRoot( vnulltime + smoothtime )
endif
set udg_zz_DCCamSystem_DistAccelOn = true
endfunction
// Camera movement functions concerning the Field Of View's movement
//------------------------------------------------------------------
function DCCamSystem_NormalFieldOfView takes real targetfieldofview, real swaytime returns nothing
if swaytime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
if targetfieldofview > 120 then //Impossible field value corrections
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorFieldOfViewInput() )
endif
set targetfieldofview = 120
elseif targetfieldofview < 20 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorFieldOfViewInput() )
endif
set targetfieldofview = 20
endif
set udg_zz_DCCamSystem_FieldAccelOn = false
set targetfieldofview = Deg2Rad( targetfieldofview )
set udg_zz_DCCamSystem_FieldTarget = targetfieldofview
if swaytime > 0 then
set udg_zz_DCCamSystem_FieldV = ( targetfieldofview - GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) ) / swaytime
else
set udg_zz_DCCamSystem_FieldV = 0
endif
set udg_zz_DCCamSystem_FieldVBegin = udg_zz_DCCamSystem_FieldV
set udg_zz_DCCamSystem_FieldVEnd = udg_zz_DCCamSystem_FieldV
call PauseTimer( udg_zz_DCCamSystem_DirChange3 )
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( targetfieldofview ), swaytime )
endfunction
function DCCamSystem_BrakeFieldOfViewPoint takes real targetfieldofview, boolean linear returns real
local real distance
if targetfieldofview > 120 then //Impossible field value corrections
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorFieldOfViewInput() )
endif
set targetfieldofview = 120
elseif targetfieldofview < 20 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorFieldOfViewInput() )
endif
set targetfieldofview = 20
endif
if udg_zz_DCCamSystem_FieldV == 0 then //Error
if RAbsBJ( distance ) <= .1 then
return 0
endif
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakePointV() )
endif
return 0
endif
set udg_zz_DCCamSystem_FieldAccelOn = false
set targetfieldofview = Deg2Rad( targetfieldofview )
set distance = targetfieldofview - GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW)
if (distance > 0 and udg_zz_DCCamSystem_FieldV < 0) or (distance < 0 and udg_zz_DCCamSystem_FieldV > 0) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeFieldOfViewPoint() )
endif
return 0
endif
set udg_zz_DCCamSystem_FieldTarget = targetfieldofview
set udg_zz_DCCamSystem_LinearField = linear
set udg_zz_DCCamSystem_FieldVEnd = 0
set udg_zz_DCCamSystem_FieldVBegin = udg_zz_DCCamSystem_FieldV
if linear then
set udg_zz_DCCamSystem_FieldVNullTime = RAbsBJ( distance * 2 / udg_zz_DCCamSystem_FieldV )
else
set udg_zz_DCCamSystem_FieldVNullTime = RAbsBJ( distance * 3 / udg_zz_DCCamSystem_FieldV ) / 2
endif
if udg_zz_DCCamSystem_FieldVNullTime < 0.1 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothField() )
endif
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( targetfieldofview ), udg_zz_DCCamSystem_FieldVNullTime )
call PauseTimer( udg_zz_DCCamSystem_DirChange3 )
return 0
endif
set udg_zz_DCCamSystem_FieldAccelTime = udg_zz_DCCamSystem_FieldVNullTime
set udg_zz_DCCamSystem_FieldAccelNull = udg_zz_DCCamSystem_Time
call PauseTimer( udg_zz_DCCamSystem_DirChange3 )
call TimerStart( udg_zz_DCCamSystem_StopTimer3, udg_zz_DCCamSystem_FieldVNullTime, false, function DCCamSystem_StopFieldOfView )
if linear then
set udg_zz_DCCamSystem_FieldFactor = - udg_zz_DCCamSystem_FieldVBegin / udg_zz_DCCamSystem_FieldVNullTime
else
set udg_zz_DCCamSystem_FieldFactor = udg_zz_DCCamSystem_FieldVBegin / SquareRoot( udg_zz_DCCamSystem_FieldVNullTime )
endif
set udg_zz_DCCamSystem_FieldAccelOn = true
return udg_zz_DCCamSystem_FieldVNullTime
endfunction
function DCCamSystem_BrakeFieldOfViewTime takes real brakingtime, boolean linear returns nothing
local real distance
if brakingtime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_FieldAccelOn = false
call PauseTimer( udg_zz_DCCamSystem_DirChange3 )
if brakingtime < 0.01 or udg_zz_DCCamSystem_FieldV == 0 then
set udg_zz_DCCamSystem_FieldV = 0
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( GetCameraField( CAMERA_FIELD_FIELD_OF_VIEW ) ), 0 )
return
endif
call TimerStart( udg_zz_DCCamSystem_StopTimer3, brakingtime, false, function DCCamSystem_StopFieldOfView )
set udg_zz_DCCamSystem_FieldVEnd = 0
set udg_zz_DCCamSystem_FieldVBegin = udg_zz_DCCamSystem_FieldV
set udg_zz_DCCamSystem_FieldVNullTime = brakingtime
if linear then
set distance = udg_zz_DCCamSystem_FieldVBegin * udg_zz_DCCamSystem_FieldVNullTime / 2
else
set distance = 2 * udg_zz_DCCamSystem_FieldVBegin * udg_zz_DCCamSystem_FieldVNullTime / 3
endif
if GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) + distance > Deg2Rad( 120 ) or GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) + distance < Deg2Rad( 20 ) then
if udg_zz_DCCamSystem_FieldV > 0 then
call DCCamSystem_BrakeFieldOfViewPoint( 120, linear )
else
call DCCamSystem_BrakeFieldOfViewPoint( 20, linear )
endif
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeFieldOfViewTime() )
endif
return
endif
set udg_zz_DCCamSystem_FieldAccelTime = udg_zz_DCCamSystem_FieldVNullTime
set udg_zz_DCCamSystem_FieldTarget = GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) + distance
set udg_zz_DCCamSystem_LinearField = linear
set udg_zz_DCCamSystem_FieldAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_FieldFactor = - udg_zz_DCCamSystem_FieldVBegin / brakingtime
else
set udg_zz_DCCamSystem_FieldFactor = udg_zz_DCCamSystem_FieldVBegin / SquareRoot( brakingtime )
endif
set udg_zz_DCCamSystem_FieldAccelOn = true
endfunction
function DCCamSystem_SmoothFieldOfView takes real targetfieldofview, real totaltime, real smoothtime, boolean linear returns nothing
local real distance
local integer Power = 0
local real localbrake
local real vnulltime = 0
if targetfieldofview > 120 then //Impossible field value corrections
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorFieldOfViewInput() )
endif
set targetfieldofview = 120
elseif targetfieldofview < 20 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorFieldOfViewInput() )
endif
set targetfieldofview = 20
endif
if smoothtime < 0 or totaltime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
if (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
endif
return
elseif (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
return
endif
set udg_zz_DCCamSystem_FieldAccelOn = false
set targetfieldofview = Deg2Rad( targetfieldofview )
set distance = targetfieldofview - GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW)
if RAbsBJ( distance ) < .01 then
return
endif
call PauseTimer( udg_zz_DCCamSystem_DirChange3 )
set udg_zz_DCCamSystem_FieldAccelNull = udg_zz_DCCamSystem_Time
set udg_zz_DCCamSystem_FieldVBegin = udg_zz_DCCamSystem_FieldV
set udg_zz_DCCamSystem_LinearField = linear
if smoothtime == 0 then
//No accelleration necessary
call DCCamSystem_NormalFieldOfView( Rad2Deg( targetfieldofview ), totaltime )
return
else
//Set accelleration values
if udg_zz_DCCamSystem_FieldV == 0 then
//Acceleration from null
if linear then
set udg_zz_DCCamSystem_FieldVEnd = distance / ( smoothtime / 2 + totaltime - smoothtime )
else
set udg_zz_DCCamSystem_FieldVEnd = distance / ( smoothtime * 2 / 3 + totaltime - smoothtime )
endif
else
//Accelleration from current speed, if it is greater than null
if ( udg_zz_DCCamSystem_FieldV < 0 and distance > 0 ) or ( udg_zz_DCCamSystem_FieldV > 0 and distance < 0 ) then
//Brake and change of direction necessary
if linear then
set localbrake = smoothtime / ( RAbsBJ( distance / ( totaltime - smoothtime ) / udg_zz_DCCamSystem_FieldV ) + 1 )
else
set localbrake = smoothtime / ( Pow( distance / ( totaltime - smoothtime ), 2 ) / Pow( udg_zz_DCCamSystem_FieldV, 2 ) + 1 )
endif
if linear then
set vnulltime = localbrake * Rad2Deg( udg_zz_DCCamSystem_FieldV / 2 ) + Rad2Deg( GetCameraField( CAMERA_FIELD_FIELD_OF_VIEW ) ) //<- just using vnulltime as temp variable here
if vnulltime > 120 then
set localbrake = DCCamSystem_BrakeFieldOfViewPoint( 120, linear )
elseif vnulltime < 20 then
set localbrake = DCCamSystem_BrakeFieldOfViewPoint( 20, linear )
else
call DCCamSystem_BrakeFieldOfViewTime( localbrake, linear )
endif
else
set vnulltime = localbrake * Rad2Deg( udg_zz_DCCamSystem_FieldV *2 / 3 ) + Rad2Deg( GetCameraField( CAMERA_FIELD_FIELD_OF_VIEW ) ) //<- just using vnulltime as temp variable here
if vnulltime > 120 then
set localbrake = DCCamSystem_BrakeFieldOfViewPoint( 120, linear )
elseif vnulltime < 20 then
set localbrake = DCCamSystem_BrakeFieldOfViewPoint( 20, linear )
else
call DCCamSystem_BrakeFieldOfViewTime( localbrake, linear )
endif
endif
set udg_zz_DCCamSystem_FieldTarget2 = Rad2Deg( targetfieldofview )
set udg_zz_DCCamSystem_FieldTotal2 = totaltime - localbrake
set udg_zz_DCCamSystem_FieldSmooth2 = smoothtime - localbrake
call TimerStart( udg_zz_DCCamSystem_DirChange3, localbrake, false, function DCCamSystem_DirChangeFieldOfViewTimer )
return
endif
if linear then
if RAbsBJ( udg_zz_DCCamSystem_FieldV * smoothtime / 2 ) > RAbsBJ( distance ) then
//shortening smoothtime to make sway possible
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeField() )
endif
if DCCamSystem_FieldMinSpeed() * totaltime + 0.05 * ( RAbsBJ( udg_zz_DCCamSystem_FieldV ) - DCCamSystem_FieldMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothField() )
endif
call DCCamSystem_NormalFieldOfView( Rad2Deg( targetfieldofview ), totaltime )
return
endif
if distance > 0 then
set udg_zz_DCCamSystem_FieldVEnd = DCCamSystem_FieldMinSpeed()
else
set udg_zz_DCCamSystem_FieldVEnd = - DCCamSystem_FieldMinSpeed()
endif
set distance = distance - udg_zz_DCCamSystem_FieldVEnd * totaltime
loop
exitwhen Power < -2
loop
set smoothtime = smoothtime - Pow( 10, Power )
exitwhen RAbsBJ(udg_zz_DCCamSystem_FieldVBegin - udg_zz_DCCamSystem_FieldVEnd) * smoothtime / 2 < RAbsBJ( distance )
endloop
set smoothtime = smoothtime + Pow( 10, Power )
set Power = Power - 1
endloop
else
//normal, possible smooth sway
set udg_zz_DCCamSystem_FieldVEnd = ( distance - udg_zz_DCCamSystem_FieldVBegin * smoothtime / 2 ) / ( totaltime - smoothtime / 2 )
endif
else
//Calculate approximate value of VNullTime
if RAbsBJ( udg_zz_DCCamSystem_FieldV ) * totaltime < RAbsBJ( distance ) then
//Accelleration
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_FieldVEnd = ( distance + udg_zz_DCCamSystem_FieldV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_FieldVEnd / SquareRoot( smoothtime + vnulltime ) * SquareRoot( vnulltime ) ) > RAbsBJ( udg_zz_DCCamSystem_FieldV )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_FieldVEnd = ( distance + udg_zz_DCCamSystem_FieldV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
else
//Decelleration
if RAbsBJ( 2 * udg_zz_DCCamSystem_FieldV * smoothtime / 3 ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeField() )
endif
if DCCamSystem_FieldMinSpeed() * totaltime + 0.07 * ( RAbsBJ( udg_zz_DCCamSystem_FieldV ) - DCCamSystem_FieldMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothField() )
endif
call DCCamSystem_NormalFieldOfView( Rad2Deg( targetfieldofview ), totaltime )
return
endif
set vnulltime = 0
if distance > 0 then
set udg_zz_DCCamSystem_FieldVEnd = DCCamSystem_FieldMinSpeed()
else
set udg_zz_DCCamSystem_FieldVEnd = - DCCamSystem_FieldMinSpeed()
endif
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set smoothtime = vnulltime
exitwhen RAbsBJ( udg_zz_DCCamSystem_FieldVBegin / SquareRoot( vnulltime ) * 2 / 3 * Pow( vnulltime, 1.5 ) + udg_zz_DCCamSystem_FieldVEnd * ( totaltime - vnulltime ) ) > RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set smoothtime = - Pow( udg_zz_DCCamSystem_FieldVEnd, 2 ) * vnulltime / Pow( udg_zz_DCCamSystem_FieldVBegin, 2 ) + vnulltime
else
set vnulltime = smoothtime
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_FieldVEnd = udg_zz_DCCamSystem_FieldVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_FieldVBegin / SquareRoot( vnulltime ) * 2 / 3 * ( Pow( vnulltime, 1.5 ) - Pow( vnulltime - smoothtime, 1.5 ) ) ) + RAbsBJ( udg_zz_DCCamSystem_FieldVEnd * ( totaltime - smoothtime ) ) >= RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_FieldVEnd = udg_zz_DCCamSystem_FieldVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
endif
endif
endif
endif
endif
set udg_zz_DCCamSystem_FieldVNullTime = vnulltime
set udg_zz_DCCamSystem_FieldAccelTime = smoothtime
set udg_zz_DCCamSystem_FieldTarget = targetfieldofview
set udg_zz_DCCamSystem_FieldAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_FieldFactor = ( udg_zz_DCCamSystem_FieldVEnd - udg_zz_DCCamSystem_FieldVBegin ) / smoothtime
elseif RAbsBJ( udg_zz_DCCamSystem_FieldVEnd ) < RAbsBJ( udg_zz_DCCamSystem_FieldV ) then
set udg_zz_DCCamSystem_FieldFactor = udg_zz_DCCamSystem_FieldVBegin / SquareRoot( vnulltime )
else
set udg_zz_DCCamSystem_FieldFactor = udg_zz_DCCamSystem_FieldVEnd / SquareRoot( vnulltime + smoothtime )
endif
set udg_zz_DCCamSystem_FieldAccelOn = true
endfunction
// Camera movement functions concerning the Angle Of Attack's movement
//--------------------------------------------------------------------
function DCCamSystem_NormalAngle takes real target, real swaytime returns nothing
if swaytime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_AngleAccelOn = false
set udg_zz_DCCamSystem_AngleSmooth2 = -1
call PauseTimer( udg_zz_DCCamSystem_DirChange4 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway4 )
set target = Deg2Rad( target )
set udg_zz_DCCamSystem_AngleTarget = target
if swaytime > 0 then
set udg_zz_DCCamSystem_AngleV = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), target ) / swaytime
else
set udg_zz_DCCamSystem_AngleV = 0
endif
set udg_zz_DCCamSystem_AngleVBegin = udg_zz_DCCamSystem_AngleV
set udg_zz_DCCamSystem_AngleVEnd = udg_zz_DCCamSystem_AngleV
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( target ), swaytime )
endfunction
function DCCamSystem_BrakeAnglePoint takes real targetangleofattack, boolean linear returns real
local real distance
set targetangleofattack = Deg2Rad( targetangleofattack )
set distance = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), targetangleofattack )
if udg_zz_DCCamSystem_AngleV == 0 then //Errors
if RAbsBJ(distance) <= .01 then
return 0
endif
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakePointV() )
endif
return 0
endif
if ( distance < 0 and udg_zz_DCCamSystem_AngleV > 0 ) or ( distance > 0 and udg_zz_DCCamSystem_AngleV < 0 ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeAnglePoint() )
endif
return 0
endif
set udg_zz_DCCamSystem_AngleAccelOn = false
set udg_zz_DCCamSystem_AngleSmooth2 = -1
set udg_zz_DCCamSystem_AngleTarget = targetangleofattack
set udg_zz_DCCamSystem_LinearAngle = linear
set udg_zz_DCCamSystem_AngleVEnd = 0
set udg_zz_DCCamSystem_AngleVBegin = udg_zz_DCCamSystem_AngleV
if linear then
set udg_zz_DCCamSystem_AngleVNullTime = RAbsBJ( distance * 2 / udg_zz_DCCamSystem_AngleV )
else
set udg_zz_DCCamSystem_AngleVNullTime = RAbsBJ( distance * 3 / udg_zz_DCCamSystem_AngleV / 2 )
endif
if udg_zz_DCCamSystem_AngleVNullTime < 0.1 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothAngle() )
endif
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( targetangleofattack ), udg_zz_DCCamSystem_AngleVNullTime )
call PauseTimer( udg_zz_DCCamSystem_DirChange4 )
return 0
endif
set udg_zz_DCCamSystem_AngleAccelTime = udg_zz_DCCamSystem_AngleVNullTime
set udg_zz_DCCamSystem_AngleAccelNull = udg_zz_DCCamSystem_Time
call PauseTimer( udg_zz_DCCamSystem_DirChange4 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway4 )
call TimerStart( udg_zz_DCCamSystem_StopTimer4, udg_zz_DCCamSystem_AngleVNullTime, false, function DCCamSystem_StopAngle )
if linear then
set udg_zz_DCCamSystem_AngleFactor = - udg_zz_DCCamSystem_AngleVBegin / udg_zz_DCCamSystem_AngleVNullTime
else
set udg_zz_DCCamSystem_AngleFactor = udg_zz_DCCamSystem_AngleVBegin / SquareRoot( udg_zz_DCCamSystem_AngleVNullTime )
endif
set udg_zz_DCCamSystem_AngleAccelOn = true
return udg_zz_DCCamSystem_AngleVNullTime
endfunction
function DCCamSystem_BrakeAngleTime takes real brakingtime, boolean linear returns nothing
local real distance
if brakingtime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_AngleAccelOn = false
set udg_zz_DCCamSystem_AngleSmooth2 = -1
call PauseTimer( udg_zz_DCCamSystem_DirChange4 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway4 )
if brakingtime < 0.01 or udg_zz_DCCamSystem_AngleV == 0 then
set udg_zz_DCCamSystem_AngleV = 0
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ) ), 0 )
return
endif
call TimerStart( udg_zz_DCCamSystem_StopTimer4, brakingtime, false, function DCCamSystem_StopAngle )
set udg_zz_DCCamSystem_AngleVEnd = 0
set udg_zz_DCCamSystem_AngleVBegin = udg_zz_DCCamSystem_AngleV
set udg_zz_DCCamSystem_AngleVNullTime = brakingtime
if linear then
set distance = udg_zz_DCCamSystem_AngleVBegin * udg_zz_DCCamSystem_AngleVNullTime / 2
else
set distance = 2 * udg_zz_DCCamSystem_AngleVBegin * udg_zz_DCCamSystem_AngleVNullTime / 3
endif
set udg_zz_DCCamSystem_AngleAccelTime = udg_zz_DCCamSystem_AngleVNullTime
set udg_zz_DCCamSystem_AngleTarget = GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK) + distance
set udg_zz_DCCamSystem_LinearAngle = linear
set udg_zz_DCCamSystem_AngleAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_AngleFactor = - udg_zz_DCCamSystem_AngleVBegin / brakingtime
else
set udg_zz_DCCamSystem_AngleFactor = udg_zz_DCCamSystem_AngleVBegin / SquareRoot( brakingtime )
endif
set udg_zz_DCCamSystem_AngleAccelOn = true
endfunction
function DCCamSystem_SmoothAngle takes real targetangleofattack, real totaltime, real smoothtime, boolean linear returns nothing
local real distance
local integer Power = 0
local real localbrake
local real vnulltime = 0
local boolean longangle = false
set targetangleofattack = Deg2Rad( targetangleofattack )
set distance = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), targetangleofattack )
if RAbsBJ( distance ) < .1 then
return
endif
if smoothtime < 0 or totaltime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
if (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
endif
return
elseif (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
return
endif
set udg_zz_DCCamSystem_AngleAccelOn = false
set udg_zz_DCCamSystem_AngleSmooth2 = -1
call PauseTimer( udg_zz_DCCamSystem_DirChange4 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway4 )
set udg_zz_DCCamSystem_AngleAccelNull = udg_zz_DCCamSystem_Time
set udg_zz_DCCamSystem_AngleVBegin = udg_zz_DCCamSystem_AngleV
set udg_zz_DCCamSystem_LinearAngle = linear
if smoothtime == 0 then
//No accelleration necessary
call DCCamSystem_NormalAngle( Rad2Deg( targetangleofattack ), totaltime )
return
else
//Set accelleration values
if udg_zz_DCCamSystem_AngleV == 0 then
//Acceleration from null
if linear then
set udg_zz_DCCamSystem_AngleVEnd = distance / ( smoothtime / 2 + totaltime - smoothtime )
else
set udg_zz_DCCamSystem_AngleVEnd = distance / ( smoothtime * 2 / 3 + totaltime - smoothtime )
endif
else
//Accelleration from current speed, if it is greater than null
if ( udg_zz_DCCamSystem_AngleV < 0 and distance > 0 ) or ( udg_zz_DCCamSystem_AngleV > 0 and distance < 0 ) then
if linear then
set localbrake = smoothtime / ( RAbsBJ( distance / ( totaltime - smoothtime ) / udg_zz_DCCamSystem_AngleV ) + 1 )
else
set localbrake = smoothtime / ( Pow( distance / ( totaltime - smoothtime ), 2 ) / Pow( udg_zz_DCCamSystem_AngleV, 2 ) + 1 )
endif
if ( ( DistanceBetweenAnglesRad( 2 * udg_zz_DCCamSystem_AngleVBegin * localbrake / 3 + GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ), targetangleofattack ) > 0 and not linear ) or ( DistanceBetweenAnglesRad( udg_zz_DCCamSystem_AngleVBegin * localbrake / 2 + GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ), targetangleofattack ) > 0 and linear ) ) and udg_zz_DCCamSystem_AngleV > 0 then
//Long angle sway necessary
set longangle = true
set distance = 6.28319 + distance
elseif ( ( DistanceBetweenAnglesRad( 2 * udg_zz_DCCamSystem_AngleVBegin * localbrake / 3 + GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ), targetangleofattack ) < 0 and not linear ) or ( DistanceBetweenAnglesRad( udg_zz_DCCamSystem_AngleVBegin * localbrake / 2 + GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ), targetangleofattack ) < 0 and linear ) ) and udg_zz_DCCamSystem_AngleV < 0 then
//Long angle sway necessary
set longangle = true
set distance = -6.28319 + distance
else
//Brake and change of direction necessary
set udg_zz_DCCamSystem_AngleTarget2 = Rad2Deg( targetangleofattack )
set udg_zz_DCCamSystem_AngleTotal2 = totaltime - localbrake
call DCCamSystem_BrakeAngleTime( localbrake, linear )
set udg_zz_DCCamSystem_AngleSmooth2 = smoothtime - localbrake
call TimerStart( udg_zz_DCCamSystem_DirChange4, localbrake, false, function DCCamSystem_DirChangeAngleTimer )
return
endif
endif
if linear then
if RAbsBJ( udg_zz_DCCamSystem_AngleV * smoothtime / 2 ) > RAbsBJ( distance ) then
//shortening smoothtime to make sway possible
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeAngle() )
endif
if DCCamSystem_AngleMinSpeed() * totaltime + 0.05 * ( RAbsBJ( udg_zz_DCCamSystem_AngleV ) - DCCamSystem_AngleMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothAngle() )
endif
call DCCamSystem_NormalAngle( Rad2Deg(targetangleofattack), totaltime )
return
endif
if distance > 0 then
set udg_zz_DCCamSystem_AngleVEnd = DCCamSystem_AngleMinSpeed()
else
set udg_zz_DCCamSystem_AngleVEnd = - DCCamSystem_AngleMinSpeed()
endif
set distance = distance - udg_zz_DCCamSystem_AngleVEnd * totaltime
loop
exitwhen Power < -2
loop
set smoothtime = smoothtime - Pow( 10, Power )
exitwhen RAbsBJ(udg_zz_DCCamSystem_AngleVBegin - udg_zz_DCCamSystem_AngleVEnd) * smoothtime / 2 < RAbsBJ( distance )
endloop
set smoothtime = smoothtime + Pow( 10, Power )
set Power = Power - 1
endloop
else
//normal, possible smooth sway
set udg_zz_DCCamSystem_AngleVEnd = ( distance - udg_zz_DCCamSystem_AngleVBegin * smoothtime / 2 ) / ( totaltime - smoothtime / 2 )
endif
else
//Calculate approximate value of VNullTime
if RAbsBJ( udg_zz_DCCamSystem_AngleV ) * totaltime < RAbsBJ( distance ) then
//Accelleration
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_AngleVEnd = ( distance + udg_zz_DCCamSystem_AngleV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_AngleVEnd / SquareRoot( smoothtime + vnulltime ) * SquareRoot( vnulltime ) ) >= RAbsBJ( udg_zz_DCCamSystem_AngleV )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_AngleVEnd = ( distance + udg_zz_DCCamSystem_AngleV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
else
//Decelleration
if RAbsBJ( 2 * udg_zz_DCCamSystem_AngleV * smoothtime / 3 ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeAngle() )
endif
if DCCamSystem_AngleMinSpeed() * totaltime + 0.07 * ( RAbsBJ( udg_zz_DCCamSystem_AngleV ) - DCCamSystem_AngleMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothAngle() )
endif
call DCCamSystem_NormalAngle( Rad2Deg( targetangleofattack ), totaltime )
return
endif
set vnulltime = 0
if distance > 0 then
set udg_zz_DCCamSystem_AngleVEnd = DCCamSystem_AngleMinSpeed()
else
set udg_zz_DCCamSystem_AngleVEnd = - DCCamSystem_AngleMinSpeed()
endif
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set smoothtime = vnulltime
exitwhen RAbsBJ( udg_zz_DCCamSystem_AngleVBegin / SquareRoot( vnulltime ) * 2 / 3 * Pow( vnulltime, 1.5 ) + udg_zz_DCCamSystem_AngleVEnd * ( totaltime - vnulltime ) ) > RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set smoothtime = - Pow( udg_zz_DCCamSystem_AngleVEnd, 2 ) * vnulltime / Pow( udg_zz_DCCamSystem_AngleVBegin, 2 ) + vnulltime
else
set vnulltime = smoothtime
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_AngleVEnd = udg_zz_DCCamSystem_AngleVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_AngleVBegin / SquareRoot( vnulltime ) * 2 / 3 * ( Pow( vnulltime, 1.5 ) - Pow( vnulltime - smoothtime, 1.5 ) ) ) + RAbsBJ( udg_zz_DCCamSystem_AngleVEnd * ( totaltime - smoothtime ) ) >= RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_AngleVEnd = udg_zz_DCCamSystem_AngleVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
endif
endif
endif
endif
endif
set udg_zz_DCCamSystem_AngleVNullTime = vnulltime
set udg_zz_DCCamSystem_AngleAccelTime = smoothtime
if longangle then
call TimerStart( udg_zz_DCCamSystem_LongAngleSway4, localbrake, false, function DCCamSystem_LongAngleAngleTimer )
set udg_zz_DCCamSystem_AngleTarget2 = targetangleofattack
set udg_zz_DCCamSystem_AngleSmooth2 = 0
if distance < 0 then
set udg_zz_DCCamSystem_AngleTarget = GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ) - 3.14
else
set udg_zz_DCCamSystem_AngleTarget = GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ) + 3.14
endif
else
set udg_zz_DCCamSystem_AngleTarget = targetangleofattack
endif
set udg_zz_DCCamSystem_AngleAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_AngleFactor = ( udg_zz_DCCamSystem_AngleVEnd - udg_zz_DCCamSystem_AngleVBegin ) / smoothtime
elseif RAbsBJ( udg_zz_DCCamSystem_AngleVEnd ) < RAbsBJ( udg_zz_DCCamSystem_AngleV ) then
set udg_zz_DCCamSystem_AngleFactor = udg_zz_DCCamSystem_AngleVBegin / SquareRoot( vnulltime )
else
set udg_zz_DCCamSystem_AngleFactor = udg_zz_DCCamSystem_AngleVEnd / SquareRoot( vnulltime + smoothtime )
endif
set udg_zz_DCCamSystem_AngleAccelOn = true
endfunction
// Camera movement functions concerning the Rotation's movement
//-------------------------------------------------------------
function DCCamSystem_NormalRotation takes real target, real swaytime returns nothing
if swaytime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_RotaAccelOn = false
set udg_zz_DCCamSystem_RotaSmooth2 = -1
call PauseTimer( udg_zz_DCCamSystem_DirChange5 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway5 )
set target = Deg2Rad( target )
set udg_zz_DCCamSystem_RotaTarget = target
if swaytime > 0 then
set udg_zz_DCCamSystem_RotaV = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), target ) / swaytime
else
set udg_zz_DCCamSystem_RotaV = 0
endif
set udg_zz_DCCamSystem_RotaVBegin = udg_zz_DCCamSystem_RotaV
set udg_zz_DCCamSystem_RotaVEnd = udg_zz_DCCamSystem_RotaV
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( target ), swaytime )
endfunction
function DCCamSystem_BrakeRotationPoint takes real targetrotation, boolean linear returns real
local real distance
set targetrotation = Deg2Rad( targetrotation )
set distance = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), targetrotation )
if udg_zz_DCCamSystem_RotaV == 0 then //Errors
if RAbsBJ( distance ) <= .01 then
return 0
endif
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakePointV() )
endif
return 0
endif
set udg_zz_DCCamSystem_RotaSmooth2 = -1
if distance < 0 and udg_zz_DCCamSystem_RotaV > 0 or distance > 0 and udg_zz_DCCamSystem_RotaV < 0 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeRotationPoint() )
endif
return 0
endif
set udg_zz_DCCamSystem_RotaAccelOn = false
set udg_zz_DCCamSystem_RotaTarget = targetrotation
set udg_zz_DCCamSystem_LinearRotation = linear
set udg_zz_DCCamSystem_RotaVEnd = 0
set udg_zz_DCCamSystem_RotaVBegin = udg_zz_DCCamSystem_RotaV
if linear then
set udg_zz_DCCamSystem_RotaVNullTime = RAbsBJ( distance * 2 / udg_zz_DCCamSystem_RotaV )
else
set udg_zz_DCCamSystem_RotaVNullTime = RAbsBJ( distance * 3 / udg_zz_DCCamSystem_RotaV / 2 )
endif
set udg_zz_DCCamSystem_RotaAccelTime = udg_zz_DCCamSystem_RotaVNullTime
set udg_zz_DCCamSystem_RotaAccelNull = udg_zz_DCCamSystem_Time
call PauseTimer( udg_zz_DCCamSystem_DirChange5 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway5 )
call TimerStart( udg_zz_DCCamSystem_StopTimer5, udg_zz_DCCamSystem_RotaVNullTime, false, function DCCamSystem_StopRotation )
if linear then
set udg_zz_DCCamSystem_RotaFactor = - udg_zz_DCCamSystem_RotaVBegin / udg_zz_DCCamSystem_RotaVNullTime
else
set udg_zz_DCCamSystem_RotaFactor = udg_zz_DCCamSystem_RotaVBegin / SquareRoot( udg_zz_DCCamSystem_RotaVNullTime )
endif
set udg_zz_DCCamSystem_RotaAccelOn = true
return udg_zz_DCCamSystem_RotaVNullTime
endfunction
function DCCamSystem_BrakeRotationTime takes real brakingtime, boolean linear returns nothing
local real distance
if brakingtime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_RotaSmooth2 = -1
set udg_zz_DCCamSystem_RotaAccelOn = false
call PauseTimer( udg_zz_DCCamSystem_DirChange5 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway5 )
if brakingtime < 0.01 or udg_zz_DCCamSystem_RotaV == 0 then
set udg_zz_DCCamSystem_RotaV = 0
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( GetCameraField( CAMERA_FIELD_ROTATION ) ), 0 )
return
endif
call TimerStart( udg_zz_DCCamSystem_StopTimer5, brakingtime, false, function DCCamSystem_StopRotation )
set udg_zz_DCCamSystem_RotaVEnd = 0
set udg_zz_DCCamSystem_RotaVBegin = udg_zz_DCCamSystem_RotaV
set udg_zz_DCCamSystem_RotaVNullTime = brakingtime
if linear then
set distance = udg_zz_DCCamSystem_RotaVBegin * udg_zz_DCCamSystem_RotaVNullTime / 2
else
set distance = 2 * udg_zz_DCCamSystem_RotaVBegin * udg_zz_DCCamSystem_RotaVNullTime / 3
endif
set udg_zz_DCCamSystem_RotaAccelTime = udg_zz_DCCamSystem_RotaVNullTime
set udg_zz_DCCamSystem_RotaTarget = GetCameraField(CAMERA_FIELD_ROTATION) + distance
set udg_zz_DCCamSystem_LinearRotation = linear
set udg_zz_DCCamSystem_RotaAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_RotaFactor = - udg_zz_DCCamSystem_RotaVBegin / brakingtime
else
set udg_zz_DCCamSystem_RotaFactor = udg_zz_DCCamSystem_RotaVBegin / SquareRoot( brakingtime )
endif
set udg_zz_DCCamSystem_RotaAccelOn = true
endfunction
function DCCamSystem_SmoothRotation takes real targetrotation, real totaltime, real smoothtime, boolean linear returns nothing
local real distance
local integer Power = 0
local real localbrake
local real vnulltime = 0
local boolean longangle = false
set targetrotation = Deg2Rad( targetrotation )
set distance = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), targetrotation )
if RAbsBJ( distance ) <= 0.01 then
return
endif
if smoothtime < 0 or totaltime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
if (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
endif
return
elseif (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
return
endif
set udg_zz_DCCamSystem_RotaAccelOn = false
set udg_zz_DCCamSystem_RotaSmooth2 = -1
call PauseTimer( udg_zz_DCCamSystem_DirChange5 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway5 )
set udg_zz_DCCamSystem_RotaVBegin = udg_zz_DCCamSystem_RotaV
set udg_zz_DCCamSystem_RotaAccelNull = udg_zz_DCCamSystem_Time
set udg_zz_DCCamSystem_LinearRotation = linear
if smoothtime == 0 then
//No accelleration necessary
call DCCamSystem_NormalRotation( Rad2Deg( targetrotation ), totaltime )
return
else
//Set accelleration values
if udg_zz_DCCamSystem_RotaV == 0 then
//Acceleration from null
if linear then
set udg_zz_DCCamSystem_RotaVEnd = distance / ( smoothtime / 2 + totaltime - smoothtime )
else
set udg_zz_DCCamSystem_RotaVEnd = distance / ( smoothtime * 2 / 3 + totaltime - smoothtime )
endif
else
//Accelleration from current speed, if it is greater than null
if ( udg_zz_DCCamSystem_RotaV < 0 and distance > 0 ) or ( udg_zz_DCCamSystem_RotaV > 0 and distance < 0 ) then
if linear then
set localbrake = smoothtime / 2
else
set localbrake = smoothtime / 2
endif
if ( ( DistanceBetweenAnglesRad( 2 * udg_zz_DCCamSystem_RotaVBegin * localbrake / 3 + GetCameraField( CAMERA_FIELD_ROTATION ), targetrotation ) > 0 and not linear ) or ( DistanceBetweenAnglesRad( udg_zz_DCCamSystem_RotaVBegin * localbrake / 2 + GetCameraField( CAMERA_FIELD_ROTATION ), targetrotation ) > 0 and linear ) ) and udg_zz_DCCamSystem_RotaV > 0 then
//Long angle sway necessary
set longangle = true
set distance = 6.28319 + distance
elseif ( ( DistanceBetweenAnglesRad( 2 * udg_zz_DCCamSystem_RotaVBegin * localbrake / 3 + GetCameraField( CAMERA_FIELD_ROTATION ), targetrotation ) < 0 and not linear ) or ( DistanceBetweenAnglesRad( udg_zz_DCCamSystem_RotaVBegin * localbrake / 2 + GetCameraField( CAMERA_FIELD_ROTATION ), targetrotation ) < 0 and linear ) ) and udg_zz_DCCamSystem_RotaV < 0 then
//Long angle sway necessary
set longangle = true
set distance = -6.28319 + distance
else
//Brake and change of direction necessary
set udg_zz_DCCamSystem_RotaTarget2 = Rad2Deg( targetrotation )
set udg_zz_DCCamSystem_RotaTotal2 = totaltime - localbrake
call DCCamSystem_BrakeRotationTime( localbrake, linear )
set udg_zz_DCCamSystem_RotaSmooth2 = smoothtime - localbrake
call TimerStart( udg_zz_DCCamSystem_DirChange5, localbrake, false, function DCCamSystem_DirChangeRotationTimer )
return
endif
endif
if linear then
if RAbsBJ( udg_zz_DCCamSystem_RotaV * smoothtime / 2 ) > RAbsBJ( distance ) then
//shortening smoothtime to make sway possible
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeRota() )
endif
if DCCamSystem_RotaMinSpeed() * totaltime + 0.05 * ( RAbsBJ( udg_zz_DCCamSystem_RotaV ) - DCCamSystem_RotaMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothRota() )
endif
call DCCamSystem_NormalRotation( Rad2Deg(targetrotation), totaltime )
return
endif
if distance > 0 then
set udg_zz_DCCamSystem_RotaVEnd = DCCamSystem_RotaMinSpeed()
else
set udg_zz_DCCamSystem_RotaVEnd = - DCCamSystem_RotaMinSpeed()
endif
set distance = distance - udg_zz_DCCamSystem_RotaVEnd * totaltime
loop
exitwhen Power < -2
loop
set smoothtime = smoothtime - Pow( 10, Power )
exitwhen RAbsBJ(udg_zz_DCCamSystem_RotaVBegin - udg_zz_DCCamSystem_RotaVEnd) * smoothtime / 2 < RAbsBJ( distance )
endloop
set smoothtime = smoothtime + Pow( 10, Power )
set Power = Power - 1
endloop
else
//normal, possible smooth sway
set udg_zz_DCCamSystem_RotaVEnd = ( distance - udg_zz_DCCamSystem_RotaVBegin * smoothtime / 2 ) / ( totaltime - smoothtime / 2 )
endif
else
//Calculate approximate value of VNullTime
if RAbsBJ( udg_zz_DCCamSystem_RotaV ) * totaltime < RAbsBJ( distance ) then
//Accelleration
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_RotaVEnd = ( distance + udg_zz_DCCamSystem_RotaV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_RotaVEnd / SquareRoot( smoothtime + vnulltime ) * SquareRoot( vnulltime ) ) >= RAbsBJ( udg_zz_DCCamSystem_RotaV )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_RotaVEnd = ( distance + udg_zz_DCCamSystem_RotaV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
else
//Decelleration
if RAbsBJ( 2 * udg_zz_DCCamSystem_RotaV * smoothtime / 3 ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeRota() )
endif
if DCCamSystem_RotaMinSpeed() * totaltime + 0.07 * ( RAbsBJ( udg_zz_DCCamSystem_RotaV ) - DCCamSystem_RotaMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothRota() )
endif
call DCCamSystem_NormalRotation( Rad2Deg(targetrotation), totaltime )
return
endif
set vnulltime = 0
if distance > 0 then
set udg_zz_DCCamSystem_RotaVEnd = DCCamSystem_RotaMinSpeed()
else
set udg_zz_DCCamSystem_RotaVEnd = - DCCamSystem_RotaMinSpeed()
endif
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set smoothtime = vnulltime
exitwhen RAbsBJ( udg_zz_DCCamSystem_RotaVBegin / SquareRoot( vnulltime ) * 2 / 3 * Pow( vnulltime, 1.5 ) + udg_zz_DCCamSystem_RotaVEnd * ( totaltime - vnulltime ) ) > RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set smoothtime = - Pow( udg_zz_DCCamSystem_RotaVEnd, 2 ) * vnulltime / Pow( udg_zz_DCCamSystem_RotaVBegin, 2 ) + vnulltime
else
set vnulltime = smoothtime
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_RotaVEnd = udg_zz_DCCamSystem_RotaVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_RotaVBegin / SquareRoot( vnulltime ) * 2 / 3 * ( Pow( vnulltime, 1.5 ) - Pow( vnulltime - smoothtime, 1.5 ) ) ) + RAbsBJ( udg_zz_DCCamSystem_RotaVEnd * ( totaltime - smoothtime ) ) >= RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_RotaVEnd = udg_zz_DCCamSystem_RotaVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
endif
endif
endif
endif
endif
set udg_zz_DCCamSystem_RotaVNullTime = vnulltime
set udg_zz_DCCamSystem_RotaAccelTime = smoothtime
set udg_zz_DCCamSystem_RotaVBegin = udg_zz_DCCamSystem_RotaV
if longangle then
call TimerStart( udg_zz_DCCamSystem_LongAngleSway5, totaltime / 2, false, function DCCamSystem_LongAngleRotationTimer )
set udg_zz_DCCamSystem_RotaTarget2 = targetrotation
set udg_zz_DCCamSystem_RotaSmooth2 = 0
if distance < 0 then
set udg_zz_DCCamSystem_RotaTarget = GetCameraField( CAMERA_FIELD_ROTATION ) - 3.14
else
set udg_zz_DCCamSystem_RotaTarget = GetCameraField( CAMERA_FIELD_ROTATION ) + 3.14
endif
else
set udg_zz_DCCamSystem_RotaTarget = targetrotation
endif
if linear then
set udg_zz_DCCamSystem_RotaFactor = ( udg_zz_DCCamSystem_RotaVEnd - udg_zz_DCCamSystem_RotaVBegin ) / smoothtime
elseif RAbsBJ( udg_zz_DCCamSystem_RotaVEnd ) < RAbsBJ( udg_zz_DCCamSystem_RotaV ) then
set udg_zz_DCCamSystem_RotaFactor = udg_zz_DCCamSystem_RotaVBegin / SquareRoot( vnulltime )
else
set udg_zz_DCCamSystem_RotaFactor = udg_zz_DCCamSystem_RotaVEnd / SquareRoot( vnulltime + smoothtime )
endif
set udg_zz_DCCamSystem_RotaAccelOn = true
endfunction
// Camera movement functions concerning the Roll's movement
//---------------------------------------------------------
function DCCamSystem_NormalRoll takes real target, real swaytime returns nothing
if swaytime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_RollAccelOn = false
set udg_zz_DCCamSystem_RollSmooth2 = -1
call PauseTimer( udg_zz_DCCamSystem_DirChange6 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway6 )
set target = Deg2Rad( target )
set udg_zz_DCCamSystem_RollTarget = target
if swaytime > 0 then
set udg_zz_DCCamSystem_RollV = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), target ) / swaytime
else
set udg_zz_DCCamSystem_RollV = 0
endif
set udg_zz_DCCamSystem_RollVBegin = udg_zz_DCCamSystem_RollV
set udg_zz_DCCamSystem_RollVEnd = udg_zz_DCCamSystem_RollV
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( target ), swaytime )
endfunction
function DCCamSystem_BrakeRollPoint takes real targetroll, boolean linear returns real
local real distance
set targetroll = Deg2Rad( targetroll )
set distance = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), targetroll )
if udg_zz_DCCamSystem_RollV == 0 then //Errors
if RAbsBJ( distance ) <= .01 then
return 0
endif
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakePointV() )
endif
return 0
endif
if distance < 0 and udg_zz_DCCamSystem_RollV > 0 or distance > 0 and udg_zz_DCCamSystem_RollV < 0 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeRollPoint() )
endif
return 0
endif
set udg_zz_DCCamSystem_RollAccelOn = false
set udg_zz_DCCamSystem_RollSmooth2 = -1
set udg_zz_DCCamSystem_RollTarget = targetroll
set udg_zz_DCCamSystem_RollVEnd = 0
set udg_zz_DCCamSystem_LinearRoll = linear
set udg_zz_DCCamSystem_RollVBegin = udg_zz_DCCamSystem_RollV
if linear then
set udg_zz_DCCamSystem_RollVNullTime = RAbsBJ( distance * 2 / udg_zz_DCCamSystem_RollV )
else
set udg_zz_DCCamSystem_RollVNullTime = RAbsBJ( distance * 3 / udg_zz_DCCamSystem_RollV / 2 )
endif
set udg_zz_DCCamSystem_RollAccelTime = udg_zz_DCCamSystem_RollVNullTime
set udg_zz_DCCamSystem_RollAccelNull = udg_zz_DCCamSystem_Time
call PauseTimer( udg_zz_DCCamSystem_DirChange6 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway6 )
call TimerStart( udg_zz_DCCamSystem_StopTimer6, udg_zz_DCCamSystem_RollVNullTime, false, function DCCamSystem_StopRoll )
if linear then
set udg_zz_DCCamSystem_RollFactor = - udg_zz_DCCamSystem_RollVBegin / udg_zz_DCCamSystem_RollVNullTime
else
set udg_zz_DCCamSystem_RollFactor = udg_zz_DCCamSystem_RollVBegin / SquareRoot( udg_zz_DCCamSystem_RollVNullTime )
endif
set udg_zz_DCCamSystem_RollAccelOn = true
return udg_zz_DCCamSystem_RollVNullTime
endfunction
function DCCamSystem_BrakeRollTime takes real brakingtime, boolean linear returns nothing
local real distance
if brakingtime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
return
endif
set udg_zz_DCCamSystem_RollAccelOn = false
set udg_zz_DCCamSystem_RollSmooth2 = -1
call PauseTimer( udg_zz_DCCamSystem_DirChange6 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway6 )
if brakingtime < 0.01 or udg_zz_DCCamSystem_RollV == 0 then
set udg_zz_DCCamSystem_RollV = 0
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( GetCameraField( CAMERA_FIELD_ROLL ) ), 0 )
return
endif
call TimerStart( udg_zz_DCCamSystem_StopTimer6, brakingtime, false, function DCCamSystem_StopRoll )
set udg_zz_DCCamSystem_RollVEnd = 0
set udg_zz_DCCamSystem_RollVBegin = udg_zz_DCCamSystem_RollV
set udg_zz_DCCamSystem_RollVNullTime = brakingtime
if linear then
set distance = udg_zz_DCCamSystem_RollVBegin * udg_zz_DCCamSystem_RollVNullTime / 2
else
set distance = 2 * udg_zz_DCCamSystem_RollVBegin * udg_zz_DCCamSystem_RollVNullTime / 3
endif
set udg_zz_DCCamSystem_RollAccelTime = udg_zz_DCCamSystem_RollVNullTime
set udg_zz_DCCamSystem_RollTarget = GetCameraField(CAMERA_FIELD_ROLL) + distance
set udg_zz_DCCamSystem_LinearRoll = linear
set udg_zz_DCCamSystem_RollAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_RollFactor = - udg_zz_DCCamSystem_RollVBegin / brakingtime
else
set udg_zz_DCCamSystem_RollFactor = udg_zz_DCCamSystem_RollVBegin / SquareRoot( brakingtime )
endif
set udg_zz_DCCamSystem_RollAccelOn = true
endfunction
function DCCamSystem_SmoothRoll takes real targetroll, real totaltime, real smoothtime, boolean linear returns nothing
local real distance
local integer Power = 0
local real localbrake
local real vnulltime = 0
local real stoptimer
local boolean longangle = false
set targetroll = Deg2Rad( targetroll )
set distance = DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), targetroll )
if RAbsBJ(distance) <= 0.01 then
return
endif
if smoothtime < 0 or totaltime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
if (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
endif
return
elseif (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
return
endif
set udg_zz_DCCamSystem_RollAccelOn = false
set udg_zz_DCCamSystem_RollSmooth2 = -1
call PauseTimer( udg_zz_DCCamSystem_DirChange6 )
call PauseTimer( udg_zz_DCCamSystem_LongAngleSway6 )
set udg_zz_DCCamSystem_LinearRoll = linear
set udg_zz_DCCamSystem_RollAccelNull = udg_zz_DCCamSystem_Time
set udg_zz_DCCamSystem_RollVBegin = udg_zz_DCCamSystem_RollV
if smoothtime == 0 then
//No accelleration necessary
call DCCamSystem_NormalRoll( Rad2Deg( targetroll ), totaltime )
return
else
//Set accelleration values
if udg_zz_DCCamSystem_RollV == 0 then
//Acceleration from null
if linear then
set udg_zz_DCCamSystem_RollVEnd = distance / ( smoothtime / 2 + totaltime - smoothtime )
else
set udg_zz_DCCamSystem_RollVEnd = distance / ( smoothtime * 2 / 3 + totaltime - smoothtime )
endif
else
//Accelleration from current speed, if it is greater than null
if ( udg_zz_DCCamSystem_RollV < 0 and distance > 0 ) or ( udg_zz_DCCamSystem_RollV > 0 and distance < 0 ) then
if linear then
set localbrake = smoothtime / ( RAbsBJ( distance / ( totaltime - smoothtime ) / udg_zz_DCCamSystem_RollV ) + 1 )
else
set localbrake = smoothtime / ( Pow( distance / ( totaltime - smoothtime ), 2 ) / Pow( udg_zz_DCCamSystem_RollV, 2 ) + 1 )
endif
if ( ( DistanceBetweenAnglesRad( 2 * udg_zz_DCCamSystem_RollVBegin * localbrake / 3 + GetCameraField( CAMERA_FIELD_ROLL ), targetroll ) > 0 and not linear ) or ( DistanceBetweenAnglesRad( udg_zz_DCCamSystem_RollVBegin * localbrake / 2 + GetCameraField( CAMERA_FIELD_ROLL ), targetroll ) > 0 and linear ) ) and udg_zz_DCCamSystem_RollV > 0 then
//Long angle sway necessary
set longangle = true
set distance = 6.28319 + distance
elseif ( ( DistanceBetweenAnglesRad( 2 * udg_zz_DCCamSystem_RollVBegin * localbrake / 3 + GetCameraField( CAMERA_FIELD_ROLL ), targetroll ) < 0 and not linear ) or ( DistanceBetweenAnglesRad( udg_zz_DCCamSystem_RollVBegin * localbrake / 2 + GetCameraField( CAMERA_FIELD_ROLL ), targetroll ) < 0 and linear ) ) and udg_zz_DCCamSystem_RollV < 0 then
//Long angle sway necessary
set longangle = true
set distance = -6.28319 + distance
else
//Brake and change of direction necessary
set udg_zz_DCCamSystem_RollTarget2 = Rad2Deg( targetroll )
set udg_zz_DCCamSystem_RollTotal2 = totaltime - localbrake
call DCCamSystem_BrakeRollTime( localbrake, linear )
set udg_zz_DCCamSystem_RollSmooth2 = smoothtime - localbrake
call TimerStart( udg_zz_DCCamSystem_DirChange6, localbrake, false, function DCCamSystem_DirChangeRollTimer )
return
endif
endif
if linear then
if RAbsBJ( udg_zz_DCCamSystem_RollV * smoothtime / 2 ) > RAbsBJ( distance ) then
//shortening smoothtime to make sway possible
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeRoll() )
endif
if DCCamSystem_RollMinSpeed() * totaltime + 0.05 * ( RAbsBJ( udg_zz_DCCamSystem_RollV ) - DCCamSystem_RollMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothRoll() )
endif
call DCCamSystem_NormalRoll( Rad2Deg(targetroll), totaltime )
return
endif
if distance > 0 then
set udg_zz_DCCamSystem_RollVEnd = DCCamSystem_RollMinSpeed()
else
set udg_zz_DCCamSystem_RollVEnd = - DCCamSystem_RollMinSpeed()
endif
set distance = distance - udg_zz_DCCamSystem_RollVEnd * totaltime
loop
exitwhen Power < -2
loop
set smoothtime = smoothtime - Pow( 10, Power )
exitwhen RAbsBJ(udg_zz_DCCamSystem_RollVBegin - udg_zz_DCCamSystem_RollVEnd) * smoothtime / 2 < RAbsBJ( distance )
endloop
set smoothtime = smoothtime + Pow( 10, Power )
set Power = Power - 1
endloop
else
//normal, possible smooth sway
set udg_zz_DCCamSystem_RollVEnd = ( distance - udg_zz_DCCamSystem_RollVBegin * smoothtime / 2 ) / ( totaltime - smoothtime / 2 )
endif
else
//Calculate approximate value of VNullTime
if RAbsBJ( udg_zz_DCCamSystem_RollV ) * totaltime < RAbsBJ( distance ) then
//Accelleration
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_RollVEnd = ( distance + udg_zz_DCCamSystem_RollV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_RollVEnd / SquareRoot( smoothtime + vnulltime ) * SquareRoot( vnulltime ) ) >= RAbsBJ( udg_zz_DCCamSystem_RollV )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_RollVEnd = ( distance + udg_zz_DCCamSystem_RollV * vnulltime * 2 /3 ) / ( ( vnulltime + smoothtime ) * 2 / 3 + totaltime - smoothtime )
else
//Decelleration
if RAbsBJ( 2 * udg_zz_DCCamSystem_RollV * smoothtime / 3 ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothBrakeRoll() )
endif
if DCCamSystem_RollMinSpeed() * totaltime + 0.07 * ( RAbsBJ( udg_zz_DCCamSystem_RollV ) - DCCamSystem_RollMinSpeed() ) > RAbsBJ( distance ) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorSmoothRoll() )
endif
call DCCamSystem_NormalRoll( Rad2Deg( targetroll ), totaltime )
return
endif
set vnulltime = 0
if distance > 0 then
set udg_zz_DCCamSystem_RollVEnd = DCCamSystem_RollMinSpeed()
else
set udg_zz_DCCamSystem_RollVEnd = - DCCamSystem_RollMinSpeed()
endif
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set smoothtime = vnulltime
exitwhen RAbsBJ( udg_zz_DCCamSystem_RollVBegin / SquareRoot( vnulltime ) * 2 / 3 * Pow( vnulltime, 1.5 ) + udg_zz_DCCamSystem_RollVEnd * ( totaltime - vnulltime ) ) > RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set smoothtime = - Pow( udg_zz_DCCamSystem_RollVEnd, 2 ) * vnulltime / Pow( udg_zz_DCCamSystem_RollVBegin, 2 ) + vnulltime
else
set vnulltime = smoothtime
loop
exitwhen Power < -2
loop
set vnulltime = vnulltime + Pow( 10, Power )
set udg_zz_DCCamSystem_RollVEnd = udg_zz_DCCamSystem_RollVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
exitwhen RAbsBJ( udg_zz_DCCamSystem_RollVBegin / SquareRoot( vnulltime ) * 2 / 3 * ( Pow( vnulltime, 1.5 ) - Pow( vnulltime - smoothtime, 1.5 ) ) ) + RAbsBJ( udg_zz_DCCamSystem_RollVEnd * ( totaltime - smoothtime ) ) >= RAbsBJ( distance )
endloop
set vnulltime = vnulltime - Pow( 10, Power )
set Power = Power - 1
endloop
set udg_zz_DCCamSystem_RollVEnd = udg_zz_DCCamSystem_RollVBegin / SquareRoot( vnulltime ) * SquareRoot( vnulltime - smoothtime )
endif
endif
endif
endif
endif
set udg_zz_DCCamSystem_RollVNullTime = vnulltime
set udg_zz_DCCamSystem_RollAccelTime = smoothtime
if longangle then
call TimerStart( udg_zz_DCCamSystem_LongAngleSway6, localbrake, false, function DCCamSystem_LongAngleRollTimer )
set udg_zz_DCCamSystem_RollTarget2 = targetroll
set udg_zz_DCCamSystem_RollSmooth2 = 0
if distance < 0 then
set udg_zz_DCCamSystem_RollTarget = GetCameraField( CAMERA_FIELD_ROLL ) - 3.14
else
set udg_zz_DCCamSystem_RollTarget = GetCameraField( CAMERA_FIELD_ROLL ) + 3.14
endif
else
set udg_zz_DCCamSystem_RollTarget = targetroll
endif
set udg_zz_DCCamSystem_RollAccelNull = udg_zz_DCCamSystem_Time
if linear then
set udg_zz_DCCamSystem_RollFactor = ( udg_zz_DCCamSystem_RollVEnd - udg_zz_DCCamSystem_RollVBegin ) / smoothtime
elseif RAbsBJ( udg_zz_DCCamSystem_RollVEnd ) < RAbsBJ( udg_zz_DCCamSystem_RollV ) then
set udg_zz_DCCamSystem_RollFactor = udg_zz_DCCamSystem_RollVBegin / SquareRoot( vnulltime )
else
set udg_zz_DCCamSystem_RollFactor = udg_zz_DCCamSystem_RollVEnd / SquareRoot( vnulltime + smoothtime )
endif
set udg_zz_DCCamSystem_RollAccelOn = true
endfunction
// General camera movement Functions
//----------------------------------
function DCCamSystem_NormalCam takes camerasetup camera, real swaytime returns nothing
if swaytime < 0 then //Errors
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
return
endif
call DCCamSystem_NormalTarget( CameraSetupGetDestPositionLoc( camera ), swaytime )
call DCCamSystem_NormalZOffset( CameraSetupGetField( camera, CAMERA_FIELD_ZOFFSET ), swaytime )
call DCCamSystem_NormalDistance( CameraSetupGetField( camera, CAMERA_FIELD_TARGET_DISTANCE ), swaytime )
call DCCamSystem_NormalFieldOfView( CameraSetupGetField( camera, CAMERA_FIELD_FIELD_OF_VIEW ), swaytime )
call DCCamSystem_NormalAngle( CameraSetupGetField( camera, CAMERA_FIELD_ANGLE_OF_ATTACK ), swaytime )
call DCCamSystem_NormalRotation( CameraSetupGetField( camera, CAMERA_FIELD_ROTATION ), swaytime )
call DCCamSystem_NormalRoll( CameraSetupGetField( camera, CAMERA_FIELD_ROLL ), swaytime )
call SetCameraField( CAMERA_FIELD_FARZ, CameraSetupGetField( camera, CAMERA_FIELD_FARZ ), swaytime )
endfunction
function DCCamSystem_BrakeCamTime takes real brakingtime, boolean linear returns nothing
if brakingtime < 0 then //Errors
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
return
endif
if brakingtime == 0 then
call DCCamSystem_NormalCam( GetCurrentCameraSetup(), 0 )
return
endif
call DCCamSystem_BrakeTargetTime( brakingtime, linear )
call DCCamSystem_BrakeZOffsetTime( brakingtime, linear )
call DCCamSystem_BrakeDistanceTime( brakingtime, linear )
call DCCamSystem_BrakeFieldOfViewTime( brakingtime, linear )
call DCCamSystem_BrakeAngleTime( brakingtime, linear )
call DCCamSystem_BrakeRotationTime( brakingtime, linear )
call DCCamSystem_BrakeRollTime( brakingtime, linear )
endfunction
function DCCamSystem_BrakeCamPoint takes camerasetup camera, boolean linear returns real
local integer i = 0
local integer shortest = 10
local real targetX = CameraSetupGetDestPositionX( camera )
local real targetY = CameraSetupGetDestPositionY( camera )
local real array distance
local real array time
local real shortesttime = 200
local boolean array stoppoint
local location targetloc = CameraSetupGetDestPositionLoc( camera )
if camera == GetCurrentCameraSetup() then
call DCCamSystem_NormalCam( GetCurrentCameraSetup(), 0 )
return 0
endif
set udg_zz_DCCamSystem_LinearTarget = linear
set udg_zz_DCCamSystem_LinearZOffset = linear
set udg_zz_DCCamSystem_LinearDistance = linear
set udg_zz_DCCamSystem_LinearField = linear
set udg_zz_DCCamSystem_LinearAngle = linear
set udg_zz_DCCamSystem_LinearRotation = linear
set udg_zz_DCCamSystem_LinearRoll = linear
loop
exitwhen i == 7
set stoppoint[i] = true
set i = i + 1
endloop
set i = 0
set distance[0] = DCCamSystem_CurveDistance( targetX, targetY )
set distance[1] = CameraSetupGetField( camera, CAMERA_FIELD_ZOFFSET ) - GetCameraField(CAMERA_FIELD_ZOFFSET)
set distance[2] = CameraSetupGetField( camera, CAMERA_FIELD_TARGET_DISTANCE ) - GetCameraField( CAMERA_FIELD_TARGET_DISTANCE )
set distance[3] = Deg2Rad( CameraSetupGetField( camera, CAMERA_FIELD_FIELD_OF_VIEW ) ) - GetCameraField( CAMERA_FIELD_FIELD_OF_VIEW )
set distance[4] = DistanceBetweenAnglesRad( GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ), Deg2Rad( CameraSetupGetField( camera, CAMERA_FIELD_ANGLE_OF_ATTACK ) ) )
set distance[5] = DistanceBetweenAnglesRad( GetCameraField( CAMERA_FIELD_ROTATION ), Deg2Rad( CameraSetupGetField( camera, CAMERA_FIELD_ROTATION ) ) )
set distance[6] = DistanceBetweenAnglesRad( GetCameraField( CAMERA_FIELD_ROLL ), Deg2Rad( CameraSetupGetField( camera, CAMERA_FIELD_ROLL ) ) )
if linear then
if udg_zz_DCCamSystem_TargetV > 0 then
set time[0] = distance[0] * 2 / udg_zz_DCCamSystem_TargetV
else
set time[0] = -1
set stoppoint[0] = false
endif
if udg_zz_DCCamSystem_ZOffV != 0 then
set time[1] = distance[1] * 2 / udg_zz_DCCamSystem_ZOffV
else
set time[1] = -1
set stoppoint[1] = false
endif
if udg_zz_DCCamSystem_DistV != 0 then
set time[2] = distance[2] * 2 / udg_zz_DCCamSystem_DistV
else
set time[2] = -1
set stoppoint[2] = false
endif
if udg_zz_DCCamSystem_FieldV != 0 then
set time[3] = distance[3] * 2 / udg_zz_DCCamSystem_FieldV
else
set time[3] = -1
set stoppoint[3] = false
endif
if udg_zz_DCCamSystem_AngleV != 0 then
set time[4] = distance[4] * 2 / udg_zz_DCCamSystem_AngleV
else
set time[4] = -1
set stoppoint[4] = false
endif
if udg_zz_DCCamSystem_RotaV != 0 then
set time[5] = distance[5] * 2 / udg_zz_DCCamSystem_RotaV
else
set time[5] = -1
set stoppoint[5] = false
endif
if udg_zz_DCCamSystem_RollV != 0 then
set time[6] = distance[6] * 2 / udg_zz_DCCamSystem_RollV
else
set time[6] = -1
set stoppoint[6] = false
endif
else
if udg_zz_DCCamSystem_TargetV > 0 then
set time[0] = distance[0] / 2 / udg_zz_DCCamSystem_TargetV * 3
else
set time[0] = -1
set stoppoint[0] = false
endif
if udg_zz_DCCamSystem_ZOffV != 0 then
set time[1] = distance[1] / 2 / udg_zz_DCCamSystem_ZOffV * 3
else
set time[1] = -1
set stoppoint[1] = false
endif
if udg_zz_DCCamSystem_DistV != 0 then
set time[2] = distance[2] / 2 / udg_zz_DCCamSystem_DistV * 3
else
set time[2] = -1
set stoppoint[2] = false
endif
if udg_zz_DCCamSystem_FieldV != 0 then
set time[3] = distance[3] / 2 / udg_zz_DCCamSystem_FieldV * 3
else
set time[3] = -1
set stoppoint[3] = false
endif
if udg_zz_DCCamSystem_AngleV != 0 then
set time[4] = distance[4] / 2 / udg_zz_DCCamSystem_AngleV * 3
else
set time[4] = -1
set stoppoint[4] = false
endif
if udg_zz_DCCamSystem_RotaV != 0 then
set time[5] = distance[5] / 2 / udg_zz_DCCamSystem_RotaV * 3
else
set time[5] = -1
set stoppoint[5] = false
endif
if udg_zz_DCCamSystem_RollV != 0 then
set time[6] = distance[6] / 2 / udg_zz_DCCamSystem_RollV * 3
else
set time[6] = -1
set stoppoint[6] = false
endif
endif
loop //check for shortest brakingtime > 0.5 seconds
exitwhen i == 7
if time[i] < shortesttime and time[i] > 0.5 then
set shortest = i
set shortesttime = time[i]
elseif time[i] < 0 and stoppoint[i] then
set stoppoint[i] = false
if udg_DCCamSystem_DebugModeOn then
if i == 1 then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeZOffsetPoint() )
elseif i == 2 then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeDistancePoint() )
elseif i == 3 then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeFieldOfViewPoint() )
elseif i == 4 then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeAnglePoint() )
elseif i == 5 then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeRotationPoint() )
else
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorBrakeRollPoint() )
endif
endif
elseif time[i] <= 0.5 and time[i] > 0 then
set stoppoint[i] = false
if i == 0 then
call DCCamSystem_BrakeTargetPoint( targetloc, linear )
elseif i == 1 then
call DCCamSystem_BrakeZOffsetPoint( CameraSetupGetField( camera, CAMERA_FIELD_ZOFFSET ), linear )
elseif i == 2 then
call DCCamSystem_BrakeDistancePoint( CameraSetupGetField( camera, CAMERA_FIELD_TARGET_DISTANCE ), linear )
elseif i == 3 then
call DCCamSystem_BrakeFieldOfViewPoint( CameraSetupGetField( camera, CAMERA_FIELD_FIELD_OF_VIEW ), linear )
elseif i == 4 then
call DCCamSystem_BrakeAnglePoint( CameraSetupGetField( camera, CAMERA_FIELD_ANGLE_OF_ATTACK ), linear )
elseif i == 5 then
call DCCamSystem_BrakeRotationPoint( CameraSetupGetField( camera, CAMERA_FIELD_ROTATION ), linear )
else
call DCCamSystem_BrakeRollPoint( CameraSetupGetField( camera, CAMERA_FIELD_ROLL ), linear )
endif
endif
set i = i + 1
endloop
//check for camera aspects that have to be accelerated to arrive in time with the shortest brakingtime
if shortesttime * udg_zz_DCCamSystem_TargetV * 2 / 3 < distance [0] and stoppoint[0] then
call DCCamSystem_SmoothTarget( targetloc, shortesttime / 2, shortesttime / 3, linear )
endif
if shortesttime * udg_zz_DCCamSystem_ZOffV * 2 / 3 < distance [1] and stoppoint[1] then
call DCCamSystem_SmoothZOffset( CameraSetupGetField( camera, CAMERA_FIELD_ZOFFSET ), shortesttime / 2, shortesttime / 3, linear )
endif
if shortesttime * udg_zz_DCCamSystem_DistV * 2 / 3 < distance [2] and stoppoint[2] then
call DCCamSystem_SmoothDistance( CameraSetupGetField( camera, CAMERA_FIELD_TARGET_DISTANCE ), shortesttime / 2, shortesttime / 3, linear )
endif
if shortesttime * udg_zz_DCCamSystem_FieldV * 2 / 3 < distance [3] and stoppoint[3] then
call DCCamSystem_SmoothFieldOfView( CameraSetupGetField( camera, CAMERA_FIELD_FIELD_OF_VIEW ), shortesttime / 2, shortesttime / 3, linear )
endif
if shortesttime * udg_zz_DCCamSystem_AngleV * 2 / 3 < distance [4] and stoppoint[4] then
call DCCamSystem_SmoothAngle( CameraSetupGetField( camera, CAMERA_FIELD_ANGLE_OF_ATTACK ), shortesttime / 2, shortesttime / 3, linear )
endif
if shortesttime * udg_zz_DCCamSystem_RotaV * 2 / 3 < distance [5] and stoppoint[5] then
call DCCamSystem_SmoothRotation( CameraSetupGetField( camera, CAMERA_FIELD_ROTATION ), shortesttime / 2, shortesttime / 3, linear )
endif
if shortesttime * udg_zz_DCCamSystem_RollV * 2 / 3 < distance [6] and stoppoint[6] then
call DCCamSystem_SmoothRoll( CameraSetupGetField( camera, CAMERA_FIELD_ROLL ), shortesttime / 2, shortesttime / 3, linear )
endif
set udg_zz_DCCamSystem_StopPoint0 = stoppoint[0]
set udg_zz_DCCamSystem_StopPoint1 = stoppoint[1]
set udg_zz_DCCamSystem_StopPoint2 = stoppoint[2]
set udg_zz_DCCamSystem_StopPoint3 = stoppoint[3]
set udg_zz_DCCamSystem_StopPoint4 = stoppoint[4]
set udg_zz_DCCamSystem_StopPoint5 = stoppoint[5]
set udg_zz_DCCamSystem_StopPoint6 = stoppoint[6]
//Begin braking for the field with the shortest braking time directly and setup braking for the other fields
if shortest == 0 then
call DCCamSystem_BrakeTargetPoint( targetloc, linear )
set udg_zz_DCCamSystem_StopPoint0 = false
elseif shortest == 1 then
call DCCamSystem_BrakeZOffsetPoint( CameraSetupGetField( camera, CAMERA_FIELD_ZOFFSET ), linear )
set udg_zz_DCCamSystem_StopPoint1 = false
elseif shortest == 2 then
call DCCamSystem_BrakeDistancePoint( CameraSetupGetField( camera, CAMERA_FIELD_TARGET_DISTANCE ), linear )
set udg_zz_DCCamSystem_StopPoint2 = false
elseif shortest == 3 then
call DCCamSystem_BrakeFieldOfViewPoint( CameraSetupGetField( camera, CAMERA_FIELD_FIELD_OF_VIEW ), linear )
set udg_zz_DCCamSystem_StopPoint3 = false
elseif shortest == 4 then
call DCCamSystem_BrakeAnglePoint( CameraSetupGetField( camera, CAMERA_FIELD_ANGLE_OF_ATTACK ), linear )
set udg_zz_DCCamSystem_StopPoint4 = false
elseif shortest == 5 then
call DCCamSystem_BrakeRotationPoint( CameraSetupGetField( camera, CAMERA_FIELD_ROTATION ), linear )
set udg_zz_DCCamSystem_StopPoint5 = false
else
call DCCamSystem_BrakeRollPoint( CameraSetupGetField( camera, CAMERA_FIELD_ROLL ), linear )
set udg_zz_DCCamSystem_StopPoint6 = false
endif
call TimerStart( udg_zz_DCCamSystem_CamStop, shortesttime, false, null )
set udg_zz_DCCamSystem_StopCam = camera
set targetloc = null
return shortesttime
endfunction
function DCCamSystem_SmoothCam takes camerasetup camera, real totaltime, real smoothtime, boolean linear returns nothing
if smoothtime < 0 or totaltime < 0 then //Errors
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_NegativeTimeValue() )
endif
if (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
endif
return
elseif (smoothtime >= totaltime) then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_SmoothGreaterTotal() )
endif
return
endif
call DCCamSystem_SmoothTarget( CameraSetupGetDestPositionLoc( camera ), totaltime, smoothtime, linear )
call DCCamSystem_SmoothZOffset( CameraSetupGetField( camera, CAMERA_FIELD_ZOFFSET ), totaltime, smoothtime, linear )
call DCCamSystem_SmoothDistance( CameraSetupGetField( camera, CAMERA_FIELD_TARGET_DISTANCE ), totaltime, smoothtime, linear )
call DCCamSystem_SmoothFieldOfView( CameraSetupGetField( camera, CAMERA_FIELD_FIELD_OF_VIEW ), totaltime, smoothtime, linear )
call DCCamSystem_SmoothAngle( CameraSetupGetField( camera, CAMERA_FIELD_ANGLE_OF_ATTACK ), totaltime, smoothtime, linear )
call DCCamSystem_SmoothRotation( CameraSetupGetField( camera, CAMERA_FIELD_ROTATION ), totaltime, smoothtime, linear )
call DCCamSystem_SmoothRoll( CameraSetupGetField( camera, CAMERA_FIELD_ROLL ), totaltime, smoothtime, linear )
call SetCameraField( CAMERA_FIELD_FARZ, CameraSetupGetField( camera, CAMERA_FIELD_FARZ ), totaltime )
endfunction
function DCCamSystem_StopCam takes nothing returns nothing
local camerasetup currentcam = GetCurrentCameraSetup()
//Turn off any current acceleration
set udg_zz_DCCamSystem_TargetAccelOn = false
set udg_zz_DCCamSystem_ZOffAccelOn = false
set udg_zz_DCCamSystem_DistAccelOn = false
set udg_zz_DCCamSystem_FieldAccelOn = false
set udg_zz_DCCamSystem_AngleAccelOn = false
set udg_zz_DCCamSystem_RotaAccelOn = false
set udg_zz_DCCamSystem_RollAccelOn = false
//Reset speed variables
set udg_zz_DCCamSystem_TargetV = 0
set udg_zz_DCCamSystem_TargetDir = -1
set udg_zz_DCCamSystem_ZOffV = 0
set udg_zz_DCCamSystem_DistV = 0
set udg_zz_DCCamSystem_FieldV = 0
set udg_zz_DCCamSystem_AngleV = 0
set udg_zz_DCCamSystem_RotaV = 0
set udg_zz_DCCamSystem_RollV = 0
//Prevent timer events
call PauseTimer( udg_zz_DCCamSystem_StopTimer0 )
call PauseTimer( udg_zz_DCCamSystem_StopTimer1 )
call PauseTimer( udg_zz_DCCamSystem_StopTimer2 )
call PauseTimer( udg_zz_DCCamSystem_StopTimer3 )
call PauseTimer( udg_zz_DCCamSystem_StopTimer4 )
call PauseTimer( udg_zz_DCCamSystem_StopTimer5 )
call PauseTimer( udg_zz_DCCamSystem_StopTimer6 )
set udg_zz_DCCamSystem_ZOffSmooth2 = -1
set udg_zz_DCCamSystem_DistSmooth2 = -1
set udg_zz_DCCamSystem_FieldSmooth2 = -1
set udg_zz_DCCamSystem_AngleSmooth2 = -1
set udg_zz_DCCamSystem_RotaSmooth2 = -1
set udg_zz_DCCamSystem_RollSmooth2 = -1
//Stop Camera
call CameraSetupApply( currentcam, true, false )
set currentcam = null
endfunction
// The looping function that does every movement change for acceleration/braking
//------------------------------------------------------------------------------
function DCCamSystem_Loop takes nothing returns nothing
local real LastTargetV = udg_zz_DCCamSystem_TargetV
local real CamTargetX = GetCameraTargetPositionX()
local real CamTargetY = GetCameraTargetPositionY()
local real time
local real stoptimer
set udg_zz_DCCamSystem_Time = udg_zz_DCCamSystem_Time + DCCamSystem_LoopFrequence()
set udg_zz_DCCamSystem_CamTarIncorrect = false
//Movement direction corrections Camera Target
if udg_zz_DCCamSystem_TargetCurve then
if (DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2], udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2 + 1] )) < DCCamSystem_LoopFrequence() * udg_zz_DCCamSystem_TargetV then
loop
set udg_zz_DCCamSystem_CurveLevel = udg_zz_DCCamSystem_CurveLevel + 1
if udg_DCCamSystem_DebugModeOn then
call AddLightning( "CLSB", true, udg_zz_DCCamSystem_TargetPointsXY [ udg_zz_DCCamSystem_CurveLevel * 2 - 2 ], udg_zz_DCCamSystem_TargetPointsXY [ udg_zz_DCCamSystem_CurveLevel * 2 - 1 ], udg_zz_DCCamSystem_TargetPointsXY[ udg_zz_DCCamSystem_CurveLevel * 2 ], udg_zz_DCCamSystem_TargetPointsXY [ udg_zz_DCCamSystem_CurveLevel * 2 + 1 ] )
endif
exitwhen (DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2], udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2 + 1] ) > DCCamSystem_LoopFrequence() * udg_zz_DCCamSystem_TargetV) or (udg_zz_DCCamSystem_CurveFinalX == udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2] and udg_zz_DCCamSystem_CurveFinalY == udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2 + 1])
endloop
if udg_zz_DCCamSystem_CurveFinalX == udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2] and udg_zz_DCCamSystem_CurveFinalY == udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2 + 1] then
set udg_zz_DCCamSystem_TargetCurve = false
endif
set udg_zz_DCCamSystem_TargetDir = AngleBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2], udg_zz_DCCamSystem_TargetPointsXY[udg_zz_DCCamSystem_CurveLevel * 2 + 1] )
set udg_zz_DCCamSystem_TargetX = udg_zz_DCCamSystem_TargetPointsXY[ udg_zz_DCCamSystem_CurveLevel * 2 ]
set udg_zz_DCCamSystem_TargetY = udg_zz_DCCamSystem_TargetPointsXY[ udg_zz_DCCamSystem_CurveLevel * 2 + 1 ]
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / udg_zz_DCCamSystem_TargetV )
endif
endif
//Movement speed corrections Camera Target
if udg_zz_DCCamSystem_TargetAccelOn then
set time = udg_zz_DCCamSystem_Time - udg_zz_DCCamSystem_TargetAccelNull + DCCamSystem_LoopFrequence() / 2
if udg_zz_DCCamSystem_LinearTarget then
set udg_zz_DCCamSystem_TargetV = udg_zz_DCCamSystem_TargetFactor * time + udg_zz_DCCamSystem_TargetVBegin
if (( udg_zz_DCCamSystem_TargetVBegin < udg_zz_DCCamSystem_TargetVEnd ) and ( udg_zz_DCCamSystem_TargetV >= udg_zz_DCCamSystem_TargetVEnd )) or (( udg_zz_DCCamSystem_TargetVBegin > udg_zz_DCCamSystem_TargetVEnd ) and ( udg_zz_DCCamSystem_TargetV <= udg_zz_DCCamSystem_TargetVEnd )) then
if udg_zz_DCCamSystem_TargetVEnd != 0 then
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / udg_zz_DCCamSystem_TargetVEnd )
set udg_zz_DCCamSystem_TargetV = udg_zz_DCCamSystem_TargetVEnd
else
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / DCCamSystem_TargetMinSpeed() )
set udg_zz_DCCamSystem_TargetV = 0
endif
set udg_zz_DCCamSystem_TargetAccelOn = false
endif
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / udg_zz_DCCamSystem_TargetV )
else
if ( udg_zz_DCCamSystem_TargetV < udg_zz_DCCamSystem_TargetVEnd ) then
//Accellerating Movement
set udg_zz_DCCamSystem_TargetV = udg_zz_DCCamSystem_TargetFactor * SquareRoot( udg_zz_DCCamSystem_TargetVNullTime + time )
if udg_zz_DCCamSystem_TargetV > udg_zz_DCCamSystem_TargetVEnd then
set udg_zz_DCCamSystem_TargetV = udg_zz_DCCamSystem_TargetVEnd
set udg_zz_DCCamSystem_TargetAccelOn = false
endif
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / udg_zz_DCCamSystem_TargetV )
else
//Braking Movement
set udg_zz_DCCamSystem_TargetV = udg_zz_DCCamSystem_TargetFactor * SquareRoot( udg_zz_DCCamSystem_TargetVNullTime - time )
if udg_zz_DCCamSystem_TargetV <= udg_zz_DCCamSystem_TargetVEnd then
if udg_zz_DCCamSystem_TargetVEnd != 0 then
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / udg_zz_DCCamSystem_TargetVEnd )
set udg_zz_DCCamSystem_TargetV = udg_zz_DCCamSystem_TargetVEnd
else
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / DCCamSystem_TargetMinSpeed() )
set udg_zz_DCCamSystem_TargetV = 0
endif
set udg_zz_DCCamSystem_TargetAccelOn = false
else
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsXYXY( CamTargetX, CamTargetY, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / udg_zz_DCCamSystem_TargetV )
endif
endif
endif
endif
//Movement speed corrections ZOffset
if udg_zz_DCCamSystem_ZOffAccelOn then
set time = udg_zz_DCCamSystem_Time - udg_zz_DCCamSystem_ZOffAccelNull + DCCamSystem_LoopFrequence() / 2
if udg_zz_DCCamSystem_LinearZOffset then
set udg_zz_DCCamSystem_ZOffV = udg_zz_DCCamSystem_ZOffFactor * time + udg_zz_DCCamSystem_ZOffVBegin
if (( udg_zz_DCCamSystem_ZOffVBegin < udg_zz_DCCamSystem_ZOffVEnd ) and ( udg_zz_DCCamSystem_ZOffV >= udg_zz_DCCamSystem_ZOffVEnd )) or (( udg_zz_DCCamSystem_ZOffVBegin > udg_zz_DCCamSystem_ZOffVEnd ) and ( udg_zz_DCCamSystem_ZOffV <= udg_zz_DCCamSystem_ZOffVEnd )) then
if udg_zz_DCCamSystem_ZOffVEnd != 0 then
set udg_zz_DCCamSystem_ZOffV = udg_zz_DCCamSystem_ZOffVEnd
call SetCameraField( CAMERA_FIELD_ZOFFSET, udg_zz_DCCamSystem_ZOffTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_ZOFFSET) - udg_zz_DCCamSystem_ZOffTarget ) / udg_zz_DCCamSystem_ZOffVEnd ) )
else
call SetCameraField( CAMERA_FIELD_ZOFFSET, udg_zz_DCCamSystem_ZOffTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_ZOFFSET) - udg_zz_DCCamSystem_ZOffTarget ) / DCCamSystem_ZOffMinSpeed() ) )
set udg_zz_DCCamSystem_ZOffV = 0
endif
set udg_zz_DCCamSystem_ZOffAccelOn = false
else
call SetCameraField( CAMERA_FIELD_ZOFFSET, udg_zz_DCCamSystem_ZOffTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_ZOFFSET) - udg_zz_DCCamSystem_ZOffTarget ) / udg_zz_DCCamSystem_ZOffV ) )
endif
else
if ( RAbsBJ( udg_zz_DCCamSystem_ZOffV ) < RAbsBJ( udg_zz_DCCamSystem_ZOffVEnd ) ) then
//Accellerating Movement
set udg_zz_DCCamSystem_ZOffV = udg_zz_DCCamSystem_ZOffFactor * SquareRoot( udg_zz_DCCamSystem_ZOffVNullTime + time )
if RAbsBJ( udg_zz_DCCamSystem_ZOffV ) >= RAbsBJ( udg_zz_DCCamSystem_ZOffVEnd ) then
set udg_zz_DCCamSystem_ZOffV = udg_zz_DCCamSystem_ZOffVEnd
set udg_zz_DCCamSystem_ZOffAccelOn = false
endif
call SetCameraField( CAMERA_FIELD_ZOFFSET, udg_zz_DCCamSystem_ZOffTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_ZOFFSET) - udg_zz_DCCamSystem_ZOffTarget ) / udg_zz_DCCamSystem_ZOffV ) )
else
//Braking Movement
set udg_zz_DCCamSystem_ZOffV = udg_zz_DCCamSystem_ZOffFactor * SquareRoot( udg_zz_DCCamSystem_ZOffVNullTime - time )
if RAbsBJ( udg_zz_DCCamSystem_ZOffV ) <= RAbsBJ( udg_zz_DCCamSystem_ZOffVEnd ) then
if udg_zz_DCCamSystem_ZOffVEnd != 0 then
call SetCameraField( CAMERA_FIELD_ZOFFSET, udg_zz_DCCamSystem_ZOffTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_ZOFFSET) - udg_zz_DCCamSystem_ZOffTarget ) / udg_zz_DCCamSystem_ZOffVEnd ) )
set udg_zz_DCCamSystem_ZOffV = udg_zz_DCCamSystem_ZOffVEnd
else
call SetCameraField( CAMERA_FIELD_ZOFFSET, udg_zz_DCCamSystem_ZOffTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_ZOFFSET) - udg_zz_DCCamSystem_ZOffTarget ) / DCCamSystem_ZOffMinSpeed() ) )
set udg_zz_DCCamSystem_ZOffV = 0
endif
set udg_zz_DCCamSystem_ZOffAccelOn = false
else
//Acceleration/Decelleration not finished yet
call SetCameraField( CAMERA_FIELD_ZOFFSET, udg_zz_DCCamSystem_ZOffTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_ZOFFSET) - udg_zz_DCCamSystem_ZOffTarget ) / udg_zz_DCCamSystem_ZOffV ) )
endif
endif
endif
endif
//Movement speed corrections Target Distance
if udg_zz_DCCamSystem_DistAccelOn then
set time = udg_zz_DCCamSystem_Time - udg_zz_DCCamSystem_DistAccelNull + DCCamSystem_LoopFrequence() / 2
if udg_zz_DCCamSystem_LinearDistance then
set udg_zz_DCCamSystem_DistV = udg_zz_DCCamSystem_DistFactor * time + udg_zz_DCCamSystem_DistVBegin
if (( udg_zz_DCCamSystem_DistVBegin < udg_zz_DCCamSystem_DistVEnd ) and ( udg_zz_DCCamSystem_DistV >= udg_zz_DCCamSystem_DistVEnd )) or (( udg_zz_DCCamSystem_DistVBegin > udg_zz_DCCamSystem_DistVEnd ) and ( udg_zz_DCCamSystem_DistV <= udg_zz_DCCamSystem_DistVEnd )) then
if udg_zz_DCCamSystem_DistVEnd != 0 then
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_zz_DCCamSystem_DistTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - udg_zz_DCCamSystem_DistTarget ) / udg_zz_DCCamSystem_DistVEnd ) )
set udg_zz_DCCamSystem_DistV = udg_zz_DCCamSystem_DistVEnd
else
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_zz_DCCamSystem_DistTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - udg_zz_DCCamSystem_DistTarget ) / DCCamSystem_DistMinSpeed() ) )
set udg_zz_DCCamSystem_DistV = 0
endif
set udg_zz_DCCamSystem_DistAccelOn = false
else
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_zz_DCCamSystem_DistTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - udg_zz_DCCamSystem_DistTarget ) / udg_zz_DCCamSystem_DistV ) )
endif
else
if ( RAbsBJ( udg_zz_DCCamSystem_DistV ) < RAbsBJ( udg_zz_DCCamSystem_DistVEnd ) ) then
//Accellerating Movement
set udg_zz_DCCamSystem_DistV = udg_zz_DCCamSystem_DistFactor * SquareRoot( udg_zz_DCCamSystem_DistVNullTime + time )
if RAbsBJ( udg_zz_DCCamSystem_DistV ) >= RAbsBJ( udg_zz_DCCamSystem_DistVEnd ) then
set udg_zz_DCCamSystem_DistV = udg_zz_DCCamSystem_DistVEnd
set udg_zz_DCCamSystem_DistAccelOn = false
endif
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_zz_DCCamSystem_DistTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - udg_zz_DCCamSystem_DistTarget ) / udg_zz_DCCamSystem_DistV ) )
else
//Braking Movement
set udg_zz_DCCamSystem_DistV = udg_zz_DCCamSystem_DistFactor * SquareRoot( udg_zz_DCCamSystem_DistVNullTime - time )
if RAbsBJ( udg_zz_DCCamSystem_DistV ) <= RAbsBJ( udg_zz_DCCamSystem_DistVEnd ) then
if udg_zz_DCCamSystem_DistVEnd != 0 then
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_zz_DCCamSystem_DistTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - udg_zz_DCCamSystem_DistTarget ) / udg_zz_DCCamSystem_DistVEnd ) )
set udg_zz_DCCamSystem_DistV = udg_zz_DCCamSystem_DistVEnd
else
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_zz_DCCamSystem_DistTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - udg_zz_DCCamSystem_DistTarget ) / DCCamSystem_DistMinSpeed() ) )
set udg_zz_DCCamSystem_DistV = 0
endif
set udg_zz_DCCamSystem_DistAccelOn = false
else
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_zz_DCCamSystem_DistTarget, RAbsBJ( ( GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - udg_zz_DCCamSystem_DistTarget ) / udg_zz_DCCamSystem_DistV ) )
endif
endif
endif
endif
//Movement speed corrections Field Of View
if udg_zz_DCCamSystem_FieldAccelOn then
set time = udg_zz_DCCamSystem_Time - udg_zz_DCCamSystem_FieldAccelNull + DCCamSystem_LoopFrequence() / 2
if udg_zz_DCCamSystem_LinearField then
set udg_zz_DCCamSystem_FieldV = udg_zz_DCCamSystem_FieldFactor * time + udg_zz_DCCamSystem_FieldVBegin
if (( udg_zz_DCCamSystem_FieldVBegin < udg_zz_DCCamSystem_FieldVEnd ) and ( udg_zz_DCCamSystem_FieldV >= udg_zz_DCCamSystem_FieldVEnd )) or (( udg_zz_DCCamSystem_FieldVBegin > udg_zz_DCCamSystem_FieldVEnd ) and ( udg_zz_DCCamSystem_FieldV <= udg_zz_DCCamSystem_FieldVEnd )) then
if udg_zz_DCCamSystem_FieldVEnd != 0 then
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( udg_zz_DCCamSystem_FieldTarget ), RAbsBJ( ( GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) - udg_zz_DCCamSystem_FieldTarget ) / udg_zz_DCCamSystem_FieldVEnd ) )
set udg_zz_DCCamSystem_FieldV = udg_zz_DCCamSystem_FieldVEnd
else
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( udg_zz_DCCamSystem_FieldTarget ), RAbsBJ( ( GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) - udg_zz_DCCamSystem_FieldTarget ) / DCCamSystem_FieldMinSpeed() ) )
set udg_zz_DCCamSystem_FieldV = 0
endif
set udg_zz_DCCamSystem_FieldAccelOn = false
else
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( udg_zz_DCCamSystem_FieldTarget ), RAbsBJ( ( GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) - udg_zz_DCCamSystem_FieldTarget ) / udg_zz_DCCamSystem_FieldV ) )
endif
else
if ( RAbsBJ( udg_zz_DCCamSystem_FieldV ) < RAbsBJ( udg_zz_DCCamSystem_FieldVEnd ) ) then
//Accellerating Movement
set udg_zz_DCCamSystem_FieldV = udg_zz_DCCamSystem_FieldFactor * SquareRoot( udg_zz_DCCamSystem_FieldVNullTime + time )
if RAbsBJ( udg_zz_DCCamSystem_FieldV ) >= RAbsBJ( udg_zz_DCCamSystem_FieldVEnd ) then
set udg_zz_DCCamSystem_FieldV = udg_zz_DCCamSystem_FieldVEnd
set udg_zz_DCCamSystem_FieldAccelOn = false
endif
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( udg_zz_DCCamSystem_FieldTarget ), RAbsBJ( ( GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) - udg_zz_DCCamSystem_FieldTarget ) / udg_zz_DCCamSystem_FieldV ) )
else
//Braking Movement
set udg_zz_DCCamSystem_FieldV = udg_zz_DCCamSystem_FieldFactor * SquareRoot( udg_zz_DCCamSystem_FieldVNullTime - time )
if RAbsBJ( udg_zz_DCCamSystem_FieldV ) <= RAbsBJ( udg_zz_DCCamSystem_FieldVEnd ) then
if udg_zz_DCCamSystem_FieldVEnd != 0 then
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( udg_zz_DCCamSystem_FieldTarget ), RAbsBJ( ( GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW ) - udg_zz_DCCamSystem_FieldTarget ) / udg_zz_DCCamSystem_FieldVEnd ) )
set udg_zz_DCCamSystem_FieldV = udg_zz_DCCamSystem_FieldVEnd
else
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( udg_zz_DCCamSystem_FieldTarget ), RAbsBJ( ( GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW ) - udg_zz_DCCamSystem_FieldTarget ) / DCCamSystem_FieldMinSpeed() ) )
set udg_zz_DCCamSystem_FieldV = 0
endif
set udg_zz_DCCamSystem_FieldAccelOn = false
else
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, Rad2Deg( udg_zz_DCCamSystem_FieldTarget ), RAbsBJ( ( GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW ) - udg_zz_DCCamSystem_FieldTarget ) / udg_zz_DCCamSystem_FieldV ) )
endif
endif
endif
endif
//Movement speed corrections Angle Of Attack
if udg_zz_DCCamSystem_AngleAccelOn then
set time = udg_zz_DCCamSystem_Time - udg_zz_DCCamSystem_AngleAccelNull + DCCamSystem_LoopFrequence() / 2
if udg_zz_DCCamSystem_LinearAngle then
set udg_zz_DCCamSystem_AngleV = udg_zz_DCCamSystem_AngleFactor * time + udg_zz_DCCamSystem_AngleVBegin
if (( udg_zz_DCCamSystem_AngleVBegin < udg_zz_DCCamSystem_AngleVEnd ) and ( udg_zz_DCCamSystem_AngleV >= udg_zz_DCCamSystem_AngleVEnd )) or (( udg_zz_DCCamSystem_AngleVBegin > udg_zz_DCCamSystem_AngleVEnd ) and ( udg_zz_DCCamSystem_AngleV <= udg_zz_DCCamSystem_AngleVEnd )) then
if udg_zz_DCCamSystem_AngleVEnd != 0 then
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( udg_zz_DCCamSystem_AngleTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), udg_zz_DCCamSystem_AngleTarget ) / udg_zz_DCCamSystem_AngleVEnd ) )
set udg_zz_DCCamSystem_AngleV = udg_zz_DCCamSystem_AngleVEnd
else
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( udg_zz_DCCamSystem_AngleTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), udg_zz_DCCamSystem_AngleTarget ) / DCCamSystem_AngleMinSpeed() ) )
set udg_zz_DCCamSystem_AngleV = 0
endif
set udg_zz_DCCamSystem_AngleAccelOn = false
else
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( udg_zz_DCCamSystem_AngleTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), udg_zz_DCCamSystem_AngleTarget ) / udg_zz_DCCamSystem_AngleV ) )
endif
else
if ( RAbsBJ( udg_zz_DCCamSystem_AngleV ) < RAbsBJ( udg_zz_DCCamSystem_AngleVEnd ) ) then
//Accellerating Movement
set udg_zz_DCCamSystem_AngleV = udg_zz_DCCamSystem_AngleFactor * SquareRoot( udg_zz_DCCamSystem_AngleVNullTime + time )
if RAbsBJ( udg_zz_DCCamSystem_AngleV ) >= RAbsBJ( udg_zz_DCCamSystem_AngleVEnd ) then
set udg_zz_DCCamSystem_AngleV = udg_zz_DCCamSystem_AngleVEnd
set udg_zz_DCCamSystem_AngleAccelOn = false
endif
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( udg_zz_DCCamSystem_AngleTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), udg_zz_DCCamSystem_AngleTarget ) / udg_zz_DCCamSystem_AngleV ) )
else
//Braking Movement
set udg_zz_DCCamSystem_AngleV = udg_zz_DCCamSystem_AngleFactor * SquareRoot( udg_zz_DCCamSystem_AngleVNullTime - time )
if RAbsBJ( udg_zz_DCCamSystem_AngleV ) <= RAbsBJ( udg_zz_DCCamSystem_AngleVEnd ) then
if udg_zz_DCCamSystem_AngleVEnd != 0 then
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( udg_zz_DCCamSystem_AngleTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), udg_zz_DCCamSystem_AngleTarget ) / udg_zz_DCCamSystem_AngleVEnd ) )
set udg_zz_DCCamSystem_AngleV = udg_zz_DCCamSystem_AngleVEnd
else
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( udg_zz_DCCamSystem_AngleTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), udg_zz_DCCamSystem_AngleTarget ) / DCCamSystem_AngleMinSpeed() ) )
set udg_zz_DCCamSystem_AngleV = 0
endif
set udg_zz_DCCamSystem_AngleAccelOn = false
else
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, Rad2Deg( udg_zz_DCCamSystem_AngleTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), udg_zz_DCCamSystem_AngleTarget ) / udg_zz_DCCamSystem_AngleV ) )
endif
endif
endif
endif
//Movement speed corrections Rotation
if udg_zz_DCCamSystem_RotaAccelOn then
set time = udg_zz_DCCamSystem_Time - udg_zz_DCCamSystem_RotaAccelNull + DCCamSystem_LoopFrequence() / 2
if udg_zz_DCCamSystem_LinearRotation then
set udg_zz_DCCamSystem_RotaV = udg_zz_DCCamSystem_RotaFactor * time + udg_zz_DCCamSystem_RotaVBegin
if (( udg_zz_DCCamSystem_RotaVBegin < udg_zz_DCCamSystem_RotaVEnd ) and ( udg_zz_DCCamSystem_RotaV >= udg_zz_DCCamSystem_RotaVEnd )) or (( udg_zz_DCCamSystem_RotaVBegin > udg_zz_DCCamSystem_RotaVEnd ) and ( udg_zz_DCCamSystem_RotaV <= udg_zz_DCCamSystem_RotaVEnd )) then
if udg_zz_DCCamSystem_RotaVEnd != 0 then
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( udg_zz_DCCamSystem_RotaTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), udg_zz_DCCamSystem_RotaTarget ) / udg_zz_DCCamSystem_RotaVEnd ) )
set udg_zz_DCCamSystem_RotaV = udg_zz_DCCamSystem_RotaVEnd
else
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( udg_zz_DCCamSystem_RotaTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), udg_zz_DCCamSystem_RotaTarget ) / DCCamSystem_RotaMinSpeed() ) )
set udg_zz_DCCamSystem_RotaV = 0
endif
set udg_zz_DCCamSystem_RotaAccelOn = false
else
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( udg_zz_DCCamSystem_RotaTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), udg_zz_DCCamSystem_RotaTarget ) / udg_zz_DCCamSystem_RotaV ) )
endif
else
if ( RAbsBJ( udg_zz_DCCamSystem_RotaV ) < RAbsBJ( udg_zz_DCCamSystem_RotaVEnd ) ) then
//Accellerating Movement
set udg_zz_DCCamSystem_RotaV = udg_zz_DCCamSystem_RotaFactor * SquareRoot( udg_zz_DCCamSystem_RotaVNullTime + time )
if RAbsBJ( udg_zz_DCCamSystem_RotaV ) >= RAbsBJ( udg_zz_DCCamSystem_RotaVEnd ) then
set udg_zz_DCCamSystem_RotaV = udg_zz_DCCamSystem_RotaVEnd
set udg_zz_DCCamSystem_RotaAccelOn = false
endif
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( udg_zz_DCCamSystem_RotaTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), udg_zz_DCCamSystem_RotaTarget ) / udg_zz_DCCamSystem_RotaV ) )
else
//Braking Movement
set udg_zz_DCCamSystem_RotaV = udg_zz_DCCamSystem_RotaFactor * SquareRoot( udg_zz_DCCamSystem_RotaVNullTime - time )
if RAbsBJ( udg_zz_DCCamSystem_RotaV ) <= RAbsBJ( udg_zz_DCCamSystem_RotaVEnd ) then
if udg_zz_DCCamSystem_RotaVEnd != 0 then
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( udg_zz_DCCamSystem_RotaTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), udg_zz_DCCamSystem_RotaTarget ) / udg_zz_DCCamSystem_RotaVEnd ) )
set udg_zz_DCCamSystem_RotaV = udg_zz_DCCamSystem_RotaVEnd
else
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( udg_zz_DCCamSystem_RotaTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), udg_zz_DCCamSystem_RotaTarget ) / DCCamSystem_RotaMinSpeed() ) )
set udg_zz_DCCamSystem_RotaV = 0
endif
set udg_zz_DCCamSystem_RotaAccelOn = false
else
call SetCameraField( CAMERA_FIELD_ROTATION, Rad2Deg( udg_zz_DCCamSystem_RotaTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), udg_zz_DCCamSystem_RotaTarget ) / udg_zz_DCCamSystem_RotaV ) )
endif
endif
endif
endif
//Movement speed corrections Roll
if udg_zz_DCCamSystem_RollAccelOn then
set time = udg_zz_DCCamSystem_Time - udg_zz_DCCamSystem_RollAccelNull + DCCamSystem_LoopFrequence() / 2
if udg_zz_DCCamSystem_LinearRoll then
set udg_zz_DCCamSystem_RollV = udg_zz_DCCamSystem_RollFactor * time + udg_zz_DCCamSystem_RollVBegin
if (( udg_zz_DCCamSystem_RollVBegin < udg_zz_DCCamSystem_RollVEnd ) and ( udg_zz_DCCamSystem_RollV >= udg_zz_DCCamSystem_RollVEnd )) or (( udg_zz_DCCamSystem_RollVBegin > udg_zz_DCCamSystem_RollVEnd ) and ( udg_zz_DCCamSystem_RollV <= udg_zz_DCCamSystem_RollVEnd )) then
if udg_zz_DCCamSystem_RollVEnd != 0 then
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( udg_zz_DCCamSystem_RollTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), udg_zz_DCCamSystem_RollTarget ) / udg_zz_DCCamSystem_RollVEnd ) )
set udg_zz_DCCamSystem_RollV = udg_zz_DCCamSystem_RollVEnd
else
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( udg_zz_DCCamSystem_RollTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), udg_zz_DCCamSystem_RollTarget ) / DCCamSystem_RollMinSpeed() ) )
set udg_zz_DCCamSystem_RollV = 0
endif
set udg_zz_DCCamSystem_RollAccelOn = false
else
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( udg_zz_DCCamSystem_RollTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), udg_zz_DCCamSystem_RollTarget ) / udg_zz_DCCamSystem_RollV ) )
endif
else
if ( RAbsBJ( udg_zz_DCCamSystem_RollV ) < RAbsBJ( udg_zz_DCCamSystem_RollVEnd ) ) then
//Accellerating Movement
set udg_zz_DCCamSystem_RollV = udg_zz_DCCamSystem_RollFactor * SquareRoot( udg_zz_DCCamSystem_RollVNullTime + time )
if RAbsBJ( udg_zz_DCCamSystem_RollV ) >= RAbsBJ( udg_zz_DCCamSystem_RollVEnd ) then
set udg_zz_DCCamSystem_RollV = udg_zz_DCCamSystem_RollVEnd
set udg_zz_DCCamSystem_RollAccelOn = false
endif
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( udg_zz_DCCamSystem_RollTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), udg_zz_DCCamSystem_RollTarget ) / udg_zz_DCCamSystem_RollV ) )
else
//Braking Movement
set udg_zz_DCCamSystem_RollV = udg_zz_DCCamSystem_RollFactor * SquareRoot( udg_zz_DCCamSystem_RollVNullTime - time )
if RAbsBJ( udg_zz_DCCamSystem_RollV ) <= RAbsBJ( udg_zz_DCCamSystem_RollVEnd ) then
if udg_zz_DCCamSystem_RollVEnd != 0 then
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( udg_zz_DCCamSystem_RollTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), udg_zz_DCCamSystem_RollTarget ) / udg_zz_DCCamSystem_RollVEnd ) )
set udg_zz_DCCamSystem_RollV = udg_zz_DCCamSystem_RollVEnd
else
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( udg_zz_DCCamSystem_RollTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), udg_zz_DCCamSystem_RollTarget ) / DCCamSystem_RollMinSpeed() ) )
set udg_zz_DCCamSystem_RollV = 0
endif
set udg_zz_DCCamSystem_RollAccelOn = false
else
call SetCameraField( CAMERA_FIELD_ROLL, Rad2Deg( udg_zz_DCCamSystem_RollTarget ), RAbsBJ( DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), udg_zz_DCCamSystem_RollTarget ) / udg_zz_DCCamSystem_RollV ) )
endif
endif
endif
endif
set stoptimer = TimerGetRemaining( udg_zz_DCCamSystem_CamStop )
if stoptimer > 0 then
if udg_zz_DCCamSystem_LinearTarget then
//Check if braking for other aspects should be started: Target
if udg_zz_DCCamSystem_StopPoint0 and DCCamSystem_CurveDistance( CameraSetupGetDestPositionX( udg_zz_DCCamSystem_StopCam ), CameraSetupGetDestPositionY( udg_zz_DCCamSystem_StopCam ) ) / udg_zz_DCCamSystem_TargetV * 2 <= stoptimer then
call DCCamSystem_BrakeTargetPoint( CameraSetupGetDestPositionLoc( udg_zz_DCCamSystem_StopCam ), udg_zz_DCCamSystem_LinearTarget )
set udg_zz_DCCamSystem_StopPoint0 = false
endif
//ZOffset
if udg_zz_DCCamSystem_StopPoint1 and RAbsBJ( (GetCameraField(CAMERA_FIELD_ZOFFSET) - CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ZOFFSET )) / udg_zz_DCCamSystem_ZOffV * 2 ) <= stoptimer then
call DCCamSystem_BrakeZOffsetPoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ZOFFSET ), udg_zz_DCCamSystem_LinearZOffset )
set udg_zz_DCCamSystem_StopPoint1 = false
endif
//Distance
if udg_zz_DCCamSystem_StopPoint2 and RAbsBJ( (GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_TARGET_DISTANCE )) / udg_zz_DCCamSystem_DistV * 2 ) <= stoptimer then
call DCCamSystem_BrakeDistancePoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_TARGET_DISTANCE ), udg_zz_DCCamSystem_LinearZOffset )
set udg_zz_DCCamSystem_StopPoint2 = false
endif
//Field of view
if udg_zz_DCCamSystem_StopPoint3 and RAbsBJ( (GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) - CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_FIELD_OF_VIEW )) / udg_zz_DCCamSystem_FieldV * 2 ) <= stoptimer then
call DCCamSystem_BrakeFieldOfViewPoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_FIELD_OF_VIEW ), udg_zz_DCCamSystem_LinearField )
set udg_zz_DCCamSystem_StopPoint3 = false
endif
//Angle of Attack
if udg_zz_DCCamSystem_StopPoint4 and DistanceBetweenAnglesRad( GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ), Deg2Rad( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ANGLE_OF_ATTACK ) ) ) / udg_zz_DCCamSystem_AngleV * 2 <= stoptimer then
call DCCamSystem_BrakeAnglePoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ANGLE_OF_ATTACK ), udg_zz_DCCamSystem_LinearAngle )
set udg_zz_DCCamSystem_StopPoint4 = false
endif
//Rotation
if udg_zz_DCCamSystem_StopPoint5 and DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), Deg2Rad( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ROTATION ) ) ) / udg_zz_DCCamSystem_RotaV * 2 <= stoptimer then
call DCCamSystem_BrakeRotationPoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ROTATION ), udg_zz_DCCamSystem_LinearRotation )
set udg_zz_DCCamSystem_StopPoint5 = false
endif
//Roll
if udg_zz_DCCamSystem_StopPoint6 and DistanceBetweenAnglesRad(GetCameraField(CAMERA_FIELD_ROLL), Deg2Rad( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ROLL ) ) ) / udg_zz_DCCamSystem_RollV * 2 <= stoptimer then
call DCCamSystem_BrakeRollPoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ROLL ), udg_zz_DCCamSystem_LinearRoll )
set udg_zz_DCCamSystem_StopPoint6 = false
endif
else
//Check if braking for other aspects should be started: Target
if udg_zz_DCCamSystem_StopPoint0 and DCCamSystem_CurveDistance( CameraSetupGetDestPositionX( udg_zz_DCCamSystem_StopCam ), CameraSetupGetDestPositionY( udg_zz_DCCamSystem_StopCam ) ) * 3 / udg_zz_DCCamSystem_TargetV / 2 <= stoptimer then
call DCCamSystem_BrakeTargetPoint( CameraSetupGetDestPositionLoc( udg_zz_DCCamSystem_StopCam ), udg_zz_DCCamSystem_LinearTarget )
set udg_zz_DCCamSystem_StopPoint0 = false
endif
//ZOffset
if udg_zz_DCCamSystem_StopPoint1 and RAbsBJ( (GetCameraField(CAMERA_FIELD_ZOFFSET) - CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ZOFFSET )) * 3 / udg_zz_DCCamSystem_ZOffV / 2 ) <= stoptimer then
call DCCamSystem_BrakeZOffsetPoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ZOFFSET ), udg_zz_DCCamSystem_LinearZOffset )
set udg_zz_DCCamSystem_StopPoint1 = false
endif
//Distance
if udg_zz_DCCamSystem_StopPoint2 and RAbsBJ( (GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) - CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_TARGET_DISTANCE )) * 3 / udg_zz_DCCamSystem_DistV / 2 ) <= stoptimer then
call DCCamSystem_BrakeDistancePoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_TARGET_DISTANCE ), udg_zz_DCCamSystem_LinearDistance )
set udg_zz_DCCamSystem_StopPoint2 = false
endif
//Field of view
if udg_zz_DCCamSystem_StopPoint3 and RAbsBJ( (GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) - CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_FIELD_OF_VIEW )) * 3 / udg_zz_DCCamSystem_FieldV / 2 ) <= stoptimer then
call DCCamSystem_BrakeFieldOfViewPoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_FIELD_OF_VIEW ), udg_zz_DCCamSystem_LinearField )
set udg_zz_DCCamSystem_StopPoint3 = false
endif
//Angle of Attack
if udg_zz_DCCamSystem_StopPoint4 and DistanceBetweenAnglesRad(GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), Deg2Rad( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ANGLE_OF_ATTACK ) ) ) * 3 / udg_zz_DCCamSystem_AngleV / 2 <= stoptimer then
call DCCamSystem_BrakeAnglePoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ANGLE_OF_ATTACK ), udg_zz_DCCamSystem_LinearAngle )
set udg_zz_DCCamSystem_StopPoint4 = false
endif
//Rotation
if udg_zz_DCCamSystem_StopPoint5 and DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROTATION), Deg2Rad( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ROTATION ) ) ) * 3 / udg_zz_DCCamSystem_RotaV / 2 <= stoptimer then
call DCCamSystem_BrakeRotationPoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ROTATION ), udg_zz_DCCamSystem_LinearRotation )
set udg_zz_DCCamSystem_StopPoint5 = false
endif
//Roll
if udg_zz_DCCamSystem_StopPoint6 and DistanceBetweenAnglesRad( GetCameraField(CAMERA_FIELD_ROLL), Deg2Rad( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ROLL ) ) ) * 3 / udg_zz_DCCamSystem_RollV / 2 <= stoptimer then
call DCCamSystem_BrakeRollPoint( CameraSetupGetField( udg_zz_DCCamSystem_StopCam, CAMERA_FIELD_ROLL ), udg_zz_DCCamSystem_LinearRoll )
set udg_zz_DCCamSystem_StopPoint6 = false
endif
endif
endif
endfunction
// Change Direction of Movement Functions
//---------------------------------------
function DCCamSystem_DirChangeZOffset takes nothing returns nothing //DirectionChangeTrigger Index 1
set udg_zz_DCCamSystem_ZOffV = 0
call DCCamSystem_SmoothZOffset( udg_zz_DCCamSystem_ZOffTarget2, udg_zz_DCCamSystem_ZOffTotal2, udg_zz_DCCamSystem_ZOffSmooth2, udg_zz_DCCamSystem_LinearZOffset )
endfunction
function DCCamSystem_DirChangeDistance takes nothing returns nothing //DirectionChangeTrigger Index 2
set udg_zz_DCCamSystem_DistV = 0
call DCCamSystem_SmoothDistance( udg_zz_DCCamSystem_DistTarget2, udg_zz_DCCamSystem_DistTotal2, udg_zz_DCCamSystem_DistSmooth2, udg_zz_DCCamSystem_LinearDistance )
endfunction
function DCCamSystem_DirChangeFieldOfView takes nothing returns nothing //DirectionChangeTrigger Index 3
set udg_zz_DCCamSystem_FieldV = 0
call DCCamSystem_SmoothFieldOfView( udg_zz_DCCamSystem_FieldTarget2, udg_zz_DCCamSystem_FieldTotal2, udg_zz_DCCamSystem_FieldSmooth2, udg_zz_DCCamSystem_LinearField )
endfunction
function DCCamSystem_DirChangeAngle takes nothing returns nothing //DirectionChangeTrigger Index 4
set udg_zz_DCCamSystem_AngleV = 0
call DCCamSystem_SmoothAngle( udg_zz_DCCamSystem_AngleTarget2, udg_zz_DCCamSystem_AngleTotal2, udg_zz_DCCamSystem_AngleSmooth2, udg_zz_DCCamSystem_LinearAngle )
endfunction
function DCCamSystem_DirChangeRotation takes nothing returns nothing //DirectionChangeTrigger Index 5
set udg_zz_DCCamSystem_RotaV = 0
call DCCamSystem_SmoothRotation( udg_zz_DCCamSystem_RotaTarget2, udg_zz_DCCamSystem_RotaTotal2, udg_zz_DCCamSystem_RotaSmooth2, udg_zz_DCCamSystem_LinearRotation )
endfunction
function DCCamSystem_DirChangeRoll takes nothing returns nothing //DirectionChangeTrigger Index 6
set udg_zz_DCCamSystem_RollV = 0
call DCCamSystem_SmoothRoll( udg_zz_DCCamSystem_RollTarget2, udg_zz_DCCamSystem_RollTotal2, udg_zz_DCCamSystem_RollSmooth2, udg_zz_DCCamSystem_LinearRoll )
endfunction
// Camera System initialization Function
//--------------------------------------
function DCCamSystem_Init takes nothing returns nothing
local integer i = 0
//Local Player Variable
set udg_zz_DCCamSystem_LocalPlayer = GetLocalPlayer()
//Initialize Main Loop
set udg_zz_DCCamSystem_Loop = CreateTrigger( )
call TriggerRegisterTimerEvent( udg_zz_DCCamSystem_Loop, DCCamSystem_LoopFrequence(), true )
call TriggerAddAction( udg_zz_DCCamSystem_Loop, function DCCamSystem_Loop )
endfunction
// Useful Additional Functions
//----------------------------
function DCCamSystem_RadiusPointAnglePoint takes location start, real startangle, location target returns real
local real startx = GetLocationX( start )
local real starty = GetLocationY( start )
local real targetx = GetLocationX( target )
local real targety = GetLocationY( target )
local real angleST = Atan2(targety - starty, targetx - startx)
local real distance = DistanceBetweenPointsXYXY( startx, starty, targetx, targety )
local real middlex = ( startx + targetx) / 2
local real middley = ( starty + targety) / 2
local real radiuslength
local real radiusangle
if distance == 0 then
if udg_DCCamSystem_DebugModeOn then
call DisplayTextToPlayer( udg_zz_DCCamSystem_LocalPlayer, 0, 0, DCCamSystem_Error() + DCCamSystem_ErrorTargetCurve() )
endif
return 0.5
endif
set startangle = Deg2Rad(startangle)
if DistanceBetweenAnglesRad( startangle, angleST ) < 0 then
set radiusangle = startangle - bj_PI / 2
else
set radiusangle = startangle + bj_PI / 2
endif
set radiuslength = SquareRoot((startx - middlex) * (startx - middlex) + (starty - middley) * (starty - middley)) / Cos( angleST - radiusangle )
return radiuslength / distance * 1.70
endfunction
function DCCamSystem_CurveSway takes location start, real startdegrees, location target, real time returns nothing
local real reserve = udg_DCCamSystem_CurveRadius
local real startx = GetLocationX( start )
local real starty = GetLocationY( start )
call SetCameraPosition( startx, starty )
set udg_zz_DCCamSystem_CamTarIncorrect = true
set udg_zz_DCCamSystem_TargetReserveX = startx
set udg_zz_DCCamSystem_TargetReserveY = starty
set udg_zz_DCCamSystem_TargetDir = startdegrees
set udg_DCCamSystem_CurveRadius = DCCamSystem_RadiusPointAnglePoint( start, startdegrees, target )
set udg_zz_DCCamSystem_TargetV = DCCamSystem_TargetCurve( GetLocationX( target ), GetLocationY( target ) ) / time
call PanCameraToTimed( udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY, DistanceBetweenPointsLocXY( start, udg_zz_DCCamSystem_TargetX, udg_zz_DCCamSystem_TargetY ) / udg_zz_DCCamSystem_TargetV )
set udg_DCCamSystem_CurveRadius = reserve
endfunction
Name | Type | is_array | initial_value |
DCCamSystem_CurveRadius | real | No | |
DCCamSystem_DebugModeOn | boolean | No | |
KillEffects | effect | Yes | |
NextTrigger | timer | No | |
RunningTrigger | trigger | No | |
zz_DCCamSystem_AngleAccelNull | real | No | |
zz_DCCamSystem_AngleAccelOn | boolean | No | |
zz_DCCamSystem_AngleAccelTime | real | No | |
zz_DCCamSystem_AngleFactor | real | No | |
zz_DCCamSystem_AngleSmooth2 | real | No | |
zz_DCCamSystem_AngleTarget | real | No | |
zz_DCCamSystem_AngleTarget2 | real | No | |
zz_DCCamSystem_AngleTotal2 | real | No | |
zz_DCCamSystem_AngleV | real | No | |
zz_DCCamSystem_AngleVBegin | real | No | |
zz_DCCamSystem_AngleVEnd | real | No | |
zz_DCCamSystem_AngleVNullTime | real | No | |
zz_DCCamSystem_CamStop | timer | No | |
zz_DCCamSystem_CamTarIncorrect | boolean | No | |
zz_DCCamSystem_CurveFinalX | real | No | |
zz_DCCamSystem_CurveFinalY | real | No | |
zz_DCCamSystem_CurveLevel | integer | No | |
zz_DCCamSystem_DirChange1 | timer | No | |
zz_DCCamSystem_DirChange2 | timer | No | |
zz_DCCamSystem_DirChange3 | timer | No | |
zz_DCCamSystem_DirChange4 | timer | No | |
zz_DCCamSystem_DirChange5 | timer | No | |
zz_DCCamSystem_DirChange6 | timer | No | |
zz_DCCamSystem_DistAccelNull | real | No | |
zz_DCCamSystem_DistAccelOn | boolean | No | |
zz_DCCamSystem_DistAccelTime | real | No | |
zz_DCCamSystem_DistFactor | real | No | |
zz_DCCamSystem_DistSmooth2 | real | No | |
zz_DCCamSystem_DistTarget | real | No | |
zz_DCCamSystem_DistTarget2 | real | No | |
zz_DCCamSystem_DistTotal2 | real | No | |
zz_DCCamSystem_DistV | real | No | |
zz_DCCamSystem_DistVBegin | real | No | |
zz_DCCamSystem_DistVEnd | real | No | |
zz_DCCamSystem_DistVNullTime | real | No | |
zz_DCCamSystem_FieldAccelNull | real | No | |
zz_DCCamSystem_FieldAccelOn | boolean | No | |
zz_DCCamSystem_FieldAccelTime | real | No | |
zz_DCCamSystem_FieldFactor | real | No | |
zz_DCCamSystem_FieldSmooth2 | real | No | |
zz_DCCamSystem_FieldTarget | real | No | |
zz_DCCamSystem_FieldTarget2 | real | No | |
zz_DCCamSystem_FieldTotal2 | real | No | |
zz_DCCamSystem_FieldV | real | No | |
zz_DCCamSystem_FieldVBegin | real | No | |
zz_DCCamSystem_FieldVEnd | real | No | |
zz_DCCamSystem_FieldVNullTime | real | No | |
zz_DCCamSystem_LinearAngle | boolean | No | |
zz_DCCamSystem_LinearDistance | boolean | No | |
zz_DCCamSystem_LinearField | boolean | No | |
zz_DCCamSystem_LinearRoll | boolean | No | |
zz_DCCamSystem_LinearRotation | boolean | No | |
zz_DCCamSystem_LinearTarget | boolean | No | |
zz_DCCamSystem_LinearZOffset | boolean | No | |
zz_DCCamSystem_LocalPlayer | player | No | |
zz_DCCamSystem_LongAngleSway4 | timer | No | |
zz_DCCamSystem_LongAngleSway5 | timer | No | |
zz_DCCamSystem_LongAngleSway6 | timer | No | |
zz_DCCamSystem_Loop | trigger | No | |
zz_DCCamSystem_RollAccelNull | real | No | |
zz_DCCamSystem_RollAccelOn | boolean | No | |
zz_DCCamSystem_RollAccelTime | real | No | |
zz_DCCamSystem_RollFactor | real | No | |
zz_DCCamSystem_RollSmooth2 | real | No | |
zz_DCCamSystem_RollTarget | real | No | |
zz_DCCamSystem_RollTarget2 | real | No | |
zz_DCCamSystem_RollTotal2 | real | No | |
zz_DCCamSystem_RollV | real | No | |
zz_DCCamSystem_RollVBegin | real | No | |
zz_DCCamSystem_RollVEnd | real | No | |
zz_DCCamSystem_RollVNullTime | real | No | |
zz_DCCamSystem_RotaAccelNull | real | No | |
zz_DCCamSystem_RotaAccelOn | boolean | No | |
zz_DCCamSystem_RotaAccelTime | real | No | |
zz_DCCamSystem_RotaFactor | real | No | |
zz_DCCamSystem_RotaSmooth2 | real | No | |
zz_DCCamSystem_RotaTarget | real | No | |
zz_DCCamSystem_RotaTarget2 | real | No | |
zz_DCCamSystem_RotaTotal2 | real | No | |
zz_DCCamSystem_RotaV | real | No | |
zz_DCCamSystem_RotaVBegin | real | No | |
zz_DCCamSystem_RotaVEnd | real | No | |
zz_DCCamSystem_RotaVNullTime | real | No | |
zz_DCCamSystem_StopCam | camerasetup | No | |
zz_DCCamSystem_StopPoint0 | boolean | No | |
zz_DCCamSystem_StopPoint1 | boolean | No | |
zz_DCCamSystem_StopPoint2 | boolean | No | |
zz_DCCamSystem_StopPoint3 | boolean | No | |
zz_DCCamSystem_StopPoint4 | boolean | No | |
zz_DCCamSystem_StopPoint5 | boolean | No | |
zz_DCCamSystem_StopPoint6 | boolean | No | |
zz_DCCamSystem_StopTimer0 | timer | No | |
zz_DCCamSystem_StopTimer1 | timer | No | |
zz_DCCamSystem_StopTimer2 | timer | No | |
zz_DCCamSystem_StopTimer3 | timer | No | |
zz_DCCamSystem_StopTimer4 | timer | No | |
zz_DCCamSystem_StopTimer5 | timer | No | |
zz_DCCamSystem_StopTimer6 | timer | No | |
zz_DCCamSystem_TargetAccelNull | real | No | |
zz_DCCamSystem_TargetAccelOn | boolean | No | |
zz_DCCamSystem_TargetAccelTime | real | No | |
zz_DCCamSystem_TargetCurve | boolean | No | |
zz_DCCamSystem_TargetDir | real | No | |
zz_DCCamSystem_TargetFactor | real | No | |
zz_DCCamSystem_TargetPointsXY | real | Yes | |
zz_DCCamSystem_TargetReserveX | real | No | |
zz_DCCamSystem_TargetReserveY | real | No | |
zz_DCCamSystem_TargetV | real | No | |
zz_DCCamSystem_TargetVBegin | real | No | |
zz_DCCamSystem_TargetVEnd | real | No | |
zz_DCCamSystem_TargetVNullTime | real | No | |
zz_DCCamSystem_TargetX | real | No | |
zz_DCCamSystem_TargetY | real | No | |
zz_DCCamSystem_Time | real | No | |
zz_DCCamSystem_ZOffAccelNull | real | No | |
zz_DCCamSystem_ZOffAccelOn | boolean | No | |
zz_DCCamSystem_ZOffAccelTime | real | No | |
zz_DCCamSystem_ZOffFactor | real | No | |
zz_DCCamSystem_ZOffSmooth2 | real | No | |
zz_DCCamSystem_ZOffTarget | real | No | |
zz_DCCamSystem_ZOffTarget2 | real | No | |
zz_DCCamSystem_ZOffTotal2 | real | No | |
zz_DCCamSystem_ZOffV | real | No | |
zz_DCCamSystem_ZOffVBegin | real | No | |
zz_DCCamSystem_ZOffVEnd | real | No | |
zz_DCCamSystem_ZOffVNullTime | real | No |