本文整理汇总了C++中npc::add_effect方法的典型用法代码示例。如果您正苦于以下问题:C++ npc::add_effect方法的具体用法?C++ npc::add_effect怎么用?C++ npc::add_effect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类npc
的用法示例。
在下文中一共展示了npc::add_effect方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start_training
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 );
}
示例2: debugmsg
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 );
}
示例3: give_equipment
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 );
}
示例4: give_aid
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 );
}
示例5: give_all_aid
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 );
}
}
}
}
}
示例6: deny_personal_info
void talk_function::deny_personal_info( npc &p )
{
p.add_effect( effect_asked_personal_info, 3_hours );
}
示例7: deny_train
void talk_function::deny_train( npc &p )
{
p.add_effect( effect_asked_to_train, 6_hours );
}
示例8: deny_equipment
void talk_function::deny_equipment( npc &p )
{
p.add_effect( effect_asked_for_item, 1_hours );
}
示例9: deny_lead
void talk_function::deny_lead( npc &p )
{
p.add_effect( effect_asked_to_lead, 6_hours );
}
示例10: deny_follow
void talk_function::deny_follow( npc &p )
{
p.add_effect( effect_asked_to_follow, 6_hours );
}