Games/ETS2/Modding guides/1.32

From SCS Modding Wiki
Jump to navigation Jump to search

Introduction

The following page contains modding guidelines for the new update of the game.

To better understand changes in units it is recommended to check Units documentation page.

Recommendations

  • When basing your model on the original ones, add to your mod also ALL original /automat/ files used by it. The names of the files are generated as CityHash64 hash of theirs content so whenever we change the parameters of the material in any way, a different file will be used to store them and the original file might cease to exist if there is no other model utilizing the original parameters.
  • When modifying original models, always include ALL components of the model (pmg+pmd) instead of just those you changed. Otherwise you risk crash if we change the model.
  • As always when adding new objects to files which support multi-file approach (e.g. road_look.sii) it is HIGHLY RECOMMENDED to use suffix or prefix in the name to avoid conflicts with new objects we are adding in patches. Otherwise you might have to use the batch renaming functionality (see Batch renaming) to fix the conflicts when new patch appears.

How to convert map

  • Set parameter instanced to true for all signs which have dynamic set to true. Models which need this will be reported using "Non instanced dynamic road model is not supported! (sign)" error message.
  • If your mod defs are directly referencing spruce vegetation models (found in /model/vegetation/poly_vegetation/), you need to update the definitions to reference the new versions.
  • Load map
  • Do rebuild (F8)
  • Save map
  • Select correct looks for models where the selection of the looks changed

Changes

Map format changes

Semaphore profiles can be overridden on prefab item level.

UI texture changes

We changed the blending of UI textures to be gamma correct. As result alpha transitions in UI textures (e.g. accessory icons, custom loading screens) and alpha values specified in UI screen definitions will yield a different result than before. When creating transparent textures, you should configure your graphics editor to use Gamma value of 1.0 to get the composition to behave in the same way as in the game.

While there is no fully automated way to modify the textures to get exactly the same result as before, the attached Perl script can be used to adjust alpha channel to keep the appearance similar based on assumption that the blend is done over middle-gray background based on expression mentioned bellow. Note that after using the script you might still need to manually adjust the images to get the appearance you want.

S .. source sRGB color in UI texture
a .. source alpha in UI texture
D .. background sRGB color, we assume middle gray #808080
b .. recomputed alpha

The old blending expression:

OLD = S * a + D * (1 - a)

The new blending expression:

NEW = sRGB(rgb(S) * b + rgb(D) * (1 - b))

Alpha which would result in the same final value after blend:

b = (rgb(OLD) - rgb(D)) / (rgb(S) - rgb(D))

Economy system changes

The whole cargo generator was dramatically changed since previous versions:

  1. Cargo is now defined by units instead of simple weight. One unit of cargo takes some volume, which gives count of unit that might fit into trailer body. From this unit count mass and reward are also derived. Mass is subject for further limitation either by trailer itself or country laws. Both might result in decreasing of cargo unit count loaded.
  2. Another new concept are body types, trailers and cargo are not linked directly but rather they are being matched by body types. Trailer that has body type flatbed will have only generated jobs that consists of cargo that is compatible with flatbed body.

Cargo data

Attributes price_coef (float), mass (float array, per trailer) and cog_height_offset (float array, per trailer) has been. Attribute array trailers remain only for compatibility of some cargoes.

New attributes:

  • [token array] body_types - List of trailer bodies cargo can be loaded in.
  • [float] volume - volume of single one unit, in cubic meters (m3)
  • [float] mass - mass of one cargo unit, in kilograms (kg)
  • [float] unit_reward_per_km - reward for transport of one cargo unit per 1km of distance
  • [float] unit_load_time - loading time of one cargo unit, in second
  • [bool] overweight - cargo with this flag is used regularly but ignores any trailer or country limitations.

Trailer def

Structure trailer_def was greatly improved and redesigned as its core of the economy. Old system with list of trailers for given cargo is used for remaining old trailers only (using cargo folder placement with filled trailer link and fake underscored trailer body_types).

Additionally trailer defs using new owned trailer system are now placed in /def/vehicle/trailer_defs folder. Old system trailer defs, however, remain in it's original place.

New fields support system that matches cargoes to trailer only through trailer body types with additional information. Most important are:

  • [float] gross_trailer_weight_limit - technical or logical limit of trailer(s) + cargo mass, also limited by bridge formula or similar rules.
  • [token] body_type - defines cargo that can be loaded in, should equal to body_type of bodies of all trailers in set
  • [token array] country_validity - list of countries the trailer is allowed in, empty list impose no limitation

