Camera Lock System v2.5.0.1

This bundle is marked as approved. It works and satisfies the submission rules.
This is a system requested by neo sluf made by me.
Configurables and systems abilities.
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 also allows for partial control meaning that you can control some players cameras when you want and leave other players cameras free to their will. This comes in handy when you want areas of your map to have certain limitations.
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.

  • HeroCameraConfig Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- If this boolean is true then the players will have full control over locking / unlocking the camera to and from the hero. --------
      • -------- If this boolean is false then the map creator will have partial control over whether the camera can lock / unlock from the hero. You have to use the ForceLock function to have partial control over the players --------
      • -------- If you want the ability to toggle between letting the players choose and not choose later in the game leave this as true then wait after 0.01 seconds and change the boolean. --------
      • Set heroCamSysPlayerControl = True
      • -------- --------
      • -------- --------
      • -------- If the boolean heroCamSysPlayerControl is true then this is the string that the players will type to lock there camera. --------
      • -------- This is an exact match so capitilization matters. --------
      • Set heroCamSysPlayerLockString = -heroCamLock
      • -------- --------
      • -------- --------
      • -------- If the boolean heroCamSysPlayerControl is true then this is the string that the players will type to unlock there camera. --------
      • -------- This is an exact match so capitilization matters. --------
      • Set heroCamSysPlayerUnLockString = -heroCamUnLock
      • -------- --------
      • -------- --------
      • -------- This is an exact match so capitilization matters. --------
      • Set heroCamSysFacingLockString = -heroCamFacingLock
      • -------- --------
      • -------- --------
      • -------- This is an exact match so capitilization matters. --------
      • Set heroCamSysFacingUnLockString = -heroCamFacingUnLock
      • -------- --------
      • -------- --------
      • -------- This string changes the command string for if players want to change angel of attack by using the up or down button. --------
      • -------- Enter this string a second time to change it back to height. --------
      • -------- This is an exact match so capitilization matters. --------
      • -------- note this changes direction just like height when the invert string is used. --------
      • Set heroCamSysAttAngleString = -attAngle
      • -------- --------
      • -------- --------
      • -------- This string allows players to invert there up and down actions. What that means is that if they want the camera to move down when pressing up all they have to do is type this string in. --------
      • -------- They can then type in the string again at any time in game to invert back. --------
      • Set heroCamSysInvUDString = -invertUD
      • -------- --------
      • -------- --------
      • -------- This string allows players to invert there left and right actions. What that means is that if they want the camera to move right when pressing uleft all they have to do is type this string in. --------
      • -------- They can then type in the string again at any time in game to invert back. --------
      • Set heroCamSysInvLRString = -invertLR
      • -------- --------
      • -------- --------
      • -------- This variable is the start height that you want the distance to be at. --------
      • Set heroCamSysHeightStartValue = 500.00
      • -------- --------
      • -------- --------
      • -------- This variable is the distance that the camera will move from the target in the z axis for every 0.03125 seconds that you hold down the up or down button. --------
      • Set heroCamSysHeightInc = 10.00
      • -------- --------
      • -------- --------
      • -------- This variable is the start height that you want the distance to be at. --------
      • Set heroCamSysAttAngleStartValue = 300.00
      • -------- --------
      • -------- --------
      • -------- This variable is the angle of attack that the camera will change for every 0.03125 seconds that you hold down the up or down button. --------
      • Set heroCamSysAttAngleInc = 2.00
      • -------- --------
      • -------- --------
      • -------- This variable is the start rotation that you want the rotation to be at. --------
      • Set heroCamSysRotationStartValue = 90.00
      • -------- --------
      • -------- --------
      • -------- This variable is the amount that you will rotate the camera left or right for every 0.03125 seconds that you hold down the left or right button. --------
      • Set heroCamSysRotationInc = 5.00
      • -------- --------
      • -------- --------
      • -------- This variable is for the x offset value when locking to a unit. What this does is moves were you lock to the unit by using the x value. --------
      • -------- This shouldn't have to be changed but I put it here so you could tweak it to your liking. --------
      • Set heroCamSysXOffset = 0.00
      • -------- --------
      • -------- --------
      • -------- This variable is for the y offset value when locking to a unit. What this does is moves were you lock to the unit by using the y value. --------
      • -------- This shouldn't have to be changed but I put it here so you could tweak it to your liking. --------
      • Set heroCamSysYOffset = 0.00
      • -------- --------
      • -------- --------
      • -------- This variable is for the speed of the trigger. It is for the periodic movement event that changes the rotation / height. I put this in so you have more room to tweak it to your liking. --------
      • -------- I use custom script because you can then set this to a more desirable real number. 0.031250000 will run 32 times a second so 32 FPS. --------
      • Custom script: set udg_heroCamSysSpeed = 0.031250000
      • -------- --------
      • -------- --------
      • -------- This variable is for the speed of the facing unit system. This determines how often the cameras get moved. This is normally set at 0.03125000 for a good period. This runs at 32 fps. --------
      • -------- I use custom script because you can then set this to a more desirable real number. 0.031250000 will run 32 times a second so 32 FPS. --------
      • Custom script: set udg_heroCamSysFacingTimerSpeed = 0.031250000
      • -------- --------
      • -------- --------
      • -------- Delete everything after this after you copy the trigger to your map. --------
      • Set heroCamPlayerFacingControl = True
      • Set heroCamPlayerFacingPartControl = True
      • Set heroCamSysAttAngleBool[0] = False
      • Set heroCamSysAttAnglePlayer[0] = 0.00
      • Set heroCamSysEnabledAttAngPlayer[0] = False
      • Set heroCamSysEnabledHeightPlayer[0] = False
      • Set heroCamSysEnabledRotPlayer[0] = False
      • Set heroCamSysFacingBool[0] = True
      • Set heroCamSysCamLockBoolPlayer[0] = False
      • Set heroCamSysFacingList[0] = 0
      • Set heroCamSysFacingListBool[0] = False
      • Set heroCamSysFacingMaxIndex = 0
      • Set heroCamSysFacingPlayerKey[0] = 0
      • Set heroCamSysFacingTimer = heroCamSysFacingTimer
      • Set heroCamSysFacingTimerSpeed = 0.00
      • Set heroCamSysHeightPlayer[0] = 0.00
      • Set heroCamSysPartialControl = False
      • Set heroCamSysHeroLockPlayer[0] = True
      • Set heroCamSysHeroUnitPlayer[0] = No unit
      • Set heroCamSysInvLRPlayer[0] = False
      • Set heroCamSysInvUDPlayer[0] = False
      • Set heroCamSysRotationPlayer[0] = 0.00
      • Set heroCamSysSpeed = 0.00
      • Set heroCamSysTimersIndexInt[0] = 0
      • Set heroCamSysTimersPlayer[0] = heroCamSysTimersPlayer[0]
