You are here

Mod Transition Guide: CR to CMD

Mad Mike's picture
Velociraptor Fister
Kickstarter Backer
Posts: 1129
Mod Transition Guide: CR to CMD
#1 Submitted: Fri, 04/11/2016 - 23:10

________________________________________________________________________________________

Vehicle Mod Transition Guide:

Reincarnation to Max Damage

Update Log:
01/Mar/2017: Added Trailer setup
22/Jan/2017: Updated Trailer Hitch section within 'Structure.xml'
26/Nov/2016: Added Towing Multipliers to 'Structure.xml'
06/Nov/2016: Added Basic UI Text setup to 'Vehicle_Setup.lol'

This is a basic guide/FYI on updating custom content, more specifically vehicles, from CR to CMD. This is not a guide to help with first time setup, this is for those who have vehicles working in CR, and wish to move them over to CMD.

Note: at the time of writing this. Trent hasn't had a chance to update Minge yet, so mods have to be installed manually in CMD (editing CarMODgeddon.lua). Alternatively, you can install content to CR using Minge, and then move the whole CarMODgeddon folder to the CMD folder. Minge has now been updated for use in C:MD, so mods can now be easily compiled & packaged for distribution.
__________________________

1] Hierarchy & Model

A]

Vehicles without a custom trailer hitch

Unless you want to set up a custom trailer hitch point, there is no need to update any of your vehicle model parts or the collision model for use in CMD. CMD will automatically set a hitch point for attaching a camper/caravan.

B]

Vehicles with custom trailer hitches

If you do want to set up a custom trailer hitch, such as the fifth wheel for a Semi Truck, then you will need a trailer hitch model that is seperate from the root of your vehicle. Make sure that the "Trailer Hitch" Part, is parented to the "c_Body", and that its pivot-point/local-axis/object-origin, is set to the point you want the connection to be made. The "Trailer hitch" will be a non-crushable part, so set a single vertex to the weld colour (Green/RGB:000,255,000).

Furthermore, if you are building a semi-truck, you will need to have a con-cave collision shape to allow the trailer to reach the hitch point. You will need to have a collision model consisting of at least two parts, the 'c_Body_Collision' will usually represent the chassis below the hitching point (incorporating the full length & width of the vehicle), with a second collision object for the cab, this second part can be called whatever you want, and must be parented to the "c_Body_Collision" model. Below, you can see an example taken from the '72 Moth Truck.

Red Outlines is the 'c_Body_Collision'
Yellow Outlines is the 'cab_Collision' which is parented to 'c_Body_Collision'

__________________________

2] Paperwork

- Structure.xml

A]

Vehicles without a custom trailer hitch

No changes have to be made for any regular vehicles, unless you wish to take advantage of new features, such as disabling splitting.

B]

Vehicles with custom trailer hitches

The "Trailer Hitch" will need to have its own part entry in the structure.xml. It needs to be set as a non-crushable part, and must not be detachable from its parent. Additionally, the trailer hitch will need to have the following method assigned to it.

CDamageParameters:Set_TrailerHitch( 0, 0, 0, 1 )

The first three values define the trailer hitch point in part space, if the pivot-point/local-axis/object-origin of the Trailer hitch is already set to where you want the connection to be made, then these can remain as 0,0,0. The Fourth value is the Trailer Hitch ID, which can serve as a way of 'locking off' certain trailers from this trailer hitch, resulting in the 'This Trailer Cannot be Attached' prompt in-game. The following values for the 'Hitch ID' on a vehicle will allow the you to attach the following official trailers:

  • '1' - Caravan & Rig Trailers can be attached
  • '0' - Caravan only, however the hitch point position will be offset from where you've defined it, it seems that the game overrides the hitch location, lifting it in the Y axis, and offsetting in the Z axis depending on vehicle length
  • '-1' - Caravan & Rig Trailers can be attached
  • '-2' - Caravan only

