示例#1
0
VOID CObject_PlayerOther::UpdateCharRace(VOID)
{
	m_pCharRace = NULL;

	CCharacterData *pCharacterData = GetCharacterData();
	if(pCharacterData != NULL && pCharacterData->Get_RaceID() != INVALID_ID)
	{
		DBC_DEFINEHANDLE(s_pCharacterRace, DBC_CHARACTER_RACE);
		m_pCharRace = (const _DBC_CHAR_RACE*)(s_pCharacterRace->Search_Index_EQU(pCharacterData->Get_RaceID()));
	}
}
	//一键换装:得到装备套装的名字
	INT QuickChange::Lua_GetSuitName( LuaPlus::LuaState* state )
	{
		LuaStack args(state);
		if( !(args[2].IsInteger()) )return 0;

		INT suitId = args[2].GetInteger();

		// 读取装备guid
		CCharacterData* pData = ((CObject_Character*)CObjectManager::GetMe()->GetMySelf())->GetCharacterData();
		_SUIT_SETTING aSuit = pData->Get_EquipSuit(suitId);

		state->PushString( aSuit.m_SuitName );

		return 1;


	}
	// 一键换装:保存装备
	INT QuickChange::Lua_SaveSuit( LuaPlus::LuaState* state )
	{
		LuaStack args(state);
		if( !args[ 2 ].IsInteger() ) return 0;
		if( !args[ 3 ].IsInteger() ) return 0;

		int isSend = args[ 2 ].GetInteger(); // 是否发送
		int suitId = args[ 3 ].GetInteger(); // 套装id

		// 填充需要保存的装备guid
		if( isSend == 0 )
		{
			int idx = args[ 4 ].GetInteger();			// 一套中的装备点

			// server guid
			int world = args[ 5 ].GetInteger();			
			int server = args[ 6 ].GetInteger();		
			int serial = args[ 7 ].GetInteger();	

			int index = args[ 8 ].GetInteger();		// 一套中的套装索引

			// 读取装备guid
			CCharacterData* pData = ((CObject_Character*)CObjectManager::GetMe()->GetMySelf())->GetCharacterData();
			if( index == 0 )
			{
				_SUIT_SETTING aSuit;
				pData->Set_EquipSuit(suitId, aSuit);
			}

			_SUIT_SETTING aSuit = pData->Get_EquipSuit(suitId);
			if( world == -1 )
			{
				return 0;
			}

			// 设置装备guid
			_ITEM_GUID item_guid;
			item_guid.m_World = (BYTE)world;
			item_guid.m_Server = (BYTE)server;
			item_guid.m_Serial = (INT)serial;
			aSuit.m_EquipData[idx] = item_guid;
			pData->Set_EquipSuit(suitId, aSuit);
		}
		// 发送保存装备消息
		else if( isSend == 1 )
		{
			char* name = (char*)args[ 4 ].GetString();	// 套装名字
			CCharacterData* pData = ((CObject_Character*)CObjectManager::GetMe()->GetMySelf())->GetCharacterData();
			_SUIT_SETTING aSuit = pData->Get_EquipSuit(suitId);
			sprintf( aSuit.m_SuitName, name, sizeof(CHAR)*MAX_SUIT_NAME_SIZE );
			pData->Set_EquipSuit(suitId, aSuit);

			CGameInterface::GetMe()->PacketItem_SaveSuit(suitId);
		}

		return 0;
	}
	INT	SuperTooltips::GetItemDesc(LuaPlus::LuaState* state)
	{
		// 不利用保存的指针。要重新得到指针。 
		m_pActionItem = (CActionItem*)CActionSystem::GetMe()->GetAction(m_nActionId);

		if(!m_pActionItem)
		{
			state->PushString("");
			return 1;
		}

		STRING type( m_pActionItem->GetType_String() );
		if( type == "changesuit" )
		{
			CCharacterData* pData = ((CObject_Character*)CObjectManager::GetMe()->GetMySelf())->GetCharacterData();
			INT id = pData->Get_EquipSuitId();

			_SUIT_SETTING aSuit = pData->Get_EquipSuit( id );
			STRING name(aSuit.m_SuitName);
			if( !name.empty() )
			{
				CHAR szTemp[100];	
				_snprintf(szTemp, 10, "%s套装", name.c_str());
				state->PushString(szTemp);

			}
			else
			{
				CHAR szTemp[100];	
				_snprintf(szTemp, 10, "这是自定义的第%d套套装", id);
				state->PushString(szTemp);
			}

			return 1;
		}

		//得到详细说明.
		state->PushString(m_pActionItem->GetDesc());
		return 1;
	}
