Exemplo n.º 1
0
VOID CTeamOrGroup::FillMyInfo(TeamMemberInfo* member)
{
	Assert( member );

	CObject_PlayerMySelf* pMe = CObjectManager::GetMe()->GetMySelf();

	Assert( member->m_GUID == pMe->GetServerGUID() );

	CCharacterData* pMyData = pMe->GetCharacterData();

	if(NULL == pMyData)
	{
		return ;
	}
	strncpy(member->m_szNick, pMyData->Get_Name(), MAX_CHARACTER_NAME-1);
	std::string utfstr;
	StringConvert::mbcs_to_utf8(member->m_szNick,utfstr);
	strncpy(member->m_szUtf8Nick,utfstr.c_str(),MAX_CHARACTER_NAME*2-1);
	member->m_szNick[MAX_CHARACTER_NAME-1] = '\0';
	member->m_szUtf8Nick[MAX_CHARACTER_NAME*2-1];

	member->m_uFamily		= pMyData->Get_MenPai();
	member->m_uDataID		= pMyData->Get_RaceID();
	member->m_uLevel		= pMyData->Get_Level();
	member->m_nPortrait		= pMyData->Get_PortraitID();	// 头像
	member->m_WorldPos.m_fX = pMe->GetPosition().x;
	member->m_WorldPos.m_fZ = pMe->GetPosition().z;
	member->m_nHP			= pMyData->Get_HP();
	member->m_dwMaxHP		= pMyData->Get_MaxHP();
	member->m_nMP			= pMyData->Get_MP();
	member->m_dwMaxMP		= pMyData->Get_MaxMP();
	member->m_nAnger		= pMyData->Get_Rage();		// 怒气

	member->m_WeaponID		= pMyData->Get_Equip(HEQUIP_MAINHAND);
	member->m_AssiID		= pMyData->Get_Equip(HEQUIP_ASSIHAND);
	member->m_CapID			= pMyData->Get_Equip(HEQUIP_HEAD);
	member->m_ArmourID		= pMyData->Get_Equip(HEQUIP_BACK);
	member->m_ShoulderID	= pMyData->Get_Equip(HEQUIP_SHOULDER);
	member->m_CuffID		= pMyData->Get_Equip(HEQUIP_WRIST);
	member->m_FootID		= pMyData->Get_Equip(HEQUIP_FEET);

	member->m_uFaceMeshID = pMyData->Get_FaceMesh();
	member->m_uHairMeshID = pMyData->Get_HairMesh();
	member->m_uHairColor  = pMyData->Get_HairColor();

	member->m_bDead			= ( pMe->CharacterLogic_Get( CObject_Character::LOGIC_BASE ) == CObject_Character::CHARACTER_LOGIC_DEAD );
}
	INT		PlayerMySelf::GetData( LuaPlus::LuaState* state )
	{
		LuaPlus::LuaStack args(state);
		if( !args[ 2 ].IsString() ) return 0;

		CCharacterData* pCharData = CObjectManager::GetMe()->GetMySelf()->GetCharacterData();

		std::string  str = args[ 2 ].GetString();
		if( str == "LEVEL" )	//等级
		{
			state->PushInteger(pCharData->Get_Level());
			return 1;
		}
		else if( str == "HP" )					//生命值
		{
			state->PushInteger(pCharData->Get_HP());
			return 1;
		}
		else if( str == "MP" )//魔法值
		{
			state->PushInteger(pCharData->Get_MP());
			return 1;
		}
		else if( str == "EXP" )					//经验
		{
			if(pCharData->Get_Exp() < 0)
			{
				state->PushInteger(0);
			}
			else
			{
				state->PushInteger(pCharData->Get_Exp());
			}
			return 1;
		}
		else if( str == "NEEDEXP" )				//升级经验
		{
			state->PushInteger(pCharData->Get_MaxExp());
			return 1;
		}
		else if( str == "STRIKEPOINT" )				//连击点
		{
			state->PushInteger(pCharData->Get_StrikePoint());
			return 1;
		}
		else if( str == "MONEY" )				//货币
		{
			state->PushInteger(pCharData->Get_Money());

			//同时输出转换为金、银、铜币的数值
			INT nMoney = pCharData->Get_Money();

			INT nGoldCoin;	
			INT nSilverCoin;
			INT nCopperCoin;

			nCopperCoin = nMoney % 100;

			if( nMoney >= 100 )
			{
				nSilverCoin = ((nMoney-nCopperCoin)/100) % 100;
			}
			else
			{
				nSilverCoin = 0;
			}

			if ( nMoney >= 10000 )
			{
				nGoldCoin = (((nMoney-nCopperCoin)/100)-nSilverCoin)/100;
			}
			else
				nGoldCoin = 0;

			state->PushInteger(nGoldCoin);
			state->PushInteger(nSilverCoin);
			state->PushInteger(nCopperCoin);
			return 4;
		}
		else if( str == "RMB" )			//人物元宝数量
		{
			state->PushInteger(pCharData->Get_RMB());
			return 1;
		}
		else if( str == "STR" )					//力量 力量
		{
			state->PushInteger(pCharData->Get_STR());
			return 1;
		}
		else if( str == "SPR" )					//灵气 灵力
		{
			state->PushInteger(pCharData->Get_SPR());
			return 1;
		}
		else if( str == "CON" )					//体制 体制
		{
			state->PushInteger(pCharData->Get_CON());
			return 1;
		}
		else if( str == "INT" )					//定力 智力
		{
			state->PushInteger(pCharData->Get_INT());
			return 1;
		}								   
		else if( str == "DEX" )					//身法 敏捷
		{
			state->PushInteger(pCharData->Get_DEX());
			return 1;
		}								   
		else if( str == "POINT_REMAIN" )			//剩余点数
		{
			state->PushInteger(pCharData->Get_PointRemain());
			return 1;
		}								   
		else if( str == "ATT_PHYSICS" )			//物理攻击力
		{
			state->PushInteger(pCharData->Get_AttPhysics());
			return 1;
		}								   
		else if( str == "DEF_PHYSICS" )			//物理防御力
		{
			state->PushInteger(pCharData->Get_DefPhysics());
			return 1;
		}
		else if( str == "ATT_MAGIC" )			//魔法攻击力
		{
			state->PushInteger(pCharData->Get_AttMagic());
			return 1;
		}								   
		else if( str == "DEF_MAGIC" )			//魔法防御力
		{
			state->PushInteger(pCharData->Get_DefMagic());
			return 1;
		}								   
		else if( str == "MAXHP" )				//最大生命值
		{
			state->PushInteger(pCharData->Get_MaxHP());
			return 1;
		}								   
		else if( str == "MAXMP" )				//最大魔法值
		{			
			state->PushInteger(pCharData->Get_MaxMP());
			return 1;
		}								   
		else if( str == "RAGE" )				//怒气
		{			
			state->PushInteger(pCharData->Get_Rage());
			return 1;
		}								   
		else if( str == "MAXRAGE" )				//最大怒气
		{			
			state->PushInteger(BASE_MAX_RAGE);
			return 1;
		}								   
		else if( str == "HP_RESPEED" )			//HP恢复速度  点/秒
		{			
			state->PushInteger(pCharData->Get_HPRespeed());
			return 1;
		}								   
		else if( str == "MP_RESPEED" )			//MP恢复速度  点/秒
		{
			state->PushInteger(pCharData->Get_MPRespeed());
			return 1;
		}								   
		else if( str == "HIT" )					//命中率
		{
			state->PushInteger(pCharData->Get_Hit());
			return 1;
		}								   
		else if( str == "MISS" )					//闪避率
		{
			state->PushInteger(pCharData->Get_Miss());
			return 1;
		}								   
		else if( str == "CRITRATE" )				//会心率
		{
			state->PushInteger(pCharData->Get_CritRate());
			return 1;								   
		}								   
		else if( str == "MOVESPEED" )			//移动速度
		{
			state->PushNumber(pCharData->Get_MoveSpeed());
			return 1;								   
		}								   
		else if( str == "ATTACKSPEED" )			//攻击速度
		{
			state->PushInteger(pCharData->Get_AttackSpeed());
			return 1;
		}
		else if( str == "ATTACKCOLD" )			//冰攻击
		{
			state->PushInteger(pCharData->Get_AttCold());
			return 1;								   
		}								   
		else if( str == "DEFENCECOLD" )			//冰防御
		{
			state->PushInteger(pCharData->Get_DefCold());
			return 1;								   
		}								   
		else if( str == "ATTACKFIRE" )			//火攻击
		{
			state->PushInteger(pCharData->Get_AttFire());
			return 1;								   
		}								   
		else if( str == "DEFENCEFIRE" )			//火防御
		{
			state->PushInteger(pCharData->Get_DefFire());
			return 1;								   
		}								   
		else if( str == "ATTACKLIGHT" )			//电攻击
		{
			state->PushInteger(pCharData->Get_AttLight());
			return 1;								   
		}								   
		else if( str == "DEFENCELIGHT" )			//电防御
		{
			state->PushInteger(pCharData->Get_DefLight());
			return 1;								   
		}								   
		else if( str == "ATTACKPOISON" )			//毒攻击
		{
			state->PushInteger(pCharData->Get_AttPosion());
			return 1;								   
		}								   
		else if( str == "DEFENCEPOISON" )		//毒防御
		{
			state->PushInteger(pCharData->Get_DefPosion());
			return 1;								   
		}								   
		else if( str == "MEMPAI" )				//门派
		{
			state->PushInteger(pCharData->Get_MenPai());
			return 1;								   
		}								   
		else if( str == "CAMP" )					//阵营  fujia 2007.12.14
		{
			state->PushInteger(pCharData->Get_CampData()->m_nCampID);
			return 1;
		}
		//else if( str == "VIGOR")
		//{
		//	state->PushInteger(pCharData->Get_Vigor());
		//	return 1;
		//}
		//else if( str == "MAXVIGOR")	
		//{
		//	state->PushInteger(pCharData->Get_MaxVigor());
		//	return 1;
		//}
		else if( str == "GUILD")
		{
			state->PushInteger(pCharData->Get_Guild());
		}
		//else if( str == "ENERGY")
		//{
		//	state->PushInteger(pCharData->Get_Energy());
		//	return 1;
		//}
		//else if( str == "MAXENERGY")
		//{
		//	state->PushInteger(pCharData->Get_MaxEnergy());
		//	return 1;
		//}
		else if( str == "PORTRAIT" )			//人物头像
		{
			
			// 得到玩家和自己的头像信息
			LPCSTR pImageName = NULL;
			DBC_DEFINEHANDLE(s_pFaceImageDBC, DBC_CHARACTER_FACE)
			//打开生物定义表
			const _DBC_CHAR_FACE* pFaceImage = NULL;
			pFaceImage = (const _DBC_CHAR_FACE*)(s_pFaceImageDBC->Search_Index_EQU(pCharData->Get_PortraitID()));
				
			if(pFaceImage)
			{
				pImageName = pFaceImage->pImageSetName;
			}
			//else // 默认状态不显示头像图标, 头像图标显示空
			//{
			//	pFaceImage = (const _DBC_CHAR_FACE*)(s_pFaceImageDBC->Search_LineNum_EQU(0));
			//	pImageName = pFaceImage->pImageSetName;
			//}//
					
			if(pImageName)
			{
				state->PushString(pImageName);
			}
			else
			{
				state->PushString(_T(""));
			}

			return 1;
		}