Skip to content

Commit

Permalink
Merge pull request CleverRaven#68630 from ehughsbaird/which,-doctor
Browse files Browse the repository at this point in the history
Allow NPC docs to install & remove CBMs from NPCS
  • Loading branch information
Maleclypse authored Oct 14, 2023
2 parents 34dae9f + 514271b commit cfcc682
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,24 @@
"effect": "bionic_install",
"condition": { "npc_service": true }
},
{
"text": "I was wondering if you could install a cybernetic implant in my friend here…",
"topic": "TALK_DONE",
"effect": "bionic_install_allies",
"condition": { "npc_service": true }
},
{
"text": "I need help removing an implant…",
"topic": "TALK_DONE",
"effect": "bionic_remove",
"condition": { "npc_service": true }
},
{
"text": "I need help removing an implant from one of my friends…",
"topic": "TALK_DONE",
"effect": "bionic_remove_allies",
"condition": { "npc_service": true }
},
{ "text": "Oh no, I was wondering if you knew where to get some.", "topic": "TALK_ANCILLA_DOCTOR_FIND_BIONICS" },
{ "text": "Never mind.", "topic": "TALK_NONE" }
]
Expand Down
8 changes: 5 additions & 3 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2580,12 +2580,14 @@ class bionic_install_surgeon_preset : public inventory_selector_preset
}
};

item_location game_menus::inv::install_bionic( Character &you, Character &patient, bool surgeon )
item_location game_menus::inv::install_bionic( Character &installer, Character &patron,
Character &patient, bool surgeon )
{
if( surgeon ) {
return autodoc_internal( you, patient, bionic_install_surgeon_preset( you, patient ), 5, surgeon );
return autodoc_internal( patron, patient, bionic_install_surgeon_preset( installer, patient ), 5,
surgeon );
} else {
return autodoc_internal( you, patient, bionic_install_preset( you, patient ), 5 );
return autodoc_internal( patron, patient, bionic_install_preset( installer, patient ), 5 );
}

}
Expand Down
3 changes: 2 additions & 1 deletion src/game_inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ item_location salvage( Character &you, const salvage_actor *actor );
/** Repair menu. */
item_location repair( Character &you, const repair_item_actor *actor, const item *main_tool );
/** Bionic install menu. */
item_location install_bionic( Character &you, Character &patient, bool surgeon = false );
item_location install_bionic( Character &installer, Character &patron, Character &patient,
bool surgeon = false );
/**Autoclave sterilize menu*/
item_location sterilize_cbm( Character &you );
/** Change sprite menu. */
Expand Down
2 changes: 1 addition & 1 deletion src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5431,7 +5431,7 @@ void iexamine::autodoc( Character &you, const tripoint &examp )

switch( amenu.ret ) {
case INSTALL_CBM: {
item_location bionic = game_menus::inv::install_bionic( you, patient );
item_location bionic = game_menus::inv::install_bionic( you, you, patient );

if( !bionic ) {
return;
Expand Down
2 changes: 2 additions & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5729,7 +5729,9 @@ void talk_effect_t::parse_string_effect( const std::string &effect_id, const Jso
WRAP( morale_chat ),
WRAP( morale_chat_activity ),
WRAP( bionic_install ),
WRAP( bionic_install_allies ),
WRAP( bionic_remove ),
WRAP( bionic_remove_allies ),
WRAP( drop_items_in_place ),
WRAP( follow ),
WRAP( follow_only ),
Expand Down
2 changes: 2 additions & 0 deletions src/npctalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ void buy_horse( npc & );
void buy_cow( npc & );
void buy_chicken( npc & );
void bionic_install( npc & );
void bionic_install_allies( npc & );
void bionic_remove( npc & );
void bionic_remove_allies( npc & );
void dismount( npc & );
void find_mount( npc & );

Expand Down
52 changes: 39 additions & 13 deletions src/npctalk_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,9 @@ void talk_function::insult_combat( npc &p )
p.set_attitude( NPCATT_KILL );
}

void talk_function::bionic_install( npc &p )
static void bionic_install_common( npc &p, Character &patron, Character &patient )
{
avatar &player_character = get_avatar();
item_location bionic = game_menus::inv::install_bionic( p, player_character, true );
item_location bionic = game_menus::inv::install_bionic( p, patron, patient, true );

if( !bionic ) {
return;
Expand All @@ -513,26 +512,40 @@ void talk_function::bionic_install( npc &p )
tmp->set_var( VAR_TRADE_IGNORE, 1 );
const itype &it = *tmp->type;

signed int price = npc_trading::bionic_install_price( p, player_character, bionic );
signed int price = npc_trading::bionic_install_price( p, patient, bionic );
bool const ret = npc_trading::pay_npc( p, price );
tmp->erase_var( VAR_TRADE_IGNORE );
if( !ret ) {
return;
}

//Makes the doctor awesome at installing but not perfect
if( player_character.can_install_bionics( it, p, false, 20 ) ) {
if( patient.can_install_bionics( it, p, false, 20 ) ) {
bionic.remove_item();
player_character.install_bionics( it, p, false, 20 );
patient.install_bionics( it, p, false, 20 );
}
}

void talk_function::bionic_remove( npc &p )
void talk_function::bionic_install( npc &p )
{
Character &player_character = get_player_character();
const bionic_collection all_bio = *player_character.my_bionics;
Character &pc = get_player_character();
bionic_install_common( p, pc, pc );
}

void talk_function::bionic_install_allies( npc &p )
{
npc *patient = pick_follower();
if( !patient ) {
return;
}
bionic_install_common( p, get_player_character(), *patient );
}

static void bionic_remove_common( npc &p, Character &patient )
{
const bionic_collection all_bio = *patient.my_bionics;
if( all_bio.empty() ) {
popup( _( "You don't have any bionics installed…" ) );
popup( _( "%s doesn't have any bionics installed…" ), patient.get_name() );
return;
}

Expand Down Expand Up @@ -572,10 +585,23 @@ void talk_function::bionic_remove( npc &p )
}

//Makes the doctor awesome at uninstalling but not perfect
if( player_character.can_uninstall_bionic( *bionics[bionic_index], p,
false, 20 ) ) {
player_character.uninstall_bionic( *bionics[bionic_index], p, false, 20 );
if( patient.can_uninstall_bionic( *bionics[bionic_index], p, false, 20 ) ) {
patient.uninstall_bionic( *bionics[bionic_index], p, false, 20 );
}
}

void talk_function::bionic_remove( npc &p )
{
bionic_remove_common( p, get_player_character() );
}

void talk_function::bionic_remove_allies( npc &p )
{
npc *patient = pick_follower();
if( !patient ) {
return;
}
bionic_remove_common( p, *patient );
}

void talk_function::give_equipment( npc &p )
Expand Down

0 comments on commit cfcc682

Please sign in to comment.