JASS:
// 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


version 2.5.0.1
fixed some bugs in code.
Fxed what nes pointed out.​
version 2.5.0.0
With this update i have added in the ability for first person view.
This allows players or the user to lock the camera to each of the players heros facing angle.
This can allow users to still change angle of attack or height but still have facing angle locked.
This can allow users to make close to 1st person camera only with no movement for the players.​
version 2.0.0.0
This was a huge upgrade.
This system can now change the attack angle of a players camera using the up and down buttons.
This can be done after using the -attAngle string ( which is changeable by the user).
To change back to changing the height just use -attAngle string again.
This now allows the user more flexibility as they can now turn off rotation / height / att angle changing.​
version 1.0.0.6
Fixed a stupid mistake.​
version 1.0.0.5
Fixed problem with ignoring the boolean.​
version 1.0.0.4
Added a function call to get whether the player is in control of their camera.​
version 1.0.0.3
Updated the description on the functions you can use.​
version 1.0.0.2
Height and rotation starting value is now configurable​
version 1.0.0.1
Fixed small bug with returning to game camera​
version 1.0.0.0
First version released​


Any questions or improvements please let me know.

Note: It is preset to not lock onto the unit. So to properly test the system first start the test map then type -heroCamLock ( the capitalization matters). Then try to move around. To change to move the attack angle type in -attAngle ( again caps matters)

