本文整理汇总了C++中AiAgent类的典型用法代码示例。如果您正苦于以下问题:C++ AiAgent类的具体用法?C++ AiAgent怎么用?C++ AiAgent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AiAgent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool TangibleObjectImplementation::isAttackableBy(CreatureObject* object) {
if (isImperial() && !(object->isRebel())) {
return false;
} else if (isRebel() && !(object->isImperial())) {
return false;
} else if (object->isPlayerCreature() && object->getPlayerObject()) {
if (isImperial() && (object->getPlayerObject())->getFactionStatus() == 0) {
return false;
}
if (isRebel() && (object->getPlayerObject())->getFactionStatus() == 0) {
return false;
}
} else if (object->isAiAgent()) {
AiAgent* ai = object->asAiAgent();
if (ai->getHomeObject().get() == asTangibleObject()) {
return false;
}
if (ai->isPet()) {
ManagedReference<PetControlDevice*> pcd = ai->getControlDevice().get().castTo<PetControlDevice*>();
if (pcd != NULL && pcd->getPetType() == PetManager::FACTIONPET && isNeutral()) {
return false;
}
}
}
return pvpStatusBitmask & CreatureFlag::ATTACKABLE;
}
示例2: getTemplateToSpawn
CreatureObject* CreatureManagerImplementation::spawnCreatureAsEventMob(uint32 templateCRC, float x, float z, float y, uint64 parentID) {
CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(templateCRC);
if (creoTempl == NULL)
return NULL;
CreatureObject* creo = NULL;
String templateToSpawn = getTemplateToSpawn(templateCRC);
uint32 objectCRC = templateToSpawn.hashCode();
creo = createCreature(objectCRC, false, templateCRC);
if (creo != NULL && creo->isAiAgent()) {
AiAgent* creature = cast<AiAgent*>(creo);
creature->loadTemplateData(creoTempl);
UnicodeString eventName;
eventName = creature->getDisplayedName() + " (event)";
creature->setCustomObjectName(eventName, false);
} else if (creo == NULL) {
error("could not spawn template " + templateToSpawn);
}
placeCreature(creo, x, z, y, parentID);
if (creo != NULL && creo->isAiAgent())
cast<AiAgent*>(creo)->activateLoad("");
return creo;
}
示例3: error
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);
}
示例4: spawnCreature
CreatureObject* CreatureManagerImplementation::spawnCreature(uint32 templateCRC, uint32 objectCRC, float x, float z, float y, uint64 parentID, bool persistent) {
CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(templateCRC);
if (creoTempl == NULL)
return spawnCreature(objectCRC, x, z, y, parentID);
CreatureObject* creature = NULL;
String templateToSpawn;
if (objectCRC == 0) {
templateToSpawn = getTemplateToSpawn(templateCRC);
objectCRC = templateToSpawn.hashCode();
}
creature = createCreature(objectCRC, persistent, templateCRC);
if (creature != NULL && creature->isAiAgent()) {
AiAgent* npc = cast<AiAgent*>(creature);
npc->loadTemplateData(creoTempl);
} else if (creature == NULL) {
error("could not spawn template " + templateToSpawn);
}
placeCreature(creature, x, z, y, parentID);
return creature;
}
示例5: setTrainingCommand
void PetControlDeviceImplementation::setTrainingCommand( unsigned int commandID ){
ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
if (controlledObject == NULL || !controlledObject->isAiAgent())
return;
AiAgent* pet = cast<AiAgent*>(controlledObject.get());
if( pet == NULL )
return;
// Check power on droids
if( petType == PetManager::DROIDPET) {
ManagedReference<DroidObject*> droid = this->controlledObject.get().castTo<DroidObject*>();
if (droid == NULL)
return;
if( !droid->hasPower() ){
droid->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0); // "*Low Power*"
return;
}
}
trainingCommand = commandID;
pet->showFlyText("npc_reaction/flytext","alert", 204, 0, 0); // "?"
}
示例6: switch
int LairObserverImplementation::notifyObserverEvent(unsigned int eventType, Observable* observable, ManagedObject* arg1, int64 arg2) {
int ret = 1;
int i = 0;
Reference<LairAggroTask*> task = NULL;
SceneObject* sourceObject = cast<SceneObject*>(arg1);
AiAgent* agent = NULL;
ManagedReference<LairObserver*> lairObserver = _this.get();
ManagedReference<TangibleObject*> lair = cast<TangibleObject*>(observable);
ManagedReference<TangibleObject*> attacker = cast<TangibleObject*>(arg1);
switch (eventType) {
case ObserverEventType::OBJECTREMOVEDFROMZONE:
despawnSpawns();
return 1;
break;
case ObserverEventType::OBJECTDESTRUCTION:
notifyDestruction(lair, attacker, (int)arg2);
return 1;
break;
case ObserverEventType::DAMAGERECEIVED:
// if there are living creatures, make them aggro
if(getLivingCreatureCount() > 0 ){
task = new LairAggroTask(lair, attacker.get(), _this.get(), false);
task->execute();
}
EXECUTE_TASK_3(lairObserver, lair, attacker, {
Locker locker(lair_p);
lairObserver_p->checkForNewSpawns(lair_p, attacker_p);
});
checkForHeal(lair, attacker);
break;
case ObserverEventType::AIMESSAGE:
if (sourceObject == NULL) {
Logger::console.error("LairObserverImplemenation::notifyObserverEvent does not have a source object");
return 1;
}
for (i = 0; i < spawnedCreatures.size(); i++) {
agent = cast<AiAgent*>(spawnedCreatures.get(i).get());
if (agent == NULL)
continue;
agent->activateInterrupt(sourceObject, arg2);
}
break;
}
示例7: despawnSpawns
void SpawnObserverImplementation::despawnSpawns() {
for (int i = 0; i < spawnedCreatures.size(); ++i) {
CreatureObject* obj = spawnedCreatures.get(i);
if (obj->isAiAgent()) {
AiAgent* aiObj = cast<AiAgent*>(obj);
Locker locker(aiObj);
aiObj->setDespawnOnNoPlayerInRange(true);
}
}
spawnedCreatures.removeAll();
}
示例8: lua_touserdata
int LuaAiAgent::assist(lua_State* L) {
SceneObject* obj = (SceneObject*) lua_touserdata(L, -1);
if (obj == NULL || !obj->isAiAgent())
return 0;
AiAgent* agent = cast<AiAgent*>(obj);
if (agent == NULL)
return 0;
SceneObject* target = agent->getFollowObject();
Locker locker(realObject);
realObject->setDefender(target);
return 0;
}
示例9: switch
int LairObserverImplementation::notifyObserverEvent(unsigned int eventType, Observable* observable, ManagedObject* arg1, int64 arg2) {
int ret = 1;
int i = 0;
Reference<LairAggroTask*> task = NULL;
SceneObject* sourceObject = cast<SceneObject*>(arg1);
AiAgent* agent = NULL;
switch (eventType) {
case ObserverEventType::OBJECTDESTRUCTION:
notifyDestruction(cast<TangibleObject*>(observable), cast<TangibleObject*>(arg1), (int)arg2);
return 1;
break;
case ObserverEventType::DAMAGERECEIVED:
// if there are living creatures, make them aggro
if(getLivingCreatureCount() > 0 ){
task = new LairAggroTask(cast<TangibleObject*>(observable), cast<TangibleObject*>(arg1), _this.get(), false);
task->execute();
}
// if new creatures have spawned or there are live creatures near the lair
if( checkForNewSpawns(cast<TangibleObject*>(observable), cast<TangibleObject*>(arg1)) || getLivingCreatureCount() > 0 )
checkForHeal(cast<TangibleObject*>(observable), cast<TangibleObject*>(arg1));
break;
case ObserverEventType::AIMESSAGE:
if (sourceObject == NULL) {
Logger::console.error("LairObserverImplemenation::notifyObserverEvent does not have a source object");
return 1;
}
for (i = 0; i < spawnedCreatures.size(); i++) {
agent = cast<AiAgent*>(spawnedCreatures.get(i).get());
if (agent == NULL)
continue;
agent->activateInterrupt(sourceObject, arg2);
}
break;
}
return 0;
}
示例10: trainAsMount
void PetControlDeviceImplementation::trainAsMount(CreatureObject* player) {
if (isTrainedAsMount())
return;
PetManager* petManager = player->getZoneServer()->getPetManager();
if (petManager == NULL)
return;
if (petManager->checkMountEligibility(_this.get()) != PetManager::CANBEMOUNTTRAINED)
return;
ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
if (controlledObject == NULL || !controlledObject->isAiAgent())
return;
AiAgent* pet = cast<AiAgent*>(controlledObject.get());
if( pet == NULL )
return;
trainedAsMount = true;
pet->setOptionsBitmask(0x1080);
}
示例11: notifyObserverEvent
int HuntingMissionObjectiveImplementation::notifyObserverEvent(MissionObserver* observer, uint32 eventType, Observable* observable, ManagedObject* arg1, int64 arg2) {
ManagedReference<MissionObject* > mission = this->mission.get();
if (eventType == ObserverEventType::KILLEDCREATURE) {
if (cast<CreatureObject*>(observable) != getPlayerOwner().get())
return 0;
CreatureObject* creature = cast<CreatureObject*>(arg1);
AiAgent* agent = cast<AiAgent*>(creature);
if (agent == NULL)
return 0;
CreatureTemplate* creatureTemplate = agent->getCreatureTemplate();
if (creatureTemplate == NULL)
return 0;
String temp1 = mission->getTemplateString1();
String temp2 = mission->getTemplateString2();
if (creatureTemplate->getTemplateName() == temp1 || creatureTemplate->getTemplateName() == temp2) {
targetsKilled--;
if (targetsKilled <= 0) {
complete();
return 1;
}
StringIdChatParameter message("mission/mission_generic", "hunting_kills_remaining");
message.setDI(targetsKilled);
message.setTO(mission->getTargetName());
getPlayerOwner().get()->sendSystemMessage(message);
}
}
return 0;
}
示例12: isValidPet
bool PetControlDeviceImplementation::isValidPet() {
ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
if (controlledObject == NULL || !controlledObject->isAiAgent())
return true;
AiAgent* pet = cast<AiAgent*>(controlledObject.get());
if (pet == NULL)
return true;
PetDeed* deed = pet->getPetDeed();
if (deed != NULL) {
// time to calculate!
int calculatedLevel = deed->calculatePetLevel();
if (pet->getTemplateLevel() == 0)
return true;
if (pet->getTemplateLevel() >= (calculatedLevel * 0.85)) {
return true;
} else {
return false;
}
}
return true;
}
示例13: canAddObject
int FactionRecruiterContainerComponent::canAddObject(SceneObject* sceneObject, SceneObject* object, int containmentType, String& errorDescription) {
if (sceneObject == object) {
return TransferErrorCode::CANTADDTOITSELF;
}
if (!sceneObject->isAiAgent()) {
return TransferErrorCode::INVALIDTYPE;
}
AiAgent* recruiter = cast<AiAgent*>(sceneObject);
String recruiterFaction = recruiter->getFactionString().toLowerCase();
if (recruiterFaction != "imperial" && recruiterFaction != "rebel") {
return TransferErrorCode::INVALIDTYPE;
}
CreatureObject* player = object->getParentRecursively(SceneObjectType::PLAYERCREATURE).get().castTo<CreatureObject*>();
if (player == NULL) {
return TransferErrorCode::MUSTBEINPLAYERINVENTORY;
}
if (object->getObjectTemplate()->getFullTemplateString() == "object/tangible/encoded_disk/message_assembled_base.iff") {
CoaMessageDataComponent* data = object->getDataObjectComponent()->castTo<CoaMessageDataComponent*>();
if (data != NULL) {
String faction = data->getFaction().toLowerCase();
if (faction == "imperial" || faction == "rebel") {
return TransferErrorCode::SUCCESS;
}
}
}
return TransferErrorCode::INVALIDTYPE;
}
示例14: if
bool TangibleObjectImplementation::isAttackableBy(CreatureObject* object) {
if (isImperial() && !(object->isRebel())) {
return false;
} else if (isRebel() && !(object->isImperial())) {
return false;
} else if (object->isPlayerCreature() && object->getPlayerObject()) {
if (isImperial() && (object->getPlayerObject())->getFactionStatus() == 0) {
return false;
}
if (isRebel() && (object->getPlayerObject())->getFactionStatus() == 0) {
return false;
}
} else if (object->isAiAgent()) {
AiAgent* ai = cast<AiAgent*>(object);
if (ai->getHomeObject() == _this.get()) {
return false;
}
}
return pvpStatusBitmask & CreatureFlag::ATTACKABLE;
}
示例15: trainAsMount
void PetControlDeviceImplementation::trainAsMount(CreatureObject* player) {
if (isTrainedAsMount() || !player->hasSkill("outdoors_creaturehandler_support_04"))
return;
PetManager* petManager = player->getZoneServer()->getPetManager();
if (petManager == NULL)
return;
if (petManager->checkMountEligibility(_this.getReferenceUnsafeStaticCast()) != PetManager::CANBEMOUNTTRAINED)
return;
ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
if (controlledObject == NULL || !controlledObject->isAiAgent())
return;
AiAgent* pet = cast<AiAgent*>(controlledObject.get());
if( pet == NULL )
return;
assert(pet->isLockedByCurrentThread());
trainedAsMount = true;
pet->setOptionBit(0x1000);
}