void BountyMissionObjectiveImplementation::handlePlayerKilled(ManagedObject* arg1) { CreatureObject* killer = NULL; killer = cast<CreatureObject*>(arg1); ManagedReference<MissionObject* > mission = this->mission.get(); ManagedReference<CreatureObject*> owner = getPlayerOwner(); if (owner != NULL && killer != NULL) { if (owner->getObjectID() == killer->getObjectID()) { //Target killed by player, complete mission. ZoneServer* zoneServer = owner->getZoneServer(); if (zoneServer != NULL) { ManagedReference<CreatureObject*> target = zoneServer->getObject(mission->getTargetObjectId()).castTo<CreatureObject*>(); if (target != NULL) { VisibilityManager::instance()->clearVisibility(target); owner->getZoneServer()->getPlayerManager()->awardExperience(target, "jedi_general", -30000, true); } } complete(); } else if (mission->getTargetObjectId() == killer->getObjectID() || (npcTarget != NULL && npcTarget->getObjectID() == killer->getObjectID())) { //Player killed by target, fail mission. owner->sendSystemMessage("@mission/mission_generic:failed"); // Mission failed killer->sendSystemMessage("You have defeated a bounty hunter, ruining his mission against you!"); fail(); } } }
void SuiManager::sendInputBox(SceneObject* terminal, SceneObject* player, const String& play, const String& callback, const String& prompt, const String& button) { if (terminal == NULL) return; if (player == NULL || !player->isCreatureObject()) return; CreatureObject* creature = cast<CreatureObject*>(player); PlayerObject* playerObject = creature->getPlayerObject(); if (playerObject != NULL) { ManagedReference<SuiInputBox*> confirmSui = new SuiInputBox(creature, 0x00); confirmSui->setCallback(new LuaSuiCallback(creature->getZoneServer(), play, callback)); confirmSui->setUsingObject(terminal); confirmSui->setPromptText(prompt); confirmSui->setOkButton(true, button); confirmSui->setOtherButton(false, ""); confirmSui->setCancelButton(false, ""); confirmSui->setForceCloseDistance(32); creature->sendMessage(confirmSui->generateMessage()); playerObject->addSuiBox(confirmSui); } }
CreatureObject* ThreatMap::getHighestThreatCreature() { Locker locker(&lockMutex); ManagedReference<CreatureObject*> currentThreat = this->currentThreat.get(); if(currentThreat != NULL && !currentThreat->isDead() && !currentThreat->isIncapacitated() && !currentThreat->isDestroyed() && !cooldownTimerMap.isPast("doEvaluation")) return currentThreat; threatMatrix.clear(); for (int i = 0; i < size(); ++i) { ThreatMapEntry* entry = &elementAt(i).getValue(); CreatureObject* creature = elementAt(i).getKey(); ManagedReference<CreatureObject*> selfStrong = cast<CreatureObject*>(self.get().get()); if (!creature->isDead() && !creature->isIncapacitated() && creature->isInRange(selfStrong, 128.f) && creature->isAttackableBy(selfStrong)) threatMatrix.add(creature, entry); } this->currentThreat = threatMatrix.getLargestThreat(); cooldownTimerMap.updateToCurrentAndAddMili("doEvaluation", ThreatMap::EVALUATIONCOOLDOWN); return this->currentThreat.get().get(); }
CreatureObject* CreatureManagerImplementation::createCreature(uint32 templateCRC, bool persistent, uint32 mobileTemplateCRC) { ManagedReference<SceneObject*> object = zoneServer->createObject(templateCRC, persistent); if (object == NULL) { StringBuffer errMsg; errMsg << "could not spawn creature... wrong template? 0x" << hex << templateCRC; error(errMsg.toString()); return NULL; } if (!object->isCreatureObject()) { StringBuffer errMsg; errMsg << "server did not create a creature object wrong template? 0x" << hex << templateCRC; error(errMsg.toString()); return NULL; } CreatureObject* creature = cast<CreatureObject*>( object.get()); if (!createCreatureChildrenObjects(creature, templateCRC, creature->isPersistent(), mobileTemplateCRC)) { StringBuffer errMsg; errMsg << "could not create children objects for creature... 0x" << templateCRC; error(errMsg.toString()); return NULL; } return creature; }
/** * Sets a creature into the "Flee" state where he runs away from another object. * * @param env Java environment * @param self class calling this function * @param mob id of creature to access * @param target target id of creature to flee * * @return JNI_TRUE if the creature stopped, or false if there was an error */ jboolean JNICALL ScriptMethodsActionStatesNamespace::flee(JNIEnv *env, jobject self, jlong mob, jlong target, jfloat minDistance, jfloat maxDistance) { UNREF(self); if (mob == 0 || target == 0) return JNI_FALSE; CreatureObject * object = 0; AICreatureController * controller = 0; jboolean result=JNI_FALSE; if (!JavaLibrary::getObjectController(mob, object, controller)) return result; NetworkId mobId = object->getNetworkId(); NetworkId targetId(target); if(mobId == targetId) { JavaLibrary::throwInternalScriptError("ScriptMethodsActionStatesNamespace::flee - Creature is trying to flee from itself\n"); return JNI_FALSE; } if (controller->flee(NetworkId(target), minDistance, maxDistance)) result = JNI_TRUE; return result; }
int BountyMissionObjectiveImplementation::handleNpcTargetReceivesDamage(ManagedObject* arg1) { CreatureObject* target = NULL; target = cast<CreatureObject*>(arg1); ManagedReference<MissionObject* > mission = this->mission.get(); ManagedReference<CreatureObject*> owner = getPlayerOwner(); if (owner != NULL && target != NULL && target->getFirstName() == owner->getFirstName() && target->isPlayerCreature() && objectiveStatus == HASBIOSIGNATURESTATUS) { updateMissionStatus(mission->getMissionLevel()); String diffString = "easy"; if (mission->getMissionLevel() == 3) { diffString = "hard"; } else if (mission->getMissionLevel() == 2) { diffString = "medium"; } target->getZoneServer()->getChatManager()->broadcastMessage(npcTarget, "@mission/mission_bounty_neutral_" + diffString + ":m" + String::valueOf(mission->getMissionNumber()) + "v", 0, 0, 0); return 1; } return 0; }
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; }
float GroupObjectImplementation::getGroupHarvestModifier(CreatureObject* player) { String skillNovice = "outdoors_ranger_novice"; String skillMaster = "outdoors_ranger_master"; float modifier = 1.2f; for(int i = 0; i < groupMembers.size(); ++i) { Reference<SceneObject*> scno = getGroupMember(i); if(scno->isPlayerCreature()) { CreatureObject* groupMember = cast<CreatureObject*>( scno.get()); if(groupMember == player) continue; if(groupMember->hasSkill(skillNovice)) { if(groupMember->isInRange(player, 64.0f)) { if(groupMember->hasSkill(skillMaster)) { modifier = 1.4f; break; } modifier = 1.3f; } } } } return modifier; }
bool EVState::validate(uint32 &reply1, uint32 &reply2, uint64 targetId, uint32 opcode, ObjectControllerCmdProperties*& cmdProperties) { CreatureObject* creature = dynamic_cast<CreatureObject*>(mController->getObject()); if(creature && cmdProperties) { //gLogger->log(LogManager::DEBUG, "locomotionMask(%u) & creature->getLocomotion (%u) ==%u", //cmdProperties->mLocomotionMask,mController->getLocoValidator(creature->states.getLocomotion()), cmdProperties->mLocomotionMask & creature->states.getLocomotion()); // skip over commands with no state requirement and check the rest if((cmdProperties->mStates != 0) && creature->states.checkStates(cmdProperties->mStates)) { LOG(info) << "EVState::validate :: states Mask" << cmdProperties->mStates << " creature : " << creature->GetStateBitmask(); reply1 = kCannotDoWhileState; reply2 = this->mController->getLowestCommonBit(creature->GetStateBitmask(), cmdProperties->mStates); return false; } //command_table.deny_in_locomotion if (cmdProperties->mLocomotionMask !=0 && ((cmdProperties->mLocomotionMask & creature->states.getLocomotion()) != 0)) { LOG(info) << "EVState::validate :: Locomotion Mask" << cmdProperties->mLocomotionMask << " creature : " << creature->states.getLocomotion(); reply1 = kCannotDoWhileLocomotion; reply2 = mController->getPostureValidator(creature->states.getLocomotion()); return false; } } return true; }
void SpawnAreaImplementation::notifyEnter(SceneObject* object) { if (!(tier & SpawnAreaMap::SPAWNAREA)) { ActiveAreaImplementation::notifyEnter(object); return; } if (!object->isPlayerCreature()) return; CreatureObject* creo = cast<CreatureObject*>(object); if (creo->isInvisible()) { return; } ManagedReference<SceneObject*> parent = object->getParent(); if (parent != NULL && parent->isCellObject()) return; if (object->getCityRegion() != NULL) return; ManagedReference<SpawnArea*> spawnArea = _this.getReferenceUnsafeStaticCast(); ManagedReference<SceneObject*> obj = object; EXECUTE_TASK_2(spawnArea, obj, { spawnArea_p->tryToSpawn(obj_p); });
void GarageZoneComponent::notifyPositionUpdate(SceneObject* sceneObject, QuadTreeEntry* entry) const { ManagedReference<SceneObject*> obj = cast<SceneObject*>(entry); if (obj == NULL || !obj->isPlayerCreature()) return; GarageDataComponent* data = cast<GarageDataComponent*>(sceneObject->getDataObjectComponent()->get()); if (data == NULL) return; uint64 objID = obj->getObjectID(); float deltaX = sceneObject->getPositionX() - obj->getPositionX(); float deltaY = sceneObject->getPositionY() - obj->getPositionY(); float rangeSq = deltaX * deltaX + deltaY * deltaY; if (rangeSq > 4096) { // 64^2 if (data->hasNotifiedPlayer(objID)) data->removeNotifiedPlayer(objID); } else { ManagedReference<SceneObject*> rootParent = obj->getRootParent().get(); if (rootParent == NULL || !rootParent->isVehicleObject()) return; if (!data->hasNotifiedPlayer(objID)) { data->addNotifiedPlayer(objID); CreatureObject* player = obj->asCreatureObject(); player->sendSystemMessage("@pet/pet_menu:garage_proximity"); //You have entered into the proximity of a vehicle garage. } } }
int LuaSceneObject::getPlayersInRange(lua_State *L) { int range = lua_tonumber(L, -1); Zone* thisZone = realObject->getZone(); if (thisZone == NULL) { lua_pushnil(L); return 1; } lua_newtable(L); Reference<SortedVector<ManagedReference<QuadTreeEntry*> >*> closeObjects = new SortedVector<ManagedReference<QuadTreeEntry*> >(); thisZone->getInRangeObjects(realObject->getWorldPositionX(), realObject->getWorldPositionY(), range, closeObjects, true); int numPlayers = 0; for (int i = 0; i < closeObjects->size(); ++i) { SceneObject* object = cast<SceneObject*>(closeObjects->get(i).get()); if (object == NULL || !object->isPlayerCreature()) continue; CreatureObject* player = object->asCreatureObject(); if (player == NULL || player->isInvisible()) continue; numPlayers++; lua_pushlightuserdata(L, object); lua_rawseti(L, -2, numPlayers); } return 1; }
void PlayerZoneComponent::teleport(SceneObject* sceneObject, float newPositionX, float newPositionZ, float newPositionY, uint64 parentID) { //sceneObject->setTeleporting(true); CreatureObject* player = NULL; if (sceneObject->isPlayerCreature()) { player = cast<CreatureObject*>( sceneObject); } if (player != NULL && sceneObject->getParent() != NULL && parentID != 0) { ManagedReference<SceneObject*> par = sceneObject->getParent(); if (par->isVehicleObject() || par->isMount()) { player->executeObjectControllerAction(String("dismount").hashCode()); } } ZoneComponent::teleport(sceneObject, newPositionX, newPositionZ, newPositionY, parentID); if (player != NULL) { PlayerObject* ghost = player->getPlayerObject(); ghost->setTeleporting(true); ghost->updateLastValidatedPosition(); player->setMovementCounter(0); ghost->setClientLastMovementStamp(0); } }
void GroupObjectImplementation::calcGroupLevel() { int highestPlayer = 0; groupLevel = 0; for (int i = 0; i < getGroupSize(); i++) { Reference<SceneObject*> member = getGroupMember(i); if (member->isPet()) { CreatureObject* creature = cast<CreatureObject*>(member.get()); groupLevel += creature->getLevel() / 5; } else if (member->isPlayerCreature()) { CreatureObject* creature = cast<CreatureObject*>(member.get()); int memberLevel = creature->getLevel(); if (memberLevel > highestPlayer) { groupLevel += (memberLevel - highestPlayer + (highestPlayer / 5)); highestPlayer = memberLevel; } else { groupLevel += memberLevel / 5; } } } GroupObjectDeltaMessage6* msg = new GroupObjectDeltaMessage6(_this.getReferenceUnsafeStaticCast()); msg->updateLevel(this->groupLevel); msg->close(); broadcastMessage(msg); }
bool CellPermissions::isOnList(PermissionList const &permList, CreatureObject const &who) // static { const int guildId = who.getGuildId(); // if either their name or their guild is on the list, consider them on the list for (PermissionList::const_iterator i = permList.begin(); i != permList.end(); ++i) { const std::string& name = (*i).getName(); // objectId if (name == who.getNetworkId().getValueString()) return true; // first name if (!_stricmp(name.c_str(), Unicode::wideToNarrow(who.getAssignedObjectFirstName()).c_str())) return true; // guilds if (guildId && !_strnicmp(name.c_str(), "Guild:", 6)) { std::string checkStr(Unicode::getTrim((name).substr(6))); if ( !_stricmp(checkStr.c_str(), GuildInterface::getGuildAbbrev(guildId).c_str()) || !_stricmp(checkStr.c_str(), GuildInterface::getGuildName(guildId).c_str())) return true; } } return false; }
void WorldManager::removePlayerfromAccountMap(uint64 playerID) { CreatureObject* creature = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(playerID)); if(!creature) { LOG (error) << "WorldManager::removePlayerfromAccountMap : no player"; return; } PlayerObject* player = creature->GetGhost(); if(player) { PlayerAccMap::iterator playerAccIt = mPlayerAccMap.find(player->getAccountId()); if(playerAccIt != mPlayerAccMap.end()) { LOG(info) << "Player left [" << player->getId() << "] Total players on zone [" << (getPlayerAccMap()->size() -1) << "]"; mPlayerAccMap.erase(playerAccIt); } else { LOG(error) << "Error removing player from account map [" << player->getAccountId() << "]"; } } else { LOG(error) << "Error removing player from account map [" << player->getAccountId() << "]"; } }
void BountyMissionObjectiveImplementation::handleNpcTargetKilled(ManagedObject* arg1) { CreatureObject* attacker = NULL; attacker = cast<CreatureObject*>(arg1); ManagedReference<MissionObject* > mission = this->mission.get(); ManagedReference<CreatureObject*> owner = getPlayerOwner(); if (owner == NULL) return; if (attacker != NULL && attacker->getObjectID() == owner->getObjectID() && attacker->isPlayerCreature()) { //Target killed by player, complete mission. complete(); } else if (attacker != NULL && attacker->isPet()) { // Target killed by pet ManagedReference<CreatureObject*> petOwner = attacker->getLinkedCreature().get(); if (petOwner != NULL && petOwner->getObjectID() == owner->getObjectID()) { // Pet is owned by mission owner, complete mission. complete(); } } else { //Target killed by other player, fail mission. owner->sendSystemMessage("@mission/mission_generic:failed"); // Mission failed abort(); removeMissionFromPlayer(); } }
uint64 CreatureObject::getNearestAttackingDefender(void) { uint64 defenederId = 0; float minLenght = FLT_MAX; ObjectIDList::iterator it = mDefenders.begin(); while(it != mDefenders.end()) { if((*it) != 0) { CreatureObject* defender = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById((*it))); if (defender && !defender->isDead() && !defender->isIncapacitated()) { if ((defender->getCreoGroup() == CreoGroup_Player) || (defender->getCreoGroup() == CreoGroup_Creature)) { float len = glm::distance(this->mPosition, defender->mPosition); if (len < minLenght) { minLenght = len; defenederId = (*it); } } } } ++it; } return defenederId; }
CreatureObject* CreatureManagerImplementation::spawnCreatureAsBaby(uint32 templateCRC, float x, float z, float y, uint64 parentID) { CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(templateCRC); if (creoTempl == NULL || creoTempl->getTame() <= 0) return NULL; CreatureObject* creo = NULL; String templateToSpawn = getTemplateToSpawn(templateCRC); uint32 objectCRC = templateToSpawn.hashCode(); creo = createCreature(objectCRC, false, templateCRC); if (creo != NULL && creo->isCreature()) { Creature* creature = cast<Creature*>(creo); creature->loadTemplateDataForBaby(creoTempl); } else { error("could not spawn template " + templateToSpawn + " as baby."); creo = NULL; } placeCreature(creo, x, z, y, parentID); if (creo != NULL && creo->isAiAgent()) cast<AiAgent*>(creo)->activateLoad(""); else { error("could not spawn template " + templateToSpawn + " as baby with AI."); creo = NULL; } return creo; }
/** * Returns all the max mental states for a creature. * * @param env Java environment * @param self class calling this function * @param mob id of creature to access * * @return the max mental states for the creature */ jobjectArray JNICALL ScriptMethodsMentalStatesNamespace::getMaxMentalStates(JNIEnv *env, jobject self, jlong mob) { UNREF(self); CreatureObject * creature = 0; if (!JavaLibrary::getObject(mob, creature)) return 0; // create the array of mental states LocalObjectArrayRefPtr attribs = createNewObjectArray( MentalStates::NumberOfMentalStates, JavaLibrary::getClsMentalState()); if (env->ExceptionCheck()) { env->ExceptionDescribe(); return 0; } // set the array elements for (int i = 0; i < MentalStates::NumberOfMentalStates; ++i) { LocalRefPtr mentalState = createNewObject(JavaLibrary::getClsMentalState(), JavaLibrary::getMidMentalState(), i, creature->getMaxMentalState(static_cast<MentalStates::Enumerator>(i))); if (env->ExceptionCheck()) { env->ExceptionDescribe(); return 0; } setObjectArrayElement(*attribs, i, *mentalState); } return attribs->getReturnValue(); } // JavaLibrary::getMaxMentalStates
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; }
/** * Adds a value to a creature's mental state. * * @param env Java environment * @param self class calling this function * @param mob id of creature to access * @param mentalState mental state we are interested in * @param value value to add to the mental state * * @return true on success, false on fail */ jboolean JNICALL ScriptMethodsMentalStatesNamespace::addToMentalStateTowardClampBehavior(JNIEnv *env, jobject self, jlong mob, jlong target, jint mentalState, jfloat value, jint behavior) { UNREF(self); if (target == 0 || mentalState < 0 || mentalState >= MentalStates::NumberOfMentalStates) return JNI_FALSE; CreatureObject * creature = 0; if (!JavaLibrary::getObject(mob, creature)) return JNI_FALSE; NetworkId targetId(target); if (!targetId) return JNI_FALSE; MentalStates::Value current = creature->getMentalStateToward(targetId, static_cast<MentalStates::Enumerator>(mentalState)); LOGC(ConfigServerGame::isAiLoggingEnabled(), "debug_ai", ("ScriptMethodsMentalStates::addToMentalStateTowardClampBehavior() %s->%s state(%s) value(%.0f+%.0f) behavior(%s)", creature->getNetworkId().getValueString().c_str(), targetId.getValueString().c_str(), CreatureObject::getMentalStateString(mentalState), current, value, CreatureObject::getBehaviorString(behavior))); creature->setMentalStateTowardClampBehavior(targetId, static_cast<MentalStates::Enumerator>(mentalState), static_cast<MentalStates::Value>(current + value), static_cast<Behaviors::Enumerator>(behavior)); return JNI_TRUE; } // JavaLibrary::addToMentalState
/** * Sets a creature into the "Follow" state where he follows someone else around. * * @param env Java environment * @param self class calling this function * @param mob id of creature to access * @param target target id of creature to follow * @param minDist closest to get to creature * @param maxDist farthest to get from target * * @return JNI_TRUE if the creature stopped, or false if there was an error */ jboolean JNICALL ScriptMethodsActionStatesNamespace::followOffset(JNIEnv *env, jobject self, jlong mob, jlong target, jobject offset) { UNREF(self); if (mob == 0 || target == 0) return JNI_FALSE; CreatureObject * object = 0; AICreatureController * controller = 0; jboolean result=JNI_FALSE; if (!JavaLibrary::getObjectController(mob, object, controller)) return result; Vector location; NetworkId cell; ScriptConversion::convert(offset, location, cell, object->getPosition_w()); NetworkId mobId = object->getNetworkId(); NetworkId targetId(target); if(mobId == targetId) { JavaLibrary::throwInternalScriptError("ScriptMethodsActionStatesNamespace::followOffset - Creature is trying to follow itself\n"); return JNI_FALSE; } if (controller->follow(NetworkId(target), location)) result = JNI_TRUE; return result; }
/** * Adds values to the mental states for a creature. * * @param env Java environment * @param self class calling this function * @param mob id of creature to access * @param values mental state/value pairs to add * * @return true on success, false on fail */ jboolean JNICALL ScriptMethodsMentalStatesNamespace::addToMentalStatesToward(JNIEnv *env, jobject self, jlong mob, jlong target, jobjectArray values) { UNREF(self); if (target == 0) return JNI_FALSE; CreatureObject * creature = 0; if (!JavaLibrary::getObject(mob, creature)) return JNI_FALSE; NetworkId targetId(target); if (!targetId) return JNI_FALSE; int count = env->GetArrayLength(values); for (int i = 0; i < count; ++i) { LocalRefPtr mentalState = getObjectArrayElement(LocalObjectArrayRefParam(values), i); if (mentalState == LocalRef::cms_nullPtr) return JNI_FALSE; int type = getIntField(*mentalState, JavaLibrary::getFidMentalStateType()); float delta = getFloatField(*mentalState, JavaLibrary::getFidMentalStateValue()); if (type < 0 || type >= MentalStates::NumberOfMentalStates) return JNI_FALSE; MentalStates::Value value = creature->getMentalStateToward(targetId, static_cast<MentalStates::Enumerator>(type)); creature->setMentalStateToward(targetId, static_cast<MentalStates::Enumerator>(type), static_cast<MentalStates::Value>(value+delta)); } return JNI_TRUE; } // JavaLibrary::addToMentalStates
void LairObserverImplementation::notifyDestruction(TangibleObject* lair, TangibleObject* attacker, int condition) { ThreatMap* threatMap = lair->getThreatMap(); Reference<DisseminateExperienceTask*> deTask = new DisseminateExperienceTask(lair, threatMap, &spawnedCreatures); deTask->execute(); threatMap->removeObservers(); threatMap->removeAll(); // we can clear the original one if (lair->getZone() == NULL) { spawnedCreatures.removeAll(); return; } PlayClientEffectObjectMessage* explode = new PlayClientEffectObjectMessage(lair, "clienteffect/lair_damage_heavy.cef", ""); lair->broadcastMessage(explode, false); PlayClientEffectLoc* explodeLoc = new PlayClientEffectLoc("clienteffect/lair_damage_heavy.cef", lair->getZone()->getZoneName(), lair->getPositionX(), lair->getPositionZ(), lair->getPositionY()); lair->broadcastMessage(explodeLoc, false); lair->destroyObjectFromWorld(true); for (int i = 0; i < spawnedCreatures.size(); ++i) { CreatureObject* obj = spawnedCreatures.get(i); if (obj->isAiAgent()) (cast<AiAgent*>(obj))->setDespawnOnNoPlayerInRange(true); } spawnedCreatures.removeAll(); }
void TangibleObjectImplementation::broadcastPvpStatusBitmask() { if (getZone() == NULL) return; if (closeobjects != NULL) { Zone* zone = getZone(); CreatureObject* thisCreo = asCreatureObject(); SortedVector<ManagedReference<QuadTreeEntry*> > closeObjects(closeobjects->size(), 10); closeobjects->safeCopyTo(closeObjects); for (int i = 0; i < closeObjects.size(); ++i) { SceneObject* obj = cast<SceneObject*>(closeObjects.get(i).get()); if (obj != NULL && obj->isCreatureObject()) { CreatureObject* creo = obj->asCreatureObject(); sendPvpStatusTo(creo); if (thisCreo != NULL) creo->sendPvpStatusTo(thisCreo); } } } }
void SuiManager::sendMessageBox(SceneObject* usingObject, SceneObject* player, const String& title, const String& text, const String& okButton, const String& screenplay, const String& callback) { if (usingObject == NULL) return; if (player == NULL || !player->isCreatureObject()) return; CreatureObject* creature = cast<CreatureObject*>(player); PlayerObject* playerObject = creature->getPlayerObject(); if (playerObject != NULL) { ManagedReference<SuiMessageBox*> messageBox = new SuiMessageBox(creature, 0x00); messageBox->setCallback(new LuaSuiCallback(creature->getZoneServer(), screenplay, callback)); messageBox->setPromptTitle(title); messageBox->setPromptText(text); messageBox->setUsingObject(usingObject); messageBox->setOkButton(true, okButton); messageBox->setCancelButton(true, "@cancel"); messageBox->setForceCloseDistance(32.f); creature->sendMessage(messageBox->generateMessage()); playerObject->addSuiBox(messageBox); } }
int LootContainerComponent::notifyObjectRemoved(SceneObject* sceneObject, SceneObject* object, SceneObject* destination) { if (destination != NULL) { ManagedReference<SceneObject*> rootParent = destination->getParent(); if (rootParent != NULL && rootParent->isCreatureObject()) { CreatureObject* creature = cast<CreatureObject*>(rootParent.get()); if (creature != NULL) { ManagedReference<GroupObject*> group = creature->getGroup(); if (group != NULL) { StringIdChatParameter params("group", "notify_single_loot"); //[GROUP] %TU looted %TO from %TT. params.setTO(object->getDisplayedName()); params.setTU(creature->getDisplayedName()); params.setTT(sceneObject->getParent().get()); group->sendSystemMessage(params); } else { StringIdChatParameter params("base_player", "prose_item_looted_self"); //You looted: %TT. params.setTT(object); creature->sendSystemMessage(params); } } } } return 0; }
int ResourceManagerImplementation::notifyObserverEvent(uint32 eventType, Observable* observable, ManagedObject* arg1, int64 arg2) { if (eventType == ObserverEventType::POSTURECHANGED) { CreatureObject* creature = cast<CreatureObject*>( observable); if (creature == NULL) { return 0; } // Cancel Sampling on posture change Reference<SampleTask*> task = creature->getPendingTask("sample").castTo<SampleTask*>( ); Reference<SampleResultsTask*> sampleResultsTask = creature->getPendingTask("sampleresults").castTo<SampleResultsTask*>( ); if (task != NULL) { task->stopSampling(); //creature->removePendingTask("sample"); if(sampleResultsTask != NULL) { sampleResultsTask->cancel(); creature->removePendingTask("sampleresults"); } creature->sendSystemMessage("@survey:sample_cancel"); } return 1; } return 0; }
bool EVWeapon::validate(uint32 &reply1, uint32 &reply2, uint64 targetId, uint32 opcode, ObjectControllerCmdProperties*& cmdProperties) { CreatureObject* creature = dynamic_cast<CreatureObject*>(mController->getObject()); // check our equipped weapon uint32 weaponGroup = WeaponGroup_Unarmed; if(Item* weapon = dynamic_cast<Item*>(creature->getEquipManager()->getEquippedObject(CreatureEquipSlot_Hold_Left))) { // could be an instrument if(weapon->getItemFamily() == ItemFamily_Weapon) { weaponGroup = dynamic_cast<Weapon*>(weapon)->getGroup(); } } if(cmdProperties->mRequiredWeaponGroup && (weaponGroup & cmdProperties->mRequiredWeaponGroup) != weaponGroup) { reply1 = 0; reply2 = 1; if(PlayerObject* player = dynamic_cast<PlayerObject*>(creature)) { gMessageLib->SendSystemMessage(::common::OutOfBand("cbt_spam", "no_attack_wrong_weapon"), player); } return(false); } return(true); }