Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsonize vehicle parts requiring other vehicle parts to be installed #37453

Merged
merged 32 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ff5c40a
jsonize vehicle part requir
Hirmuolio Jan 28, 2020
8e9af0b
json changes
Hirmuolio Jan 28, 2020
47e9802
Merge branch 'master' into Hirmuolio-vehicle-jsonize
Hirmuolio Jan 28, 2020
240aaf2
change json file
Hirmuolio Jan 28, 2020
e3f4764
remove test thing
Hirmuolio Jan 28, 2020
d184c3b
minor text changes
Hirmuolio Jan 28, 2020
444ae28
translate thing
Hirmuolio Jan 28, 2020
4e9b667
translate thing
Hirmuolio Jan 28, 2020
d425a6e
Update src/veh_type.h
Hirmuolio Jan 28, 2020
4c92f96
empty check
Hirmuolio Jan 28, 2020
2ba3b74
Update src/vehicle.cpp
Hirmuolio Jan 28, 2020
41d554f
translations.h
Hirmuolio Jan 28, 2020
9a8e1f6
extract_json_strings.py
Hirmuolio Jan 28, 2020
f9d19aa
documentation
Hirmuolio Feb 3, 2020
2b960cb
documentation
Hirmuolio Feb 3, 2020
a615253
Merge branch 'master' into Hirmuolio-vehicle-jsonize
Hirmuolio Feb 9, 2020
99a0d65
revert translation change
Hirmuolio Feb 9, 2020
67dcc17
revert translation change
Hirmuolio Feb 9, 2020
f145a24
display part that prevents removal
Hirmuolio Feb 11, 2020
9f0903e
remove stray thing
Hirmuolio Feb 11, 2020
77f0e31
remove stray thing
Hirmuolio Feb 11, 2020
5786bb4
period
Hirmuolio Feb 11, 2020
9408d11
change alternator flag
Hirmuolio Feb 12, 2020
3139799
remove unnecessary check
Hirmuolio Feb 12, 2020
72c842f
Merge branch 'master' into Hirmuolio-vehicle-jsonize
Hirmuolio Feb 12, 2020
8696724
adjust alternator flag
Hirmuolio Feb 12, 2020
65a2017
adjust alternator flag
Hirmuolio Feb 12, 2020
643ecf1
Merge branch 'Hirmuolio-vehicle-jsonize' of https://github.com/Hirmuo…
Hirmuolio Feb 12, 2020
eab295d
removed thing from doc
Hirmuolio Feb 12, 2020
32ca02d
Merge branch 'master' into Hirmuolio-vehicle-jsonize
Hirmuolio Mar 23, 2020
08971a2
rename window requiring flag
Hirmuolio Mar 26, 2020
bbe2b53
rename window requiring flag
Hirmuolio Mar 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/json/vehicleparts/vehicle_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@
"removal": { "skills": [ [ "mechanics", 1 ] ], "time": "5 m", "using": [ [ "vehicle_screw", 1 ] ] },
"repair": { "skills": [ [ "mechanics", 1 ] ], "time": "20 s", "using": [ [ "adhesive", 1 ] ] }
},
"flags": [ "OPENABLE", "OPENCLOSE_INSIDE", "OPAQUE", "CURTAIN", "WINDOW_CURTAIN", "MULTISQUARE" ],
"flags": [ "OPENABLE", "OPENCLOSE_INSIDE", "OPAQUE", "CURTAIN", "MULTISQUARE", "NEEDS_WINDOW" ],
"breaks_into": [ ]
},
{
Expand Down
75 changes: 72 additions & 3 deletions data/json/vehicleparts/vp_flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"id": "ALTERNATOR",
"type": "json_flag",
"context": [ "vehicle_part" ],
"info": "An alternator. When mounted on a gasoline or diesel engine and the engine is on, will produce electrical power that can be stored in a battery."
"info": "An alternator. When mounted on a gasoline or diesel engine and the engine is on, will produce electrical power that can be stored in a battery.",
"requires_flag": "E_ALTERNATOR"
},
{
"id": "AISLE",
Expand Down Expand Up @@ -65,6 +66,12 @@
"context": [ "vehicle_part" ],
"info": "Closed, it prevents people from seeing through the curtain. A door motor allows you to remotely open or close it from the vehicle controls."
},
{
"id": "NEEDS_WINDOW",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "WINDOW"
},
{
"id": "DOOR",
"type": "json_flag",
Expand Down Expand Up @@ -123,7 +130,8 @@
"id": "SEATBELT",
"type": "json_flag",
"context": [ "vehicle_part" ],
"info": "This part will help prevent you from being thrown from the vehicle in a collision. You will automatically enable this part when you move into a tile with it."
"info": "This part will help prevent you from being thrown from the vehicle in a collision. You will automatically enable this part when you move into a tile with it.",
"requires_flag": "BELTABLE"
},
{
"id": "STABLE",
Expand All @@ -141,7 +149,14 @@
"id": "TURRET",
"type": "json_flag",
"context": [ "vehicle_part" ],
"info": "A heavy weapon mounted in a turret. It can be fired from the vehicle controls."
"info": "A heavy weapon mounted in a turret. It can be fired from the vehicle controls.",
"requires_flag": "TURRET_MOUNT"
},
{
"id": "TURRET_CONTROLS",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "TURRET"
},
{
"id": "WHEEL",
Expand All @@ -160,5 +175,59 @@
"type": "json_flag",
"context": [ "vehicle_part" ],
"info": "You can craft here."
},
{
"id": "NEEDS_WHEEL_MOUNT_LIGHT",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "WHEEL_MOUNT_LIGHT"
},
{
"id": "NEEDS_WHEEL_MOUNT_MEDIUM",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "WHEEL_MOUNT_MEDIUM"
},
{
"id": "NEEDS_WHEEL_MOUNT_HEAVY",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "WHEEL_MOUNT_HEAVY"
},
{
"id": "NEEDS_BATTERY_MOUNT",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "BATTERY_MOUNT"
},
{
"id": "ON_CONTROLS",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "CONTROLS"
},
{
"id": "INTERNAL",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "CARGO"
},
{
"id": "CARGO_LOCKING",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "LOCKABLE_CARGO"
},
{
"id": "DOOR_MOTOR",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "OPENABLE"
},
{
"id": "ON_ROOF",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "ROOF"
}
]
23 changes: 16 additions & 7 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ Those flags are added by the game code to specific items (that specific welder,
- ```AUTOPILOT``` This part will enable a vehicle to have a simple autopilot.
- ```AISLE_LIGHT```
- ```AISLE``` Player can move over this part with less speed penalty than normal.
- ```ALTERNATOR``` Recharges batteries installed on the vehicle.
- ```ALTERNATOR``` Recharges batteries installed on the vehicle. Can only be installed on a part with ```E_ALTERNATOR``` flag.
- ```ANCHOR_POINT``` Allows secure seatbelt attachment.
- ```ANIMAL_CTRL``` Can harness an animal, need HARNESS_bodytype flag to specify bodytype of animal.
- ```ARMOR``` Protects the other vehicle parts it's installed over during collisions.
Expand All @@ -1326,7 +1326,7 @@ Those flags are added by the game code to specific items (that specific welder,
- ```CAMERA_CONTROL```
- ```CAMERA```
- ```CAPTURE_MOSNTER_VEH``` Can be used to capture monsters when mounted on a vehicle.
- ```CARGO_LOCKING``` This cargo area is inaccessible to NPCs.
- ```CARGO_LOCKING``` This cargo area is inaccessible to NPCs. Can only be installed on a part with ```LOCKABLE_CARGO``` flag.
- ```CARGO``` Cargo holding area.
- ```CHEMLAB``` Acts as a chemistry set for crafting.
- ```CHIMES``` Generates continuous noise when used.
Expand All @@ -1341,7 +1341,7 @@ Those flags are added by the game code to specific items (that specific welder,
- ```CURTAIN``` Can be installed over a part flagged with ```WINDOW```, and functions the same as blinds found on windows in buildings.
- ```DIFFICULTY_REMOVE```
- ```DOME_LIGHT```
- ```DOOR_MOTOR```
- ```DOOR_MOTOR``` Can only be installed on a part with ```OPENABLE``` flag.
- ```ENGINE``` Is an engine and contributes towards vehicle mechanical power.
- ```EVENTURN``` Only on during even turns.
- ```EXTRA_DRAG``` tells the vehicle that the part exerts engine power reduction.
Expand All @@ -1363,7 +1363,7 @@ Those flags are added by the game code to specific items (that specific welder,
- ```HARNESS_bodytype``` Replace bodytype with `any` to accept any type, or with the targeted type.
- ```HORN``` Generates noise when used.
- ```INITIAL_PART``` When starting a new vehicle via the construction menu, this vehicle part will be the initial part of the vehicle (if the used item matches the item required for this part). The items of parts with this flag are automatically added as component to the vehicle start construction.
- ```INTERNAL``` Must be mounted inside a cargo area.
- ```INTERNAL``` Can only be installed on a part with ```CARGO``` flag.
- ```KITCHEN``` Acts as a kitchen unit and heat source for crafting.
- ```LOCKABLE_CARGO``` Cargo containers that are able to have a lock installed.
- ```MUFFLER``` Muffles the noise a vehicle makes while running.
Expand All @@ -1376,7 +1376,7 @@ Those flags are added by the game code to specific items (that specific welder,
- ```NO_JACK```
- ```OBSTACLE``` Cannot walk through part, unless the part is also ```OPENABLE```.
- ```ODDTURN``` Only on during odd turns.
- ```ON_CONTROLS```
- ```ON_CONTROLS``` Can only be installed on a part with ```CONTROLS``` flag.
- ```ON_ROOF``` - Parts with this flag could only be installed on a roof (parts with ```ROOF``` flag).
- ```OPAQUE``` Cannot be seen through.
- ```OPENABLE``` Can be opened or closed.
Expand All @@ -1394,7 +1394,7 @@ Those flags are added by the game code to specific items (that specific welder,
- ```REVERSIBLE``` Removal has identical requirements to installation but is twice as quick
- ```ROOF``` Covers a section of the vehicle. Areas of the vehicle that have a roof and roofs on surrounding sections, are considered inside. Otherwise they're outside.
- ```SCOOP``` Pulls items from underneath the vehicle to the cargo space of the part. Also mops up liquids.
- ```SEATBELT``` Helps prevent the player from being ejected from the vehicle during an accident.
- ```SEATBELT``` Helps prevent the player from being ejected from the vehicle during an accident. Can only be installed on a part with ```BELTABLE``` flag.
- ```SEAT``` A seat where the player can sit or sleep.
- ```SECURITY```
- ```SHARP``` Striking a monster with this part does cutting damage instead of bashing damage, and prevents stunning the monster.
Expand All @@ -1410,7 +1410,7 @@ Those flags are added by the game code to specific items (that specific welder,
- ```TOWEL``` Can be used to dry yourself up.
- ```TRACKED``` Contributes to steering effectiveness but doesn't count as a steering axle for install difficulty and still contributes to drag for the center of steering calculation.
- ```TRACK``` Allows the vehicle installed on, to be marked and tracked on map.
- ```TURRET_CONTROLS``` If part with this flag is installed over the turret, it allows to set said turret's targeting mode to full auto.
- ```TURRET_CONTROLS``` If part with this flag is installed over the turret, it allows to set said turret's targeting mode to full auto. Can only be installed on a part with ```TURRET``` flag.
- ```TURRET_MOUNT``` Parts with this flag are suitable for installing turrets.
- ```TURRET``` Is a weapon turret. Can only be installed on a part with ```TURRET_MOUNT``` flag.
- ```UNMOUNT_ON_DAMAGE``` Part breaks off the vehicle when destroyed by damage.
Expand All @@ -1428,6 +1428,15 @@ Those flags are added by the game code to specific items (that specific welder,
- ```WIND_POWERED``` This engine is powered by wind ( sails etc ).
- ```WIND_TURBINE``` Recharges vehicle batteries when exposed to wind.
- ```WORKBENCH``` Can craft at this part, must be paired with a workbench json entry.
- ```NEEDS_WINDOW``` Can only be installed on a part with ```WINDOW``` flag.
- ```NEEDS_WHEEL_MOUNT_LIGHT``` Can only be installed on a part with ```WHEEL_MOUNT_LIGHT``` flag.
- ```NEEDS_WHEEL_MOUNT_MEDIUM``` Can only be installed on a part with ```WHEEL_MOUNT_MEDIUM``` flag.
- ```NEEDS_WHEEL_MOUNT_HEAVY``` Can only be installed on a part with ```WHEEL_MOUNT_HEAVY``` flag.

### Vehicle parts requiring other vehicle parts

The requirement for other vehicle parts is defined for a json flag by setting ```requires_flag``` for the flag. ```requires_flag``` is the other flag that a part with this flag requires.


### Fuel types

Expand Down
1 change: 1 addition & 0 deletions src/flag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void json_flag::load( const JsonObject &jo )
jo.read( "conflicts", f.conflicts_ );
jo.read( "inherit", f.inherit_ );
jo.read( "craft_inherit", f.craft_inherit_ );
jo.read( "requires_flag", f.requires_flag_ );
jo.read( "taste_mod", f.taste_mod_ );

// FIXME: most flags have a "context" field that isn't used for anything
Expand Down
6 changes: 6 additions & 0 deletions src/flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class json_flag
return craft_inherit_;
}

/** Requires this flag to be installed on vehicle */
std::string requires_flag() const {
return requires_flag_;
}

/** The flag's modifier on the fun value of comestibles */
int taste_mod() const {
return taste_mod_;
Expand All @@ -51,6 +56,7 @@ class json_flag
std::set<std::string> conflicts_;
bool inherit_ = true;
bool craft_inherit_ = false;
std::string requires_flag_;
int taste_mod_ = 0;

json_flag( const std::string &id = std::string() ) : id_( id ) {}
Expand Down
3 changes: 3 additions & 0 deletions src/veh_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ class vpart_info
// Display order in vehicle interact display
int list_order = 0;

const std::set<std::string> &get_flags() const {
return flags;
}
bool has_flag( const std::string &flag ) const {
return flags.count( flag ) != 0;
}
Expand Down
Loading