Additionally, if you are setting up a vehicle with a unique trailer set, and you do not want this vehicle to be able to hitch up to the standard rig trailers, then other trailer hitch IDs can be used. For example, one of my new big rigs (& its' respective trailer) have a higher than normal trailer hitch. I have assigned a hitch ID of 2 to both Rig & Trailer, which allows the rig to attach its' unique trailer, but it cannot hitch up to the regular rig trailers.

Furthermore, you can make use of additional multiplier values to manipulate your vehicles Power Multiplier, Steering Speed and Base Traction Values when towing with the following methods. The following were taken from the Rig O Mortis.

	CVehicleCharacteristics:Set_TowingPowerMultiplier( 2.5 )
	CVehicleCharacteristics:Set_TowingTractionMultiplier( 2.0 )
	CVehicleCharacteristics:Set_TowingSteerSpeedMultiplier( 0.5 )

__________________________

3] Paperwork

- Systemsdamage.xml

No updates required
__________________________

4] Paperwork

- Vehicle_Setup.cfg

A]

Changes common to all vehicles

_________________
i] Engine sounds
Some of the engine sound sets in CMD are named differently to their CR counterparts.
'Jeep' in CR = 'SUV' in CMD
'Camaro' in CR = 'Drag' in CMD
'Fearari' in CR = 'Sportscar' in CMD
'Maserati' in CR = 'Euro_V8' in CMD

The other four engine sounds from CR are unaltered, and are joined by one new sound set 'Project_X'
_________________
ii] Exhaust Particle FX
Some of the exhaust PFX from CR no longer exist in CMD. From a quick look in the 'Effects' folder within 'Scripts.zad', the following exhaust PFX are available:

  • f_diesel_exhaustsmoke02
  • f_diesel_exhaustsmoke03
  • f_diesel_exhaustsmoke04
  • f_megawootexhausts
  • f_siamesedreamexhaust
  • f_venomexhaust
  • f_yankv8_exhaustsmoke02
  • f_yankv8_exhaustsmoke03
  • f_yankv8_exhaustsmoke04
  • f_turbo
  • f_hotrod
  • f_megaturbo

_________________
iii] Horns
All horns from CR are still present, there is also one new horn

  • americansemi_horn

_________________
iv] In-car camera
CMD will automatically work out a position for your in-car camera based off of the driver box, which is unlikely to be exactly where you want it to go. The position can be manually offset from there with the following method.

[in_car_cam_offset]
-0.1,-0.13,-0.09

This defines an XYZ transformation in vehicle space
Positive X Values = Right, Negative X Values = Left
Positive Y Values = Up, Negative Y Values = Down
Positive Z Values = Forward, Negative Z Values = Back
_________________
iv] Garage Camera Offset

If you have a vehicle that is especially large, then you can add the following command to offset the camera from the vehicle to fit it on-screen.

[garage_camera_offset]
1.03,0.47,1.03

This is an XYZ Transformation. It is best to increment the X & Z values in tandem

B]

Changes specific to vehicles with custom trailer hitches

i] Trailer Maps
If you want your vehicle to spawn with a paticular trailer when an event loads, then you will need to add trailer maps. Below is an example taken from the Rig O Mortis.

[Human_Trailer]
Tanker
Tanker
Tanker
Tanker
Flatbed
Flatbed
Flatbed_Empty
Flatbed_Empty

[AI_Trailer]
Tanker
Tanker
Tanker
Tanker
Flatbed
Flatbed
Flatbed_Empty
Flatbed_Empty
None

[MP_Trailer]
None

Note that trailer maps do not influence what trailers the vehicle can actually hitch up to, they only set what trailers the vehicle can spawn with upon event commencement. Whether or not a trailer can be attached is determined by the proximity of the "trailer_hitch" on the vehicle to the "trailer_hitch" on any given trailer. If the Hitch points get close enough, then the game will make the connection, irrespective of what the trailer maps dictate.
__________________________

