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


C++ CreatureObject::getPvPStatus方法代码示例

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


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

示例1: _verifyCombatState

bool CombatManager::_verifyCombatState(CreatureObject* attacker, uint64 defenderId)
{
	PlayerObject* playerAttacker = dynamic_cast<PlayerObject*>(attacker);
	CreatureObject* defender = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(defenderId));

	if (!defender)
	{
		// No such object.
		return(false);
	}

	// Do not try to attack already incapped or dead objects.
	if (defender->isIncapacitated() || defender->isDead())
	{
		return false;
	}

	//Do not attack if we are incapped or already dead or mounted.
	if (attacker->isIncapacitated() || attacker->isDead() || playerAttacker->checkIfMounted())
	{
		return false;
	}

	// make sure we got both objects
	if (playerAttacker && defender)
	{
		//Do not attack if we are mounted
		if(playerAttacker->checkIfMounted())
		{
			return false;
		}

		// if our target is a player, he must be dueling us or both need to be overt(TODO)
		if (PlayerObject* defenderPlayer = dynamic_cast<PlayerObject*>(defender))
		{
			// also return, if our target is incapacitated or dead
			if(!playerAttacker->checkDuelList(defenderPlayer) || !defenderPlayer->checkDuelList(playerAttacker)
			|| defenderPlayer == playerAttacker)
			{
				return(false);
			}

			if(defenderPlayer->isIncapacitated())
			{
				// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_incap");
				return(false);
			}
			else if(defenderPlayer->isDead())
			{
				// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_dead");
				return(false);
			}

			// put us in combat state	
			gStateManager.setCurrentActionState(attacker, CreatureState_Combat);
            gStateManager.setCurrentActionState(attacker, CreatureState_CombatAttitudeNormal);
			// put our target in combat state
			if(!defenderPlayer->states.checkState(CreatureState_Combat))
			{

				gStateManager.setCurrentActionState(defender, CreatureState_Combat);
                gStateManager.setCurrentActionState(defender, CreatureState_CombatAttitudeNormal);
			}

			// update our defender list
			if (!playerAttacker->checkDefenderList(defenderPlayer->getId()))
			{
				playerAttacker->AddDefender(defenderPlayer->getId());
			}

			// update our targets defender list
			if (!defenderPlayer->checkDefenderList(playerAttacker->getId()))
			{
				playerAttacker->AddDefender(defenderPlayer->getId());
			}

			if (!defenderPlayer->autoAttackEnabled())
			{
				// Player can/may start auto-attack if idle.
				defenderPlayer->getController()->enqueueAutoAttack(playerAttacker->getId());
			}

		}
		else
		{
			// our target is a creature
			if (defender->isIncapacitated())
			{
				// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_incap");
				return(false);
			}
			else if (defender->isDead())
			{
				// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_dead");
				return(false);
			}

			// Vefify that out target is attackable. It's not nice to spam attacks at innocent npc's.
			if (!(defender->getPvPStatus() & CreaturePvPStatus_Attackable))
			{
//.........这里部分代码省略.........
开发者ID:behaart,项目名称:mmoserver,代码行数:101,代码来源:CombatManager.cpp

示例2: _verifyCombatState

bool NpcManager::_verifyCombatState(CreatureObject* attacker, uint64 defenderId)
{
	if (!attacker || !defenderId)
	{
		return false;
	}

	CreatureObject* defender = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(defenderId));
	if (!defender)
	{
		return false;
	}

	// If the target (defender) do have me in his defender list, we should not bother.
	/*
	if (defender->checkDefenderList(attacker->getId()))
	{
		return true;
	}
	*/

	PlayerObject* playerAttacker = dynamic_cast<PlayerObject*>(attacker);

	// make sure we got both objects
	if (playerAttacker && defender)
	{
		// if our target is a player, he must be dueling us or both need to be overt(TODO)
		if (PlayerObject* defenderPlayer = dynamic_cast<PlayerObject*>(defender))
		{
			// also return, if our target is incapacitated or dead
			if(!playerAttacker->checkDuelList(defenderPlayer) || !defenderPlayer->checkDuelList(playerAttacker)
			|| defenderPlayer == playerAttacker)
			{
				return(false);
			}

			if(defenderPlayer->GetCreature()->isIncapacitated())
			{
				// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_incap");
				return(false);
			}
			else if(defenderPlayer->GetCreature()->isDead())
			{
				// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_dead");
				return(false);
			}

			// put us in combat state
			if(!playerAttacker->GetCreature()->states.checkState(CreatureState_Combat))
			{
                gStateManager.setCurrentActionState(playerAttacker->GetCreature(),CreatureState_Combat);
                gStateManager.setCurrentActionState(playerAttacker->GetCreature(),CreatureState_CombatAttitudeNormal);
			}

			// put our target in combat state
			if(!defenderPlayer->GetCreature()->states.checkState(CreatureState_Combat))
			{
				gStateManager.setCurrentActionState(defenderPlayer->GetCreature(),CreatureState_Combat);
                gStateManager.setCurrentActionState(defenderPlayer->GetCreature(),CreatureState_CombatAttitudeNormal);
			}

			// update our defender list
			if (!playerAttacker->GetCreature()->checkDefenderList(defenderPlayer->getId())) // or if (!playerAttacker->checkDefenderList(defenderId)
			{
				playerAttacker->GetCreature()->AddDefender(defenderPlayer->getId());
			}

			// update our targets defender list
			if (!defenderPlayer->GetCreature()->checkDefenderList(playerAttacker->getId()))
			{
				playerAttacker->GetCreature()->AddDefender(defenderPlayer->getId());
			}
		}
		else
		{
			// our target is a creature
			if (defender->isIncapacitated())
			{
				// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_incap");
				return(false);
			}
			else if (defender->isDead())
			{
				// gMessageLib->sendSystemMessage(playerAttacker,L"","base_player","prose_target_dead");
				return(false);
			}

			// Vefify that our target is attackable. It's not nice to spam attacks at innocent npc's.
			if (!(defender->getPvPStatus() & CreaturePvPStatus_Attackable))
			{
				return(false);
			}

			// put us in combat state
			if (!playerAttacker->GetCreature()->states.checkState(CreatureState_Combat))
			{
				gStateManager.setCurrentActionState(playerAttacker->GetCreature(),CreatureState_Combat);
                gStateManager.setCurrentActionState(playerAttacker->GetCreature(),CreatureState_CombatAttitudeNormal);
			}

//.........这里部分代码省略.........
开发者ID:ELMERzark,项目名称:mmoserver,代码行数:101,代码来源:NpcManager.cpp


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