• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ npc类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中npc的典型用法代码示例。如果您正苦于以下问题:C++ npc类的具体用法?C++ npc怎么用?C++ npc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了npc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: equip_shooter

static void equip_shooter( npc &shooter, std::vector<std::string> apparel )
{
    tripoint shooter_pos( 60, 60, 0 );
    shooter.setpos( shooter_pos );
    shooter.worn.clear();
    shooter.inv.clear();
    for( const std::string article : apparel ) {
        shooter.wear_item( item( article ) );
    }
}
开发者ID:BrianLefler,项目名称:Cataclysm-DDA,代码行数:10,代码来源:ranged_balance.cpp


示例2: set_crew

bool vehicle_part::set_crew( const npc &who )
{
    if( who.is_dead_state() || !who.is_friend() ) {
        return false;
    }
    if( is_broken() || ( !is_seat() && !is_turret() ) ) {
        return false;
    }
    crew_id = who.getID();
    return true;
}
开发者ID:OzoneH3,项目名称:Cataclysm-DDA,代码行数:11,代码来源:vehicle_part.cpp


示例3: test_needs

void test_needs( const npc &who, const numeric_interval<int> &hunger,
                 const numeric_interval<int> &thirst,
                 const numeric_interval<int> &fatigue )
{
    CHECK( who.get_hunger() <= hunger.max );
    CHECK( who.get_hunger() >= hunger.min );
    CHECK( who.get_thirst() <= thirst.max );
    CHECK( who.get_thirst() >= thirst.min );
    CHECK( who.get_fatigue() <= fatigue.max );
    CHECK( who.get_fatigue() >= fatigue.min );
}
开发者ID:BevapDin,项目名称:Cataclysm-DDA,代码行数:11,代码来源:npc_test.cpp


示例4: npc_thankful

void talk_function::npc_thankful( npc &p )
{
    if( p.get_attitude() == NPCATT_MUG || p.get_attitude() == NPCATT_WAIT_FOR_LEAVE ||
        p.get_attitude() == NPCATT_FLEE || p.get_attitude() == NPCATT_KILL ||
        p.get_attitude() == NPCATT_FLEE_TEMP ) {
        p.set_attitude( NPCATT_NULL );
    }
    if( p.chatbin.first_topic != "TALK_FRIEND" ) {
        p.chatbin.first_topic = "TALK_STRANGER_FRIENDLY";
    }
    p.personality.aggression -= 1;

}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:13,代码来源:npctalk_funcs.cpp


示例5: arm_shooter

static void arm_shooter( npc &shooter, std::string gun_type, std::vector<std::string> mods = {} )
{
    shooter.remove_weapon();

    itype_id gun_id( gun_type );
    // Give shooter a loaded gun of the requested type.
    item &gun = shooter.i_add( item( gun_id ) );
    const itype_id ammo_id = gun.ammo_default();
    if( gun.magazine_integral() ) {
        item &ammo = shooter.i_add( item( ammo_id, calendar::turn, gun.ammo_capacity() ) );
        REQUIRE( gun.is_reloadable_with( ammo_id ) );
        REQUIRE( shooter.can_reload( gun, ammo_id ) );
        gun.reload( shooter, item_location( shooter, &ammo ), gun.ammo_capacity() );
    } else {
        const itype_id magazine_id = gun.magazine_default();
        item &magazine = shooter.i_add( item( magazine_id ) );
        item &ammo = shooter.i_add( item( ammo_id, calendar::turn, magazine.ammo_capacity() ) );
        REQUIRE( magazine.is_reloadable_with( ammo_id ) );
        REQUIRE( shooter.can_reload( magazine, ammo_id ) );
        magazine.reload( shooter, item_location( shooter, &ammo ), magazine.ammo_capacity() );
        gun.reload( shooter, item_location( shooter, &magazine ), magazine.ammo_capacity() );
    }
    for( auto mod : mods ) {
        gun.contents.push_back( item( itype_id( mod ) ) );
    }
    shooter.wield( gun );
}
开发者ID:alapazam,项目名称:Cataclysm-DDA,代码行数:27,代码来源:ranged_balance.cpp


示例6: hostile

void talk_function::hostile( npc &p )
{
    if( p.get_attitude() == NPCATT_KILL ) {
        return;
    }

    if( p.sees( g->u ) ) {
        add_msg( _( "%s turns hostile!" ), p.name );
    }

    g->u.add_memorial_log( pgettext( "memorial_male", "%s became hostile." ),
                           pgettext( "memorial_female", "%s became hostile." ),
                           p.name );
    p.set_attitude( NPCATT_KILL );
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:15,代码来源:npctalk_funcs.cpp


示例7: 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 );
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:26,代码来源:npctalk_funcs.cpp


示例8: morale_chat_activity