VOID CGameInterface::PacketItem_UserEquip( INT nIndex )
{
	tObject_Item* pItem = CDataPool::GetMe()->UserBag_GetItem( nIndex );
	if(pItem == NULL ) return;

	//摆摊时不可以随便换装
	if(TRUE == CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_IsInStall())
	{
		CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE,"你正在摆摊……");
		return;
	}

	int iNeedLevel   = 0;
	int iPlayerLevel = 0;
	int iNeedJob = -1;

	//验证是否可以使用
	if(!pItem->Rule(tObject_Item::RULE_USE))
	{
		CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, pItem->RuleFailMessage(tObject_Item::RULE_USE).c_str());
		return;
	}

	CCharacterData* pCharData = CObjectManager::GetMe()->GetMySelf()->GetCharacterData();
	iNeedJob = pItem->GetNeedJob();
	if( pCharData )
	{
		if( iNeedJob != -1 && iNeedJob != pCharData->Get_MenPai() )
		{
			CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, "此物品无法装备");
			return;
		}
	}


	//判断等级
	iNeedLevel = pItem->GetNeedLevel();
	if(pCharData)
	{
		iPlayerLevel = pCharData->Get_Level();
	}

	if(iPlayerLevel < iNeedLevel)
	{
		CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, "等级不够");
		return;
	}

	//是否鉴定
	if(((CObject_Item_Equip*)pItem)->GetEquipQuantity() == CObject_Item_Equip::BLUE_EQUIP &&
		((CObject_Item_Equip*)pItem)->GetEquipAttrib() == CObject_Item_Equip::EQUIP_ATTRIB_UNIDENTIFY)
	{
		CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, "此物品需要鉴定");
		return;
	}

	//取得详细信息
	LPCTSTR szExtraInfo = ((tObject_Item*)pItem)->GetExtraDesc();

	//如果没有详细信息,从服务器上请求详细信息
	if(!szExtraInfo)
	{
		CDataPool::GetMe()->UserBag_AskExtraInfo( nIndex );
	}

	CGUseEquip msg;
	msg.setBagIndex( nIndex );
	CNetManager::GetMe()->SendPacket( &msg );
}
示例#6
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 );
}
示例#7
0
RC_RESULT CObject_PlayerOther::OnCommand(const SCommand_Object *pCmd )
{
	RC_RESULT rcResult = RC_SKIP;

	switch ( pCmd->m_wID )
	{
	case OC_UPDATE_EQUIPMENT:
		{
			UINT	dwModifyFlags	= pCmd->m_adwParam[0];
			UINT	*pData			= (UINT*)(pCmd->m_apParam[1]);
			UINT	i, dwIndex;
			dwIndex = 0;
			for ( i = 0; i < HEQUIP_NUMBER; i++ )
			{
				if ( dwModifyFlags & (1<<i) )
				{
					GetCharacterData()->Set_Equip((HUMAN_EQUIP)i, pData[dwIndex]);
					dwIndex++;
				}
			}
			rcResult = RC_OK;
		}
		break;
	case OC_UPDATE_TEAM_FLAG:
		{
			if(this != CObjectManager::GetMe()->GetMySelf())
			{
				CCharacterData* pData = GetCharacterData();
				pData->Set_HaveTeamFlag( pCmd->m_abParam[0] );
				pData->Set_TeamLeaderFlag( pCmd->m_abParam[1] );
				pData->Set_TeamFullFlag( pCmd->m_abParam[2] );
			}
			rcResult = RC_OK;
		}
		break;
	case OC_TEAM_FOLLOW_MEMBER:
		{
			CCharacterData* pData = GetCharacterData();

			pData->Set_TeamFollowListCount( pCmd->m_adwParam[0] );

			for( INT i=0; i<(INT)(pCmd->m_adwParam[0]); ++i )
			{
				pData->Set_TeamFollowedMember(i, pCmd->m_adwParam[i+1]);
			}

			rcResult = RC_OK;
		}
		break;
	case OC_UPDATE_TEAM_FOLLOW_FLAG:
		{
			CCharacterData* pData = GetCharacterData();

			pData->Set_TeamFollowFlag( pCmd->m_abParam[0] );
			CharacterLogic_GetAI()->OnAIStopped();

			rcResult = RC_OK;
		}
		break;
	default:
		return CObject_PlayerNPC::OnCommand(pCmd);
	}

	return rcResult;
}
示例#8
0
VOID CObject_PlayerOther::UpdateEquip(HUMAN_EQUIP point)
{
	CCharacterData *pCharacterData = GetCharacterData();
	if(pCharacterData == NULL)
	{
		return ;
	}

	if(point == HEQUIP_WEAPON && IsHideWeapon())
	{
		return ;
	}

	if(!GetFakeObjectFlag())
	{
		if(pCharacterData->Get_ModelID() != INVALID_ID)
		{
			return ;
		}
	}

	//生成一个临时的Item对象
	CObject_Item_Equip *pTempEquip = NULL;
	INT nID = pCharacterData->Get_Equip(point);
	if(nID != INVALID_ID)
	{
		pTempEquip = (CObject_Item_Equip *)CObject_Item::NewItem(nID);
	}

	//如果是装备根据装配点装备物品
	if(pTempEquip != NULL && ICLASS_EQUIP == pTempEquip->GetItemClass())
	{
		switch(pTempEquip->GetItemType())
		{
		case HEQUIP_WEAPON:				//武器,挂接类装备
			{
				EquipItem_BodyLocator(pTempEquip->GetItemType(), pTempEquip->GetVisualID());
				SetWeaponType( pTempEquip->GetWeaponType() );
			}
			break;
		case HEQUIP_CAP:				//帽子, 身体, 手臂, 鞋, 装备类物品
		case HEQUIP_ARMOR:				
		case HEQUIP_CUFF:				
		case HEQUIP_BOOT:	
			{
				EquipItem_BodyPart(pTempEquip->GetItemType(), pTempEquip->GetVisualID());
			}
			break;
		case HEQUIP_SASH:				//腰带, 戒子, 项链
		case HEQUIP_RING:				
		case HEQUIP_NECKLACE:		
		default:
			break;
		}
	}
	else
	{
		//卸载装备
		UnEquipItem(point);
	}

	//如果是UI物体,重新设置VisibleFlag
	if(GetFakeObjectFlag())
	{
		m_pRenderInterface->Actor_SetUIVisibleFlag();
	}

	CObject_Item::DestroyItem(pTempEquip);
}
	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;
		}