openOMSI GitHub Discord
Modding overview

Docs / Making content / Modding overview

Damage

4 min readEdit this pagedocs/MODDING.md

On this page
  1. Where the engine is
  2. Keywords
  3. Script variables

With Realistic damage on (the default; Options, Simulation), a vehicle that runs into something takes damage where it was hit. Off, vehicles take none, as in OMSI 2. The collision scripts (coll_energy, {trigger:collision}) run the same way either way.

  • Dents. The body crumples round the blow: a rounded hollow, deepest in the middle, with the ripples a buckled panel shows. Every mesh the blow reaches moves by the same amount, so the seams between panels stay closed. Blows add up, but no panel is pushed in further than [damage_max_depth]. The player's bus and the AI vehicles are dented alike.
  • Scratches. Sliding along a wall, a post or another vehicle leaves a scratch along the paint, as long as the slide went on: a scuffed band with bare metal and gouged paint in it. It follows the curve of the body. A light knock without a slide scuffs the spot.
  • Glass. A windscreen is laminated: it cracks in a web round a crushed spot and stays in its frame.

    A side or rear window is tempered: it crumbles into small cubes over the whole pane, and most of the time it falls out a moment later, its crumbs dropping to the road. openOMSI takes a pane named like a windscreen, or one facing forward at the front, for a windscreen, and any other pane for tempered glass.

  • Engine. Where the engine's place is known, a blow near it damages it. A damaged engine gives less drive, misfires now and then and smokes out of the engine bay, light grey at first, then thick and black. A wrecked engine gives no drive at all. Braking with the engine is left as it is.

The workshop's repair mends all of it.

Where the engine is#

openOMSI does not guess where an engine is. It uses the vehicle file's [damage_engine], or the sound configuration: the engine's running sounds (those whose pitch, volume or condition follows engine_n) are placed where they come from.

The place is taken only when at least one of them has a [3d] place of its own (one at the model's origin is heard all round and has none) and two thirds of them agree within 2.5 m along the bus. A vehicle whose engine sounds are not placed, or placed all over, gets no engine damage and no smoke; its body and glass still take damage.

Give it [damage_engine] to change that, or [damage_engine_none] for an electric bus or a trolleybus whose motor sounds follow engine_n.

Keywords#

A vehicle works without any of them. OMSI 2 skips them.

Keyword File What it does
[damage_off] .bus, .ovh No dents, scratches, broken glass or engine damage on this vehicle.
[damage_stiffness] + a number .bus, .ovh How hard the body is: 2 dents half as deep and over a smaller area, 0.5 twice as deep. The default is 1.
[damage_max_depth] + metres .bus, .ovh How far a panel can be pushed in at most, all blows together. The default is 0.35.
[damage_no_scratches] .bus, .ovh The paint takes no scratches.
[damage_rigid] + a mesh .bus, .ovh This mesh is never dented: a frame, the chassis, a part that should keep its shape. One keyword per mesh.
[damage_glass] + a mesh + a kind .bus, .ovh How this pane breaks: laminated (a web of cracks, stays in), tempered (crumbles, falls out) or none (a mesh whose name only sounds like glass, or glass that never breaks).
[damage_engine] + x, y, z .bus, .ovh Where the engine is, in the vehicle's frame (x right, y forward, z up, metres).
[damage_engine_none] .bus, .ovh No engine to damage.
[damage_engine_toughness] + a number .bus, .ovh 2: the engine takes half the damage from the same blow. The default is 1.
[damage_smoke] + x, y, z .bus, .ovh Where a damaged engine's smoke leaves the body. Without it, the smoke comes out of the end of the body the engine sits near, or from under the floor.

A mesh is named by its file (Fenster_vorne.o3d; the folder is optional) or its [mesh_ident]. For example:

[damage_stiffness]
1.5

[damage_glass]
model\Scheibe_vorne_rechts.o3d
laminated

[damage_engine]
0
-4.9
0.9

Script variables#

A vehicle's scripts see the damage in these variables, if they declare them in a varlist. openOMSI writes them every frame.

Variable What it holds
Damage_Engine The engine, 0 sound to 1 wrecked. A script that sets it mends or breaks the engine.
Damage_Body The worst of the four zones below.
Damage_Front, Damage_Rear, Damage_Left, Damage_Right Each zone of the body, 0 to 1.
Damage_Glass How many panes are broken.
Damage_Misfire 1 while the engine misfires.
Damage_Repair Set it to 1 and everything is mended. It goes back to 0.

A script can, for example, switch on a warning lamp above Damage_Engine 0.5, cut the engine when it reaches 1, or let the driver mend the bus with a key.

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open