Intial Commit

This commit is contained in:
2026-10-27 17:27:44 -04:00
parent 1fa6e14bde
commit 5743c34a21
49 changed files with 1454 additions and 0 deletions
@@ -0,0 +1,113 @@
KLTLAV = KLTLAV or {}
local L = KLTLAV
L.scriptName = "Base.84gageV300fsv"
L.weaponPart = "KLT_LAV90"
L.storagePart = "KLT_LAVAmmo"
L.ammoType = "KLT.Shell90AP"
L.heAmmoType = "KLT.Shell90HE"
L.pendingReload = L.pendingReload or {}
function L.isAmmoType(fullType)
return fullType == L.ammoType or fullType == L.heAmmoType
end
function L.isLAV(vehicle)
return vehicle ~= nil and vehicle:getScriptName() == L.scriptName
end
function L.isGunner(vehicle, character)
return L.isLAV(vehicle) and character ~= nil and not character:isDead()
and character:getVehicle() == vehicle and vehicle:getSeat(character) == 1
end
function L.AmmoAccess(vehicle, part, character)
return L.isGunner(vehicle, character)
end
function L.BreechAccess(vehicle, part, character)
-- The reload action alone inserts one round. Storage remains accessible.
return false
end
function L.InitGloveBox(vehicle, part)
part:setModelVisible("BaseV300FSV", false)
part:setModelVisible("InteriorV3002", false)
end
function L.InitTurret(vehicle, part)
local pose = part:getModData().kltPose or vehicle:getModData().turretAnimID or "002"
vehicle:getModData().turretAnimID = pose
part:setModelVisible("Default", true)
vehicle:playPartAnim(part, pose)
local glove = vehicle:getPartById("GloveBox")
if glove then L.InitGloveBox(vehicle, glove) end
end
function L.InitInterior(vehicle, part)
-- One animated model per part. B42 updates each ModelInfo against the
-- first ModelInfo for its part; two independent players on Turrent would
-- clear the owner's track pointer and leak its frozen pose tracks.
part:setModelVisible("Default", true)
end
function L.CreateGunnerDoor(vehicle, part)
Vehicles.Create.Door(vehicle, part)
part:setModelVisible("KLT_RigLink", true)
end
function L.InitGunnerDoor(vehicle, part)
Vehicles.Init.Door(vehicle, part)
part:setModelVisible("KLT_RigLink", true)
end
local function initializePart(vehicle, part)
local data = part:getModData()
if not data.kltInitialized then
if not part:getInventoryItem() then
VehicleUtils.createPartInventoryItem(part)
part:setCondition(100)
end
data.kltInitialized = 1
end
end
L.InitWeapon = initializePart
L.InitStorage = initializePart
function L.weaponReady(vehicle)
if not L.isLAV(vehicle) then return false end
local part = vehicle:getPartById(L.weaponPart)
return part ~= nil and part:getInventoryItem() ~= nil and part:getCondition() > 0
end
function L.poseForAngle(angle)
local pose = math.floor(math.floor((angle % 360) + 0.5) / 2) * 2 + 2
if pose > 360 then pose = 2 end
return string.format("%03d", pose)
end
function L.savePose(vehicle, pose)
local part = vehicle:getPartById("Turrent")
if not part then return end
vehicle:getModData().turretAnimID = pose
if part:getModData().kltPose ~= pose then
part:getModData().kltPose = pose
if isServer() then vehicle:transmitPartModData(part) end
end
end
function L.patchScript()
local script = getScriptManager():getVehicle(L.scriptName)
if not script then print("[KI5LAVTurret] LAV FSV script unavailable."); return false end
if script:getPartById(L.weaponPart) then return true end
if not script:getPartById("WindowGunnerHatch") or not script:getPartById("GloveBox")
or not script:getPartById("DoorRearLeft") or not script:getPartById("V300fsvViewports") then
print("[KI5LAVTurret] Unexpected LAV FSV layout; adapter not applied.")
return false
end
-- Merge only the named parts. Loaded() would rescale finalized physics.
script:Load("84gageV300fsv", require "KLT_LAVPatch")
print("[KI5LAVTurret] LAV FSV parts applied (v0.1.2).")
return true
end
Events.OnGameBoot.Add(L.patchScript)
Events.OnInitGlobalModData.Add(L.patchScript)