5] Paperwork

- Vehicle_Setup.lol

A]

Car Class

You can use the Vehicle_Setup.lol to set a car class for multiplayer. The following is usually placed after 'Shipped = True'.

class_rounded = false
class_speedy = true
class_smashy = false

Simply set 'true' or 'false' for the desired class. Hopefully at some point, custom classes can be added.

B]

UI Text

At the moment, you can set basic UI text for the following vehicle elements:

  • - Vehicle Name
  • - Driver Name
  • - Driver Bio

Just add the following to the end of your 'vehicle_setup.lol'

override_vehicle_name = "YOUR VEHICLE NAME HERE"
override_driver_name = "YOUR DRIVER NAME HERE"
override_bio = "YOUR DRIVER BIO HERE"

The game will automatically use the full driver name for the short driver name (in-game).
__________________________

6] Paperwork

- Setup.lol

If you made use of the shrapnel effect in CR, such as this

car:SetCollisionEffect("effects.f_carsharpnel05", 10)

then you will need to change the '05' to '06', as '05' no longer exists.
__________________________

7] Paperwork

- Vfx_anchors.lol

No changes required
__________________________

8] Materials

There are lots of new materials in CMD, you do not have to make use of them, but you might find some strange things happening if you don't.

For example, any material on a vehicle referencing 'Simple_Base', will be made invisible when the vehicle is split. You can use 'Car_Shader_Base' in its place with "normal_n" as the normal map, and "spec_s" as the specular map. Both "normal_n" & "spec_s" are standard non_VT textures in CMD.

__________________________
________________________________________________________________________________________

Trailer Set-up Guide

Rough guide on Trailer setup. Only for those familiar with vehicle setup.
Trailers are essentially simplified vehicles, and most of the setup steps are similar, if not identical, to any normal vehicle.

At this point in time, CarMODgeddon does not support trailers, so you will have to load custom trailers in using a zad mod. The folder structure within the zad file will be as follows.
Vehicles\Trailers\YourTrailerFolderNameHere

__________________________

1] Hierarchy & Model

____________

A]

Root of the Trailer

In the same way as any normal vehicle, the root of a trailer is the 'c_Body' mesh, which should be oriented in such a way that the front and rear of the trailer is split roughly equidistant in the Z axis (along the plane Z = 0, known by default as Y = 0 in 3dsmax), and it's pivot point/local-axis/object origin should be set to 0,0,0 in world-space, like below.

____________

B]

Trailer Hitch

Like any regular vehicle with a custom trailer hitch. Every trailer should have a 'Trailer_Hitch' part, which should be parented to the 'c_Body'. Ideally the pivot point of the 'Trailer_Hitch' part should be set to the point in world space, where the phyiscal connection will be made between vehicle & trailer. See below for reference.

____________

C]

Trailer Legs

Depending on what type of trailer you are constructing, this will affect some of the other requisite parts. For example, a semi trailer will need legs to visually hold the trailer up when it is not hitched up to a vehicle. If your trailer needs legs, then you will need two sets - One to represent the legs in the 'lifted' position, the other to represent the legs in the 'deployed' position. See below for reference.

Lifted:

Deployed:

Both sets of legs should be parented to the 'c_Body'
____________

D]

Collision Models

Unlike regular vehicles, trailers have two collision hierarchies - 'Collision.cnt' & 'Static_Collision.cnt'. The 'Collision.cnt' applies whilst the trailer is hitched up, and the 'static_collision.cnt' applies when the trailer is not hitched up. In some instances (rigid chassis trailers), the 'static_collision.cnt' can just be a duplicate of the regular 'collision.cnt'.

