Intial Commit
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
-- Local compatibility adapter. Original Workshop files remain dependencies.
|
||||
KFTFerret = KFTFerret or {}
|
||||
local F = KFTFerret
|
||||
F.scriptName = "Base.62daimlerFerretMk2"
|
||||
F.weaponPart = "KFT_FerretMG"
|
||||
F.ammoType = "Base.762x63mm"
|
||||
F.version = 1
|
||||
|
||||
function F.isFerret(vehicle)
|
||||
return vehicle ~= nil and vehicle:getScriptName() == F.scriptName
|
||||
end
|
||||
|
||||
function F.isGunner(vehicle, character)
|
||||
return F.isFerret(vehicle) and character ~= nil
|
||||
and character:getVehicle() == vehicle and vehicle:getSeat(character) == 1
|
||||
end
|
||||
|
||||
function F.AmmoAccess(vehicle, part, character)
|
||||
return F.isGunner(vehicle, character)
|
||||
end
|
||||
|
||||
function F.InitTurret(vehicle, part)
|
||||
local data = part:getModData()
|
||||
local vehicleData = vehicle:getModData()
|
||||
local pose = data.kftPose or vehicleData.turretAnimID or "002"
|
||||
vehicleData.turretAnimID = pose
|
||||
part:setModelVisible("Default", true)
|
||||
vehicle:playPartAnim(part, pose)
|
||||
local gloveBox = vehicle:getPartById("GloveBox")
|
||||
if gloveBox then gloveBox:setModelVisible("interiorTop", false) end
|
||||
end
|
||||
|
||||
function F.InitGloveBox(vehicle, part)
|
||||
part:setModelVisible("interiorTop", false)
|
||||
end
|
||||
|
||||
function F.InitWeapon(vehicle, part)
|
||||
local data = part:getModData()
|
||||
if not data.kftInitialized then
|
||||
-- Called once for a newly added part, including an existing-save migration.
|
||||
-- A removed or destroyed gun is never recreated on subsequent loads.
|
||||
if not part:getInventoryItem() then
|
||||
VehicleUtils.createPartInventoryItem(part)
|
||||
part:setCondition(100)
|
||||
end
|
||||
data.kftInitialized = F.version
|
||||
end
|
||||
end
|
||||
|
||||
function F.weaponReady(vehicle)
|
||||
if not F.isFerret(vehicle) then return false end
|
||||
local part = vehicle:getPartById(F.weaponPart)
|
||||
return part ~= nil and part:getInventoryItem() ~= nil and part:getCondition() > 0
|
||||
end
|
||||
|
||||
function F.poseForAngle(relativeAngle)
|
||||
local pose = math.floor(math.floor((relativeAngle % 360) + 0.5) / 2) * 2 + 2
|
||||
if pose > 360 then pose = 2 end
|
||||
return string.format("%03d", pose)
|
||||
end
|
||||
|
||||
function F.savePose(vehicle, pose)
|
||||
local turret = vehicle:getPartById("Turrent")
|
||||
if not turret then return end
|
||||
vehicle:getModData().turretAnimID = pose
|
||||
local data = turret:getModData()
|
||||
if data.kftPose ~= pose then
|
||||
data.kftPose = pose
|
||||
if isServer() then vehicle:transmitPartModData(turret) end
|
||||
end
|
||||
end
|
||||
|
||||
function F.patchScript()
|
||||
local script = getScriptManager():getVehicle(F.scriptName)
|
||||
if not script then
|
||||
print("[KI5FerretTurret] Ferret Mk2 script unavailable; adapter not applied.")
|
||||
return false
|
||||
end
|
||||
if script:getPartById(F.weaponPart) then return true end
|
||||
if not script:getPartById("GloveBox") or not script:getPartById("FER62HatchTurret") then
|
||||
print("[KI5FerretTurret] Unexpected Ferret layout; adapter not applied.")
|
||||
return false
|
||||
end
|
||||
-- Load merges only the named parts. Do NOT call Loaded(): in B42.21 it
|
||||
-- multiplies chassis dimensions and suspension by modelScale a second time.
|
||||
script:Load("62daimlerFerretMk2", require "KFT_FerretPatch")
|
||||
print("[KI5FerretTurret] Ferret Mk2 turret parts applied (v0.1.1).")
|
||||
return true
|
||||
end
|
||||
|
||||
Events.OnGameBoot.Add(F.patchScript)
|
||||
Events.OnInitGlobalModData.Add(F.patchScript)
|
||||
@@ -0,0 +1,214 @@
|
||||
return [=[
|
||||
{
|
||||
part GloveBox
|
||||
{
|
||||
lua { create = Vehicles.Create.Default, init = KFTFerret.InitGloveBox, }
|
||||
}
|
||||
part Turrent
|
||||
{
|
||||
category = nodisplay,
|
||||
area = SeatFrontRight,
|
||||
model Default { file = KFT_FerretTurret, scale = 1.0, offset = 0 0 0, rotate = 0 0 0, }
|
||||
lua { create = KFTFerret.InitTurret, init = KFTFerret.InitTurret, }
|
||||
anim 002 { anim = KFT_FerretYaw_002, animate = FALSE, }
|
||||
anim 004 { anim = KFT_FerretYaw_004, animate = FALSE, }
|
||||
anim 006 { anim = KFT_FerretYaw_006, animate = FALSE, }
|
||||
anim 008 { anim = KFT_FerretYaw_008, animate = FALSE, }
|
||||
anim 010 { anim = KFT_FerretYaw_010, animate = FALSE, }
|
||||
anim 012 { anim = KFT_FerretYaw_012, animate = FALSE, }
|
||||
anim 014 { anim = KFT_FerretYaw_014, animate = FALSE, }
|
||||
anim 016 { anim = KFT_FerretYaw_016, animate = FALSE, }
|
||||
anim 018 { anim = KFT_FerretYaw_018, animate = FALSE, }
|
||||
anim 020 { anim = KFT_FerretYaw_020, animate = FALSE, }
|
||||
anim 022 { anim = KFT_FerretYaw_022, animate = FALSE, }
|
||||
anim 024 { anim = KFT_FerretYaw_024, animate = FALSE, }
|
||||
anim 026 { anim = KFT_FerretYaw_026, animate = FALSE, }
|
||||
anim 028 { anim = KFT_FerretYaw_028, animate = FALSE, }
|
||||
anim 030 { anim = KFT_FerretYaw_030, animate = FALSE, }
|
||||
anim 032 { anim = KFT_FerretYaw_032, animate = FALSE, }
|
||||
anim 034 { anim = KFT_FerretYaw_034, animate = FALSE, }
|
||||
anim 036 { anim = KFT_FerretYaw_036, animate = FALSE, }
|
||||
anim 038 { anim = KFT_FerretYaw_038, animate = FALSE, }
|
||||
anim 040 { anim = KFT_FerretYaw_040, animate = FALSE, }
|
||||
anim 042 { anim = KFT_FerretYaw_042, animate = FALSE, }
|
||||
anim 044 { anim = KFT_FerretYaw_044, animate = FALSE, }
|
||||
anim 046 { anim = KFT_FerretYaw_046, animate = FALSE, }
|
||||
anim 048 { anim = KFT_FerretYaw_048, animate = FALSE, }
|
||||
anim 050 { anim = KFT_FerretYaw_050, animate = FALSE, }
|
||||
anim 052 { anim = KFT_FerretYaw_052, animate = FALSE, }
|
||||
anim 054 { anim = KFT_FerretYaw_054, animate = FALSE, }
|
||||
anim 056 { anim = KFT_FerretYaw_056, animate = FALSE, }
|
||||
anim 058 { anim = KFT_FerretYaw_058, animate = FALSE, }
|
||||
anim 060 { anim = KFT_FerretYaw_060, animate = FALSE, }
|
||||
anim 062 { anim = KFT_FerretYaw_062, animate = FALSE, }
|
||||
anim 064 { anim = KFT_FerretYaw_064, animate = FALSE, }
|
||||
anim 066 { anim = KFT_FerretYaw_066, animate = FALSE, }
|
||||
anim 068 { anim = KFT_FerretYaw_068, animate = FALSE, }
|
||||
anim 070 { anim = KFT_FerretYaw_070, animate = FALSE, }
|
||||
anim 072 { anim = KFT_FerretYaw_072, animate = FALSE, }
|
||||
anim 074 { anim = KFT_FerretYaw_074, animate = FALSE, }
|
||||
anim 076 { anim = KFT_FerretYaw_076, animate = FALSE, }
|
||||
anim 078 { anim = KFT_FerretYaw_078, animate = FALSE, }
|
||||
anim 080 { anim = KFT_FerretYaw_080, animate = FALSE, }
|
||||
anim 082 { anim = KFT_FerretYaw_082, animate = FALSE, }
|
||||
anim 084 { anim = KFT_FerretYaw_084, animate = FALSE, }
|
||||
anim 086 { anim = KFT_FerretYaw_086, animate = FALSE, }
|
||||
anim 088 { anim = KFT_FerretYaw_088, animate = FALSE, }
|
||||
anim 090 { anim = KFT_FerretYaw_090, animate = FALSE, }
|
||||
anim 092 { anim = KFT_FerretYaw_092, animate = FALSE, }
|
||||
anim 094 { anim = KFT_FerretYaw_094, animate = FALSE, }
|
||||
anim 096 { anim = KFT_FerretYaw_096, animate = FALSE, }
|
||||
anim 098 { anim = KFT_FerretYaw_098, animate = FALSE, }
|
||||
anim 100 { anim = KFT_FerretYaw_100, animate = FALSE, }
|
||||
anim 102 { anim = KFT_FerretYaw_102, animate = FALSE, }
|
||||
anim 104 { anim = KFT_FerretYaw_104, animate = FALSE, }
|
||||
anim 106 { anim = KFT_FerretYaw_106, animate = FALSE, }
|
||||
anim 108 { anim = KFT_FerretYaw_108, animate = FALSE, }
|
||||
anim 110 { anim = KFT_FerretYaw_110, animate = FALSE, }
|
||||
anim 112 { anim = KFT_FerretYaw_112, animate = FALSE, }
|
||||
anim 114 { anim = KFT_FerretYaw_114, animate = FALSE, }
|
||||
anim 116 { anim = KFT_FerretYaw_116, animate = FALSE, }
|
||||
anim 118 { anim = KFT_FerretYaw_118, animate = FALSE, }
|
||||
anim 120 { anim = KFT_FerretYaw_120, animate = FALSE, }
|
||||
anim 122 { anim = KFT_FerretYaw_122, animate = FALSE, }
|
||||
anim 124 { anim = KFT_FerretYaw_124, animate = FALSE, }
|
||||
anim 126 { anim = KFT_FerretYaw_126, animate = FALSE, }
|
||||
anim 128 { anim = KFT_FerretYaw_128, animate = FALSE, }
|
||||
anim 130 { anim = KFT_FerretYaw_130, animate = FALSE, }
|
||||
anim 132 { anim = KFT_FerretYaw_132, animate = FALSE, }
|
||||
anim 134 { anim = KFT_FerretYaw_134, animate = FALSE, }
|
||||
anim 136 { anim = KFT_FerretYaw_136, animate = FALSE, }
|
||||
anim 138 { anim = KFT_FerretYaw_138, animate = FALSE, }
|
||||
anim 140 { anim = KFT_FerretYaw_140, animate = FALSE, }
|
||||
anim 142 { anim = KFT_FerretYaw_142, animate = FALSE, }
|
||||
anim 144 { anim = KFT_FerretYaw_144, animate = FALSE, }
|
||||
anim 146 { anim = KFT_FerretYaw_146, animate = FALSE, }
|
||||
anim 148 { anim = KFT_FerretYaw_148, animate = FALSE, }
|
||||
anim 150 { anim = KFT_FerretYaw_150, animate = FALSE, }
|
||||
anim 152 { anim = KFT_FerretYaw_152, animate = FALSE, }
|
||||
anim 154 { anim = KFT_FerretYaw_154, animate = FALSE, }
|
||||
anim 156 { anim = KFT_FerretYaw_156, animate = FALSE, }
|
||||
anim 158 { anim = KFT_FerretYaw_158, animate = FALSE, }
|
||||
anim 160 { anim = KFT_FerretYaw_160, animate = FALSE, }
|
||||
anim 162 { anim = KFT_FerretYaw_162, animate = FALSE, }
|
||||
anim 164 { anim = KFT_FerretYaw_164, animate = FALSE, }
|
||||
anim 166 { anim = KFT_FerretYaw_166, animate = FALSE, }
|
||||
anim 168 { anim = KFT_FerretYaw_168, animate = FALSE, }
|
||||
anim 170 { anim = KFT_FerretYaw_170, animate = FALSE, }
|
||||
anim 172 { anim = KFT_FerretYaw_172, animate = FALSE, }
|
||||
anim 174 { anim = KFT_FerretYaw_174, animate = FALSE, }
|
||||
anim 176 { anim = KFT_FerretYaw_176, animate = FALSE, }
|
||||
anim 178 { anim = KFT_FerretYaw_178, animate = FALSE, }
|
||||
anim 180 { anim = KFT_FerretYaw_180, animate = FALSE, }
|
||||
anim 182 { anim = KFT_FerretYaw_182, animate = FALSE, }
|
||||
anim 184 { anim = KFT_FerretYaw_184, animate = FALSE, }
|
||||
anim 186 { anim = KFT_FerretYaw_186, animate = FALSE, }
|
||||
anim 188 { anim = KFT_FerretYaw_188, animate = FALSE, }
|
||||
anim 190 { anim = KFT_FerretYaw_190, animate = FALSE, }
|
||||
anim 192 { anim = KFT_FerretYaw_192, animate = FALSE, }
|
||||
anim 194 { anim = KFT_FerretYaw_194, animate = FALSE, }
|
||||
anim 196 { anim = KFT_FerretYaw_196, animate = FALSE, }
|
||||
anim 198 { anim = KFT_FerretYaw_198, animate = FALSE, }
|
||||
anim 200 { anim = KFT_FerretYaw_200, animate = FALSE, }
|
||||
anim 202 { anim = KFT_FerretYaw_202, animate = FALSE, }
|
||||
anim 204 { anim = KFT_FerretYaw_204, animate = FALSE, }
|
||||
anim 206 { anim = KFT_FerretYaw_206, animate = FALSE, }
|
||||
anim 208 { anim = KFT_FerretYaw_208, animate = FALSE, }
|
||||
anim 210 { anim = KFT_FerretYaw_210, animate = FALSE, }
|
||||
anim 212 { anim = KFT_FerretYaw_212, animate = FALSE, }
|
||||
anim 214 { anim = KFT_FerretYaw_214, animate = FALSE, }
|
||||
anim 216 { anim = KFT_FerretYaw_216, animate = FALSE, }
|
||||
anim 218 { anim = KFT_FerretYaw_218, animate = FALSE, }
|
||||
anim 220 { anim = KFT_FerretYaw_220, animate = FALSE, }
|
||||
anim 222 { anim = KFT_FerretYaw_222, animate = FALSE, }
|
||||
anim 224 { anim = KFT_FerretYaw_224, animate = FALSE, }
|
||||
anim 226 { anim = KFT_FerretYaw_226, animate = FALSE, }
|
||||
anim 228 { anim = KFT_FerretYaw_228, animate = FALSE, }
|
||||
anim 230 { anim = KFT_FerretYaw_230, animate = FALSE, }
|
||||
anim 232 { anim = KFT_FerretYaw_232, animate = FALSE, }
|
||||
anim 234 { anim = KFT_FerretYaw_234, animate = FALSE, }
|
||||
anim 236 { anim = KFT_FerretYaw_236, animate = FALSE, }
|
||||
anim 238 { anim = KFT_FerretYaw_238, animate = FALSE, }
|
||||
anim 240 { anim = KFT_FerretYaw_240, animate = FALSE, }
|
||||
anim 242 { anim = KFT_FerretYaw_242, animate = FALSE, }
|
||||
anim 244 { anim = KFT_FerretYaw_244, animate = FALSE, }
|
||||
anim 246 { anim = KFT_FerretYaw_246, animate = FALSE, }
|
||||
anim 248 { anim = KFT_FerretYaw_248, animate = FALSE, }
|
||||
anim 250 { anim = KFT_FerretYaw_250, animate = FALSE, }
|
||||
anim 252 { anim = KFT_FerretYaw_252, animate = FALSE, }
|
||||
anim 254 { anim = KFT_FerretYaw_254, animate = FALSE, }
|
||||
anim 256 { anim = KFT_FerretYaw_256, animate = FALSE, }
|
||||
anim 258 { anim = KFT_FerretYaw_258, animate = FALSE, }
|
||||
anim 260 { anim = KFT_FerretYaw_260, animate = FALSE, }
|
||||
anim 262 { anim = KFT_FerretYaw_262, animate = FALSE, }
|
||||
anim 264 { anim = KFT_FerretYaw_264, animate = FALSE, }
|
||||
anim 266 { anim = KFT_FerretYaw_266, animate = FALSE, }
|
||||
anim 268 { anim = KFT_FerretYaw_268, animate = FALSE, }
|
||||
anim 270 { anim = KFT_FerretYaw_270, animate = FALSE, }
|
||||
anim 272 { anim = KFT_FerretYaw_272, animate = FALSE, }
|
||||
anim 274 { anim = KFT_FerretYaw_274, animate = FALSE, }
|
||||
anim 276 { anim = KFT_FerretYaw_276, animate = FALSE, }
|
||||
anim 278 { anim = KFT_FerretYaw_278, animate = FALSE, }
|
||||
anim 280 { anim = KFT_FerretYaw_280, animate = FALSE, }
|
||||
anim 282 { anim = KFT_FerretYaw_282, animate = FALSE, }
|
||||
anim 284 { anim = KFT_FerretYaw_284, animate = FALSE, }
|
||||
anim 286 { anim = KFT_FerretYaw_286, animate = FALSE, }
|
||||
anim 288 { anim = KFT_FerretYaw_288, animate = FALSE, }
|
||||
anim 290 { anim = KFT_FerretYaw_290, animate = FALSE, }
|
||||
anim 292 { anim = KFT_FerretYaw_292, animate = FALSE, }
|
||||
anim 294 { anim = KFT_FerretYaw_294, animate = FALSE, }
|
||||
anim 296 { anim = KFT_FerretYaw_296, animate = FALSE, }
|
||||
anim 298 { anim = KFT_FerretYaw_298, animate = FALSE, }
|
||||
anim 300 { anim = KFT_FerretYaw_300, animate = FALSE, }
|
||||
anim 302 { anim = KFT_FerretYaw_302, animate = FALSE, }
|
||||
anim 304 { anim = KFT_FerretYaw_304, animate = FALSE, }
|
||||
anim 306 { anim = KFT_FerretYaw_306, animate = FALSE, }
|
||||
anim 308 { anim = KFT_FerretYaw_308, animate = FALSE, }
|
||||
anim 310 { anim = KFT_FerretYaw_310, animate = FALSE, }
|
||||
anim 312 { anim = KFT_FerretYaw_312, animate = FALSE, }
|
||||
anim 314 { anim = KFT_FerretYaw_314, animate = FALSE, }
|
||||
anim 316 { anim = KFT_FerretYaw_316, animate = FALSE, }
|
||||
anim 318 { anim = KFT_FerretYaw_318, animate = FALSE, }
|
||||
anim 320 { anim = KFT_FerretYaw_320, animate = FALSE, }
|
||||
anim 322 { anim = KFT_FerretYaw_322, animate = FALSE, }
|
||||
anim 324 { anim = KFT_FerretYaw_324, animate = FALSE, }
|
||||
anim 326 { anim = KFT_FerretYaw_326, animate = FALSE, }
|
||||
anim 328 { anim = KFT_FerretYaw_328, animate = FALSE, }
|
||||
anim 330 { anim = KFT_FerretYaw_330, animate = FALSE, }
|
||||
anim 332 { anim = KFT_FerretYaw_332, animate = FALSE, }
|
||||
anim 334 { anim = KFT_FerretYaw_334, animate = FALSE, }
|
||||
anim 336 { anim = KFT_FerretYaw_336, animate = FALSE, }
|
||||
anim 338 { anim = KFT_FerretYaw_338, animate = FALSE, }
|
||||
anim 340 { anim = KFT_FerretYaw_340, animate = FALSE, }
|
||||
anim 342 { anim = KFT_FerretYaw_342, animate = FALSE, }
|
||||
anim 344 { anim = KFT_FerretYaw_344, animate = FALSE, }
|
||||
anim 346 { anim = KFT_FerretYaw_346, animate = FALSE, }
|
||||
anim 348 { anim = KFT_FerretYaw_348, animate = FALSE, }
|
||||
anim 350 { anim = KFT_FerretYaw_350, animate = FALSE, }
|
||||
anim 352 { anim = KFT_FerretYaw_352, animate = FALSE, }
|
||||
anim 354 { anim = KFT_FerretYaw_354, animate = FALSE, }
|
||||
anim 356 { anim = KFT_FerretYaw_356, animate = FALSE, }
|
||||
anim 358 { anim = KFT_FerretYaw_358, animate = FALSE, }
|
||||
anim 360 { anim = KFT_FerretYaw_360, animate = FALSE, }
|
||||
}
|
||||
part FER62HatchTurret
|
||||
{
|
||||
parent = Turrent,
|
||||
model HATCHtop { file = KFT_FerretHatch, scale = 1.0, offset = 0 0 0, rotate = 0 0 0, }
|
||||
anim Open { anim = KFT_FerretHatch, reverse = FALSE, animate = TRUE, rate = 1.0, }
|
||||
anim Close { anim = KFT_FerretHatch, reverse = TRUE, animate = TRUE, rate = 1.5, }
|
||||
anim Closed { anim = KFT_FerretHatch, reverse = FALSE, animate = FALSE, }
|
||||
anim Opened { anim = KFT_FerretHatch, reverse = TRUE, animate = FALSE, }
|
||||
}
|
||||
part KFT_FerretMG
|
||||
{
|
||||
itemType = Base.M1919A4_Coax2,
|
||||
category = Turrent,
|
||||
area = SeatFrontRight,
|
||||
mechanicArea = SeatFrontRight,
|
||||
parent = Turrent,
|
||||
container { capacity = 10, conditionAffectsCapacity = false, test = KFTFerret.AmmoAccess, }
|
||||
lua { create = KFTFerret.InitWeapon, init = KFTFerret.InitWeapon, }
|
||||
}
|
||||
}
|
||||
]=]
|
||||
Reference in New Issue
Block a user