File size: 8,329 Bytes
b6a38d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
function SetupInitialCamera(dont_move_camera)
if IsMainMenuMap() then return end
if IsGameReplayRunning() and cameraFly.IsActive() then
return
end
if not cameraTac.IsActive() then
cameraTac.Activate(1)
if not dont_move_camera then
local lookat = (point(terrain.GetMapSize())/2):SetTerrainZ()
cameraTac.SetCamera(lookat + point(0, 1000, 1000), lookat)
end
--make the cam calc its pos
cameraTac.Normalize()
cameraTac.SetLookAtAngle(not cameraTac.GetIsInOverview() and hr.CameraTacLookAtAngle or hr.CameraTacLookAtAngleInOverview)
cameraTac.SetFloor(0)
--cameraTac.SetZoom(1000)
end
end
function OnMsg.NewMap()
if Platform.developer then
--this makes retail bugs unreproducable. why is it dev only?
--note that in dev == false CloseMapLoadingScreen calls SetupInitialCamera :|, so results are similar
SetupInitialCamera()
terrain.UpdateTerrainDebugDraw()
end
end
function OnMsg.GatherSessionData()
gv_SaveCamera = CameraBeforeActionCamera or pack_params(GetCamera())
end
function dbgCamAngle()
local ptCamera, ptCameraLookAt = GetCamera()
local cameraVector = ptCameraLookAt - ptCamera
local _, r = GetAxisAngle(axis_z, cameraVector)
local ret = 180 - r/60
print(ret)
return ret
end
function OnMsg.LoadSessionData()
if gv_SaveCamera then
SetCamera(unpack_params(gv_SaveCamera))
--make sure CameraTacLookAtAngle is obayed
cameraTac.SetupLookAtAngle()
end
end
function OnMsg.DoneMap()
camera.Unlock(1)
end
OnMsg.LoadGame = SetupInitialCamera
const.DefaultCameraRTS = {
MinHeight = 2,
MaxHeight = 20,--40 in Tropico 5
HeightInertia = 4,
MoveSpeedNormal = 3,
MoveSpeedFast = 8,
RotateSpeed = 6,
LookatDist = 22,
LowRotationRadius = 40,
HighRotationRadius = 40,
CameraYawRestore = 0,
UpDownSpeed = 150,
MinZoom = 200, --800 in Tropico 5
MaxZoom = 1000, --8000 in Tropico 5
BBox = box(point30, point30),
ScrollBorder = 20,
}
hr.CameraRTSRelativeZoomingMode = 1
hr.CameraRTSZoomingScrollEasing="SinOut"
hr.CameraRTSZoomingScrollStep="0.0005"
--------------------------------------------------------------------------------------------------------
------------------------------------Tac Cam Settings----------------------------------------------------
--------------------------------------------------------------------------------------------------------
hr.CameraTacLookAtAngle = 55*60
hr.CameraTacHeight = 1100
CameraTacMoveSpeed = 2500
GamepadCameraTacMoveSpeed = 2000
hr.CameraTacMoveSpeed = CameraTacMoveSpeed
hr.CameraTacRotationSpeed = 400
hr.CameraTacMouseEdgeScrolling = true
hr.CameraTacMinFloor = 0
hr.CameraTacOverviewTime = 60 --600ms
hr.CameraTacUseInterpolatedMovement = 3 --0 off, 1 vertical only, 2 horizontal only, 3 all
hr.CameraTacInterpolatedMovementTime = 25
hr.CameraTacInterpolatedVerticalMovementTime = 50
hr.CameraTacZoomStep = 25 --this * 10 in game units
hr.CameraTacZoomStepGamepad = 200 --this * 10 in game units
hr.CameraTacZoomTime = 50
hr.CameraTacZoomOneStepPerBtnPress = false
--zoom works as a multiplier (divided by 100) of the length of the vector formed by the cam lookat and position, so 100 means no zoom,
--200 means the camera will be positioned twice as far from the lookat than it would be without zoom
--and 50 means it will be at half the distance than it should be without zoom.
hr.CameraTacMaxZoom = 130
hr.CameraTacMinZoom = 65
hr.CameraTacMaxZoomOverview = 220
hr.CameraTacScrollBorder = 5
if FirstLoad then
hr.CameraTacFloorHeight = (const.SlabSizeZ or 0) * 4
hr.CameraTacMaxFloor = 4
hr.CameraTacZoomEasing = "Cubic out"
hr.CameraTacPosEasing = "Circle out"
hr.CameraTacPosVerticalEasing = "Cubic out"
hr.CameraTacYawEasing = "Circle out"
hr.CameraTacClampToTerrain = true
hr.CameraTacUseVoxelBorder = true
hr.CameraTacClampToTerrainOnSetPos = false --changing value requires game restart to take effect
end
function OnMsg.ShortcutsReloaded()
-- pan keys
local pan_up = GetShortcuts("actionPanUp")
hr.CameraRTSKeyPanUp = GetCameraVKCodeFromShortcut(pan_up and pan_up[1])
hr.CameraRTSKeyPanUpAlt = GetCameraVKCodeFromShortcut(pan_up and pan_up[2])
hr.CameraTacKeyPanUp = hr.CameraRTSKeyPanUp
hr.CameraTacKeyPanUpAlt = hr.CameraRTSKeyPanUpAlt
local pan_down = GetShortcuts("actionPanDown")
hr.CameraRTSKeyPanDown = GetCameraVKCodeFromShortcut(pan_down and pan_down[1])
hr.CameraRTSKeyPanDownAlt = GetCameraVKCodeFromShortcut(pan_down and pan_down[2])
hr.CameraTacKeyPanDown = hr.CameraRTSKeyPanDown
hr.CameraTacKeyPanDownAlt = hr.CameraRTSKeyPanDownAlt
local pan_left = GetShortcuts("actionPanLeft")
hr.CameraRTSKeyPanLeft = GetCameraVKCodeFromShortcut(pan_left and pan_left[1])
hr.CameraRTSKeyPanLeftAlt = GetCameraVKCodeFromShortcut(pan_left and pan_left[2])
hr.CameraTacKeyPanLeft = hr.CameraRTSKeyPanLeft
hr.CameraTacKeyPanLeftAlt = hr.CameraRTSKeyPanLeftAlt
local pan_right = GetShortcuts("actionPanRight")
hr.CameraRTSKeyPanRight = GetCameraVKCodeFromShortcut(pan_right and pan_right[1])
hr.CameraRTSKeyPanRightAlt = GetCameraVKCodeFromShortcut(pan_right and pan_right[2])
hr.CameraTacKeyPanRight = hr.CameraRTSKeyPanRight
hr.CameraTacKeyPanRightAlt = hr.CameraRTSKeyPanRightAlt
-- rot keys
local rot_left = GetShortcuts("actionRotLeft")
hr.CameraRTSKeyRotateLeft = GetCameraVKCodeFromShortcut(rot_left and rot_left[1])
hr.CameraRTSKeyRotateLeftAlt = GetCameraVKCodeFromShortcut(rot_left and rot_left[2])
hr.CameraTacKeyRotateLeft = hr.CameraRTSKeyRotateLeft
hr.CameraTacKeyRotateLeftAlt = hr.CameraRTSKeyRotateLeftAlt
hr.CameraFlyKeyMoveUp = hr.CameraRTSKeyRotateLeft
hr.CameraFlyKeyMoveUpAlt = hr.CameraRTSKeyRotateLeftAlt
local rot_right = GetShortcuts("actionRotRight")
hr.CameraRTSKeyRotateRight = GetCameraVKCodeFromShortcut(rot_right and rot_right[1])
hr.CameraRTSKeyRotateRightAlt = GetCameraVKCodeFromShortcut(rot_right and rot_right[2])
hr.CameraTacKeyRotateRight = hr.CameraRTSKeyRotateRight
hr.CameraTacKeyRotateRightAlt = hr.CameraRTSKeyRotateRightAlt
hr.CameraFlyKeyMoveDown = hr.CameraRTSKeyRotateRight
hr.CameraFlyKeyMoveDownAlt = hr.CameraRTSKeyRotateRightAlt
-- zoom keys
local zoom_in = GetShortcuts("actionZoomIn")
hr.CameraRTSKeyZoomIn = GetCameraVKCodeFromShortcut(zoom_in and zoom_in[1])
hr.CameraRTSKeyZoomInAlt = GetCameraVKCodeFromShortcut(zoom_in and zoom_in[2])
hr.CameraTacKeyZoomIn = hr.CameraRTSKeyZoomIn
hr.CameraTacKeyZoomInAlt = hr.CameraRTSKeyZoomInAlt
local zoom_out = GetShortcuts("actionZoomOut")
hr.CameraRTSKeyZoomOut = GetCameraVKCodeFromShortcut(zoom_out and zoom_out[1])
hr.CameraRTSKeyZoomOutAlt = GetCameraVKCodeFromShortcut(zoom_out and zoom_out[2])
hr.CameraTacKeyZoomOut = hr.CameraRTSKeyZoomOut
hr.CameraTacKeyZoomOutAlt = hr.CameraRTSKeyZoomOutAlt
local overview = GetShortcuts("actionCamOverview")
--[[hr.CameraTacKeyOverview = GetCameraVKCodeFromShortcut(overview and overview[1])
hr.CameraTacKeyOverviewAlt = GetCameraVKCodeFromShortcut(overview and overview[2])]]
hr.CameraTacKeyOverview = -1
hr.CameraTacKeyOverviewAlt = -1
local temp = GetShortcuts("actionCamFloorUp")
hr.CameraTacFloorUp = GetCameraVKCodeFromShortcut(temp and temp[1])
temp = GetShortcuts("actionCamFloorDown")
hr.CameraTacFloorDown = GetCameraVKCodeFromShortcut(temp and temp[1])
temp = GetShortcuts("actionCamRotateWithMouse")
hr.CameraTacKeyRotateWithMouse = GetCameraVKCodeFromShortcut(temp and temp[1])
end
function SetupMapBorders()
if not mapdata then return end
local TacCameraBorderReduction = GetUIStyleGamepad() and 0 or 10
if mapdata.CameraUseBorderArea then
local marker = GetBorderAreaMarker()
if not marker then return end
hr.CameraTacVoxelBorderWidth = marker.AreaWidth - TacCameraBorderReduction
hr.CameraTacVoxelBorderHeight = marker.AreaHeight - TacCameraBorderReduction
local pos = marker:GetPos()
hr.CameraTacVoxelBorderCenterX = pos:x()
hr.CameraTacVoxelBorderCenterY = pos:y()
else
if mapdata.CameraArea > 0 then
hr.CameraTacVoxelBorderWidth = mapdata.CameraArea - TacCameraBorderReduction
hr.CameraTacVoxelBorderHeight = mapdata.CameraArea - TacCameraBorderReduction
end
end
hr.CameraTacFloorHeight = mapdata.CameraFloorHeight * const.SlabSizeZ
hr.CameraTacMaxFloor = mapdata.CameraMaxFloor
Msg("NewMapLoadedCameraSettingsSet")
end
OnMsg.NewMapLoaded = SetupMapBorders
OnMsg.GamepadUIStyleChanged = SetupMapBorders
|