void talk_function::morale_chat_activity( npc &p )
{
    g->u.assign_activity( activity_id( "ACT_SOCIALIZE" ), 10000 );
    g->u.activity.str_values.push_back( p.name );
    add_msg( m_good, _( "That was a pleasant conversation with %s." ), p.disp_name() );
    g->u.add_morale( MORALE_CHAT, rng( 3, 10 ), 10, 200_minutes, 5_minutes / 2 );
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:7,代码来源:npctalk_funcs.cpp


示例9: 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 );
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:25,代码来源:npctalk_funcs.cpp


示例10: lead_to_safety

void talk_function::lead_to_safety( npc &p )
{
    const auto mission = mission::reserve_new( mission_type_id( "MISSION_REACH_SAFETY" ), -1 );
    mission->assign( g->u );
    p.goal = mission->get_target();
    p.set_attitude( NPCATT_LEAD );
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:7,代码来源:npctalk_funcs.cpp


示例11: get_dispersion

static dispersion_sources get_dispersion( npc &shooter, int aim_time )
{
    item &gun = shooter.weapon;
    dispersion_sources dispersion = shooter.get_weapon_dispersion( gun );

    shooter.moves = aim_time;
    shooter.recoil = MAX_RECOIL;
    // Aim as well as possible within the provided time.
    shooter.aim();
    if( aim_time > 0 ) {
        REQUIRE( shooter.recoil < MAX_RECOIL );
    }
    dispersion.add_range( shooter.recoil );

    return dispersion;
}
开发者ID:alapazam,项目名称:Cataclysm-DDA,代码行数:16,代码来源:ranged_balance.cpp


示例12: assert_encumbrance

void assert_encumbrance( npc &shooter, int encumbrance )
{
    for( body_part bp : bp_aBodyPart ) {
        INFO( "Body Part: " << body_part_name( bp ) );
        REQUIRE( shooter.encumb( bp ) == encumbrance );
    }
}
开发者ID:alapazam,项目名称:Cataclysm-DDA,代码行数:7,代码来源:ranged_balance.cpp


示例13: string_format

void talk_function::goto_location( npc &p )
{
    int i = 0;
    uilist selection_menu;
    selection_menu.text = string_format( _( "Select a destination" ) );
    std::vector<basecamp *> camps;
    tripoint destination;
    for( auto elem : g->u.camps ) {
        if( elem == p.global_omt_location() ) {
            continue;
        }
        cata::optional<basecamp *> camp = overmap_buffer.find_camp( elem.x, elem.y );
        if( !camp ) {
            continue;
        }
        basecamp *temp_camp = *camp;
        camps.push_back( temp_camp );
    }
    for( auto iter : camps ) {
        selection_menu.addentry( i++, true, MENU_AUTOASSIGN, _( "%s at (%d, %d)" ), iter->camp_name(),
                                 iter->camp_omt_pos().x, iter->camp_omt_pos().y );
    }
    selection_menu.addentry( i++, true, MENU_AUTOASSIGN, _( "My current location" ) );
    selection_menu.addentry( i++, true, MENU_AUTOASSIGN, _( "Cancel" ) );
    selection_menu.selected = 0;
    selection_menu.query();
    auto index = selection_menu.ret;
    if( index < 0 || index > static_cast<int>( camps.size() + 1 ) ||
        index == static_cast<int>( camps.size() + 1 ) || index == UILIST_CANCEL ) {
        return;
    }
    if( index == static_cast<int>( camps.size() ) ) {
        destination = g->u.global_omt_location();
    } else {
        auto selected_camp = camps[index];
        destination = selected_camp->camp_omt_pos();
    }
    p.set_companion_mission( p.global_omt_location(), "TRAVELLER", "travelling", destination );
    p.mission = NPC_MISSION_TRAVELLING;
    p.chatbin.first_topic = "TALK_FRIEND_GUARD";
    p.goal = destination;
    p.guard_pos = npc::no_goal_point;
    p.set_attitude( NPCATT_NULL );
    return;
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:45,代码来源:npctalk_funcs.cpp


示例14: add_msg

void talk_function::stop_guard( npc &p )
{
    p.set_attitude( NPCATT_FOLLOW );
    add_msg( _( "%s begins to follow you." ), p.name );
    p.mission = NPC_MISSION_NULL;
    p.chatbin.first_topic = "TALK_FRIEND";
    p.goal = npc::no_goal_point;
    p.guard_pos = npc::no_goal_point;
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:9,代码来源:npctalk_funcs.cpp


示例15: add_msg

void talk_function::stop_guard( npc &p )
{
    if( p.mission != NPC_MISSION_GUARD_ALLY ) {
        p.set_attitude( NPCATT_NULL );
        p.mission = NPC_MISSION_NULL;
        return;
    }

    p.set_attitude( NPCATT_FOLLOW );
    add_msg( _( "%s begins to follow you." ), p.name );
    p.mission = NPC_MISSION_NULL;
    p.chatbin.first_topic = "TALK_FRIEND";
    p.goal = npc::no_goal_point;
    p.guard_pos = npc::no_goal_point;
    cata::optional<basecamp *> bcp = overmap_buffer.find_camp( p.global_omt_location().x,
                                     p.global_omt_location().y );
    if( bcp ) {
        basecamp *temp_camp = *bcp;
        temp_camp->validate_assignees();
    }
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:21,代码来源:npctalk_funcs.cpp


示例16: assign_base

void talk_function::assign_base( npc &p )
{
    // TODO: decide what to do upon assign? maybe pathing required
    basecamp *camp = g->m.camp_at( g->u.pos() );
    if( !camp ) {
        dbg( D_ERROR ) << "talk_function::assign_base: Assigned to base but no base here.";
        return;
    }

    add_msg( _( "%1$s waits at %2$s" ), p.name, camp->camp_name() );
    p.mission = NPC_MISSION_BASE;
    p.set_attitude( NPCATT_NULL );
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:13,代码来源:npctalk_funcs.cpp


示例17: test_fast_shooting

static void test_fast_shooting( npc &shooter, int moves, float hit_rate )
{
    const int fast_shooting_range = 3;
    const float hit_rate_cap = hit_rate + 0.3;
    dispersion_sources dispersion = get_dispersion( shooter, moves );
    std::array<statistics, 5> fast_stats = firing_test( dispersion, fast_shooting_range, {{ -1, hit_rate, -1, -1, -1 }} );
    std::array<statistics, 5> fast_stats_upper = firing_test( dispersion, fast_shooting_range, {{ -1, hit_rate_cap, -1, -1, -1 }} );
    INFO( dispersion );
    INFO( "Range: " << fast_shooting_range );
    INFO( "Max aim speed: " << shooter.aim_per_move( shooter.weapon, MAX_RECOIL ) );
    INFO( "Min aim speed: " << shooter.aim_per_move( shooter.weapon, shooter.recoil ) );
    CAPTURE( shooter.weapon.gun_skill().str() );
    CAPTURE( shooter.get_skill_level( shooter.weapon.gun_skill() ) );
    CAPTURE( shooter.get_dex() );
    CAPTURE( to_milliliter( shooter.weapon.volume() ) );
    CAPTURE( fast_stats[1].n() );
    CAPTURE( fast_stats[1].adj_wald_error() );
    CHECK( fast_stats[1].avg() > hit_rate );
    CAPTURE( fast_stats_upper[1].n() );
    CAPTURE( fast_stats_upper[1].adj_wald_error() );
    CHECK( fast_stats_upper[1].avg() < hit_rate_cap );
}
开发者ID:alapazam,项目名称:Cataclysm-DDA,代码行数:22,代码来源:ranged_balance.cpp


示例18: clear_mission

void talk_function::clear_mission( npc &p )
{
    mission *miss = p.chatbin.mission_selected;
    if( miss == nullptr ) {
        debugmsg( "clear_mission: mission_selected == nullptr" );
        return;
    }
    const auto it = std::find( p.chatbin.missions_assigned.begin(), p.chatbin.missions_assigned.end(),
                               miss );
    if( it == p.chatbin.missions_assigned.end() ) {
        debugmsg( "clear_mission: mission_selected not in assigned" );
        return;
    }
    p.chatbin.missions_assigned.erase( it );
    if( p.chatbin.missions_assigned.empty() ) {
        p.chatbin.mission_selected = nullptr;
    } else {
        p.chatbin.mission_selected = p.chatbin.missions_assigned.front();
    }
    if( miss->has_follow_up() ) {
        p.add_new_mission( mission::reserve_new( miss->get_follow_up(), p.getID() ) );
    }
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:23,代码来源:npctalk_funcs.cpp


示例19: 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 );
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:19,代码来源:npctalk_funcs.cpp


示例20: define_camp

void basecamp::define_camp( npc &p )
{
    query_new_name();
    omt_pos = p.global_omt_location();
    sort_points = p.companion_mission_points;
    // purging the regions guarantees all entries will start with faction_base_
    for( std::pair<std::string, tripoint> expansion : talk_function::om_building_region( omt_pos, 1,
            true ) ) {
        add_expansion( expansion.first, expansion.second );
    }
    const std::string om_cur = overmap_buffer.ter( omt_pos ).id().c_str();
    if( om_cur.find( prefix ) == std::string::npos ) {
        expansion_data e;
        e.type = "camp";
        e.cur_level = 0;
        e.pos = omt_pos;
        expansions[ base_dir ] = e;
    } else {
        expansions[ base_dir ] = parse_expansion( om_cur, omt_pos );
    }
}
开发者ID:Noctifer-de-Mortem,项目名称:Cataclysm-DDA,代码行数:21,代码来源:basecamp.cpp



注:本文中的npc类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ nsACString类代码示例发布时间:2022-05-31
下一篇:
C++ not_passed_list类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap