-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Inheritance
To reduce duplication in the JSON data it is possible for some types to inherit from an existing type.
In the following condensed example 556 ammo is derived from 223 ammo via copy-from:
"id": "556",
"copy-from": "223",
"type": "AMMO",
"name": "5.56 NATO M855A1",
"description": "5.56x45mm ammunition with a 62gr FMJ bullet...",
"price": 3500,
"relative": {
"damage": -2,
"pierce": 4,
},
"extend": { "effects": [ "NEVER_MISFIRES" ] }
The following rules apply to the above example:
-
Missing fields have the same value as the parent
-
Fields explicitly specified replace those of the parent type. The above example replaces
name,descriptionandprice. -
Numeric values may be specified
relativeto the parent. For example556has lessdamagebut morepiercethan223and will maintain this relationship if the definition for223is changed. -
Flags can be added via
extend. For example556is military ammo and gains theNEVER_MISFIRESammo effect. Any existing flags specified from223are preserved.
Reloaded ammo is derived from the factory equivalent but with a 10% penalty to damage and dispersion and a chance to misfire:
"id": "reloaded_556",
"copy-from": "556",
"type": "AMMO",
"name": "reloaded 5.56 NATO",
"proportional": {
"damage": 0.9,
"dispersion": 1.1
},
"extend": { "effects": [ "RECYCLED" ] },
"delete": { "effects": [ "NEVER_MISFIRES" ] }
The following additional rules apply to the above example:
-
Chained inheritance is possible; for example
reloaded_556inherits from556which is itself derived from223 -
Numeric values may be specified
proportionalto the parent by via a decimal factor where0.5is 50% and2.0is 200%. -
Flags can be deleted via
delete. It is is not an error if the deleted flag does not exist in the parent.
It is possible to define an abstract type that exists only for other types to inherit from and cannot itself be used in game. In the following condensed example magazine_belt provides values common to all implemented ammo belts:
"abstract": "magazine_belt",
"type": "MAGAZINE",
"name": "Ammo belt",
"description": "An ammo belt consisting of metal linkages which disintegrate upon firing.",
"rigid": false,
"armor_data": {
"covers": [ "TORSO" ],
...
},
"flags": [ "MAG_BELT", "MAG_DESTROY" ]
The following additional rules apply to the above example:
-
Missing mandatory fields do not result in errors as the
abstracttype is discarded after JSON loading completes -
Missing optional fields are set to the usual defaults for that type
The following types currently support inheritance:
GENERICAMMOGUNGUNMODMAGAZINE-
TOOL(but notTOOL_ARMOR) COMESTIBLEBOOKENGINE
Back to the Guide for first time contributors