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

vehicle mounted pet carriers #24391

Merged
merged 2 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@
"type" : "item_action",
"id" : "CAPTURE_MONSTER_ACT",
"name" : "Capture/place"
},{
"type" : "item_action",
"id" : "CAPTURE_MONSTER_VEH",
"name" : "Capture/place"
},{
"type" : "item_action",
"id" : "CARVER_OFF",
Expand Down
16 changes: 16 additions & 0 deletions data/json/items/vehicle_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,22 @@
"category" : "veh_parts",
"price" : 40000
},
{
"id": "livestock_carrier",
"type": "GENERIC",
"name": "livestock carrier",
"description": "A heavy frame outfitted with tie-downs and attachment points for carrying cargo, with additional railings to keep a large animal in place. It is meant to hold large animals for transport. Use it on a suitable animal to capture, use it on an empty tile to release.",
"weight": 96000,
"volume": 250,
"price": 48000,
"category": "veh_parts",
"material": [ "steel", "plastic" ],
"symbol": "]",
"color": "light_gray",
"properties": [ [ "monster_size_capacity", "LARGE" ] ],
"use_action": "CAPTURE_MONSTER_VEH",
"flags": [ "TRADER_AVOID", "USE_PART_ITEM" ]
},
{
"type":"GENERIC",
"id": "floodlight",
Expand Down
28 changes: 28 additions & 0 deletions data/json/recipes/other/vehicle.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,33 @@
[ [ "sheet_metal", 1 ], [ "steel_standard", 1, "LIST" ] ],
[ [ "clockworks", 2 ] ]
]
},
{
"type": "recipe",
"result": "livestock_carrier",
"category": "CC_OTHER",
"subcategory": "CSC_OTHER_VEHICLE",
"skill_used": "fabrication",
"skills_required": [ "mechanics", 1 ],
"difficulty": 4,
"time": 60000,
"autolearn": true,
"using": [ [ "rope_natural", 4 ], [ "welding_standard", 12 ] ],
"qualities": [ { "id": "HAMMER", "level": 2 }, { "id": "SAW_M", "level": 1 }, { "id": "WRENCH", "level": 1 } ],
"components": [ [ [ "frame", 4 ] ], [ [ "steel_chunk", 4 ], [ "scrap", 12 ], [ "pipe", 12 ] ] ]
},
{
"type": "recipe",
"result": "livestock_carrier",
"category": "CC_OTHER",
"subcategory": "CSC_OTHER_VEHICLE",
"skill_used": "fabrication",
"skills_required": [ "mechanics", 1 ],
"difficulty": 4,
"time": 60000,
"autolearn": true,
"using": [ [ "welding_standard", 2 ] ],
"qualities": [ { "id": "HAMMER", "level": 2 }, { "id": "SAW_M", "level": 1 }, { "id": "WRENCH", "level": 1 } ],
"components": [ [ [ "pipe", 12 ] ], [ [ "cargo_rack", 1 ] ] ]
}
]
21 changes: 21 additions & 0 deletions data/json/vehicle_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,27 @@
{ "item": "scrap", "count": [ 6, 8 ] }
]
},
{
"type": "vehicle_part",
"id": "livestock_stall",
"name": "livestock stall",
"symbol": "=",
"color": "light_gray",
"broken_symbol": "#",
"broken_color": "dark_gray",
"durability": 250,
"description": "A cargo space for carrrying animals. Examine it it to capture an animal next to it, or to release the animal currently contained. While there is an animal the stall, it is impossible to access the cargo.",
"size": 800,
"item": "livestock_carrier",
"difficulty": 1,
"location": "center",
"flags": [ "BOARDABLE", "CARGO", "COVERED", "CAPTURE_MONSTER_VEH" ],
"breaks_into": [
{ "item": "steel_lump", "count": [ 6, 8 ] },
{ "item": "steel_chunk", "count": [ 6, 8 ] },
{ "item": "scrap", "count": [ 6, 8 ] }
]
},
{
"type": "vehicle_part",
"id": "recharge_station",
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ These branches are also the valid entries for the categories of `dreams` in `dre
- ```BOARDABLE``` The player can safely move over or stand on this part while the vehicle is moving.
- ```CAMERA```
- ```CAMERA_CONTROL```
- ```CAPTURE_MOSNTER_VEH``` Can be used to capture monsters when mounted on a vehicle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the typo? I'm not seeing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MOSNTER

- ```CARGO``` Cargo holding area.
- ```CARGO_LOCKING``` This cargo area is inaccessible to NPCs.
- ```CHEMLAB``` Acts as a chemistry set for crafting.
Expand Down
1 change: 1 addition & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ void Item_factory::init()
add_iuse( "CAN_GOO", &iuse::can_goo );
add_iuse( "DIRECTIONAL_HOLOGRAM", &iuse::directional_hologram );
add_iuse( "CAPTURE_MONSTER_ACT", &iuse::capture_monster_act );
add_iuse( "CAPTURE_MONSTER_VEH", &iuse::capture_monster_veh );
add_iuse( "CARVER_OFF", &iuse::carver_off );
add_iuse( "CARVER_ON", &iuse::carver_on );
add_iuse( "CATFOOD", &iuse::catfood );
Expand Down
11 changes: 11 additions & 0 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7675,6 +7675,17 @@ int iuse::directional_hologram( player *p, item *it, bool, const tripoint &pos )
return it->type->charges_to_use();
}

int iuse::capture_monster_veh( player *p, item *it, bool, const tripoint &pos )
{
if( !it->has_flag( "VEHICLE" ) ) {
p->add_msg_if_player( m_info, _( "The %s must be installed in a vehicle before being loaded." ),
it->tname().c_str() );
return 0;
}
capture_monster_act( p, it, 0, pos );
return 0;
}

int iuse::capture_monster_act( player *p, item *it, bool, const tripoint &pos )
{
if( it->has_var( "contained_name" ) ) {
Expand Down
1 change: 1 addition & 0 deletions src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class iuse
int can_goo( player *, item *, bool, const tripoint & );
int throwable_extinguisher_act( player *, item *, bool, const tripoint & );
int directional_hologram( player *, item *, bool, const tripoint & );
int capture_monster_veh( player *, item *, bool, const tripoint & );
int capture_monster_act( player *, item *, bool, const tripoint & );
int pipebomb_act( player *, item *, bool, const tripoint & );
int granade( player *, item *, bool, const tripoint & );
Expand Down
12 changes: 11 additions & 1 deletion src/pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ interact_results interact_with_vehicle( vehicle *veh, const tripoint &pos,
const bool has_washmachine = washing_machine_part >= 0;
bool washing_machine_on = ( washing_machine_part == -1 ) ? false :
veh->parts[washing_machine_part].enabled;
const bool has_monster_capture = ( veh->part_with_feature( veh_root_part,
"CAPTURE_MONSTER_VEH" ) >= 0 );
const int monster_capture_part = veh->part_with_feature( veh_root_part, "CAPTURE_MONSTER_VEH" );

typedef enum {
EXAMINE, TRACK, CONTROL, CONTROL_ELECTRONICS, GET_ITEMS, GET_ITEMS_ON_GROUND, FOLD_VEHICLE, UNLOAD_TURRET, RELOAD_TURRET,
USE_HOTPLATE, FILL_CONTAINER, DRINK, USE_WELDER, USE_PURIFIER, PURIFY_TANK, USE_WASHMACHINE
USE_HOTPLATE, FILL_CONTAINER, DRINK, USE_WELDER, USE_PURIFIER, PURIFY_TANK, USE_WASHMACHINE, USE_MONSTER_CAPTURE
} options;
uimenu selectmenu;

Expand Down Expand Up @@ -156,6 +159,9 @@ interact_results interact_with_vehicle( vehicle *veh, const tripoint &pos,
selectmenu.addentry( PURIFY_TANK, can_purify && veh->fuel_left( "water" ),
'P', _( "Purify water in vehicle tank" ) );
}
if( has_monster_capture ) {
selectmenu.addentry( USE_MONSTER_CAPTURE, true, 'G', _( "Capture or release a creature" ) );
}

int choice;
if( selectmenu.entries.size() == 1 ) {
Expand All @@ -181,6 +187,10 @@ interact_results interact_with_vehicle( vehicle *veh, const tripoint &pos,
};

switch( static_cast<options>( choice ) ) {
case USE_MONSTER_CAPTURE: {
veh->use_monster_capture( monster_capture_part, pos );
return DONE;
}

case USE_HOTPLATE:
veh_tool( "hotplate" );
Expand Down
32 changes: 30 additions & 2 deletions src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6302,11 +6302,16 @@ vehicle_part::operator bool() const {
return id != vpart_id::NULL_ID();
}

const item& vehicle_part::get_base() const
const item &vehicle_part::get_base() const
{
return base;
}

void vehicle_part::set_base( const item &new_base )
{
base = new_base;
}

item vehicle_part::properties_to_item() const
{
item tmp = base;
Expand All @@ -6330,7 +6335,8 @@ item vehicle_part::properties_to_item() const
return tmp;
}

std::string vehicle_part::name() const {
std::string vehicle_part::name() const
{
auto res = info().name();

if( base.engine_displacement() > 0 ) {
Expand All @@ -6344,6 +6350,9 @@ std::string vehicle_part::name() const {
res += ( _( " (faulty)" ) );
}

if( base.has_var( "contained_name" ) ) {
res += string_format( _( " holding %s" ), base.get_var( "contained_name" ) );
}
return res;
}

Expand Down Expand Up @@ -6760,3 +6769,22 @@ void vehicle::use_washing_machine( int p ) {
_( "You pour some detergent into the washing machine, close its lid, and turn it on. The washing machine is being filled with water from vehicle tanks." ) );
}
}

void vehicle::use_monster_capture( int part, const tripoint &pos )
{
if( parts[part].is_broken() || parts[part].removed ) {
return;
}
item base = item( parts[part].get_base() );
base.type->invoke( g->u, base, pos );
parts[part].set_base( base );
/* captured animals take up all the cargo space */
/*
if( base.has_var( "contained_name" ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this commented text should be deleted.

part_info( part ).size = 0;
} else {
part_info( part ).size = base.get_container_capacity();
}
*/
parts[part].set_base( base );
}
4 changes: 3 additions & 1 deletion src/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,12 @@ struct vehicle_part
/** Get part definition common to all parts of this type */
const vpart_info &info() const;

const item& get_base() const;

void serialize( JsonOut &jsout ) const;
void deserialize( JsonIn &jsin );

const item &get_base() const;
void set_base( const item &new_base );
/**
* Generate the corresponding item from this vehicle part. It includes
* the hp (item damage), fuel charges (battery or liquids), aspect, ...
Expand Down Expand Up @@ -1193,6 +1194,7 @@ class vehicle
*/
void set_submap_moved(int x, int y);
void use_washing_machine( int p );
void use_monster_capture( int part, const tripoint &pos );

const std::string disp_name() const;

Expand Down