本文整理汇总了C++中npc::set_companion_mission方法的典型用法代码示例。如果您正苦于以下问题:C++ npc::set_companion_mission方法的具体用法?C++ npc::set_companion_mission怎么用?C++ npc::set_companion_mission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类npc
的用法示例。
在下文中一共展示了npc::set_companion_mission方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: goto_location
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;
}