Keywords:
camera system, camera, system, GUI friendly, GUI, jass, deathismyfriend, dimf, height, att angle, rotation, zOffset, z offset, facing lock system, fac
Contents

Template Map (Map)

Reviews
Camera Lock System v2.5.0.1 | Reviewed by Maker | 27th Sep 2013 APPROVED A useful system, but it could support locking to a camera and storing/loading a camera setup [tr] In HeroCamSetFacingLoop you have a code block...

Moderator

M

Moderator


Camera Lock System v2.5.0.1 | Reviewed by Maker | 27th Sep 2013
APPROVED


126248-albums6177-picture66521.png


  • A useful system, but it could support locking to a camera and
    storing/loading a camera setup
126248-albums6177-picture66523.png


  • In HeroCamSetFacingLoop you have a code block that could be replaced with HeroCamResetCam()
  • You function input parateter names could be more descriptive.
    For example instead of takes integer p, use takes integer playerId
  • HeroCamCheckIfAllowed could be single line return cond 1 and/or/not cond 2...[icode=jass] [*]t11 could have two events, you could get rid of t12 [*]The test map is vey poor, it doesn't offer anything to make testing the system easy [/list] [/COLOR][/TD] [/tr] [/td] [/TABLE] [/TABLE]
 
Level 4
Joined
Feb 5, 2012
Messages
1,685
Ok here's the review..

I found something weird about the up and down buttom

For example if you press UP it will zoom out but if you press again it goes back to normal distance then zoom up then after releasing it goes back to normal.

What i mean for the request is..

For example the distance to the target is 500 then the player presses Up button so from starting distance which is 500 it will increase up to 1000. When the player pressess the Up button again his distance to the target would start from 1000 and will not start to 500. (This is only an example of the camera concept i want)

Same goes to Down Button

Also sometimes when i press Up my camera will start on the foot of the unit then zooms out.
 
Level 29
Joined
Oct 24, 2012
Messages
6,545
I'll test that now it is supposed to continue from the last distance not from beginning.

edit: I tested it I'm not sure what's happening it works the right way on mine.

Also sometimes when i press Up my camera will start on the foot of the unit then zooms out.
This should only happen the first time that you press up because the value is 0 so it starts at 0 for height.

edit2: I think i see what you mean i will fix it in a couple minutes.
 
Level 4
Joined
Feb 5, 2012
Messages
1,685
I'll test that now it is supposed to continue from the last distance not from beginning.

edit: I tested it I'm not sure what's happening it works the right way on mine.

Also sometimes when i press Up my camera will start on the foot of the unit then zooms out.
This should only happen the first time that you press up because the value is 0 so it starts at 0 for height.

So how about start the value from a configurable value?.. like i can put the value that i want.. is the 0 default?.. cause i want the starting height would be 500 but it is better if it is configurable.
 
Level 29
Joined
Oct 24, 2012
Messages
6,545
So how about start the value from a configurable value?.. like i can put the value that i want.. is the 0 default?.. cause i want the starting height would be 500 but it is better if it is configurable.

Will do that now. I told you i forgot something lol

Edit: updated with those configurables for height and rotation start.

Edit2: updated the description. It's now easier for GUIers to understand. It's in the form of custom scripts.
The descriptions and list of useable functions are in the jass main code.
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,306
So just saying that this doesn't work

JASS:
    function HeroCamForceLockForPlayer takes player P returns nothing
        set udg_heroCamSysHeroLockPlayer[ GetPlayerId( P) + 12] = true
        call DisplayTextToPlayer( P, 0, 0, "Your Camera has been locked")
        if GetLocalPlayer() == P then
            call SetCameraTargetController( udg_heroCamSysHeroUnitPlayer[ GetPlayerId( 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)
            endif
            set L = L + 1
        endloop
        set P = null
    endfunction

You need to continue to lock it on a timer, otherwise a player can easily unlock via CTRL + C.
 
Top