Created
December 24, 2020 11:43
-
-
Save Rylius/bf6a1fc4555ecf06c60643ebeb285fb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return function() | |
local vdvBuggy = VehicleBlueprint(ResourceManager:SearchForDataContainer('Vehicles/VDV_Buggy/VDV_Buggy')) | |
local partition = ResourceManager:FindDatabasePartition(vdvBuggy.partitionGuid) | |
local vehicle = VehicleBlueprint(vdvBuggy) | |
vehicle:MakeWritable() | |
--vehicle.name = 'ExtraVehicles/FamilyWagon_01' | |
local vehicleEntityData = VehicleEntityData(vehicle.object) | |
vehicleEntityData:MakeWritable() | |
vehicleEntityData.nametagHeightScale = 1 | |
vehicleEntityData.hudData.minimapIcon = UIHudIcon.UIHudIcon_Car | |
local staticModel = StaticModelEntityData(ObjectBlueprint(ResourceManager:SearchForDataContainer('Props/Vehicles/FamilyWagon_01/FamilyWagon_01')).object) | |
local mesh = CompositeMeshAsset(staticModel.mesh) | |
vehicleEntityData.mesh = mesh | |
-- Copy the physics data and make the rigid body dynamic | |
local physicsEntityData = PhysicsEntityData(staticModel.physicsData:Clone()) | |
physicsEntityData:MakeWritable() | |
local rigidBodyData = RigidBodyData(physicsEntityData.rigidBodies[2]) | |
rigidBodyData:MakeWritable() | |
rigidBodyData.mass = 1000 | |
rigidBodyData.motionType = RigidBodyMotionType.RigidBodyMotionType_Dynamic | |
rigidBodyData.collisionLayer = RigidBodyCollisionLayer.RigidBodyCollisionLayer_VehicleLayer | |
vehicleEntityData.physicsData = physicsEntityData | |
-- Part Indices | |
-- 0: chassis exterior | |
-- 1: light front left | |
-- 2: light front right | |
-- 3: hood | |
-- 4: hood (wreck) | |
-- 5: interior | |
-- 6: interior | |
-- 7: driver door left | |
-- 8: driver door left (wreck) | |
-- 9: sliding door | |
-- 10: sliding door (wreck) | |
-- 11: front door (right) | |
-- 12: light rear left | |
-- 13: light rear right | |
-- 14: driver door right (wreck) | |
-- 15: chassis exterior | |
-- 16: front window | |
-- 17: front window (broken) | |
-- 18: passenger window left | |
-- 19: | |
-- 20: | |
-- 21: passenger window right (broken) | |
-- 22: passenger window right | |
-- 23: passenger window right (broken) | |
-- 24: driver window left | |
-- 25: driver window left (broken) | |
-- 26: (probably window) | |
-- 27: (probably window) | |
-- 28: (probably window) | |
-- 29: passenger window left (broken) | |
-- 30: rear window | |
-- 31: rear window (broken) | |
local chassis = ChassisComponentData(vehicleEntityData.components[1]) | |
chassis:MakeWritable() | |
-- Copy chassis health states from the static model | |
local staticModelExteriorPart = PartComponentData(staticModel.components[1]) | |
chassis.healthStates:clear() | |
for _, healthState in ipairs(staticModelExteriorPart.healthStates) do | |
chassis.healthStates:add(HealthStateData(healthState:Clone())) | |
end | |
chassis.healthStates[4]:MakeWritable() | |
chassis.healthStates[4].spawnedBangerBlueprint = ObjectBlueprint(ResourceManager:FindInstanceByGuid(Guid('DAB89878-81F7-11E0-A3CF-DBFC1A592FF5'), Guid('D6F355EE-39F9-8425-8DCF-A39AE9443114'))) | |
local wheelFrontLeft = WheelComponentData(chassis.components[11]) | |
local wheelFrontRight = WheelComponentData(chassis.components[10]) | |
local wheelRearLeft = WheelComponentData(chassis.components[9]) | |
local wheelRearRight = WheelComponentData(chassis.components[8]) | |
local wheelHeight = 0.4 | |
local wheelSideDistance = 0.75 | |
wheelFrontLeft:MakeWritable() | |
wheelFrontLeft.transform.trans = Vec3(wheelSideDistance, wheelHeight, 1.15) | |
wheelFrontRight:MakeWritable() | |
wheelFrontRight.transform.trans = Vec3(-wheelSideDistance, wheelHeight, 1.15) | |
wheelRearLeft:MakeWritable() | |
wheelRearLeft.transform.trans = Vec3(wheelSideDistance, wheelHeight, -1.55) | |
wheelRearRight:MakeWritable() | |
wheelRearRight.transform.trans = Vec3(-wheelSideDistance, wheelHeight, -1.55) | |
local wheelPartIndices = { | |
{ wheelFrontLeft, -1, Quat(Vec3.up, Vec3.right) }, | |
{ wheelFrontRight, -1, Quat(Vec3.up, Vec3.left) }, | |
{ wheelRearLeft, -1, Quat(Vec3.up, Vec3.right) }, | |
{ wheelRearRight, -1, Quat(Vec3.up, Vec3.left) }, | |
} | |
for _, entry in ipairs(wheelPartIndices) do | |
local wheel = entry[1] | |
local wheelHealthState = HealthStateData(wheel.healthStates[1]) | |
wheelHealthState:MakeWritable() | |
wheelHealthState.partIndex = entry[2] | |
local tireMeshComponent = MeshComponentData() | |
tireMeshComponent.mesh = RigidMeshAsset(ResourceManager:FindInstanceByGuid(Guid('7E32F57E-97FB-AFF8-04C2-5F5735C2822B'), Guid('E918FF39-4895-EFEB-A5CD-65B54213C980'))) | |
tireMeshComponent.transform = QuatTransform(entry[3], Vec4(0, 0, 0, 0.85)):ToLinearTransform() | |
wheel.components:add(tireMeshComponent) | |
end | |
-- Adjust driver position | |
local playerEntryData = PlayerEntryComponentData(chassis.components[3]) | |
playerEntryData:MakeWritable() | |
playerEntryData.entryRadius = 4 | |
playerEntryData.transform.trans = Vec3(0.55, 1.1, 0.8) -- Camera | |
playerEntryData.soldierOffset = Vec3(0.04, 0.4, 1.18) | |
local frontPassengerPart = PartComponentData(chassis.components[5]) | |
local leftAimingConstraints = AimingConstraintsData() | |
leftAimingConstraints.minYaw = -120 | |
leftAimingConstraints.maxYaw = 45 | |
leftAimingConstraints.minPitch = -30 | |
leftAimingConstraints.maxPitch = 45 | |
local rightAimingConstraints = AimingConstraintsData() | |
rightAimingConstraints.minYaw = -45 | |
rightAimingConstraints.maxYaw = 120 | |
rightAimingConstraints.minPitch = -30 | |
rightAimingConstraints.maxPitch = 45 | |
local passengerSeats = { | |
{ Vec3(-0.35, 0.85, 0.95), rightAimingConstraints }, -- front right | |
{ Vec3(0.5, 0.85, -0.4), leftAimingConstraints }, -- middle left | |
{ Vec3(-0.35, 0.85, -0.4), rightAimingConstraints }, -- middle right | |
{ Vec3(0.5, 0.85, -1.5), leftAimingConstraints }, -- rear left | |
{ Vec3(-0.35, 0.85, -1.5), rightAimingConstraints }, -- right right | |
} | |
for _, seat in ipairs(passengerSeats) do | |
local part = PartComponentData(frontPassengerPart:Clone()) | |
part.transform.trans = seat[1] | |
local soldierEntry = SoldierEntryComponentData(part.components[1]:Clone()) | |
soldierEntry.aimingConstraints = seat[2] | |
part.components:clear() | |
part.components:add(soldierEntry) | |
chassis.components:add(part) | |
end | |
frontPassengerPart:MakeWritable() | |
frontPassengerPart.excluded = true | |
-- There is no separate steering wheel mesh, so disable it | |
local steeringWheelHealthState = HealthStateData(partition:FindInstance(Guid('0C490B1A-D5EF-499B-FF27-FB82E33EDFE4'))) | |
steeringWheelHealthState:MakeWritable() | |
steeringWheelHealthState.partIndex = -1 | |
-- Copy over all the individual parts of the static model | |
local parentPart = PartComponentData(chassis.components[14]) | |
parentPart:MakeWritable() | |
parentPart.components:clear() | |
for i, part in ipairs(staticModel.components) do | |
if i >= 2 and i <= 18 then | |
parentPart.components:add(part) | |
end | |
end | |
-- Remove the MG turret | |
local turretPart = PartComponentData(chassis.components[4]) | |
turretPart:MakeWritable() | |
turretPart.excluded = true | |
return vehicle | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment