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


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

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


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

示例1: handleAttack

bool CombatManager::handleAttack(CreatureObject* attacker, uint64 targetId, ObjectControllerCmdProperties *cmdProperties)
{
    CreatureObject* defender = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(targetId));

    // get the current weapon
	//what if he/she/it is left handed ? what if he she it has multiple appendages with weapons ?
	Weapon* weapon = dynamic_cast<Weapon*>(gWorldManager->getObjectById(attacker->GetWeaponId()));
	
	//auto weapon = dynamic_cast<Weapon*>(gWorldManager->getKernel()->GetServiceManager()->GetService<swganh::equipment::EquipmentService>("EquipmentService")->GetEquippedObject(attacker, "hold_r"));
   
    if (!weapon)    {
        return(false);
    }

    if (!defender)    {
        return(false);
    }

    // NOTE: Some weapon data just for tesing and to give the npc a fair chance...
    uint32 weaponGroup = weapon->getGroup();
    float weaponRange = 6.0;

    //if (weaponGroup <= WeaponGroup_Polearm)
    //{
    //	weaponRange = 6.0;
    //}
    // else
    if (weaponGroup == WeaponGroup_Rifle)
    {
        weaponRange = 64.0;
    }
    else if (weaponGroup == WeaponGroup_Pistol)
    {
        weaponRange = 35.0;
    }
    else if (weaponGroup == WeaponGroup_Carbine)
    {
        weaponRange = 50.0;
    }
    //else
    //{
    //	weaponRange = 6.0;
    //}

    // if we are out of range, skip this attack.
    if (glm::distance(attacker->mPosition, defender->mPosition) > weaponRange)
    {
        // Target out of range.
        PlayerObject* playerAttacker = dynamic_cast<PlayerObject*>(attacker);
        if (playerAttacker && playerAttacker->isConnected())
        {
            gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "target_out_of_range"), playerAttacker);
        }
        // It's like you shoot but missed, maintain cooldown.
        // return true;
        return false;
    }

    if(_verifyCombatState(attacker,defender->getId()))
    {

        // Execute the attack
        /*uint8 attackResult = */_executeAttack(attacker,defender,cmdProperties,weapon);

        return(true);
    }

    return(false);
}
开发者ID:behaart,项目名称:mmoserver,代码行数:69,代码来源:CombatManager.cpp

示例2: _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

示例3: sendCreateTangible

//======================================================================================================================
//
// create tangible
//
bool MessageLib::sendCreateTangible(TangibleObject* tangibleObject,PlayerObject* targetObject, bool sendchildren)
{
    if(!_checkPlayer(targetObject))
    {
        gLogger->log(LogManager::DEBUG,"MessageLib::sendCreateTangible No valid player");
        return(false);
    }

    if(ResourceContainer* resContainer = dynamic_cast<ResourceContainer*>(tangibleObject))
    {
        return sendCreateResourceContainer(resContainer,targetObject);
    }
    else if(FactoryCrate* crate = dynamic_cast<FactoryCrate*>(tangibleObject))
    {
        return sendCreateFactoryCrate(crate,targetObject);
    }
    else if(tangibleObject->getTangibleGroup() == TanGroup_Static)
    {
        return sendCreateStaticObject(tangibleObject,targetObject);
    }

    uint64 parentId = tangibleObject->getParentId();

    sendCreateObjectByCRC(tangibleObject,targetObject,false);

    if(parentId != 0)
    {
        // its in a cell, container, inventory
        if(parentId != targetObject->getId())
        {
            // could be inside a crafting tool
            Object* parent = gWorldManager->getObjectById(parentId);
            CreatureObject* parentObject = dynamic_cast<CreatureObject*>(parent);

            if(parent && dynamic_cast<CraftingTool*>(parent))
            {
                sendContainmentMessage(tangibleObject->getId(),parentId,0,targetObject);
            }
            // if equipped, also tie it to the object
            else if(parentObject)
            {
                Item* item = dynamic_cast<Item*>(tangibleObject);
                sendContainmentMessage(tangibleObject->getId(),parentObject->getId(),4,targetObject);
            }
            else
            {
                sendContainmentMessage(tangibleObject->getId(),tangibleObject->getParentId(),0xffffffff,targetObject);
            }
        }
        // or tied directly to an object
        else
        {
            sendContainmentMessage(tangibleObject->getId(),tangibleObject->getParentId(),4,targetObject);
        }
    }
    else
    {
        sendContainmentMessage(tangibleObject->getId(),tangibleObject->getParentId(),0xffffffff,targetObject);
    }

    sendBaselinesTANO_3(tangibleObject,targetObject);
    sendBaselinesTANO_6(tangibleObject,targetObject);

    //now check whether we have children!!!
    ObjectIDList*			ol = tangibleObject->getObjects();
    ObjectIDList::iterator	it = ol->begin();

    while(it != ol->end())
    {
        TangibleObject* tO = dynamic_cast<TangibleObject*>(gWorldManager->getObjectById((*it)));
        if(!tO)
        {
            gLogger->log(LogManager::DEBUG,"MessageLib::sendCreateTangible::Unable to find object with ID %PRIu64", (*it));
            it++;
            continue;
        }

        PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(targetObject->getId()));

        //for children add knownPlayers!!!!
        //tO->addKnownObjectSafe(player);
        //player->addKnownObjectSafe(tO);
        sendCreateObject(tO,player,false);
        it++;
    }

    sendEndBaselines(tangibleObject->getId(),targetObject);

    return(true);
}
开发者ID:jason83,项目名称:mmoserver,代码行数:94,代码来源:MessageLib.cpp

