Skip to content

Commit

Permalink
Jsonize vehicle parts requiring other vehicle parts to be installed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirmuolio authored Apr 2, 2020
1 parent 3bfc7cd commit 5899e2d
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 210 deletions.
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 @@ -1311,7 +1311,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 @@ -1325,7 +1325,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 @@ -1340,7 +1340,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 @@ -1362,7 +1362,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 @@ -1375,7 +1375,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 @@ -1393,7 +1393,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 @@ -1409,7 +1409,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 @@ -1427,6 +1427,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

0 comments on commit 5899e2d

Please sign in to comment.