void talk_function::start_training( npc &p ) { int cost; time_duration time = 0_turns; std::string name; const skill_id &skill = p.chatbin.skill; const matype_id &style = p.chatbin.style; if( skill.is_valid() && g->u.get_skill_level( skill ) < p.get_skill_level( skill ) ) { cost = calc_skill_training_cost( p, skill ); time = calc_skill_training_time( p, skill ); name = skill.str(); } else if( p.chatbin.style.is_valid() && !g->u.has_martialart( style ) ) { cost = calc_ma_style_training_cost( p, style ); time = calc_ma_style_training_time( p, style ); name = p.chatbin.style.str(); } else { debugmsg( "start_training with no valid skill or style set" ); return; } mission *miss = p.chatbin.mission_selected; if( miss != nullptr && miss->get_assigned_player_id() == g->u.getID() ) { clear_mission( p ); } else if( !pay_npc( p, cost ) ) { return; } g->u.assign_activity( activity_id( "ACT_TRAIN" ), to_moves<int>( time ), p.getID(), 0, name ); p.add_effect( effect_asked_to_train, 6_hours ); }
void talk_function::buy_100_logs( npc &p ) { std::vector<tripoint> places = overmap_buffer.find_all( g->u.global_omt_location(), "ranch_camp_67", 1, false ); if( places.empty() ) { debugmsg( "Couldn't find %s", "ranch_camp_67" ); return; } const auto &cur_om = g->get_cur_om(); std::vector<tripoint> places_om; for( auto &i : places ) { if( &cur_om == overmap_buffer.get_existing_om_global( i ) ) { places_om.push_back( i ); } } const tripoint site = random_entry( places_om ); tinymap bay; bay.load( site.x * 2, site.y * 2, site.z, false ); bay.spawn_item( 7, 15, "log", 100 ); bay.save(); p.add_effect( effect_currently_busy, 7_days ); add_msg( m_good, _( "%s drops the logs off in the garage..." ), p.name ); }
void talk_function::give_equipment( npc &p ) { std::vector<item_pricing> giving = init_selling( p ); int chosen = -1; while( chosen == -1 && giving.size() > 1 ) { int index = rng( 0, giving.size() - 1 ); if( giving[index].price < p.op_of_u.owed ) { chosen = index; } giving.erase( giving.begin() + index ); } if( giving.empty() ) { popup( _( "%s has nothing to give!" ), p.name ); return; } if( chosen == -1 ) { chosen = 0; } item it = *giving[chosen].loc.get_item(); giving[chosen].loc.remove_item(); popup( _( "%1$s gives you a %2$s" ), p.name, it.tname() ); g->u.i_add( it ); p.op_of_u.owed -= giving[chosen].price; p.add_effect( effect_asked_for_item, 3_hours ); }
void talk_function::give_aid( npc &p ) { p.add_effect( effect_currently_busy, 30_minutes ); for( int i = 0; i < num_hp_parts; i++ ) { const body_part bp_healed = player::hp_to_bp( hp_part( i ) ); g->u.heal( hp_part( i ), 5 * rng( 2, 5 ) ); if( g->u.has_effect( effect_bite, bp_healed ) ) { g->u.remove_effect( effect_bite, bp_healed ); } if( g->u.has_effect( effect_bleed, bp_healed ) ) { g->u.remove_effect( effect_bleed, bp_healed ); } if( g->u.has_effect( effect_infected, bp_healed ) ) { g->u.remove_effect( effect_infected, bp_healed ); } } g->u.assign_activity( activity_id( "ACT_WAIT_NPC" ), 10000 ); g->u.activity.str_values.push_back( p.name ); }
void talk_function::give_all_aid( npc &p ) { p.add_effect( effect_currently_busy, 30_minutes ); give_aid( p ); for( npc &guy : g->all_npcs() ) { if( rl_dist( guy.pos(), g->u.pos() ) < PICKUP_RANGE && guy.is_friend() ) { for( int i = 0; i < num_hp_parts; i++ ) { const body_part bp_healed = player::hp_to_bp( hp_part( i ) ); guy.heal( hp_part( i ), 5 * rng( 2, 5 ) ); if( guy.has_effect( effect_bite, bp_healed ) ) { guy.remove_effect( effect_bite, bp_healed ); } if( guy.has_effect( effect_bleed, bp_healed ) ) { guy.remove_effect( effect_bleed, bp_healed ); } if( guy.has_effect( effect_infected, bp_healed ) ) { guy.remove_effect( effect_infected, bp_healed ); } } } } }
void talk_function::deny_personal_info( npc &p ) { p.add_effect( effect_asked_personal_info, 3_hours ); }
void talk_function::deny_train( npc &p ) { p.add_effect( effect_asked_to_train, 6_hours ); }
void talk_function::deny_equipment( npc &p ) { p.add_effect( effect_asked_for_item, 1_hours ); }
void talk_function::deny_lead( npc &p ) { p.add_effect( effect_asked_to_lead, 6_hours ); }
void talk_function::deny_follow( npc &p ) { p.add_effect( effect_asked_to_follow, 6_hours ); }