Then there are cached/precomputed values for fast access without necessity of loading all accessories (instead of summing all chassis and body weights in chain) as well as data for trailers that do not have all accessories defined (eg freight market ones):

  • [float] trailer_mass - summed mass of all trailer chassis parts
  • [float] body_mass - summed mass of all trailer bodies parts
  • [float] volume - summed volume of all trailer bodies parts
  • [int] axles - counted axles of all trailers in set
  • [float] length - length of whole trailer set in meters
  • [token] chain_type - type of trailer chain (single, double, b_double, ...)

In addition, there are also cog placement parameters - unlike older mechanics right now its plain cargo cog offset in meters (before height was halved due to historical reasons).

Body types

Body type defines which cargo can be transported with trailer and is binded to economy trough cargo definition with new array attribute body_types in cargo data.

There are several predefined types that have some special handling in the code:

  • flatbed
  • curtainside
  • dryvan
  • insulated
  • refrigerated

That said one can still use custom token for body type, but do not forget to define new cargo data for it. In the future updates, however, predefined list will most probably grow with new set of body types.

Economy data

  • Added cargo_damage_cost attribute defining how much money player has to pay to for 1% of the damage.
  • Added cargo_damage_cost_factor attribute defining factor damage penalty is multiplied with every 1% of the damage.
  • Added exp_park_load_bonus attribute defining how big XP bonus player gets for parking trailer during loading of the job.
  • Added revenue_per_km_base attribute defining base revenue per km for the ai drivers (has to be proportional to regular cargo fees).
  • Added revenue_coef_per_km attribute defining salary coefficient per km for the freight market and online jobs.
  • Added cargo_market_revenue_coef_per_km attribute defining salary coefficient per km for the cargo market jobs.
  • Added driver_revenue_coef_per_km attribute defining salary coefficient for ai drivers and players quick jobs.
  • Added driver_cargo_market_revenue_coef_per_km attribute defining salary coefficient for ai drivers cargo market jobs.
  • Removed revenue_per_km.
  • Removed driver_revenue_per_km.
  • Removed trailer_damage_cost.
  • Removed trailer_damage_cost_factor.
  • Removed brands, game will now collect truck and trailer brands on startup from /def/vehicle/truck_dealer and /def/vehicle/trailer_dealer directories. Each directory inside that can be interpreted as token is a new brand.

Game data

  • Added blinker_auto_off_trigger attribute defining angle below which blinker auto disable is performed previously.

Country data

Country data has a new attribute called mass_limit_per_axle_count. It defines GVW (gross vehicle weight) - maximum allowed mass limit (in kilograms, kg) of the whole vehicle set (truck + trailer(s) + cargo) with the given amount of axles (total truck + trailer(s)) in the the country. Empty array impose no limit.

The first element is describing mass limit for vehicle with 2 axles, second for 3 axles etc. If vehicle has more axles than defined last entry will be used as limit.

country_data: country.data.uk
{
	# [...]

	mass_limit_per_axle_count[]: 18000	# 2-axle vehicle
	mass_limit_per_axle_count[]: 26000      # 3-axle vehicle
	mass_limit_per_axle_count[]: 38000      # 4-axle vehicle
	mass_limit_per_axle_count[]: 40000      # 5-axle vehicle
	mass_limit_per_axle_count[]: 44000      # 6 and more-axle vehicle
}

Flares data

Flare unit (usually found as hookup defined models inside /unit/hookup directory) got new functionality of manual curve definition for flare scaling, with two new float attributes:

  • scaling_start_distance - defines distance at which flare scaling starts.
  • scaling_end_distance - defines distance at which flare scaling ends, flare scale reaches scale_factor.

Note that both of those attributes hold distance in meters and that they won't be used unless scale_factor is bigger then 1.0.

Vehicles data

Trailer cable data

There is now support for straight trailer cables, which can be activated by using new float attribute: straight_cable_length, which, when used and it's bigger than zero, transforms spiral cable into straight one and tells the game what is actual distance of straight cable.

Additionally now there is support for so called "back faces" in cable geometry, activated with setting boolean attribute: back_faces to true. This can be useful when using transparent material on cable, so that inner wall of the cable will also be visible (for example back faces are currently used in the new trailer cables for traffic vehicles).

