Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions newmodels_azul/scripts/core/client_logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,84 @@ local reusableModelElements = {}
local currFreeIdDelay = 9500 -- ms
local FREE_ID_DELAY_STEP = 500 -- ms

local countHandlingTable = {
[1] = "mass",
[2] = "turnMass",
[3] = "dragCoeff",
[4] = "centerOfMassX",
[5] = "centerOfMassY",
[6] = "centerOfMassZ",
[7] = "percentSubmerged",
[8] = "tractionMultiplier",
[9] = "tractionLoss",
[10] = "tractionBias",
[11] = "numberOfGears",
[12] = "maxVelocity",
[13] = "engineAcceleration",
[14] = "engineInertia",
[15] = "driveType",
[16] = "engineType",
[17] = "brakeDeceleration",
[18] = "brakeBias",
[19] = "ABS",
[20] = "steeringLock",
[21] = "suspensionForceLevel",
[22] = "suspensionDamping",
[23] = "suspensionHighSpeedDamping",
[24] = "suspensionUpperLimit",
[25] = "suspensionLowerLimit",
[26] = "suspensionFrontRearBias",
[27] = "suspensionAntiDiveMultiplier",
[28] = "seatOffsetDistance",
[29] = "collisionDamageMultiplier",
[30] = "monetary",
[31] = "modelFlags",
[32] = "handlingFlags",
[33] = "headLight",
[34] = "tailLight",
[35] = "animGroup",
}

local driveTypes = {
["4"] = "awd",
["r"] = "rwd",
["f"] = "fwd",
}

local function setVehicleHandlingFromText(vehicle, text)
local t = {}
local tText = split(text, " ")
table.remove (tText, 1)
for i, v in ipairs (tText) do
t[countHandlingTable[i]] = v
end

local acceptCenterMass = false
local centerMass = {x = nil, y = nil, z = nil}
for i, v in pairs (t) do
if i == "centerOfMassX" then
centerMass.x = tonumber(v)
elseif i == "centerOfMassY" then
centerMass.y = tonumber(v)
elseif i == "centerOfMassZ" then
centerMass.z = tonumber(v)
else
if centerMass.x and centerMass.y and centerMass.z and not acceptCenterMass then
setVehicleHandling (vehicle, "centerOfMass", {centerMass.x, centerMass.y, centerMass.z})
acceptCenterMass = true
end

if i == "modelFlags" or i == "handlingFlags" then
setVehicleHandling (vehicle, i, "0x"..tostring(v))
elseif i == "driveType" then
setVehicleHandling (vehicle, i, driveTypes[v])
else
setVehicleHandling (vehicle, i, tonumber(v) or tostring(v))
end
end
end
end

local function applyElementCustomModel(element)
local customModel = elementModels[element]
if not customModel then return end
Expand Down Expand Up @@ -37,6 +115,9 @@ local function applyElementCustomModel(element)
setVehicleHandling(element, k, v)
end
end
if loadedModel.handling then
setVehicleHandlingFromText(element, loadedModel.handling)
end
if paintjob then
setVehiclePaintjob(element, paintjob)
end
Expand Down Expand Up @@ -111,6 +192,7 @@ local function finishLoadCustomModel(customModel)
col = col and col.path or nil,
},
disableAutoFree = disableAutoFree or false,
handling = customInfo.settings.handling,
}

if isElement(elementToApply) then
Expand Down
6 changes: 6 additions & 0 deletions newmodels_azul/scripts/core/server_logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ local function parseModelSettings(customModel, customModelInfo, thisFullPath, is
return false, "invalid lodDistance value: " .. settingStr
end
customModelSettings.lodDistance = lodDistance
elseif stringStartswith(settingStr, "handling=") then
local handlingText = settingStr:sub(10)
if not handlingText then
return false, "invalid handling value: " .. settingStr
end
customModelSettings.handling = handlingText
elseif stringStartswith(settingStr, "settings=") then
if isFromSettingsOption then -- prevent inception and recursion
return false, "settings option cannot point to a settings file that contains another settings option @ " .. thisFullPath
Expand Down