StimPack* DroidStimpackModuleDataComponent::findStimPack() { StimPack* pack = NULL; float biggest = 0; DroidComponent* container = cast<DroidComponent*>(getParent()); ManagedReference<SceneObject*> craftingComponents = container->getSlottedObject("crafted_components"); if(craftingComponents != NULL) { SceneObject* satchel = craftingComponents->getContainerObject(0); for (int i = 0; i < satchel->getContainerObjectsSize(); ++i) { ManagedReference<SceneObject*> sceno = satchel->getContainerObject(i); ManagedReference<TangibleObject*> tano = cast<TangibleObject*>(sceno.get()); if (tano != NULL ) { // is a stimpack if (tano->isPharmaceuticalObject()) { PharmaceuticalObject* pharma = cast<PharmaceuticalObject*>( tano.get()); if (pharma->isStimPack() && !pharma->isPetStimPack() && !pharma->isDroidRepairKit()) { StimPack* stim = cast<StimPack*>(pharma); if (stim->getEffectiveness() > biggest) { biggest = stim->getEffectiveness(); pack = stim; } } } } } } return pack; }
int ZoneImplementation::getInRangeObjects(float x, float y, float range, SortedVector<ManagedReference<QuadTreeEntry*> >* objects, bool readLockZone) { //Locker locker(_this.getReferenceUnsafeStaticCast()); bool readlock = readLockZone && !_this.getReferenceUnsafeStaticCast()->isLockedByCurrentThread(); Vector<ManagedReference<QuadTreeEntry*> > buildingObjects; // _this.getReferenceUnsafeStaticCast()->rlock(readlock); try { _this.getReferenceUnsafeStaticCast()->rlock(readlock); quadTree->inRange(x, y, range, *objects); _this.getReferenceUnsafeStaticCast()->runlock(readlock); } catch (...) { _this.getReferenceUnsafeStaticCast()->runlock(readlock); } for (int i = 0; i < objects->size(); ++i) { SceneObject* sceneObject = cast<SceneObject*>(objects->get(i).get()); BuildingObject* building = dynamic_cast<BuildingObject*>(sceneObject); if (building != NULL) { for (int j = 1; j <= building->getMapCellSize(); ++j) { CellObject* cell = building->getCell(j); if (cell != NULL) { try { ReadLocker rlocker(cell->getContainerLock()); for (int h = 0; h < cell->getContainerObjectsSize(); ++h) { ManagedReference<SceneObject*> obj = cell->getContainerObject(h); if (obj != NULL) buildingObjects.add(obj.get()); } } catch (...) { } } } } else if (sceneObject != NULL && (sceneObject->isVehicleObject() || sceneObject->isMount())) { ManagedReference<SceneObject*> rider = sceneObject->getSlottedObject("rider"); if (rider != NULL) buildingObjects.add(rider.get()); } } //_this.getReferenceUnsafeStaticCast()->runlock(readlock); for (int i = 0; i < buildingObjects.size(); ++i) objects->put(buildingObjects.get(i)); return objects->size(); }
void SlicingSessionImplementation::handleSlice(SuiListBox* suiBox) { ManagedReference<CreatureObject*> player = this->player.get(); ManagedReference<TangibleObject*> tangibleObject = this->tangibleObject.get(); if (player == NULL || tangibleObject == NULL) return; Locker locker(player); Locker clocker(tangibleObject, player); PlayerManager* playerManager = player->getZoneServer()->getPlayerManager(); suiBox->removeAllMenuItems(); suiBox->setCancelButton(false,"@cancel"); StringBuffer prompt; prompt << "@slicing/slicing:"; prompt << getPrefix(tangibleObject) + "examine"; suiBox->setPromptText(prompt.toString()); player->getPlayerObject()->addSuiBox(suiBox); player->sendMessage(suiBox->generateMessage()); if (tangibleObject->isContainerObject() || tangibleObject->getGameObjectType() == SceneObjectType::PLAYERLOOTCRATE) { handleContainerSlice(); playerManager->awardExperience(player, "slicing", 125, true); // Container Slice XP } else if (tangibleObject->isMissionTerminal()) { MissionTerminal* term = cast<MissionTerminal*>( tangibleObject.get()); playerManager->awardExperience(player, "slicing", 250, true); // Terminal Slice XP term->addSlicer(player); player->sendSystemMessage("@slicing/slicing:terminal_success"); } else if (tangibleObject->isWeaponObject()) { handleWeaponSlice(); playerManager->awardExperience(player, "slicing", 500, true); // Weapon Slice XP } else if (tangibleObject->isArmorObject()) { handleArmorSlice(); playerManager->awardExperience(player, "slicing", 1000, true); // Armor Slice XP } else if ( isBaseSlice()){ playerManager->awardExperience(player,"slicing", 1000, true); // Base slicing Zone* zone = player->getZone(); if(zone != NULL){ GCWManager* gcwMan = zone->getGCWManager(); if(gcwMan != NULL){ SecuritySliceTask* task = new SecuritySliceTask(gcwMan, tangibleObject.get(), player); task->execute(); } } } endSlicing(); }
void InstallationObjectImplementation::broadcastMessage(BasePacket* message, bool sendSelf) { Zone* zone = getZone(); if (zone == NULL) return; Locker zoneLocker(zone); SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects; zone->getInRangeObjects(getPositionX(), getPositionY(), 512, &closeSceneObjects, false); for (int i = 0; i < closeSceneObjects.size(); ++i) { ManagedReference<SceneObject*> scno = cast<SceneObject*>( closeSceneObjects.get(i).get()); if (!sendSelf && scno == _this.get()) continue; if(!scno->isPlayerCreature()) continue; CreatureObject* creo = cast<CreatureObject*>( scno.get()); if(isOnAdminList(creo)) scno->sendMessage(message->clone()); } delete message; }
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); // "?" }
ManagedWeakReference<SceneObject*> SceneObjectImplementation::getRootParent() { ManagedReference<SceneObject*> grandParent = getParent(); ManagedReference<SceneObject*> tempParent = NULL; if (grandParent == NULL) return NULL; #ifdef DEBUG_GETROOT_PARENT SortedVector<ManagedReference<SceneObject*> > parents; parents.setNoDuplicateInsertPlan(); #endif while ((tempParent = grandParent->getParent()) != NULL && grandParent != asSceneObject()) { grandParent = tempParent; #ifdef DEBUG_GETROOT_PARENT if (parents.contains(grandParent)) return NULL; else parents.put(grandParent); #endif } if (grandParent == asSceneObject()) return NULL; ManagedWeakReference<SceneObject*> weak = grandParent.get(); return weak; }
void PetControlDeviceImplementation::storeObject(CreatureObject* player, bool force) { ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get(); if (controlledObject == NULL || !controlledObject->isAiAgent()) return; ManagedReference<AiAgent*> pet = cast<AiAgent*>(controlledObject.get()); assert(pet->isLockedByCurrentThread()); if (!force && (pet->isInCombat() || player->isInCombat())) return; if (player->isRidingMount() && player->getParent() == pet) { if (!force && !player->checkCooldownRecovery("mount_dismount")) return; player->executeObjectControllerAction(STRING_HASHCODE("dismount")); if (player->isRidingMount()) return; } if( player->getCooldownTimerMap() == NULL ) return; // Check cooldown if( !player->getCooldownTimerMap()->isPast("petCallOrStoreCooldown") && !force ){ player->sendSystemMessage("@pet/pet_menu:cant_store_1sec"); //"You cannot STORE for 1 second." return; } // Not training any commands trainingCommand = 0; Reference<StorePetTask*> task = new StorePetTask(player, pet); // Store non-faction pets immediately. Store faction pets after 60sec delay. if( petType != PetManager::FACTIONPET || force || player->getPlayerObject()->isPrivileged()){ task->execute(); } else{ if(pet->getPendingTask("store_pet") == NULL) { player->sendSystemMessage( "Storing pet in 60 seconds"); pet->addPendingTask("store_pet", task, 60 * 1000); } else{ Time nextExecution; Core::getTaskManager()->getNextExecutionTime(pet->getPendingTask("store_pet"), nextExecution); int timeLeft = (nextExecution.getMiliTime() / 1000) - System::getTime(); player->sendSystemMessage( "Pet will store in " + String::valueOf(timeLeft) + " seconds." ); return; } } // Set cooldown player->getCooldownTimerMap()->updateToCurrentAndAddMili("petCallOrStoreCooldown", 1000); // 1 sec }
void JukeboxImplementation::notifyInsertToZone(Zone* zone) { ManagedReference<Jukebox*> jbox = _this.getReferenceUnsafeStaticCast(); Locker _lock(jbox); createChildObjects(); ManagedReference<JukeboxObserver*> observer = new JukeboxObserver(jbox); jbox->registerObserver(ObserverEventType::PARENTCHANGED, observer); ManagedReference<SceneObject*> obj = jbox->getRootParent().get(); if (obj == NULL || !obj->isStructureObject()) setRadius(100); else setRadius(30); SortedVector<ManagedReference<SceneObject*> >* children = jbox->getChildObjects(); for (int i = 0; i < children->size(); ++i) { ManagedReference<SceneObject*> child = children->get(i); if (child != NULL && child->isActiveArea()) { ManagedReference<ActiveArea*> area = cast<ActiveArea*>(child.get()); area->registerObserver(ObserverEventType::ENTEREDAREA, observer); area->registerObserver(ObserverEventType::EXITEDAREA, observer); } } }
int RingObjectMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) const { if (selectedID == 22) { // Propose Unity if (!sceneObject->isASubChildOf(player)) return 0; ManagedReference<SceneObject*> target = player->getZoneServer()->getObject(player->getTargetID()); if (target != NULL && target->isPlayerCreature()) { PlayerManager* playerManager = player->getZoneServer()->getPlayerManager(); if (playerManager != NULL) playerManager->proposeUnity(player, cast<CreatureObject*>(target.get()), sceneObject); return 0; } else { player->sendSystemMessage("@unity:bad_target"); // "You must have a valid player target to Propose Unity." return 0; } } else if (selectedID == 234) { // Divorce if (!sceneObject->isASubChildOf(player)) return 0; PlayerManager* playerManager = player->getZoneServer()->getPlayerManager(); if (playerManager != NULL) playerManager->promptDivorce(player); return 0; } return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID); }
void DelegateSuiCallback::run(CreatureObject* creature, SuiBox* sui, uint32 eventIndex, Vector<UnicodeString>* args) { bool cancelPressed = (eventIndex == 1); if (!sui->isTransferBox() || cancelPressed) return; uint32 received = Integer::valueOf(args->get(0).toString()); uint32 tipAmount = Integer::valueOf(args->get(1).toString()); //printf("received %d transferred %d\n", received, transferred); if (tipAmount == 0) return; ManagedReference<SceneObject*> usingObject = sui->getUsingObject().get(); if (usingObject == NULL || !usingObject->isPlayerCreature()) { return; } CreatureObject* targetPlayer = cast<CreatureObject*>(usingObject.get()); if (targetPlayer == NULL) return; DelegateFactionPointsCommand::doDelegate(creature, targetPlayer, tipAmount); }
Region* CityRegionImplementation::addRegion(float x, float y, float radius, bool persistent) { if (zone == NULL) { return NULL; } static const String temp = "object/region_area.iff"; ManagedReference<SceneObject*> obj = zone->getZoneServer()->createObject(temp.hashCode(), persistent ? 1 : 0); if (obj == NULL || !obj->isRegion()) { return NULL; } Locker clocker(obj, _this.getReferenceUnsafeStaticCast()); ManagedReference<Region*> region = cast<Region*>(obj.get()); region->setCityRegion(_this.getReferenceUnsafeStaticCast()); region->setRadius(radius); region->initializePosition(x, 0, y); region->setObjectName(regionName, false); if (isClientRegion()) region->setNoBuildArea(true); zone->transferObject(region, -1, false); regions.put(region); return region; }
void ThreatMap::addDamage(CreatureObject* target, uint32 damage, String xp) { Locker locker(&lockMutex); ManagedReference<TangibleObject*> strongSelf = self.get(); if (strongSelf == NULL || strongSelf.get() == target) return; int idx = find(target); String xpToAward = ""; if (xp == "") { WeaponObject* weapon = target->getWeapon(); xpToAward = weapon->getXpType(); } else xpToAward = xp; if (idx == -1) { ThreatMapEntry entry; entry.addDamage(xpToAward, damage); entry.addAggro(1); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addDamage(xpToAward, damage); entry->addAggro(1); } }
bool SlicingSessionImplementation::hasPrecisionLaserKnife(bool removeItem) { ManagedReference<CreatureObject*> player = this->player.get(); ManagedReference<TangibleObject*> tangibleObject = this->tangibleObject.get(); if (player == NULL) return 0; ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory"); if (inventory == NULL) return false; Locker inventoryLocker(inventory); for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) { ManagedReference<SceneObject*> sceno = inventory->getContainerObject(i); uint32 objType = sceno->getGameObjectType(); if (objType == SceneObjectType::LASERKNIFE) { PrecisionLaserKnife* knife = cast<PrecisionLaserKnife*>( sceno.get()); if (removeItem) { Locker locker(knife); knife->useCharge(player); } return 1; } } return 0; }
Reference<SceneObject*> PlanetManagerImplementation::createTicket(const String& departurePoint, const String& arrivalPlanet, const String& arrivalPoint) { ManagedReference<SceneObject*> obj = server->getZoneServer()->createObject(STRING_HASHCODE("object/tangible/travel/travel_ticket/base/base_travel_ticket.iff"), 1); if (obj == NULL) return NULL; if (!obj->isTangibleObject()) { obj->destroyObjectFromDatabase(true); return NULL; } TangibleObject* tano = cast<TangibleObject*>( obj.get()); if (!tano->isTicketObject()) { tano->destroyObjectFromDatabase(true); return NULL; } TicketObject* ticket = cast<TicketObject*>( tano); ticket->setDeparturePlanet(zone->getZoneName()); ticket->setDeparturePoint(departurePoint); ticket->setArrivalPlanet(arrivalPlanet); ticket->setArrivalPoint(arrivalPoint); return ticket; }
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; }
void MinefieldZoneComponent::notifyInsertToZone(SceneObject* sceneObject, Zone* zne){ if(zne == NULL) return; ManagedReference<InstallationObject*> installation = cast<InstallationObject*>(sceneObject); if(installation == NULL) return; ManagedReference<TurretObserver*> observer = new TurretObserver(); installation->registerObserver(ObserverEventType::OBJECTDESTRUCTION,observer); // TODO: remove. this is to get the pvpstatus bitmask correct for existing minefields uint64 oid = installation->getOwnerObjectID(); if(oid != 0) { ManagedReference<SceneObject*> sceno = zne->getZoneServer()->getObject(oid); if(sceno != NULL && sceno->isGCWBase()) { ManagedReference<BuildingObject*> building = cast<BuildingObject*>(sceno.get()); if(building != NULL){ installation->setPvpStatusBitmask(building->getPvpStatusBitmask() | 1); } } } }
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; }
void VehicleControlDeviceImplementation::storeObject(CreatureObject* player, bool force) { ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get(); if (controlledObject == NULL) return; /*if (!controlledObject->isInQuadTree()) return;*/ if (player->isRidingMount() && player->getParent() == controlledObject) { if (!force && !player->checkCooldownRecovery("mount_dismount")) return; player->executeObjectControllerAction(STRING_HASHCODE("dismount")); if (player->isRidingMount()) return; } Locker crossLocker(controlledObject, player); controlledObject->destroyObjectFromWorld(true); if (controlledObject->isCreatureObject()) (cast<CreatureObject*>(controlledObject.get()))->setCreatureLink(NULL); updateStatus(0); }
void JukeboxImplementation::setRadius(float newRadius) { ManagedReference<Jukebox*> jbox = _this.getReferenceUnsafeStaticCast(); SortedVector<ManagedReference<SceneObject*> >* children = jbox->getChildObjects(); if (newRadius == radius) return; if (children == NULL) return; radius = newRadius; for (int i = 0; i < children->size(); ++i) { ManagedReference<SceneObject*> child = children->get(i); if (child != NULL && child->isActiveArea()) { ManagedReference<ActiveArea*> area = cast<ActiveArea*>(child.get()); Locker clocker(area, jbox); area->setRadius(newRadius); return; } } }
void ThreatMap::addAggro(CreatureObject* target, int value, uint64 duration) { Locker locker(&lockMutex); ManagedReference<TangibleObject*> strongSelf = self.get(); if (strongSelf == NULL || strongSelf.get() == target) return; int idx = find(target); if (idx == -1) { ThreatMapEntry entry; entry.addAggro(value); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addAggro(value); } if(duration > 0) { Reference<RemoveAggroTask*> removeAggroTask = new RemoveAggroTask(self.get(), target, value); removeAggroTask->schedule(duration); } }
short PetManagerImplementation::checkMountEligibility(PetControlDevice* petControlDevice, float height) { ManagedReference<TangibleObject*> controlledObject = petControlDevice->getControlledObject(); if (controlledObject == NULL || !controlledObject->isAiAgent()) return PetManager::INVALIDCREATURE; ManagedReference<AiAgent*> pet = cast<AiAgent*>(controlledObject.get()); if( pet == NULL ) return PetManager::INVALIDCREATURE; //Check if the pet's species is able to be trained as a mount if (!pet->hasSlotDescriptor("rider")) return PetManager::INVALIDCREATURE; SharedObjectTemplate* objectTemplate = petControlDevice->getObjectTemplate(); if (objectTemplate == NULL) return PetManager::INVALIDCREATURE; short result; if (height == -1) result = isValidMountScale(objectTemplate->getAppearanceFilename(), 1, pet->getHeight()); else result = isValidMountScale(objectTemplate->getAppearanceFilename(), 1, height); return result; }
int ElevatorMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* creature, byte selectedID) { ManagedReference<SceneObject*> parent = creature->getParent(); if (parent == NULL || !parent->isCellObject() || parent.get() != sceneObject->getParent().get()) return 0; CellObject* cell = parent.castTo<CellObject*>(); float x = creature->getPositionX(); float y = creature->getPositionY(); float z = sceneObject->getPositionZ(); Vector<float>* floors = CollisionManager::getCellFloorCollision(x, y, cell); int floorCount = floors->size(); int i = 0; for (; i < floorCount; ++i) { float f = floors->get(i); if (fabs(z - f) < 1.f) break; //Almost certainly the same floor. } switch (selectedID) { case 198: //UP if (i <= 0) { creature->sendSystemMessage("You are already on the highest floor"); delete floors; floors = NULL; return 0; } z = floors->get(i - 1); creature->playEffect("clienteffect/elevator_rise.cef", ""); break; case 199: //DOWN if (i >= floorCount - 1) { creature->sendSystemMessage("You are already on the lowest floor"); delete floors; floors = NULL; return 0; } z = floors->get(i + 1); creature->playEffect("clienteffect/elevator_descend.cef", ""); break; default: delete floors; floors = NULL; return 0; } creature->teleport(x, z, y, sceneObject->getParentID()); delete floors; floors = NULL; return 0; }
int PlaceStructureSessionImplementation::completeSession() { if (constructionBarricade != NULL) constructionBarricade->destroyObjectFromWorld(true); String serverTemplatePath = deedObject->getGeneratedObjectTemplate(); StructureManager* structureManager = StructureManager::instance(); ManagedReference<StructureObject*> structureObject = structureManager->placeStructure(creatureObject, serverTemplatePath, positionX, positionY, directionAngle); removeTemporaryNoBuildZone(); if (structureObject == NULL) { ManagedReference<SceneObject*> inventory = creatureObject->getSlottedObject("inventory"); if (inventory != NULL) inventory->transferObject(deedObject, -1, true); return cancelSession(); } structureObject->setDeedObjectID(deedObject->getObjectID()); deedObject->notifyStructurePlaced(creatureObject, structureObject); ManagedReference<PlayerObject*> ghost = creatureObject->getPlayerObject(); if (ghost != NULL) { ghost->addOwnedStructure(structureObject); //Create Waypoint ManagedReference<WaypointObject*> waypointObject = ( zone->getZoneServer()->createObject(String("object/waypoint/world_waypoint_blue.iff").hashCode(), 1)).castTo<WaypointObject*>(); waypointObject->setCustomObjectName(structureObject->getDisplayedName(), false); waypointObject->setActive(true); waypointObject->setPosition(positionX, 0, positionY); waypointObject->setPlanetCRC(zone->getZoneCRC()); ghost->addWaypoint(waypointObject, false, true); //Create an email. ManagedReference<ChatManager*> chatManager = zone->getZoneServer()->getChatManager(); if (chatManager != NULL) { UnicodeString subject = "@player_structure:construction_complete_subject"; StringIdChatParameter emailBody("@player_structure:construction_complete"); emailBody.setTO(structureObject->getObjectName()); emailBody.setDI(ghost->getLotsRemaining()); chatManager->sendMail("@player_structure:construction_complete_sender", subject, emailBody, creatureObject->getFirstName(), waypointObject); } if (structureObject->isBuildingObject() && !structureObject->isGCWBase()) { BuildingObject* building = cast<BuildingObject*>(structureObject.get()); building->setCustomObjectName(creatureObject->getFirstName() + "'s House", true); //Set the house sign. } } return cancelSession(); //Canceling the session just removes the session from the player's map. }
bool CollisionManager::checkLineOfSightInParentCell(SceneObject* object, Vector3& endPoint) { ManagedReference<SceneObject*> parent = object->getParent(); if (parent == NULL || !parent->isCellObject()) return true; CellObject* cell = cast<CellObject*>( parent.get()); SharedObjectTemplate* objectTemplate = parent->getRootParent().get()->getObjectTemplate(); PortalLayout* portalLayout = objectTemplate->getPortalLayout(); MeshAppearanceTemplate* appearanceMesh = NULL; if (portalLayout == NULL) return true; try { appearanceMesh = portalLayout->getMeshAppearanceTemplate(cell->getCellNumber()); } catch (Exception& e) { return true; } if (appearanceMesh == NULL) { //info("null appearance mesh "); return true; } AABBTree* aabbTree = appearanceMesh->getAABBTree(); if (aabbTree == NULL) return true; //switching Y<->Z, adding 0.1 to account floor Vector3 startPoint = object->getPosition(); startPoint.set(startPoint.getX(), startPoint.getY(), startPoint.getZ() + 0.1f); endPoint.set(endPoint.getX(), endPoint.getY(), endPoint.getZ() + 0.1f); Vector3 dir = endPoint - startPoint; dir.normalize(); float distance = endPoint.distanceTo(startPoint); float intersectionDistance; Ray ray(startPoint, dir); Triangle* triangle = NULL; //nothing in the middle if (aabbTree->intersects(ray, distance, intersectionDistance, triangle, true)) return false; Ray ray2(endPoint, Vector3(0, -1, 0)); //check if we are in the cell with dir (0, -1, 0) if (!aabbTree->intersects(ray2, 64000.f, intersectionDistance, triangle, true)) return false; return true; }
void CampTerminalMenuComponent::disbandCamp(SceneObject* sceneObject, CreatureObject* player) const { Terminal* terminal = cast<Terminal*>(sceneObject); if(terminal == NULL) { error("Terminal is null in disbandCamp"); return; } if (!player->isInRange(terminal, 16)) { return; } StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject()); if(camp == NULL) { error("Camp is null in disbandCamp"); return; } if (camp->getZone() == NULL) return; PlayerObject* ghost = player->getPlayerObject(); if (ghost == NULL) { return; } if (!ghost->isOwnedStructure(camp)) { return; } if(player->isSitting()) { player->setPosture(CreaturePosture::UPRIGHT, true); } // Find Camp Area SortedVector<ManagedReference<ActiveArea* > >* areas = camp->getActiveAreas(); ManagedReference<ActiveArea*> area = NULL; for(int i = 0; i < areas->size(); ++i) { area = areas->get(i); if(area->isCampArea()) { break; } area == NULL; } CampSiteActiveArea* campArea = cast<CampSiteActiveArea*>(area.get()); if(campArea != NULL && campArea->despawnCamp()) return; StructureManager::instance()->destroyStructure(camp); if(campArea != NULL) { campArea->destroyObjectFromWorld(true); campArea->destroyObjectFromDatabase(true); } }
void CraftingSessionImplementation::createManufactureSchematic(int clientCounter) { ManagedReference<CraftingTool*> craftingTool = this->craftingTool.get(); ManagedReference<CreatureObject*> crafter = this->crafter.get(); ManagedReference<PlayerObject*> crafterGhost = this->crafterGhost.get(); ManagedReference<CraftingStation*> craftingStation = this->craftingStation.get(); ManagedReference<ManufactureSchematic*> manufactureSchematic = this->manufactureSchematic.get(); ManagedReference<TangibleObject*> prototype = this->prototype.get(); ManagedReference<CraftingManager*> craftingManager = this->craftingManager.get(); if (manufactureSchematic == NULL) { sendSlotMessage(0, IngredientSlot::NOSCHEMATIC); return; } if (prototype == NULL) { sendSlotMessage(0, IngredientSlot::PROTOTYPENOTFOUND); return; } if (!craftingManager.get()->allowManufactureSchematic(manufactureSchematic)){ sendSlotMessage(0, IngredientSlot::NOSCHEMATIC); return; } Locker locker(_this.get()); if (manufactureSchematic->isAssembled() && !manufactureSchematic->isCompleted()) { //Object Controller ObjectControllerMessage* objMsg = new ObjectControllerMessage( crafter->getObjectID(), 0x1B, 0x010C); objMsg->insertInt(0x10B); objMsg->insertInt(1); objMsg->insertByte(clientCounter); crafter->sendMessage(objMsg); ManagedReference<SceneObject*> datapad = crafter->getSlottedObject("datapad"); prototype->destroyObjectFromWorld(0); manufactureSchematic->setPersistent(2); prototype->setPersistent(2); datapad->transferObject(manufactureSchematic, -1, true); manufactureSchematic->setPrototype(prototype); } else { closeCraftingWindow(clientCounter); sendSlotMessage(clientCounter, IngredientSlot::WEIRDFAILEDMESSAGE); } cancelSession(); }
TangibleObject* ImageDesignManager::createHairObject(CreatureObject* imageDesigner, CreatureObject* targetObject, const String& hairTemplate, const String& hairCustomization) { Reference<TangibleObject*> oldHair = targetObject->getSlottedObject("hair").castTo<TangibleObject*>(); HairAssetData* hairAssetData = CustomizationIdManager::instance()->getHairAssetData(hairTemplate); if (hairTemplate.isEmpty()) { if (!CustomizationIdManager::instance()->canBeBald(getSpeciesGenderString(targetObject))) return oldHair; else return NULL; } if (hairAssetData == NULL) return oldHair; int skillMod = hairAssetData->getSkillModValue(); if (imageDesigner->getSkillMod("hair") < skillMod) return oldHair; if (hairAssetData->getServerPlayerTemplate() != targetObject->getObjectTemplate()->getFullTemplateString()) { error("hair " + hairTemplate + " is not compatible with this creature player " + targetObject->getObjectTemplate()->getFullTemplateString()); return oldHair; } ManagedReference<SceneObject*> hair = imageDesigner->getZoneServer()->createObject(hairTemplate.hashCode(), 1); //TODO: Validate hairCustomization if (hair == NULL || !hair->isTangibleObject()) { if (hair != NULL) { Locker locker(hair); hair->destroyObjectFromDatabase(true); } return oldHair; } TangibleObject* tanoHair = cast<TangibleObject*>( hair.get()); Locker locker(tanoHair); tanoHair->setContainerDenyPermission("owner", ContainerPermissions::MOVECONTAINER); tanoHair->setContainerDefaultDenyPermission(ContainerPermissions::MOVECONTAINER); String appearanceFilename = tanoHair->getObjectTemplate()->getAppearanceFilename(); CustomizationVariables data; data.parseFromClientString(hairCustomization); if (validateCustomizationString(&data, appearanceFilename, getSkillLevel(imageDesigner, "hair"))) tanoHair->setCustomizationString(hairCustomization); return tanoHair; }
int SingleUseBuffObserverImplementation::notifyObserverEvent(unsigned int eventType, Observable* observable, ManagedObject* arg1, int64 arg2) { ManagedReference<SingleUseBuff* > buff = this->buff.get(); if (buff == NULL) return 1; ManagedReference<CreatureObject*> player = buff.get()->getPlayer(); if (player == NULL) return 1; ManagedReference<ObjectController*> objectController = player->getZoneServer()->getObjectController(); unsigned int commandCRC = buff.get()->getCommandCRC(); QueueCommand* queueCommand = objectController->getQueueCommand(commandCRC); SceneObject* creature = cast<SceneObject*>( observable); queueCommand->handleBuff(creature, arg1, (int)arg2); return 0; }
void SlicingSessionImplementation::handleSliceFailed() { ManagedReference<CreatureObject*> player = this->player.get(); ManagedReference<TangibleObject*> tangibleObject = this->tangibleObject.get(); if (tangibleObject == NULL || player == NULL) return; if (tangibleObject->isMissionTerminal()) player->sendSystemMessage("@slicing/slicing:terminal_fail"); else if (tangibleObject->isWeaponObject()) player->sendSystemMessage("@slicing/slicing:fail_weapon"); else if (tangibleObject->isArmorObject()) player->sendSystemMessage("@slicing/slicing:fail_armor"); else if (tangibleObject->isContainerObject() || tangibleObject->getGameObjectType() == SceneObjectType::PLAYERLOOTCRATE) player->sendSystemMessage("@slicing/slicing:container_fail"); else if (isBaseSlice()) player->sendSystemMessage("@slicing/slicing:hq_security_fail"); // Unable to sucessfully slice the terminal, you realize that the only away else player->sendSystemMessage("Your attempt to slice the object has failed."); if (tangibleObject->isContainerObject()) { ManagedReference<Container*> container = tangibleObject.castTo<Container*>(); Locker clocker(container, player); if(!container) return; container->setSliced(true); if(!container->isRelocking()) { relockEvent = new RelockLootContainerEvent(container); relockEvent->schedule(container->getLockTime()); // This will reactivate the 'broken' lock. (1 Hour) } } else if (isBaseSlice()){ Zone* zone = player->getZone(); if(zone != NULL){ GCWManager* gcwMan = zone->getGCWManager(); if(gcwMan != NULL) gcwMan->failSecuritySlice(tangibleObject.get()); } } else if (!tangibleObject->isMissionTerminal()) { tangibleObject->setSliced(true); } endSlicing(); }
void PlantObjectImplementation::sendResourceSUI(CreatureObject* player, int type) { ManagedReference<PlayerObject*> ghost = player->getPlayerObject(); if (ghost == NULL) return; ManagedReference<SuiListBox*> suiBox = new SuiListBox(player, SuiWindowType::GROWABLE_PLANT, SuiListBox::HANDLETWOBUTTON); suiBox->setCallback(new GrowablePlantSuiCallback(player->getZoneServer())); suiBox->setPromptTitle("@plant_grow:select_resource_sub"); suiBox->setPromptText("@plant_grow:select_resource_body"); suiBox->setOkButton(true, "@ok"); suiBox->setCancelButton(true, "@cancel"); suiBox->setUsingObject(_this.getReferenceUnsafeStaticCast()); suiBox->setForceCloseDistance(32.f); ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory"); ManagedReference<SceneObject*> sceneObject = NULL; for (int i=0; i< inventory->getContainerObjectsSize(); i++) { sceneObject = inventory->getContainerObject(i); if (sceneObject == NULL) continue; if (sceneObject->isResourceContainer()) { ManagedReference<ResourceContainer*> rcno = cast<ResourceContainer*>( sceneObject.get()); if (rcno == NULL) continue; ManagedReference<ResourceSpawn*> spawn = rcno->getSpawnObject(); if (spawn == NULL) continue; if ((type == 1 && spawn->isType("organic")) || (type == 2 && spawn->isType("water"))) { suiBox->addMenuItem(spawn->getName(), sceneObject->getObjectID()); } } } if (suiBox->getMenuSize() > 0) { ghost->closeSuiWindowType(SuiWindowType::GROWABLE_PLANT); ghost->addSuiBox(suiBox); player->sendMessage(suiBox->generateMessage()); } else { if (type == 1) player->sendSystemMessage("@plant_grow:no_nutrients"); // You don't have any nutrients. else player->sendSystemMessage("@plant_grow:no_water"); // You don't have any water. } }