当前位置: 首页>>代码示例>>C++>>正文


C++ npc::getID方法代码示例

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


在下文中一共展示了npc::getID方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:29,代码来源:npctalk_funcs.cpp

示例2: follow

void talk_function::follow( npc &p )
{
    g->add_npc_follower( p.getID() );
    p.set_attitude( NPCATT_FOLLOW );
    g->u.cash += p.cash;
    p.cash = 0;
}
开发者ID:ianestrachan,项目名称:Cataclysm-DDA,代码行数:7,代码来源:npctalk_funcs.cpp

示例3: npc_die

void talk_function::npc_die( npc &p )
{
    p.die( nullptr );
    const std::shared_ptr<npc> guy = overmap_buffer.find_npc( p.getID() );
    if( guy && !guy->is_dead() ) {
        guy->marked_for_death = true;
    }
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:8,代码来源:npctalk_funcs.cpp

示例4: 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

示例5: assign_seat

bool vehicle::assign_seat( vehicle_part &pt, const npc &who )
{
    if( !pt.is_seat() || !pt.set_crew( who ) ) {
        return false;
    }

    // NPC's can only be assigned to one seat in the vehicle
    for( auto &e : parts ) {
        if( &e == &pt ) {
            continue; // skip this part
        }

        if( e.is_seat() ) {
            const npc *n = e.crew();
            if( n && n->getID() == who.getID() ) {
                e.unset_crew();
            }
        }
    }

    return true;
}
开发者ID:OzoneH3,项目名称:Cataclysm-DDA,代码行数:22,代码来源:vehicle_part.cpp

示例6: 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

示例7: leave

void talk_function::leave( npc &p )
{
    add_msg( _( "%s leaves." ), p.name );
    g->remove_npc_follower( p.getID() );
    p.set_attitude( NPCATT_NULL );
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:6,代码来源:npctalk_funcs.cpp


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