File size: 5,865 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 |
const.TunnelTypeWalk = 2^0
const.TunnelTypeStairs = 2^1
const.TunnelTypeLadder = 2^2
const.TunnelTypeDrop1 = 2^3
const.TunnelTypeDrop2 = 2^4
const.TunnelTypeDrop3 = 2^5
const.TunnelTypeDrop4 = 2^6
const.TunnelTypeClimb1 = 2^7
const.TunnelTypeClimb2 = 2^8
const.TunnelTypeClimb3 = 2^9
const.TunnelTypeClimb4 = 2^10
const.TunnelTypeJumpOver1 = 2^11
const.TunnelTypeJumpOver2 = 2^12
const.TunnelTypeJumpAcross1 = 2^13
const.TunnelTypeJumpAcross2 = 2^14
const.TunnelTypeDoor = 2^15
const.TunnelTypeDoorBlocked = 2^16
const.TunnelTypeWindow = 2^17
const.TunnelMaskWalkFlat = const.TunnelTypeWalk
const.TunnelMaskWalk = const.TunnelTypeWalk | const.TunnelTypeStairs
const.TunnelMaskClimb = const.TunnelTypeClimb1 | const.TunnelTypeClimb2 | const.TunnelTypeClimb3 | const.TunnelTypeClimb4
const.TunnelMaskDrop = const.TunnelTypeDrop1 | const.TunnelTypeDrop2 | const.TunnelTypeDrop3 | const.TunnelTypeDrop4
const.TunnelMaskClimbDrop = const.TunnelMaskClimb| const.TunnelMaskDrop
const.TunnelMaskSmallAnimals = const.TunnelMaskWalk | const.TunnelTypeClimb1 | const.TunnelTypeClimb2 | const.TunnelTypeDrop1 | const.TunnelTypeDrop2
const.TunnelMaskLargeAnimals = const.TunnelMaskWalk
const.TunnelMaskPlayerStanding = -1
const.TunnelMaskPlayerProne = const.TunnelTypeWalk
const.TunnelMaskAIStanding = const.TunnelMaskPlayerStanding & ~const.TunnelTypeDoorBlocked
const.TunnelMaskAIProne = const.TunnelMaskPlayerProne & ~const.TunnelTypeDoorBlocked
const.TunnelMaskCivilian = const.TunnelMaskPlayerStanding & ~(const.TunnelTypeDoorBlocked | const.TunnelTypeWindow | const.TunnelMaskClimbDrop)
| const.TunnelTypeDrop1 | const.TunnelTypeClimb1
const.TunnelMaskMeleeRange = const.TunnelMaskWalk | const.TunnelTypeClimb1 | const.TunnelTypeDrop1 | const.TunnelTypeJumpOver1
const.TunnelMaskClosedDoor = const.TunnelTypeDoor | const.TunnelTypeDoorBlocked
const.TunnelMaskTraverseWait =
const.TunnelTypeLadder |
const.TunnelTypeDrop2 |
const.TunnelTypeDrop3 |
const.TunnelTypeDrop4 |
const.TunnelTypeClimb1 |
const.TunnelTypeClimb2 |
const.TunnelTypeClimb3 |
const.TunnelTypeClimb4 |
const.TunnelTypeJumpOver1 |
const.TunnelTypeJumpOver2 |
const.TunnelTypeJumpAcross1 |
const.TunnelTypeJumpAcross2 |
const.TunnelTypeDoorBlocked |
const.TunnelTypeWindow
const.TunnelMaskWalkStopAnim =
const.TunnelTypeLadder |
const.TunnelTypeDrop3 |
const.TunnelTypeDrop4 |
const.TunnelTypeClimb2 |
const.TunnelTypeClimb3 |
const.TunnelTypeClimb4 |
const.TunnelTypeDoor |
const.TunnelTypeDoorBlocked |
const.TunnelTypeWindow
local costWalk = 500
local difficult_terrain_modifier = 50
local costDifficultTerrain = costWalk * (100 + difficult_terrain_modifier) / 100
if Platform.desktop and Platform.developer then
function OnMsg.Autorun()
-- update the constant depend on the preset
assert(costWalk == Presets.ConstDef["Action Point Costs"].Walk.value * const.PassTileSize / const.SlabSizeX)
assert(difficult_terrain_modifier == Presets.ConstDef["Action Point Costs"].DifficultTerrainModifier.value)
end
end
pathfind_pass_types = {
"DefaultPass",
"DifficultTerrain",
"AmbientLifeAvoid",
"FireTerrain",
}
pathfind_pass_grid_types = {
"DefaultPass",
"AmbientLifeAvoid",
"FireTerrain",
}
pathfind_water_pass_type = "DifficultTerrain"
pathfind_water_pass_type_idx = (table.find(pathfind_pass_types, pathfind_water_pass_type) or 0) - 1 -- zero based
local default_pfcontext_meta = { __index = {
depth = 100000,
min_depth = 100000,
max_path_search_radius_coef = 100,
heuristic_mul = 2 * 4, -- 2 bit fixed point
heuristic_start_depth = 20000,
task_sleep = 0,
tunnel_mask = -1,
-- pass type costs
DefaultPass = costWalk,
DifficultTerrain = costDifficultTerrain,
AmbientLifeAvoid = costWalk,
FireTerrain = costWalk * 3,
}}
pathfind = {
{ -- player controlled unit standing or crouch stance
tunnel_mask = const.TunnelMaskPlayerStanding,
},
{ -- player controlled unit prone stance
tunnel_mask = const.TunnelMaskPlayerProne,
DifficultTerrain = const.pfImpassableCost,
},
{ -- AI controlled unit standing or crouch stance
tunnel_mask = const.TunnelMaskAIStanding,
},
{ -- AI controlled unit prone stance
tunnel_mask = const.TunnelMaskAIProne,
DifficultTerrain = const.pfImpassableCost,
},
{ -- ambient life
tunnel_mask = const.TunnelMaskCivilian,
AmbientLifeAvoid = 4 * costWalk,
FireTerrain = 4 * costWalk,
},
{ -- small animals
tunnel_mask = const.TunnelMaskSmallAnimals,
},
{ -- large animals
tunnel_mask = const.TunnelMaskLargeAnimals,
large_unit_pass_radius = 1,
large_unit_collision_cost = 4 * costWalk,
},
}
for i, t in ipairs(pathfind) do
setmetatable(t, default_pfcontext_meta)
end
function CalcPFClass(side, stance, body_type)
if body_type == "Large animal" then
return 6
elseif body_type == "Small animal" then
return 5
elseif not side or side == "neutral" then
return 4
elseif side ~= "player1" and side ~= "player2" then
return stance == "Prone" and 3 or 2
end
return stance == "Prone" and 1 or 0
end
pathfind_surf_types = {}
const.MaxPassableTerrainSlope = atan(const.SlabSizeZ, const.SlabSizeX)
const.PathMaxUnitRadius = 6*guim
const.PathMaxZTolerance = 2*guim
const.PathStrandedArea = 0
const.MaxPassableWaterDepth = 0 -- when the water is marker impassable
-- Obstacle collision spheroid sizes (in cm units)
const.passSpheroidWidth = 60*guic
const.passSpheroidHeight = 165*guic
const.passSpheroidCollisionOffsetZ = 10*guic
const.passVoxelTileSpheroidWidth = 80*guic
const.passVoxelTileSpheroidHeight = 175*guic
const.passVoxelTileSpheroidCollisionOffsetZ = 10*guic
--const.PathTurnAnimBlendTime = 500
--const.PathTurnRadius = 3*guim -- Defines the max arc radius for a 90 deg turn (in normal and large pass grids)
--const.PathTurnAnimRadius = 150*guic -- Defines the arc radius of the turning animation (the min "confortable" turn radius)
--const.PathTurnMinTime = 600
|