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


C++ NPC::send_event方法代码示例

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


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

示例1: doubleclick

    void doubleclick( Network::Client *client, PKTIN_06 *msg )
	{
	  u32 serial = cfBEu32( msg->serial );
	  u32 paperdoll_macro_flag = serial & 0x80000000Lu;
	  serial &= ~0x80000000Lu; // keypress versus doubleclick switch?

	  // the find_character would find this, but most of the time it's your own paperdoll.
	  // this is special-cased for two reasons: 
	  //	  1) it's commonly done
	  //	  2) ghosts can doubleclick ONLY their paperdoll.
	  if ( serial == client->chr->serial )
	  {
		if ( !paperdoll_macro_flag )
		{
		  ScriptDef sd;
		  sd.quickconfig( "scripts/misc/dblclickself.ecl" );
		  if ( sd.exists() )
		  {
			ref_ptr<Bscript::EScriptProgram> prog;
			prog = find_script2( sd, false, Plib::systemstate.config.cache_interactive_scripts );
			if ( prog.get() != NULL && client->chr->start_script( prog.get(), false ) )
			{
			  return;
			}
		  }
		}
		send_paperdoll( client, client->chr );
		return;
	  }

	  if ( client->chr->dblclick_wait > read_gameclock() )
	  {
		private_say_above( client->chr, client->chr, "You must wait to use something again." );
		return;
	  }
	  else
		client->chr->dblclick_wait = read_gameclock() + settingsManager.ssopt.dblclick_wait;

	  if ( IsCharacter( serial ) )
	  {
		if ( client->chr->dead() )
		  return;
		Mobile::Character *chr = find_character( serial );
		if ( !chr )
		  return;

		if ( chr->isa( UObject::CLASS_NPC ) )
		{
		  NPC* npc = static_cast<NPC*>( chr );
		  if ( npc->can_accept_event( EVID_DOUBLECLICKED ) )
		  {
			npc->send_event( new Module::SourcedEvent( EVID_DOUBLECLICKED, client->chr ) );
			return;
		  }
		}

		bool script_ran = false;
		ScriptDef sd;
		sd.quickconfig( "scripts/misc/dblclickother.ecl" );
		if ( sd.exists() )
		{
		  ref_ptr<Bscript::EScriptProgram> prog;
		  prog = find_script2( sd, false, Plib::systemstate.config.cache_interactive_scripts );
		  if ( prog.get() != NULL )
			script_ran = client->chr->start_script( prog.get(), false, new Module::ECharacterRefObjImp( chr ) );
		}
		if ( !script_ran && inrange( client->chr, chr ) )
		{
		  // MuadDib Changed from a large if || || || to switch case. 1/4/2007
		  switch ( chr->graphic )
		  {
			case UOBJ_HUMAN_MALE:
			case UOBJ_HUMAN_FEMALE:
			case UOBJ_HUMAN_MALE_GHOST:
			case UOBJ_HUMAN_FEMALE_GHOST:
			case UOBJ_ELF_MALE:
			case UOBJ_ELF_FEMALE:
			case UOBJ_ELF_MALE_GHOST:
			case UOBJ_ELF_FEMALE_GHOST:
			case UOBJ_GARGOYLE_MALE:
			case UOBJ_GARGOYLE_FEMALE:
			case UOBJ_GARGOYLE_MALE_GHOST:
			case UOBJ_GARGOYLE_FEMALE_GHOST:
			case UOBJ_GAMEMASTER:
			case 0x3de:
			case 0x3df:
			case 0x3e2:
			  send_paperdoll( client, chr );
			  break;
		  }
		}
		return;
	  }
	  else // doubleclicked an item
	  {
		// next, search worn items, items in the backpack, and items in the world.
		Items::Item *item = find_legal_item( client->chr, serial );

		// next, check people's backpacks. (don't recurse down)
		//	  (not done yet)
//.........这里部分代码省略.........
开发者ID:byterj,项目名称:POL_099b,代码行数:101,代码来源:dblclick.cpp


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