Truck data

Accessory head lights data

The algorithms for sign illuminations have been changed, from now on the illumination of signs is calculated based on the color and the range of the regular truck lights.

The following attributes were made obsolete and are no longer used:

  • low_beam_sign_(color/range)
  • hi_beam_sign_(color/range)
  • front_beam_sign_(color/range)
  • roof_beam_sign_(color/range)
  • front_roof_beam_sign_(color/range)

Trailer data

There has been several additions in trailer data with new folder structures inside /def/vehicle:

  1. trailer_cargo - container folder for definition of matching cargo models to trailer bodies.
  2. trailer_chain_types - folder for definition of possible trailer chain types among all trailer in game.
  3. trailer_dealer - dealer offers for trailer dealer, sorted in <brand.model> sub-folders.
  4. trailer_defs - all configurations of possible trailer combinations in the new system (see #Cargo generator).
  5. trailer_owned - ownable trailers data defining configuration, body, paintjob and accessories (similarly as trucks), sorted in <brand.model> sub-folders.

Additionally trailer unit used to define freight market trailers has new pointer attribute trailer_definition, which can link freight market trailer to economy by pointing to new type of trailer_def.

Trailer dealer data

Trailer dealer offer is defined by exactly same way as truck dealer offer.

In folder /def/vehicle/trailer_dealer/ are folders for every trailer brand and in them are complete definitions of different pre-configured offers that player can select from in-game.

Accessory trailer data

The new unit (/def/vehicle/trailer_owned/<brand.model>/data.sii) describing brand and series of the trailer. Very similar to well known accessory_truck_data.

The attributes of the unit are:

  • [string] info[0] - (optional) brand name, if empty string is passed no brand is displayed.
  • [string] info[1] - (optional) trailer series name.
  • [string array] fallback - (optional) list of fallback accessories following format type|path
  • other regular rules and requirements for given vehicle

Accessory trailer body data

New accessory type defining trailer body in folder /def/vehicle/trailer_owned/<brand.model>/body/.

Required attributes are:

  • [float] volume - The volume of the body in m3. Limits amount of cargo units that can be loaded in.
  • [token] body_type - The type of the body. Only cargoes with given body_type can be loaded.
  • [float] mass - The mass of the empty body in kg. Might be 0 if all mass is stored in chassis.
  • [float3] total_size - The total size of the trailer in meters (currently unused).
  • [float3] size - The internal size of the trailer body in meters, shown in tooltip.

Optional attributes are:

  • [string] detail_model - The detailed model of the body.
  • [string] model - The default model of the body.
  • [string array] lods - The LOD models.
  • [string] collision - The collision of the body.
  • [token] variant - The variant of the model to use.
  • [token] look - The look of the model to use.

Ownable trailer configurations

Each ownable trailer needs it's own configurations which player can select from in the trailer configurator (eg. single 3-axles, single 2 axles, double, b-double). All configurations combinations are defined in /def/vehicle/trailer_owned/<brand.model>/configurations.

Each trailer configuration of type trailer_configuration has following attributes:

  • [string] name - Displayable name for this configuration in trailer configurator.
  • [string] icon - Displayed icon for this configuration in trailer configurator.
  • [token] chain_type - Type of the chain this configuration is using (one of chain types defined in /def/vehicle/trailer_chain_types/.
  • [string array] chassis - All chassis definitions for this configuration, first chassis for first trailer in chain, second chassis for second trailer in chain etc.
  • [trailer_body_set array] body_sets - Owner pointer array of compatible trailer_body_sets with this configuration. Except manually linked body sets in configuration file they are also gathered from sub-folder named same as base configuration file name (name of the file to first dot, so configuration "single3.sii" or "single3.mymod.sii" should have body sets in folder "/def/vehicle/trailer_owned/<brand.model>/configurations/single3").
Trailer body set

Trailer body set defines set of bodies that can be used on individual trailer configuration. Each body set is then selectable by player in trailer configurator.

Each trailer body set contains:

  • [string] name - Displayable name for this configuration in trailer configurator.
  • [string] icon - Displayed icon for this configuration in trailer configurator.
  • [trailer_def pointer] trailer_definition - Pointer to trailer definition to be used for this trailer body set, trough which game knows what kind of cargo can be used with this trailer configuration and body set.
  • [string array] body - All body definitions for this body set, first body for first trailer in chain, second body for second trailer in chain etc.