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


C++ player::add_msg_player_or_npc方法代码示例

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


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

示例1: put_into_vehicle

void put_into_vehicle( player &p, const std::list<item> &items, vehicle &veh, int part )
{
    if( items.empty() ) {
        return;
    }

    const tripoint where = veh.global_part_pos3( part );
    const std::string ter_name = g->m.name( where );
    int fallen_count = 0;

    for( auto it : items ) { // cant use constant reference here because of the spill_contents()
        if( it.is_bucket_nonempty() && !it.spill_contents( p ) ) {
            p.add_msg_player_or_npc(
                _( "To avoid spilling its contents, you set your %1$s on the %2$s." ),
                _( "To avoid spilling its contents, <npcname> sets their %1$s on the %2$s." ),
                it.display_name().c_str(), ter_name.c_str()
            );
            g->m.add_item_or_charges( where, it );
            continue;
        }
        if( !veh.add_item( part, it ) ) {
            if( it.count_by_charges() ) {
                // Maybe we can add a few charges in the trunk and the rest on the ground.
                it.mod_charges( -veh.add_charges( part, it ) );
            }
            g->m.add_item_or_charges( where, it );
            ++fallen_count;
        }
    }

    const std::string part_name = veh.part_info( part ).name();

    if( same_type( items ) ) {
        const item &it = items.front();
        const int dropcount = items.size() * ( it.count_by_charges() ? it.charges : 1 );

        p.add_msg_player_or_npc(
            ngettext( "You put your %1$s in the %2$s's %3$s.",
                      "You put your %1$s in the %2$s's %3$s.", dropcount ),
            ngettext( "<npcname> puts their %1$s in the %2$s's %3$s.",
                      "<npcname> puts their %1$s in the %2$s's %3$s.", dropcount ),
            it.tname( dropcount ).c_str(), veh.name.c_str(), part_name.c_str()
        );
    } else {
        p.add_msg_player_or_npc(
            _( "You put several items in the %1$s's %2$s." ),
            _( "<npcname> puts several items in the %1$s's %2$s." ),
            veh.name.c_str(), part_name.c_str()
        );
    }

    if( fallen_count > 0 ) {
        add_msg( m_warning, _( "The trunk is full, so some items fell to the %s." ), ter_name.c_str() );
    }
}
开发者ID:ProfoundDarkness,项目名称:Cataclysm-DDA,代码行数:55,代码来源:activity_item_handling.cpp

示例2: drop_on_map

void drop_on_map( const player &p, const std::list<item> &items, const tripoint &where )
{
    if( items.empty() ) {
        return;
    }
    const std::string ter_name = g->m.name( where );
    const bool can_move_there = g->m.passable( where );

    if( same_type( items ) ) {
        const item &it = items.front();
        const int dropcount = items.size() * ( it.count_by_charges() ? it.charges : 1 );
        const std::string it_name = it.tname( dropcount );

        if( can_move_there ) {
            p.add_msg_player_or_npc(
                ngettext( "You drop your %1$s on the %2$s.",
                          "You drop your %1$s on the %2$s.", dropcount ),
                ngettext( "<npcname> drops their %1$s on the %2$s.",
                          "<npcname> drops their %1$s on the %2$s.", dropcount ),
                it_name.c_str(), ter_name.c_str()
            );
        } else {
            p.add_msg_player_or_npc(
                ngettext( "You put your %1$s in the %2$s.",
                          "You put your %1$s in the %2$s.", dropcount ),
                ngettext( "<npcname> puts their %1$s in the %2$s.",
                          "<npcname> puts their %1$s in the %2$s.", dropcount ),
                it_name.c_str(), ter_name.c_str()
            );
        }
    } else {
        if( can_move_there ) {
            p.add_msg_player_or_npc(
                _( "You drop several items on the %s." ),
                _( "<npcname> drops several items on the %s." ),
                ter_name.c_str()
            );
        } else {
            p.add_msg_player_or_npc(
                _( "You put several items in the %s." ),
                _( "<npcname> puts several items in the %s." ),
                ter_name.c_str()
            );
        }
    }
    for( const auto &it : items ) {
        g->m.add_item_or_charges( where, it );
    }
}
开发者ID:ProfoundDarkness,项目名称:Cataclysm-DDA,代码行数:49,代码来源:activity_item_handling.cpp


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