If you are setting up a semi trailer, then your collision hierarchies will need to contain at least two models. This is to provide a concave collision shape to allow the 'trailer hitch' on the vehicle to meet the 'trailer hitch' on the trailer:

  • - 'c_Body_Collision' is the root of the hierarchy, and will typically reflect all parts above the trailer hitch (main body)
    Pivot point of this part should be set to 0,0,0 like the real 'c_Body'
  • - 'lower_collision' is parented to the 'c_Body_Collision', and will typically reflect all parts below the trailer bed (mechanical parts, wheels, etc)

Furthermore, for the 'Static_Collision.cnt', you will need a different 'lower_collision' to reflect the trailer legs having been deployed, like below.

If a trailer does not have a 'static_Collision.cnt', then the game will not use the regular 'Collision.cnt' in its' place.
____________

E]

Driver Node

Despite trailers not having drivers, all of the official trailers still have a driver node. I haven't ventured away from this practice and see no reason to do so.
____________

F]

Everything else

As trailers are a sub-class of vehicles, you need to have at least hubs, brakes, wheels & a Trailer hitch to function properly. Additionally, Trailers can make use of most features that regular vehicles can. including:

  • - Animated suspension
  • - Part Animations
  • - Weapons
  • - Detachable Parts
  • - Jointed & Flappable parts
  • - Breakable parts (Windows & lights)
  • - Functional lights
  • - >4 Wheels
  • - Tracks

These parts are set-up in the same way as on any normal vehicle, so model the required parts, and configure the hierarchy appropriately.
____________

G]

Materials

Despite it not being possible to change trailer paint-jobs, trailers still need a 'Paint' Material. Providing the materials (MT2 files) are configured correctly, this material will be the material that receives blood splatters in-game.
__________________________

2] Paperwork

- Structure.xml

Setup of the structure.xml for a trailer is largely identical to any normal vehicle. Trailers will still make use of the standard vehicle characteristics: Set_DefenceGeneral(), Set_DefenceAgainstCars(), Set_Offence(), Set_ValueFactor() just like any regular vehicle.
__________________

A]

Wheels & Suspension

The hubs, brakes & wheels are setup in the exact same way as on a normal vehicle, this includes all physics properties:
Hub_FL:

  • - FRONT_LEFT_POINT_OF_SUSPENSION
  • - FRONT_LEFT_POINT_OF_STEERING

Brake_FL:

  • - FRONT_LEFT_POINT_OF_ROTATION

Wheel_FL:

  • - FRONT_LEFT_WHEEL

Hub_FR:

  • - FRONT_RIGHT_POINT_OF_SUSPENSION
  • - FRONT_RIGHT_POINT_OF_STEERING

Brake_FR:

  • - FRONT_RIGHT_POINT_OF_ROTATION

Wheel_FR:

  • - FRONT_RIGHT_WHEEL

Hub_RL:

  • - REAR_LEFT_POINT_OF_SUSPENSION

Brake_RL:

  • - REAR_LEFT_POINT_OF_ROTATION

Wheel_RL:

  • - REAR_LEFT_WHEEL

Hub_RR:

  • - REAR_RIGHT_POINT_OF_SUSPENSION

Brake_RR:

  • - REAR_RIGHT_POINT_OF_ROTATION

Wheel_RR:

  • - REAR_RIGHT_WHEEL

If using animated suspension (Wishbone, Strut or Live Axle), then the set-up process is identical to the set-up process for vehicles.
__________________

B]

Parts specific to Trailers

There are only a few extra lines needed for the structure.xml on a trailer.
____________
I] Trailer Hitch

The "Trailer_Hitch" part needs to have a structure part entry, it must be non-crushable, welded to it's parent with a non-breakable weld, and make use of the following methods:

CDamageParameters:Set_TrailerHitch( 0, 0, 0, 1 )
CDamageParameters:Set_CollisionBoundsMultiplier( 3.0, 3.0, 3.0 )

Depending on the type of trailer you're building, it will affect the trailer hitch ID. A hitch ID value of -1 is used by the caravan, and 1 is used by the semi trailers. The collision bounds multiplier simply helps with making hitching easier.

