Moderator
M
Moderator
Camera Lock System v2.5.0.1 | Reviewed by Maker | 27th Sep 2013 | ||||
APPROVED | ||||
|
// Camera Lock System by deathismyfriend
// version 2.5.0.1
// This system can lock and unlock to the players hero whenever you want it to.
// This system allows players to have control or for you to have control on if they can lock or unlock from their hero.
// This allows players to invert the up and down actions with a string you can modify.
// This allows players to invert the left and right actions with a string you can modify.
// This allows you to control the speed of the camera movements. ( basically the loop event time.)
// The rotation value ( left / right) and the distance value ( up / down)
// You can set an x/y offset which locks the camera to the players unit offset by coordinate values.
// Function List and Explanation
//
// Custom script: call HeroCamForceLockForPlayer( player)
// This function forces a players camera to lock onto their unit.
// If you want 1 or more players cameras to be locked you need to first call the enable partial control function first.
// You also need to register which players have control and which don't using the respective function call.
// They are set to let the players have control in the beginning.
// Then you set the players that you want to be locked using this function
// If the map creator has full control then they can simply call these
// the other function to register the players in control is not needed.
//
//
// Custom script: call HeroCamForceLockForAll()
// This function forces all of the players cameras to lock onto their units.
// When using this you must first disable partial control if it isn't already disabled.
// Then call this function to force the same option for all players.
// If the map creator has full control then they can simply call these
// the other function to register the players in control is not needed.
//
//
// Custom script: call HeroCamForceUnLockForPlayer( player)
// This function forces a players camera to unlock onto their unit.
// If you want 1 or more players cameras to be unlocked you need to first call the enable partial control function first.
// You also need to register which players have control and which don't using the respective function call.
// They are set to let the players have control in the beginning.
// Then you set the players that you want to be unlocked using this function
// If the map creator has full control then they can simply call these
// the other function to register the players in control is not needed.
//
//
// Custom script: call HeroCamForceUnLockForAll()
// This function forces all of the players cameras to un-lock from their units.
// When using this you must first disable partial control if it isn't already disabled.
// Then call this function to force the same option for all players.
// If the map creator has full control then they can simply call these
// the other function to register the players in control is not needed.
//
//
// Custom script: call HeroCamEnablePlayerControl( player)
// This function lets you determine which players are in controll of their cameras.
//
//
// Custom script: call HeroCamDisablePlayerControl( player)
// This function lets you determine which players are not in controll of their cameras.
//
//
// Custom script: call HeroCamEnablePartialControl()
// This function enables partial control of players camers. This can be used if you want to lock or unlock certain players cameras.
//
//
// Custom script: call HeroCamDisablePartialControl()
// This function disables partial control of players cameras.
// After disabling you must change the heroCamSysPlayerControl to the option you want.
//
//
// Custom script: set udg_tempBoolean = GetHeroCamPlayerInControl( player)
// This function tells you if a player is in control of their locking and unlocking of their cameras.
// You return a boolean so you use tempBoolean = then the function call.
// This can be used before an ITE and then the boolean used in the condition.
//
//
// Custom script: call HeroCamChangeHeightForPlayer( player, height, duration)
// height and duration are both real variables.
// duration determines the speed at which the camera moves to the new camera height.
// This function allows the user to change a specific players camera height.
//
//
// Custom script: call HeroCamChangeHeightForAll( height, duration)
// height and duration are both real variables.
// duration determines the speed at which the camera moves to the new camera height.
// This function allows the user to change all of the players camera height.
//
//
// Custom script: call HeroCamChangeAttAngleForPlayer( player, attAngle, duration)
// attAngle and duration are both real variables.
// duration determines the speed at which the camera moves to the new camera angle of attack.
// This function allows the user to change a specific players camera angle of attack.
//
//
// Custom script: call HeroCamChangeAttAngleForAll( attAngle, duration)
// attAngle and duration are both real variables.
// duration determines the speed at which the camera moves to the new camera angle of attack.
// This function allows the user to change all of the players camera angle of attack.
//
//
// Custom script: call HeroCamChangeRotationForPlayer( player, rotation, duration)
// rotation and duration are both real variables.
// duration determines the speed at which the camera moves to the new camera rotation.
// This function allows the user to change a specific players camera height.
//
//
// Custom script: call HeroCamChangeRotationForAll( rotation, duration)
// rotation and duration are both real variables.
// duration determines the speed at which the camera moves to the new camera rotation.
// This function allows the user to change all of the players camera height.
//
//
// Custom script: call HeroCamEnablePlayerFacingControl( player)
// This function allows the player to be able to control whether or not his camera is locked to the facing angle of his hero.
// Note: If partial control is enabled then the player will still have control unless it is disabled for that player.
//
//
// Custom script: call HeroCamDisablePlayerFacingControl( player)
// This function allows the user to be able to control whether or not his camera is locked to the facing angle of his hero.
// Note: If partial control is enabled then the player will still have control unless it is disabled for that player.
//
//
// Custom script: call HeroCamEnablePartialFacingControl( player)
// This function enables partial control to the player for the players facing angle lock.
// Note: If partial control is enabled then the player will still have control unless it is disabled for that player.
//
//
// Custom script: call HeroCamDisablePartialFacingControl( player)
// This function disables partial control to the player for the players facing angle lock.
//
//
// Custom script: call GetHeroCamPlayerFacingControl( player)
// This function checks if that player is in control of their ability to lock or unlock the camera lock on facing angle.
//
//
// Custom script: call HeroCamSysEnableRotationForPlayer( player)
// This function enables the player to use change their rotation.
// This only allows it if the player has partial or full control of their camera.
//
//
// Custom script: call HeroCamSysEnableRotationForPlayer()
// This function enables all players to use change their rotation.
// This only allows it if the player has partial or full control of their camera.
//
//
// Custom script: call HeroCamSysDisableRotationForPlayer( player)
// This function Disables the player to use change their rotation.
//
//
// Custom script: call HeroCamSysDisableRotationForPlayer()
// This function Disables all players to use change their rotation.
//
//
// Custom script: call HeroCamSysEnableHeightForPlayer( player)
// This function enables the player to use change their rotation.
// This only allows it if the player has partial or full control of their camera.
//
//
// Custom script: call HeroCamSysEnableHeightForPlayer()
// This function enables all players to use change their rotation.
// This only allows it if the player has partial or full control of their camera.
//
//
// Custom script: call HeroCamSysDisableHeightForPlayer( player)
// This function Disables the player to use change their rotation.
//
//
// Custom script: call HeroCamSysDisableHeightForPlayer()
// This function Disables all players to use change their rotation.
//
//
// Custom script: call HeroCamSysEnableAttAngleForPlayer( player)
// This function enables the player to use change their rotation.
// This only allows it if the player has partial or full control of their camera.
//
//
// Custom script: call HeroCamSysEnableAttAngleForPlayer()
// This function enables all players to use change their rotation.
// This only allows it if the player has partial or full control of their camera.
//
//
// Custom script: call HeroCamSysDisableAttAngleForPlayer( player)
// This function Disables the player to use change their rotation.
//
//
// Custom script: call HeroCamSysDisableAttAngleForPlayer()
// This function Disables all players to use change their rotation.
//
//
// Custom script: call HeroCamForceFacingLockForPlayer( player)
// This function is used to force a players camera to lock on the units facing angle.
// You need to turn off the rotation for that player and the players ability to lock / unlock this with the appropriate function.
//
//
// Custom script: call HeroCamForceFacingLockForAll()
// This function is used to force all players cameras to lock on the units facing angle.
// You need to turn off the rotation for that player and the players ability to lock / unlock this with the appropriate function.
//
//
// Custom script: call HeroCamForceFacingUnLockForPlayer( player)
// This function is used to force a players camera to Unlock on the units facing angle.
// You need to turn off the rotation for that player and the players ability to lock / unlock this with the appropriate function.
//
//
// Custom script: call HeroCamForceFacingUnLockForAll()
// This function is used to force all players cameras to Unlock on the units facing angle.
// You need to turn off the rotation for that player and the players ability to lock / unlock this with the appropriate function.
//
//
//
// That is all of the functions you can use and their explanations.
//
// This function is not needed it just has to be up here.
// Do not touch or edit any functions in this area.
function HeroCamResetCam takes integer p returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call ResetToGameCamera( 0.00)
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_heroCamSysHeightPlayer[ p], 0.00)
call SetCameraField( CAMERA_FIELD_ROTATION, udg_heroCamSysRotationPlayer[ p], 0.00)
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, udg_heroCamSysAttAnglePlayer[ p], 0.00)
endif
endfunction
// This function sets the players camera to the facing angle of that players hero.
function HeroCamSetFacingLoop takes nothing returns nothing
local integer L = 1
loop
exitwhen L > udg_heroCamSysFacingMaxIndex
if udg_heroCamSysCamLockBoolPlayer[ L + 12] then
call SetCameraField( CAMERA_FIELD_ROTATION, GetUnitFacing( udg_heroCamSysHeroUnitPlayer[ udg_heroCamSysFacingList[ L] + 1]), 0.00)
endif
if udg_heroCamSysCamLockBoolPlayer[ L] then
if GetLocalPlayer() == GetTriggerPlayer() then
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_heroCamSysHeightPlayer[ L], 0.00)
call SetCameraField( CAMERA_FIELD_ROTATION, udg_heroCamSysRotationPlayer[ L], 0.00)
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, udg_heroCamSysAttAnglePlayer[ L], 0.00)
endif
endif
set L = L + 1
endloop
endfunction
function HeroCamSysFacingLock takes integer p returns nothing
// In this function i have to index that player into the facing lock system part so that it will lock that players camera to the units facing angle.
// I also have to check if it is on. If it isn't i have to turn it on.
// I first have to check if the player is in the facing system already so it doesn't bug.
if udg_heroCamSysFacingListBool[ p] then
if udg_heroCamSysFacingMaxIndex == 0 then
call TimerStart( udg_heroCamSysFacingTimer, udg_heroCamSysFacingTimerSpeed, true, function HeroCamSetFacingLoop)
endif
set udg_heroCamSysFacingMaxIndex = udg_heroCamSysFacingMaxIndex + 1
// I set the players integer to the max index
set udg_heroCamSysFacingList[ udg_heroCamSysFacingMaxIndex] = p
// I then key this array to the players integer and store the index to load the facing list faster.
set udg_heroCamSysFacingPlayerKey[ p] = udg_heroCamSysFacingMaxIndex
// I then set the boolean to say that that player is already added to the index for the facing unit setting.
set udg_heroCamSysFacingListBool[ p] = true
endif
endfunction
function HeroCamSysFacingUnLock takes integer p returns nothing
// In this function I de-index that player from the array.
// I first have to check if the player is in the facing system already so it doesn't bug.
if udg_heroCamSysFacingListBool[ p] then
// I need to change the max index to the index that is getting removed.
set udg_heroCamSysFacingList[ udg_heroCamSysFacingPlayerKey[ p]] = udg_heroCamSysFacingList[ udg_heroCamSysFacingMaxIndex]
// Now i need to change the players key that moved from the max index to its new index.
// This makes it so i can keep track of all of the indexes and were they are. ( not sure if this is what linked list is ? )
set udg_heroCamSysFacingPlayerKey[ udg_heroCamSysFacingList[ udg_heroCamSysFacingMaxIndex]] = udg_heroCamSysFacingList[ udg_heroCamSysFacingPlayerKey[ p]]
// I then need to remove the index for the triggering player so it doesn't bug later.
set udg_heroCamSysFacingPlayerKey[ p] = 0
set udg_heroCamSysFacingMaxIndex = udg_heroCamSysFacingMaxIndex - 1
// I then set the boolean to say that that player is from the index for the facing unit setting.
set udg_heroCamSysFacingListBool[ p] = false
if udg_heroCamSysFacingMaxIndex == 0 then
call PauseTimer( udg_heroCamSysFacingTimer)
endif
endif
endfunction
// The functions below are the ones you can use for the system.
function HeroCamForceLockForPlayer takes player P returns nothing
local integer p = GetPlayerId( P)
set udg_heroCamSysHeroLockPlayer[ p + 12] = true
call DisplayTextToPlayer( P, 0, 0, "Your Camera has been locked")
set udg_heroCamSysCamLockBoolPlayer[ p] = true
if GetLocalPlayer() == P then
call SetCameraTargetController( udg_heroCamSysHeroUnitPlayer[ p], udg_heroCamSysXOffset, udg_heroCamSysYOffset, false)
endif
endfunction
function HeroCamForceLockForAll takes nothing returns nothing
local integer L = 0
local player P
loop
exitwhen L > 12
set P = Player( L)
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call HeroCamForceLockForPlayer( P)
set udg_heroCamSysCamLockBoolPlayer[ L] = true
endif
set L = L + 1
endloop
set P = null
endfunction
function HeroCamForceUnLockForPlayer takes player P returns nothing
local integer p = GetPlayerId( P)
call DisplayTextToPlayer( P, 0, 0, "Your Camera has been unlocked")
set udg_heroCamSysHeroLockPlayer[ p + 12] = false
call HeroCamResetCam( p)
endfunction
function HeroCamForceUnLockForAll takes nothing returns nothing
local integer L = 0
local player P
loop
exitwhen L > 12
set P = Player( L)
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call HeroCamForceUnLockForPlayer( P)
endif
set L = L + 1
endloop
set P = null
endfunction
function HeroCamEnablePlayerControl takes player P returns nothing
set udg_heroCamSysHeroLockPlayer[ GetPlayerId( P) + 24] = true
endfunction
function HeroCamDisablePlayerControl takes player P returns nothing
set udg_heroCamSysHeroLockPlayer[ GetPlayerId( P) + 24] = false
endfunction
function HeroCamEnablePartialControl takes nothing returns nothing
set udg_heroCamSysPlayerControl = true
set udg_heroCamSysPartialControl = true
endfunction
function HeroCamDisablePartialControl takes nothing returns nothing
set udg_heroCamSysPartialControl = false
endfunction
function GetHeroCamPlayerInControl takes player P returns boolean
return udg_heroCamSysHeroLockPlayer[ GetPlayerId( P) + 24]
endfunction
function HeroCamChangeHeightForPlayer takes player P, real height, real dur returns nothing
set udg_heroCamSysHeightPlayer[ GetPlayerId( P)] = height
if GetLocalPlayer() == P then
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, height, dur)
endif
endfunction
function HeroCamChangeHeightForAll takes real height, real dur returns nothing
local integer L = 0
local player P
loop
exitwhen L > 11
set P = Player( L)
// Check if the player is playing and if that player is a user so this will only register the actual players.
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call HeroCamChangeHeightForPlayer( P, height, dur)
endif
set L = L + 1
endloop
set P = null
endfunction
function HeroCamChangeAttAngleForPlayer takes player P, real attAngle, real dur returns nothing
set udg_heroCamSysAttAnglePlayer[ GetPlayerId( P)] = attAngle
if GetLocalPlayer() == P then
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, attAngle, dur)
endif
endfunction
function HeroCamChangeAttAngleForAll takes real attAngle, real dur returns nothing
local integer L = 0
local player P
loop
exitwhen L > 11
set P = Player( L)
// Check if the player is playing and if that player is a user so this will only register the actual players.
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call HeroCamChangeAttAngleForPlayer( P, attAngle, dur)
endif
set L = L + 1
endloop
set P = null
endfunction
function HeroCamChangeRotationForPlayer takes player P, real rotation, real dur returns nothing
set udg_heroCamSysRotationPlayer[ GetPlayerId( P)] = rotation
if GetLocalPlayer() == P then
call SetCameraField( CAMERA_FIELD_ROTATION, rotation, dur)
endif
endfunction
function HeroCamChangeRotationForAll takes real rotation, real dur returns nothing
local integer L = 0
local player P
loop
exitwhen L > 11
set P = Player( L)
// Check if the player is playing and if that player is a user so this will only register the actual players.
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call HeroCamChangeRotationForPlayer( P, rotation, dur)
endif
set L = L + 1
endloop
set P = null
endfunction
function HeroCamEnablePlayerFacingControl takes player P returns nothing
// This is used for both systems but i wanted to take more advantage of the array.
// This is for enabling the players ability to lock or unlock from the facing angle system.
set udg_heroCamSysHeroLockPlayer[ GetPlayerId( P) + 48] = true
endfunction
function HeroCamDisablePlayerFacingControl takes player P returns nothing
// This is used for both systems but i wanted to take more advantage of the array.
// This is for disabling the players ability to lock or unlock from the facing angle system.
set udg_heroCamSysHeroLockPlayer[ GetPlayerId( P) + 48] = false
endfunction
function HeroCamEnablePartialFacingControl takes player P returns nothing
set udg_heroCamPlayerFacingPartControl = true
set udg_heroCamPlayerFacingControl = true
endfunction
function HeroCamDisablePartialFacingControl takes player P returns nothing
set udg_heroCamPlayerFacingPartControl = false
endfunction
function GetHeroCamPlayerFacingControl takes player P returns boolean
return udg_heroCamSysHeroLockPlayer[ GetPlayerId( P) + 48]
endfunction
function HeroCamSysEnableRotationForPlayer takes player P returns nothing
set udg_heroCamSysEnabledRotPlayer[ GetPlayerId( P)] = true
endfunction
function HeroCamSysEnableRotationForAll takes nothing returns nothing
local integer L = 0
loop
exitwhen L > 11
set udg_heroCamSysEnabledRotPlayer[ L] = true
set L = L + 1
endloop
endfunction
function HeroCamSysDisableRotationForPlayer takes player P returns nothing
set udg_heroCamSysEnabledRotPlayer[ GetPlayerId( P)] = false
endfunction
function HeroCamSysDisableRotationForAll takes nothing returns nothing
local integer L = 0
loop
exitwhen L > 11
set udg_heroCamSysEnabledRotPlayer[ L] = false
set L = L + 1
endloop
endfunction
function HeroCamSysEnableHeightForPlayer takes player P returns nothing
set udg_heroCamSysEnabledHeightPlayer[ GetPlayerId( P)] = true
endfunction
function HeroCamSysEnableHeightForAll takes nothing returns nothing
local integer L = 0
loop
exitwhen L > 11
set udg_heroCamSysEnabledHeightPlayer[ L] = true
set L = L + 1
endloop
endfunction
function HeroCamSysDisableHeightForPlayer takes player P returns nothing
set udg_heroCamSysEnabledHeightPlayer[ GetPlayerId( P)] = false
endfunction
function HeroCamSysDisableHeightForAll takes nothing returns nothing
local integer L = 0
loop
exitwhen L > 11
set udg_heroCamSysEnabledHeightPlayer[ L] = false
set L = L + 1
endloop
endfunction
function HeroCamSysEnableAttAngleForPlayer takes player P returns nothing
set udg_heroCamSysEnabledAttAngPlayer[ GetPlayerId( P)] = true
endfunction
function HeroCamSysEnableAttAngleForAll takes nothing returns nothing
local integer L = 0
loop
exitwhen L > 11
set udg_heroCamSysEnabledAttAngPlayer[ L] = true
set L = L + 1
endloop
endfunction
function HeroCamSysDisableAttAngleForPlayer takes player P returns nothing
set udg_heroCamSysEnabledAttAngPlayer[ GetPlayerId( P)] = false
endfunction
function HeroCamSysDisableAttAngleForAll takes nothing returns nothing
local integer L = 0
loop
exitwhen L > 11
set udg_heroCamSysEnabledAttAngPlayer[ L] = false
set L = L + 1
endloop
endfunction
function HeroCamForceFacingLockForPlayer takes player P returns nothing
set udg_heroCamSysCamLockBoolPlayer[ GetPlayerId( P) + 12] = true
call HeroCamSysFacingLock( GetPlayerId( P))
endfunction
function HeroCamForceFacingLockForAll takes nothing returns nothing
local integer L = 0
local player P
loop
exitwhen L > 11
set P = Player( L)
// Check if the player is playing and if that player is a user so this will only register the actual players.
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call HeroCamSysFacingLock( L)
endif
set L = L + 1
endloop
set P = null
endfunction
function HeroCamForceFacingUnLockForPlayer takes player P returns nothing
set udg_heroCamSysCamLockBoolPlayer[ GetPlayerId( P) + 12] = false
call HeroCamSysFacingUnLock( GetPlayerId( P))
endfunction
function HeroCamForceFacingUnLockForAll takes nothing returns nothing
local integer L = 0
local player P
loop
exitwhen L > 11
set P = Player( L)
call HeroCamSysFacingUnLock( L)
set L = L + 1
endloop
set P = null
endfunction
// All functions after this point are the main code. These don't need to be learned touched or used in any custom script.
// Not sure if hashtable would be better in this case as there is only the timers that would need to be stored.
function HeroCamGetPlayer takes timer tmr returns integer
local integer L = 0
local integer id = GetHandleId( tmr)
loop
exitwhen L > 12
if id == udg_heroCamSysTimersIndexInt[ L] then
return L
endif
set L = L + 1
endloop
return 13
endfunction
function HeroCamPlayerLock takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
set udg_heroCamSysHeroLockPlayer[ p] = true
if GetLocalPlayer() == Player( p) then
// the p + 1 is there to make it easier for GUIers to use this as they normally store things in arrays using player number of player as key.
call SetCameraTargetController( udg_heroCamSysHeroUnitPlayer[ p + 1], udg_heroCamSysXOffset, udg_heroCamSysYOffset, false)
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_heroCamSysHeightPlayer[ p], 0.00)
call SetCameraField( CAMERA_FIELD_ROTATION, udg_heroCamSysRotationPlayer[ p], 0.00)
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, udg_heroCamSysAttAnglePlayer[ p], 0.00)
endif
return false
endfunction
function HeroCamPlayerUnLock takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
set udg_heroCamSysHeroLockPlayer[ p] = false
call HeroCamResetCam( p)
return false
endfunction
function HeroCamCheckUnitLock takes integer p returns nothing
if not udg_heroCamSysHeroLockPlayer[ p] then
if GetLocalPlayer() == Player( p) then
// the p + 1 is there to make it easier for GUIers to use this as they normally store things in arrays using player number of player as key.
call SetCameraTargetController( udg_heroCamSysHeroUnitPlayer[ p + 1], udg_heroCamSysXOffset, udg_heroCamSysYOffset, false)
endif
endif
endfunction
function HeroCamCheckIfAllowed takes integer p returns boolean
// if first boolean is true and second boolean is false this means all players have full control over their cameras.
if ( udg_heroCamSysPlayerControl and not udg_heroCamSysPartialControl) or ( udg_heroCamSysPlayerControl and udg_heroCamSysPartialControl and udg_heroCamSysHeroLockPlayer[ p + 24]) then
return true
endif
return false
endfunction
function HeroCamAttAngleUp takes nothing returns nothing
local integer p = HeroCamGetPlayer( GetExpiredTimer())
set udg_heroCamSysAttAnglePlayer[ p] = udg_heroCamSysAttAnglePlayer[ p] + udg_heroCamSysAttAngleInc
if GetLocalPlayer() == Player( p) then
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, udg_heroCamSysAttAnglePlayer[ p], 0.00)
endif
endfunction
function HeroCamAttAngleDown takes nothing returns nothing
local integer p = HeroCamGetPlayer( GetExpiredTimer())
set udg_heroCamSysAttAnglePlayer[ p] = udg_heroCamSysAttAnglePlayer[ p] - udg_heroCamSysAttAngleInc
if GetLocalPlayer() == Player( p) then
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, udg_heroCamSysAttAnglePlayer[ p], 0.00)
endif
endfunction
function HeroCamMoveUp takes nothing returns nothing
local integer p = HeroCamGetPlayer( GetExpiredTimer())
set udg_heroCamSysHeightPlayer[ p] = udg_heroCamSysHeightPlayer[ p] + udg_heroCamSysHeightInc
if GetLocalPlayer() == Player( p) then
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_heroCamSysHeightPlayer[ p], 0.00)
endif
endfunction
function HeroCamMoveDown takes nothing returns nothing
local integer p = HeroCamGetPlayer( GetExpiredTimer())
set udg_heroCamSysHeightPlayer[ p] = udg_heroCamSysHeightPlayer[ p] - udg_heroCamSysHeightInc
if GetLocalPlayer() == Player( p) then
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_heroCamSysHeightPlayer[ p], 0.00)
endif
endfunction
function HeroCamMoveLeft takes nothing returns nothing
local integer p = HeroCamGetPlayer( GetExpiredTimer())
set udg_heroCamSysRotationPlayer[ p] = udg_heroCamSysRotationPlayer[ p] + udg_heroCamSysRotationInc
if GetLocalPlayer() == Player( p) then
call SetCameraField( CAMERA_FIELD_ROTATION, udg_heroCamSysRotationPlayer[ p], 0.00)
endif
endfunction
function HeroCamMoveRight takes nothing returns nothing
local integer p = HeroCamGetPlayer( GetExpiredTimer())
set udg_heroCamSysRotationPlayer[ p] = udg_heroCamSysRotationPlayer[ p] - udg_heroCamSysRotationInc
if GetLocalPlayer() == Player( p) then
call SetCameraField( CAMERA_FIELD_ROTATION, udg_heroCamSysRotationPlayer[ p], 0.00)
endif
endfunction
function HeroCamPressedUp takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
// Now i check if the user has the angle of attack or height enabled and if they are allowed to move their cams.
if HeroCamCheckIfAllowed( p) then
// This function checks if the player is locked to their unit.
call HeroCamCheckUnitLock( p)
if udg_heroCamSysAttAngleBool[ p] and udg_heroCamSysEnabledAttAngPlayer[ p] then
if udg_heroCamSysInvUDPlayer[ p] then
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamAttAngleDown)
else
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamAttAngleUp)
endif
elseif not udg_heroCamSysAttAngleBool[ p] and udg_heroCamSysEnabledHeightPlayer[ p] then
if udg_heroCamSysInvUDPlayer[ p] then
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamMoveDown)
else
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamMoveUp)
endif
endif
endif
return false
endfunction
function HeroCamPressedDown takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
// Now i check if the user has the angle of attack or height enabled and if they are allowed to move their cams.
if HeroCamCheckIfAllowed( p) then
// This function checks if the player is locked to their unit.
call HeroCamCheckUnitLock( p)
if udg_heroCamSysAttAngleBool[ p] and udg_heroCamSysEnabledAttAngPlayer[ p] then
if udg_heroCamSysInvUDPlayer[ p] then
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamAttAngleUp)
else
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamAttAngleDown)
endif
elseif not udg_heroCamSysAttAngleBool[ p] and udg_heroCamSysEnabledHeightPlayer[ p] then
if udg_heroCamSysInvUDPlayer[ p] then
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamMoveUp)
else
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamMoveDown)
endif
endif
endif
return false
endfunction
function HeroCamPressedLeft takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
// Now i check if the user has the rotation enabled and if they are allowed to move their cams.
if HeroCamCheckIfAllowed( p) and udg_heroCamSysEnabledRotPlayer[ p] then
// This function checks if the player is locked to their unit.
call HeroCamCheckUnitLock( p)
if udg_heroCamSysInvLRPlayer[ p] then
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamMoveRight)
else
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamMoveLeft)
endif
endif
return false
endfunction
function HeroCamPressedRight takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
// Now i check if the user has the rotation enabled and if they are allowed to move their cams.
if HeroCamCheckIfAllowed( p) and udg_heroCamSysEnabledRotPlayer[ p] then
// This function checks if the player is locked to their unit.
call HeroCamCheckUnitLock( p)
if udg_heroCamSysInvLRPlayer[ p] then
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamMoveLeft)
else
call TimerStart( udg_heroCamSysTimersPlayer[ p], udg_heroCamSysSpeed, true, function HeroCamMoveRight)
endif
endif
return false
endfunction
function HeroCamDepressedAll takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
// This checks if the players array is not permanently locked.
call PauseTimer( udg_heroCamSysTimersPlayer[ p])
// if first boolean is true and second boolean is false this means all players have full control over their cameras.
if udg_heroCamSysPlayerControl and not udg_heroCamSysPartialControl then
// This checks if the player wants to leave the camera locked to the unit or unlock from the unit.
if not udg_heroCamSysHeroLockPlayer[ p] then
call HeroCamResetCam( p)
endif
// if both booleans are true then this means that players will have partial control over their cameras.
elseif udg_heroCamSysPlayerControl and udg_heroCamSysPartialControl then
// This checks if the player wants to leave the camera locked to the unit or unlock from the unit.
// if udg_heroCamSysHeroLockPlayer[ GetPlayerId( P) + 24] is true then that means that player still has control.
if udg_heroCamSysHeroLockPlayer[ p + 24] then
// This checks if the player wants to leave the camera locked to the unit or unlock from the unit.
if not udg_heroCamSysHeroLockPlayer[ p] then
call HeroCamResetCam( p)
endif
// This means that that player is not in control of their camera locking / unlocking.
else
// This checks if the map creator wants to leave the camera locked.
// if udg_heroCamSysHeroLockPlayer[ p + 12] is true then the players camera stays locked.
if not udg_heroCamSysHeroLockPlayer[ p + 12] then
call HeroCamResetCam( p)
endif
endif
// this runs if the map creator has full control over the players cameras.
else
// Check if the map creator wants to leave the camera locked or unlocked to the unit.
// If false then the map creator wants the camera to not stay locked
// This allows for one player to be locked while others are not.
if not udg_heroCamSysHeroLockPlayer[ p + 12] then
call HeroCamResetCam( p)
endif
endif
return false
endfunction
function HeroCamPlayerInvUD takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
// This inverts the players up and down actions.
if udg_heroCamSysInvUDPlayer[ p] then
set udg_heroCamSysInvUDPlayer[ p] = false
else
set udg_heroCamSysInvUDPlayer[ p] = true
endif
return false
endfunction
function HeroCamPlayerInvLR takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
// This inverts the players left and right actions.
if udg_heroCamSysInvLRPlayer[ p] then
set udg_heroCamSysInvLRPlayer[ p] = false
else
set udg_heroCamSysInvLRPlayer[ p] = true
endif
return false
endfunction
function HeroCamPlayerAttAngle takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
// This function changes the up and down commands to use angle of attack if height was previously selected.
// If the angle of attack was selected then it changes it back to height.
if udg_heroCamSysAttAngleBool[ p] then
set udg_heroCamSysAttAngleBool[ p] = false
else
set udg_heroCamSysAttAngleBool[ p] = true
endif
return false
endfunction
function HeroCamEnableFacingLock takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
call HeroCamSysFacingLock( p)
return false
endfunction
function HeroCamDisableFacingLock takes nothing returns boolean
local integer p = GetPlayerId( GetTriggerPlayer())
call HeroCamSysFacingUnLock( p)
return false
endfunction
function HeroCamCodeSetup takes nothing returns boolean
local timer tmr = GetExpiredTimer()
local integer L = 0
local player P
local trigger t = CreateTrigger()
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
local trigger t3 = CreateTrigger()
local trigger t4 = CreateTrigger()
local trigger t5 = CreateTrigger()
local trigger t6 = CreateTrigger()
local trigger t7 = CreateTrigger()
local trigger t8 = CreateTrigger()
local trigger t9 = CreateTrigger()
local trigger t10 = CreateTrigger()
local trigger t11 = CreateTrigger()
local trigger t12 = CreateTrigger()
// This loop registers everything for the array keys.
loop
exitwhen L > 12
set P = Player( L)
// Check if the player is playing and if that player is a user so this will only register the actual players.
if GetPlayerSlotState( P) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( P) == MAP_CONTROL_USER then
call TriggerRegisterPlayerEvent( t, P, EVENT_PLAYER_ARROW_UP_UP)
call TriggerRegisterPlayerEvent( t, P, EVENT_PLAYER_ARROW_DOWN_UP)
call TriggerRegisterPlayerEvent( t, P, EVENT_PLAYER_ARROW_LEFT_UP)
call TriggerRegisterPlayerEvent( t, P, EVENT_PLAYER_ARROW_RIGHT_UP)
call TriggerRegisterPlayerEvent( t1, P, EVENT_PLAYER_ARROW_UP_DOWN)
call TriggerRegisterPlayerEvent( t2, P, EVENT_PLAYER_ARROW_DOWN_DOWN)
call TriggerRegisterPlayerEvent( t3, P, EVENT_PLAYER_ARROW_LEFT_DOWN)
call TriggerRegisterPlayerEvent( t4, P, EVENT_PLAYER_ARROW_RIGHT_DOWN)
call TriggerRegisterPlayerChatEvent( t5, P, udg_heroCamSysPlayerLockString, true)
call TriggerRegisterPlayerChatEvent( t6, P, udg_heroCamSysPlayerUnLockString, true)
call TriggerRegisterPlayerChatEvent( t7, P, udg_heroCamSysInvUDString, true)
call TriggerRegisterPlayerChatEvent( t8, P, udg_heroCamSysInvLRString, true)
call TriggerRegisterPlayerChatEvent( t9, P, udg_heroCamSysAttAngleString, true)
call TriggerRegisterPlayerChatEvent( t10, P, udg_heroCamSysFacingLockString, true)
call TriggerRegisterPlayerChatEvent( t11, P, udg_heroCamSysFacingUnLockString, true)
call TriggerRegisterPlayerEvent( t12, P, EVENT_PLAYER_LEAVE)
// This stores the created timers into a useable index for returning which is the triggering player.
set udg_heroCamSysTimersIndexInt[ L] = GetHandleId( udg_heroCamSysTimersPlayer[ L])
set udg_heroCamSysHeightPlayer[ L] = udg_heroCamSysHeightStartValue
set udg_heroCamSysRotationPlayer[ L] = udg_heroCamSysRotationStartValue
set udg_heroCamSysAttAnglePlayer[ L] = udg_heroCamSysAttAngleStartValue
set udg_heroCamSysHeroLockPlayer[ L] = false
set udg_heroCamSysHeroLockPlayer[ L + 12] = false
set udg_heroCamSysHeroLockPlayer[ L + 24] = false
set udg_heroCamSysAttAngleBool[ L] = false
set udg_heroCamSysEnabledRotPlayer[ L] = true
set udg_heroCamSysEnabledHeightPlayer[ L] = true
set udg_heroCamSysEnabledAttAngPlayer[ L] = true
set udg_heroCamSysCamLockBoolPlayer[ L] = false
set udg_heroCamSysCamLockBoolPlayer[ L + 12] = false
endif
set L = L + 1
endloop
call TriggerAddCondition( t, Condition( function HeroCamDepressedAll))
call TriggerAddCondition( t1, Condition( function HeroCamPressedUp))
call TriggerAddCondition( t2, Condition( function HeroCamPressedDown))
call TriggerAddCondition( t3, Condition( function HeroCamPressedLeft))
call TriggerAddCondition( t4, Condition( function HeroCamPressedRight))
call TriggerAddCondition( t5, Condition( function HeroCamPlayerLock))
call TriggerAddCondition( t6, Condition( function HeroCamPlayerUnLock))
call TriggerAddCondition( t7, Condition( function HeroCamPlayerInvUD))
call TriggerAddCondition( t8, Condition( function HeroCamPlayerInvLR))
call TriggerAddCondition( t9, Condition( function HeroCamPlayerAttAngle))
call TriggerAddCondition( t10, Condition( function HeroCamEnableFacingLock))
call TriggerAddCondition( t11, Condition( function HeroCamDisableFacingLock))
call TriggerAddCondition( t12, Condition( function HeroCamDisableFacingLock))
call DestroyTimer( tmr)
set t = null
set t1 = null
set t2 = null
set t3 = null
set t4 = null
set t5 = null
set t6 = null
set t7 = null
set t8 = null
set t9 = null
set t10 = null
set t11 = null
set t12 = null
set tmr = null
set P = null
return false
endfunction
//===========================================================================
function InitTrig_HeroCameraCode takes nothing returns nothing
local trigger t = CreateTrigger()
local timer tmr = CreateTimer()
call TriggerAddCondition( t, Condition( function HeroCamCodeSetup))
call TriggerRegisterTimerEvent( t, 0.00, false)
set t = null
set tmr = null
endfunction