Scripts guide/Vehicle Script Guide/Example

From PZwiki
module Base

{

    vehicle MOD_NAME

    {

        mechanicType = 1,

        offRoadEfficiency = 0.8,

        engineRepairLevel = 4,

        playerDamageProtection = 0.8,

      /* The first model is always used as the vehicle's model. */

        model

        {

            file = Vehicles_MOD_NAME,

            scale = 2.15,

            offset = 0 0.20 0,

        }


       /* List the different skins for this vehicle here.

          A random skin will be chosen when a vehicle is first created.*/

        skin

        {

            texture = Vehicles/Vehicle_MOD_NAME_Shell,

        }



        textureRust = Vehicles/Vehicle_MOD_NAME_Rust,

        textureMask = Vehicles/Vehicle_MOD_NAME_Mask,

        textureLights = Vehicles/Vehicle_MOD_NAME_Lights,

         textureDamage1Overlay = Vehicles/Vehicle_MOD_NAME_Overlays_Damaged01,

        textureDamage1Shell = Vehicles/Vehicle_MOD_NAME_Shell_Damaged01,

        textureDamage2Overlay = Vehicles/Vehicle_MOD_NAME_Overlays_Damaged02,

        textureDamage2Shell = Vehicles/Vehicle_MOD_NAME_Shell_Damaged02,




        sound

        {

            horn = vehicle_horn1,

        }


       /* The size (in physics coordinates, not affected by model scale)

          of the collision body. */

        extents = 1.75 1 4.7,

       /* shadowOffset - Shadow boundaries shift:

          (right), (left),  (front), (rear) */

        shadowOffset = 0.0 0.0 0.0 0.0,

        mass = 650,

        physicsChassisShape = 1.75 0.85 4.7,


       /* Center of mass relative to the chassis origin.  The lower it

          is, the less likely the vehicle is to flip.

          Setting y too low will cause the vehicle to lean the wrong way

          in turns and when accelerating/braking. */

        centerOfMassOffset = 0.0 0.30 0.0,

      /* Amount of torque applied to each wheel.

           This provides the vehicle's acceleration */

        engineForce = 3600,

        engineQuality = 60,

        engineLoudness = 55,

        maxSpeed = 70f,

      /* Amount of braking torque applied to each wheel. */

        brakingForce = 60,


       gearRatioCount = 4,

       gearRatioR = 4.7,

       gearRatio1 = 3.6,

       gearRatio2 = 2.2,

       gearRatio3 = 1.3,

       gearRatio4 = 1.0,


       extentsOffset = 0.5 0.5,


        stoppingMovementForce = 2.0f,


       /* Reduces the rolling torque applied from the wheels that

         cause the vehicle to roll over.

          This is a bit of a hack, but it's quite effective.

          0.0 = no roll, 1.0 = physical behaviour.

          If m_frictionSlip is too high, you'll need to reduce this to

         stop the vehicle rolling over.

          You should also try lowering the vehicle's center of mass */

        rollInfluence = 1.0f,


       /* How quickly the front wheels change facing direction. */

       steeringIncrement = 0.02,


       /* Maximum steering angle. */

       steeringClamp = 0.3,


       /* The stiffness constant for the suspension.

          10.0 - Offroad buggy,

          50.0 - Sports car,

          200.0 - F1 Car */

        suspensionStiffness = 30,


       /* The damping coefficient for when the suspension is compressed.

          Set to k * 2.0 * btSqrt(m_suspensionStiffness) so k is

          proportional to critical damping.

          k = 0.0 undamped & bouncy, k = 1.0 critical damping

          0.1 to 0.3 are good values */

        suspensionCompression = 2.83 /*0.88*/ /*4.4*/, /* aka wheelsDampingCompression */


        /* The damping coefficient for when the suspension is expanding.

         See the comments for m_wheelsDampingCompression for how to

         set k.

         m_wheelsDampingRelaxation should be slightly larger than

         wheelsDampingCompression, eg 0.2 to 0.5 */

        suspensionDamping = 2.88 /*1.76*/ /*2.3*/, /* aka wheelsDampingRelaxation */


       /* The maximum distance the suspension can be compressed

          (centimetres) */

        /*    float minSuspensionLength = wheel.getSuspensionRestLength() - wheel.maxSuspensionTravelCm * 0.01f;

            float maxSuspensionLength = wheel.getSuspensionRestLength() + wheel.maxSuspensionTravelCm * 0.01f; */

        maxSuspensionTravelCm = 100,


       /* The maximum length of the suspension (metres) */

        suspensionRestLength = 0.3f,


       /* The coefficient of friction between the tire and the ground.

          Should be about 0.8 for realistic cars, but can be increased

          for better handling.

          Set large (10000.0) for kart racers */

        wheelFriction = 1.6f /*1000*/, /* aka frictionSlip */


       /* The amount of collision damage the vehicle can sustain while

          still being driveable. */

        frontEndHealth = 150,

        rearEndHealth = 150,

        seats = 4,


        wheel FrontLeft

        {

            front = true,

            /* offset of wheel-model origin from chassis origin, in unscaled model coordinate space */

            offset = 0.32f 0.14f 0.60f,

            radius = 0.3f,

            width = 0.2f,

        }


        wheel FrontRight

        {

            front = true,

            offset = -0.32f 0.14f 0.60f,

            radius = 0.3f,

            width = 0.2f,

        }


        wheel RearLeft

        {

            front = false,

            offset = 0.32f 0.14f -0.67f,

            radius = 0.3f,

            width = 0.2f,

        }


        wheel RearRight

        {

            front = false,

            offset = -0.32f 0.14f -0.67f,

            radius = 0.3f,

            width = 0.2f,

        }


        template = PassengerSeat4,


        passenger FrontLeft

        {

            position inside

            {

                offset = 0.2 0 -0.0121,

                rotate = 0.0 0.0 0.0,

            }

            position outside

            {

                offset = 0.5698 0 -0.0121,

                rotate = 0.0 0.0 0.0,

            }

        }

        passenger FrontRight

        {

            position inside

            {

                offset = -0.2 0 -0.0121,

                rotate = 0.0 0.0 0.0,

            }

            position outside

            {

                offset = -0.5698 0 -0.0121,

                rotate = 0.0 0.0 0.0,

            }

        }

        passenger RearLeft

        {

            position inside

            {

                offset = 0.2 0 -0.4,

                rotate = 0.0 0.0 0.0,

            }

            position outside

            {

            }

        }

        passenger RearRight

        {

            position inside

            {

                offset = -0.2 0 -0.4,

                rotate = 0.0 0.0 0.0,

            }

            position outside

            {

            }

        }



        area Engine

        {

            xywh = 0 1.3256 0.814 0.4651,

        }

        area TruckBed

        {

            xywh = 0 -1.3256 0.814 0.4651,

        }

        area SeatFrontLeft

        {

            xywh = 0.6395 -0.0121 0.4651 0.6512,

        }

        area SeatFrontRight

        {

            xywh = -0.6395 -0.0121 0.4651 0.6512,

        }

        area GasTank

        {

            xywh = 0.6395 -0.668 0.4651 0.4651,

        }

        area TireFrontLeft

        {

            xywh = 0.6395 0.6 0.4651 0.4651,

        }

        area TireFrontRight

        {

            xywh = -0.6395 0.6 0.4651 0.4651,

        }

        area TireRearLeft

        {

            xywh = 0.6395 -0.67 0.4651 0.4651,

        }

        area TireRearRight

        {

            xywh = -0.6395 -0.67 0.4651 0.4651,

        }


        template = TrunkDoor,


        template = Trunk/part/TruckBed,


        part TruckBed

        {

            itemType = Base.SmallTrunk,

            container

            {

                capacity = 40,

            }

        }


        template = Seat/part/SeatFrontLeft,

        template = Seat/part/SeatFrontRight,

        template = Seat/part/SeatRearLeft,

        template = Seat/part/SeatRearRight,


        part SeatRearLeft

        {

            table install

            {

                area = SeatFrontLeft,

            }

            table uninstall

            {

                area = SeatFrontLeft,

            }

        }


        part SeatRearRight

        {

            table install

            {

                area = SeatFrontRight,

            }

            table uninstall

            {

                area = SeatFrontRight,

            }

        }


        part Seat*

        {

            container

            {

                capacity = 20,

            }

            table install

            {

                skills = Mechanics:2,

            }

            table uninstall

            {

                skills = Mechanics:2,

            }

        }


        part GloveBox

        {

            area = SeatFrontRight,

            itemType = Base.GloveBox,

            container

            {

                capacity = 3,

                test = Vehicles.ContainerAccess.GloveBox,

            }

            lua

            {

                create = Vehicles.Create.Default,

            }

        }


        template = GasTank,


        template = Battery,


        template = Engine,


        template = Muffler,


        template = EngineDoor,


        part EngineDoor

        {

            mechanicRequireKey = false,

        }


        part Heater

        {

            category = engine,

            lua

            {

                update = Vehicles.Update.Heater,

            }

        }


        part PassengerCompartment

        {

            category = nodisplay,

            lua

            {

                update = Vehicles.Update.PassengerCompartment,

            }

        }


        template = Windshield/part/Windshield,

        template = Windshield/part/WindshieldRear,


        template = Window/part/WindowFrontLeft,

        template = Window/part/WindowFrontRight,

        template = Window/part/WindowRearLeft,

        template = Window/part/WindowRearRight,


        part WindowRearLeft

        {

            area = TireRearLeft,

            parent = ,

            table install

            {

                requireInstalled = ,

            }

        }


        part WindowRearRight

        {

            area = TireRearRight,

            parent = ,

            table install

            {

                requireInstalled = ,

            }

        }


        template = Door/part/DoorFrontLeft,

        template = Door/part/DoorFrontRight,


        template = Tire,


        template = Brake,


        template = Suspension,


        template = Radio,


        template = Headlight,

    }

}

Source: How to create new vehicle mods