Vehicle Scripting: Cockpits

From Mod Wiki

Jump to: navigation, search

This article describes how cockpits are hooked up and some of the options they present.

Contents

Cockpit entityDef

When the player in a position switches to a view that shows the cockpit a client entity will be spawned for that player only. This entity will use the entityDef pointed to by the "def_cockpit" key, and the script object named by the "scriptobject" key.

For all the basic behaviour of the cockpit - making sure it is at the right position relative to the vehicle, creating interior lights etc - a base class exists that implements all of this. This is called "vehicle_basic_cockpit". This is derived from for some vehicles to allow for special behaviour, for example animating the hands on the steering wheel and throttle, spinning barrels on gatling guns, etc.

Only the basic cockpit script is descriped here. For examples of more sophisticated cockpits look in the base/script/vehicles/cockpits directory.

Keys:

  • "offset" - Offsets the position of the cockpit
  • "largeFov" - Offsets the cockpit position based on the value of the player's FOV. With 110 FOV the full offset will be added, and with 90 FOV no offset will be added.
  • "noEmpEffects" - Sets that this cockpit does not get any EMP effects applied to it.
  • "climate_skin_key" - Allows the cockpit to have a climate skin.
  • "joint_attach" - The joint to attach base the view from.
  • "passenger_id" - Position number of the passenger of this cockpit (1, 2, 3, etc).
  • "fx_emped" - Effect to play when the vehicle is hit by EMP damage.
  • "joint_fx_emped" - Joint to play "fx_emped" on.
  • "foce_joint_idle - Forces the cockpit position to be based off the joint position rather than the player's view position, even if it has a passenger_id set.
  • "def_light*" - Where * is 1, 2, 3 etc. Points to the entityDefs for lights attached to the cockpit. Cockpit Lights describes these in more detail.

Cockpit Positioning Modes

There are three modes for the positioning of the cockpit. The first positions it relative to the vehicle itself. The second positions it relative to a joint of the vehicle. The third positions it relative to the view origin of the player that is in the cockpit. The third method is used if "passenger_id" is set, unless "force_joint_idle" is turned on. The second method will be used if "joint_attach". Otherwise the first method will be used.

Cockpit Lights

These allow the interior of the vehicles to be illuminated in interesting ways. Any number of lights are supported, however they will degrade performance. The main keys to configure cockpit lights are the same as for other light entities.

Cockpit lights need to have a "spawnclass" of "sdClientLight", and the scriptobject should be set to "vehicle_cockpit_light". The other key to set is the "origin", which is relative to the origin of the vehicle.

Example

entityDef vehicle_mcp_cockpit {
    "model"                      "vehicle_mcp_cockpit"
    "joint_attach"               "pilot_cam"

    "climate_skin_key"           "weapon_gdf"

    "offset"                     "7 0 -2"
    "gui"                        "guis/models/vehicles/mcp/cockpit"
    "weaponDepthHack"            "1"

    "ambientCubemap"             "cockpit_mcp"
    "def_light1"                 "vehicle_mcp_cockpit_front"
}

entityDef vehicle_mcp_cockpit_front {
    "light_radius"               "36 36 48"

    "_color"                     "0.64 0.6 0.54"
    "origin"                     "80 21 180"
    "weaponDepthHack"            "1"

    "texture"                    "lights/round_flicker3"

    "spawnclass"                 "sdClientLight"
    "scriptobject"               "vehicle_cockpit_light"
}

This is from the MCP cockpit. This features a flickering light in the cockpit, as well as a climate skin.

Personal tools