本文整理汇总了C++中AiAgent::setHomeLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ AiAgent::setHomeLocation方法的具体用法?C++ AiAgent::setHomeLocation怎么用?C++ AiAgent::setHomeLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AiAgent
的用法示例。
在下文中一共展示了AiAgent::setHomeLocation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: placeCreature
void CreatureManagerImplementation::placeCreature(CreatureObject* creature, float x, float z, float y, uint64 parentID) {
if (creature == NULL)
return;
Reference<SceneObject*> cellParent = NULL;
if (parentID != 0) {
cellParent = zoneServer->getObject(parentID);
if (cellParent != NULL && !cellParent->isCellObject()) {
error("trying to set a parent that is not a cell to creature");
cellParent = NULL;
}
}
//addCreatureToMap(creature);
Locker _locker(creature);
if (creature->isAiAgent()) {
AiAgent* aio = cast<AiAgent*>(creature);
aio->setHomeLocation(x, z, y, cellParent);
}
creature->initializePosition(x, z, y);
//creature->insertToZone(zone);
if (cellParent != NULL) {
cellParent->transferObject(creature, -1);
} else
zone->transferObject(creature, -1, true);
}
示例2: placeCreature
void CreatureManagerImplementation::placeCreature(CreatureObject* creature, float x, float z, float y, uint64 parentID) {
if (creature == NULL)
return;
Reference<CellObject*> cellParent = NULL;
if (parentID != 0) {
cellParent = zoneServer->getObject(parentID).castTo<CellObject*>();
}
Locker _locker(creature);
if (creature->isAiAgent()) {
AiAgent* aio = cast<AiAgent*>(creature);
aio->setHomeLocation(x, z, y, cellParent);
}
creature->initializePosition(x, z, y);
if (cellParent != NULL) {
cellParent->transferObject(creature, -1);
} else
zone->transferObject(creature, -1, true);
}
示例3: checkForNewSpawns
//.........这里部分代码省略.........
VectorMap<String, int> objectsToSpawn; // String mobileTemplate, int number to spawn
if (spawnNumber == 4) {
if (System::random(100) > 9)
return false;
VectorMap<String, int>* mobs = lairTemplate->getBossMobiles();
for (int i = 0; i < mobs->size(); i++) {
objectsToSpawn.put(mobs->elementAt(i).getKey(), mobs->elementAt(i).getValue());
}
} else {
Vector<String>* mobiles = lairTemplate->getWeightedMobiles();
int amountToSpawn = 0;
if (getMobType() == LairTemplate::CREATURE) {
amountToSpawn = System::random(3) + ((lairTemplate->getSpawnLimit() / 3) - 2);
} else {
amountToSpawn = System::random(lairTemplate->getSpawnLimit() / 2) + (lairTemplate->getSpawnLimit() / 2);
}
if (amountToSpawn < 1)
amountToSpawn = 1;
for (int i = 0; i < amountToSpawn; i++) {
int num = System::random(mobiles->size() - 1);
String mob = mobiles->get(num);
if (objectsToSpawn.contains(mob)) {
int value = objectsToSpawn.get(mob);
objectsToSpawn.drop(mob);
objectsToSpawn.put(mob, value + 1);
} else {
objectsToSpawn.put(mob, 1);
}
}
}
for(int i = 0; i < objectsToSpawn.size(); ++i) {
if (spawnNumber != 4 && spawnedCreatures.size() >= lairTemplate->getSpawnLimit())
return true;
String templateToSpawn = objectsToSpawn.elementAt(i).getKey();
int numberToSpawn = objectsToSpawn.get(templateToSpawn);
CreatureTemplate* creatureTemplate = CreatureTemplateManager::instance()->getTemplate(templateToSpawn);
if (creatureTemplate == NULL)
continue;
float tamingChance = creatureTemplate->getTame();
CreatureManager* creatureManager = lair->getZone()->getCreatureManager();
for (int j = 0; j < numberToSpawn; j++) {
float x = lair->getPositionX() + (size - System::random(size * 20) / 10.0f);
float y = lair->getPositionY() + (size - System::random(size * 20) / 10.0f);
float z = lair->getZone()->getHeight(x, y);
ManagedReference<CreatureObject*> creo = NULL;
if (creatureManager->checkSpawnAsBaby(tamingChance, babiesSpawned, 500)) {
creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
babiesSpawned++;
}
if (creo == NULL)
creo = creatureManager->spawnCreatureWithAi(templateToSpawn.hashCode(), x, z, y);
if (creo == NULL)
continue;
if (!creo->isAiAgent()) {
error("spawned non player creature with template " + templateToSpawn);
} else {
AiAgent* ai = cast<AiAgent*>( creo.get());
//Locker clocker(npc, lair);
ai->setDespawnOnNoPlayerInRange(false);
ai->setHomeLocation(x, z, y);
ai->setRespawnTimer(0);
ai->setHomeObject(lair);
spawnedCreatures.add(creo);
}
}
}
if (spawnNumber == 4) {
Reference<LairAggroTask*> task = new LairAggroTask(lair, attacker, _this.get(), true);
task->schedule(1000);
}
return objectsToSpawn.size() > 0;
}
示例4: spawnObject
void PetControlDeviceImplementation::spawnObject(CreatureObject* player) {
ZoneServer* zoneServer = getZoneServer();
ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
if (controlledObject == NULL)
return;
assert(controlledObject->isLockedByCurrentThread());
if (!isASubChildOf(player))
return;
ManagedReference<TradeSession*> tradeContainer = player->getActiveSession(SessionFacadeType::TRADE).castTo<TradeSession*>();
if (tradeContainer != NULL) {
server->getZoneServer()->getPlayerManager()->handleAbortTradeMessage(player);
}
controlledObject->initializePosition(player->getPositionX(), player->getPositionZ(), player->getPositionY());
ManagedReference<CreatureObject*> creature = NULL;
if (controlledObject->isCreatureObject()) {
creature = cast<CreatureObject*>(controlledObject.get());
creature->setCreatureLink(player);
creature->setControlDevice(_this.getReferenceUnsafeStaticCast());
creature->setFaction(player->getFaction());
creature->setObjectMenuComponent("PetMenuComponent");
if (player->getPvpStatusBitmask() & CreatureFlag::PLAYER)
creature->setPvpStatusBitmask(player->getPvpStatusBitmask() - CreatureFlag::PLAYER, true);
else
creature->setPvpStatusBitmask(player->getPvpStatusBitmask(), true);
if (trainedAsMount && (creature->getOptionsBitmask() ^ 0x1000)) {
creature->setOptionBit(0x1000);
}
}
Zone* zone = player->getZone();
if (zone == NULL)
return;
ManagedReference<CellObject*> parent = player->getParent().get().castTo<CellObject*>();
if (parent != NULL)
parent->transferObject(controlledObject, -1, true);
else
zone->transferObject(controlledObject, -1, true);
updateStatus(1);
if (petControlObserver != NULL)
player->dropObserver(ObserverEventType::STARTCOMBAT, petControlObserver);
AiAgent* pet = cast<AiAgent*>(creature.get());
if (pet == NULL)
return;
ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
ghost->addToActivePets(pet);
bool isDroid = false;
if (pet->isDroidObject()) {
DroidObject* droid = cast<DroidObject*>(pet);
isDroid = true;
if( droid == NULL )
return;
// Sanity check that there aren't outstanding power/skill mod tasks
droid->removePendingTask( "droid_power" );
droid->removePendingTask( "droid_skill_mod" );
droid->initDroidModules();
droid->onCall();
droid->loadSkillMods(player);
// Submit new power task
Reference<Task*> droidPowerTask = new DroidPowerTask( droid );
droid->addPendingTask("droid_power", droidPowerTask, 120000); // 2 min
// Submit new skill mod task
Reference<Task*> droidSkillModTask = new DroidSkillModTask( droid, player );
droid->addPendingTask("droid_skill_mod", droidSkillModTask, 3000); // 3 sec
}
pet->setHomeLocation(player->getPositionX(), player->getPositionZ(), player->getPositionY(), parent);
pet->setNextStepPosition(player->getPositionX(), player->getPositionZ(), player->getPositionY(), parent);
pet->clearPatrolPoints();
if (petType == PetManager::CREATUREPET) {
pet->setCreatureBitmask(CreatureFlag::PET);
}
if (petType == PetManager::DROIDPET) {
pet->setCreatureBitmask(CreatureFlag::DROID_PET);
}
if (petType == PetManager::FACTIONPET) {
pet->setCreatureBitmask(CreatureFlag::FACTION_PET);
/** dont know if npc faction pets trained via converse instead of radial
if (pet->isNonPlayerCreatureObject() && pet->getDiet() != CreatureFlag::NONE) // show converse to npcs that eat food i.e. not atst
pet->setOptionBit(OptionBitmask::CONVERSE,true);
**/
//.........这里部分代码省略.........