Lastly, the "trailer_hitch" part will need to have a joint defined after closing its weld. This is used to define how the trailer can pivot from the vehicle it is hitched to. Below is an example taken from one of my semi trailers, based off of the tanker from the Rig O'Mortis.

	    <JOINT>
		 <![CDATA[
		  CWeldJointParameters:Set_BallJoint( true )
		  CWeldJointParameters:Set_JointAxis( 0, 0, -1 )
		  CWeldJointParameters:Set_JointLocation( 0, 0, 0 )			  
		  CWeldJointParameters:Set_JointNormal( 0, 1, 0 )
		  CWeldJointParameters:Set_MinLimit( -120.0 )
		  CWeldJointParameters:Set_MaxLimit( 120.0 )
		  CWeldJointParameters:Set_MinLimit2( -10 )
		  CWeldJointParameters:Set_MaxLimit2( 10 )
		  CWeldJointParameters:Set_TorqueWeakness( 200 )
		  CWeldJointParameters:Set_Weakness( 1500 )
		  CWeldJointParameters:Set_MinTwistLimit( -5 )
		  CWeldJointParameters:Set_MaxTwistLimit( 5 )
		 ]]>
		</JOINT>

With this above configuration of the Joint Normal & Joint Axis,
- MinLimit() & MaxLimit() define the max angle of rotation in the trailers Y axis
- MinLimit2() & MaxLimit2() define the max angle of rotation in the trailers X axis
- MinTwistLimit() & MaxTwistLimit() define the max angle of rotation in the trailers Z axis
- The Weakness() Values both affect how easy it is to snap the trailer off
____________
II] Trailer Legs

If your trailer has trailer legs, the legs should not have structure part entries, but the following methods should be assigned to the part that is the parent of the trailer legs, which is usually the 'c_Body'.

CDamageParameters:Add_TrailerLegs_Down( "Name_Of_Deployed_Trailer_Legs_Goes_Here" )
CDamageParameters:Add_TrailerLegs_Up( "Name_Of_Raised_Trailer_Legs_Goes_Here" )

____________
III] Centre of Mass Declaration

If setting up a semi trailer, or indeed any trailer where the centre of mass needs to be outside of the wheelbase, then the following command

CVehicleCharacteristics:Set_AllowCOMZOutsideOfWheelbase( true )

must be added to the characteristics section.
__________________

C]

All other parts

Setup of all other features:

  • - Part Animations
  • - Weapons
  • - Detachable Parts
  • - Jointed & Flappable parts
  • - Breakable parts (Windows & lights)
  • - Functional lights
  • - >4 Wheels
  • - Tracks

is done in the same way as for a vehicle.

__________________________

3] Paperwork

- SystemsDamage.xml

Trailers do not have a SystemsDamage.xml

__________________________

4] Paperwork

- Vehicle_Setup.cfg

This is essentially a simplified version of what would be used by a regular vehicle. See any of the official trailers for reference.

__________________________

5] Paperwork

- vehicle_setup.lol

This typcially only contains the following

module(...)
camera_extra_tilt_angle = 5
camera_distance = 25

These values will adjust the relevant values to the camera when the player hitches up to this trailer. Ammend if required

__________________________

6] Paperwork

- setup.lol

This is the same file that you would find on any regular vehicle, with values for mass, suspension, grip, traction, centre of mass, and braking being the values of priority. If this trailer makes use of 'Set_AllowCOMZOutsideOfWheelbase( true )' in the structure.xml, then the 'car:SetCMPosZ()' method becomes an absolute position offset in the Z axis from the vehicles origin.
__________________________

7] Paperwork

- Vfx_anchors.lol

Not applicable to trailers.

Edited by: Mad Mike on 11/03/2017 - 16:16

One man... Alone... Wrecking opponents in the Automobile he loves
Twitter Manifestation, Mods for Max Damage

randomness