示例4: _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

示例5: destroyObject

void WorldManager::destroyObject(Object* object)
{

	switch(object->getType())
	{
		case ObjType_Player:
		{
			//destroys knownObjects in the destructor
			PlayerObject* player = dynamic_cast<PlayerObject*>(object);

			// moved most of the code to the players destructor



			// onPlayerLeft event, notify scripts
			string params;
			params.setLength(sprintf(params.getAnsi(),"%s %s %u",getPlanetNameThis(),player->getFirstName().getAnsi(),static_cast<uint32>(mPlayerAccMap.size())));

			mWorldScriptsListener.handleScriptEvent("onPlayerLeft",params);
			// gLogger->logMsg("WorldManager::destroyObject: Player Client set to NULL");
			delete player->getClient();
			player->setClient(NULL);
			player->setConnectionState(PlayerConnState_Destroying);
		}
		break;
		case ObjType_NPC:
		case ObjType_Creature:
		{
			CreatureObject* creature = dynamic_cast<CreatureObject*>(object);

			// remove any timers we got running
			removeCreatureHamToProcess(creature->getHam()->getTaskId());

			// remove from cell / SI
			if (!object->getParentId())
			{
				// Not all objects-creatures of this type are points.
				if(creature->getSubZoneId())
				{
					if(QTRegion* region = getQTRegion(creature->getSubZoneId()))
					{
						creature->setSubZoneId(0);
						region->mTree->removeObject(creature);
					}
				}
				else
				{
					mSpatialIndex->RemovePoint(object->getId(),object->mPosition.x,object->mPosition.z);
				}
			}
			else
			{
				if(CellObject* cell = dynamic_cast<CellObject*>(getObjectById(object->getParentId())))
				{
					cell->removeObject(object);
				}
				else
				{
					//gLogger->logMsgF("WorldManager::destroyObject: couldn't find cell %"PRIu64"",MSG_HIGH,object->getParentId());
				}
			}

			// destroy known objects
			object->destroyKnownObjects();

			// if its a shuttle, remove it from the shuttle list
			if(creature->getCreoGroup() == CreoGroup_Shuttle)
			{
				ShuttleList::iterator shuttleIt = mShuttleList.begin();
				while(shuttleIt != mShuttleList.end())
				{
					if((*shuttleIt)->getId() == creature->getId())
					{
						mShuttleList.erase(shuttleIt);
						break;
					}

					++shuttleIt;
				}
			}
		}
		break;


		case ObjType_Structure:
		{
			// cave what do we do with player cities ??
			// then the parent Id should be the region object. shouldnt it????

			if(object->getSubZoneId())
			{
				if(QTRegion* region = getQTRegion(object->getSubZoneId()))
				{
					object->setSubZoneId(0);
					region->mTree->removeObject(object);
				}
			}
			else
			{
				mSpatialIndex->RemovePoint(object->getId(),object->mPosition.x,object->mPosition.z);
//.........这里部分代码省略.........
开发者ID:Arnold47525,项目名称:mmoserver,代码行数:101,代码来源:WorldManagerObjectHandlers.cpp


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