Handler::Handler() { gameObjects = make_shared<vector<GameObject*>>(); shared_ptr<ofImage> inImg = make_shared<ofImage>(); inImg->load("grass.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("warehouse1.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("trees.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("mine.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("wheat.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("house.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("stockpile.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("sasCow.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("OnyxHorse.jpg"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("girl1.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("girl2.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("guy1.png"); images.push_back(inImg); inImg = make_shared<ofImage>(); inImg->load("guy2.png"); images.push_back(inImg); for (int x = 0;x < 12;x++) { map->addLine(); for (int y = 0; y < 12;y++) { map->addNode(x, y); map->getNode(x, y).setMyImage(images[objectSheet::grass]); } } spawnObject(person, 0, 0); Person* pers = dynamic_cast<Person*>((*gameObjects)[gameObjects->size() - 1]); if (pers) { guiHandler.inClick(pers); } for (int i = 0;i < 5;i++) { spawnObject(cow, 1, 1); spawnObject(person, 0, 0); } }
void SimpleGen::generate( Weapon* weapon ) { Object* owner = weapon->owner; Object* destObj = weapon->destObj; Vec2D dif = destObj->getPos() - owner->getPos(); float s= sqrtf(dif.length2()); Vec2D speed = ( weapon->bulletSpeed / s ) * dif; Object* bullet = weapon->createBullet(); bullet->setVelocity( speed ); spawnObject(bullet); }
void DirArrayGen::generate( Weapon* weapon ) { float len = ( num - 1 ) * offset; Vec2D arDir( dir.y , - dir.x ); Vec2D d = offset * arDir; Vec2D pos = difPos + ( - float(num) / 2 )* d; for( size_t i=0 ; i < num ; ++ i) { Object* bullet = weapon->createBullet(); bullet->shiftPos( pos ); bullet->setVelocity( weapon->bulletSpeed * dir ); spawnObject(bullet); pos += d; } }
bool SpawnSphere::onAdd() { if(!Parent::onAdd()) return(false); if(!isClientObject()) setMaskBits(UpdateSphereMask); if (!isGhost()) { onAdd_callback( getId()); if (mAutoSpawn) spawnObject(); } return true; }
void WidgetAugmentedView::createActions(QToolBar* menu) { QAction* action; ACTION_ICON("Spawn Object", spawnObject(), ":/add.png"); ACTION_ICON("Spawn Ball Small", spawnBallSmall(), ":/sport_golf.png"); ACTION_ICON("Spawn Ball Big", spawnBallBig(), ":/sport_soccer.png"); ACTION_ICON("Spawn Cube", spawnCube(), ":/package.png"); menu->addSeparator(); ACTION_ICON("Delete all objects", clearObjects(), ":/bin_closed.png"); menu->addSeparator(); ACTION_ICON("Change depth correction method", changeDepthCorrectionMethod(), ":/layers.png"); }
void Handler::mousePressed(int x, int y) { if (guiHandler.inClick(x, y)) { int toSpawn = guiHandler.getCurSelected(); float nX = x / 50; float nY = y / 50; int iX = abs(nX); int iY = abs(nY); spawnObject(toSpawn, iX, iY); return; } for (auto &obj : *gameObjects) { if (obj->getPos().x * 50 <= x && (obj->getPos().x * 50) + 50 >= x&&obj->getPos().y * 50 <= y && (obj->getPos().y * 50) + 50 >= y) { guiHandler.inClick(obj); return; } } }
void PetControlDeviceImplementation::callObject(CreatureObject* player) { if (player->isInCombat() || player->isDead() || player->isIncapacitated() || player->getPendingTask("tame_pet") != NULL) { player->sendSystemMessage("@pet/pet_menu:cant_call"); // You cannot call this pet right now. return; } if (player->isRidingMount()) { player->sendSystemMessage("@pet/pet_menu:mounted_call_warning"); // You cannot call a pet while mounted or riding a vehicle. return; } if (player->getParent() != NULL) { ManagedReference<SceneObject*> strongRef = player->getRootParent().get(); ManagedReference<BuildingObject*> building = NULL; if (strongRef != NULL) building = strongRef.castTo<BuildingObject*>(); if (building == NULL || building->isPrivateStructure()) { player->sendSystemMessage("@pet/pet_menu:private_house"); // You cannot call pets in a private building. return; } } if (!isASubChildOf(player)) return; ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get(); if (controlledObject == NULL || !controlledObject->isAiAgent()) return; ManagedReference<AiAgent*> pet = cast<AiAgent*>(controlledObject.get()); ManagedReference<PlayerObject*> ghost = player->getPlayerObject(); if (ghost->hasActivePet(pet)) return; if (vitality <= 0) { player->sendSystemMessage("@pet/pet_menu:dead_pet"); // This pet is dead. Select DESTROY from the radial menu to delete this pet control device. return; } if (!pet->getCooldownTimerMap()->isPast("call_cooldown")) { if (petType == PetManager::DROIDPET) player->sendSystemMessage("@pet/droid_modules:droid_maint_on_maint_run"); //You cannot call that droid. It is currently on a maintenance run. else player->sendSystemMessage("@pet/pet_menu:cant_call"); // cant call pet right now return; } assert(pet->isLockedByCurrentThread()); unsigned int petFaction = pet->getFaction(); if (petFaction != 0) { if (player->getFaction() == 0) { StringIdChatParameter message("@faction_perk:prose_be_declared"); // You must be declared to a faction to use %TT. message.setTT(pet->getDisplayedName()); player->sendSystemMessage(message); return; } if (player->getFaction() != petFaction || ghost->getFactionStatus() == FactionStatus::ONLEAVE) { StringIdChatParameter message("@faction_perk:prose_be_declared_faction"); // You must be a declared %TO to use %TT. message.setTO(pet->getFactionString()); message.setTT(pet->getDisplayedName()); player->sendSystemMessage(message); return; } } if(player->getPendingTask("call_pet") != NULL) { StringIdChatParameter waitTime("pet/pet_menu", "call_delay_finish_pet"); // Already calling a Pet: Call will be finished in %DI seconds. Time nextExecution; Core::getTaskManager()->getNextExecutionTime(player->getPendingTask("call_pet"), nextExecution); int timeLeft = (nextExecution.getMiliTime() / 1000) - System::getTime(); waitTime.setDI(timeLeft); player->sendSystemMessage(waitTime); return; } if (!growPet(player)) return; if (petType == PetManager::CREATUREPET && !isValidPet(pet)) { ManagedReference<SuiMessageBox*> box = new SuiMessageBox(player,SuiWindowType::PET_FIX_DIALOG); box->setCallback(new PetFixSuiCallback(player->getZoneServer(), _this.getReferenceUnsafeStaticCast())); box->setPromptText("@bio_engineer:pet_sui_text"); box->setPromptTitle("@bio_engineer:pet_sui_title"); box->setOkButton(true,"@bio_engineer:pet_sui_fix_stats"); box->setCancelButton(true,"@bio_engineer:pet_sui_abort"); box->setOtherButton(true,"@bio_engineer:pet_sui_fix_level"); box->setUsingObject(_this.getReferenceUnsafeStaticCast()); player->getPlayerObject()->addSuiBox(box); player->sendMessage(box->generateMessage()); return; } int currentlySpawned = 0; int spawnedLevel = 0; int maxPets = 1; int maxLevelofPets = 10; int level = pet->getLevel(); if (petType == PetManager::CREATUREPET) { ManagedReference<Creature*> creaturePet = cast<Creature*>(pet.get()); if (creaturePet == NULL) return; bool ch = player->hasSkill("outdoors_creaturehandler_novice"); if (ch) { maxPets = player->getSkillMod("keep_creature"); maxLevelofPets = player->getSkillMod("tame_level"); } if (creaturePet->getAdultLevel() > maxLevelofPets) { player->sendSystemMessage("@pet/pet_menu:control_exceeded"); // Calling this pet would exceed your Control Level ability. return; } if (creaturePet->isVicious() && (player->getSkillMod("tame_aggro") <= 0 || !ch)) { player->sendSystemMessage("@pet/pet_menu:lack_skill"); // You lack the skill to call a pet of this type. return; } } else if (petType == PetManager::FACTIONPET){ maxPets = 3; } for (int i = 0; i < ghost->getActivePetsSize(); ++i) { ManagedReference<AiAgent*> object = ghost->getActivePet(i); if (object != NULL) { if (object->isCreature() && petType == PetManager::CREATUREPET) { ManagedReference<CreatureTemplate*> activePetTemplate = object->getCreatureTemplate(); if (activePetTemplate == NULL || activePetTemplate->getTemplateName() == "at_st") continue; if (++currentlySpawned >= maxPets) { player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call. return; } spawnedLevel += object->getLevel(); if ((spawnedLevel + level) > maxLevelofPets) { player->sendSystemMessage("@pet/pet_menu:control_exceeded"); // Calling this pet would exceed your Control Level ability. return; } } else if (object->isNonPlayerCreatureObject() && petType == PetManager::FACTIONPET) { if (++currentlySpawned >= maxPets) { player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call. return; } } else if (object->isCreature() && petType == PetManager::FACTIONPET) { ManagedReference<CreatureTemplate*> activePetTemplate = object->getCreatureTemplate(); ManagedReference<CreatureTemplate*> callingPetTemplate = pet->getCreatureTemplate(); if (activePetTemplate == NULL || callingPetTemplate == NULL || activePetTemplate->getTemplateName() != "at_st") continue; if (++currentlySpawned >= maxPets || (activePetTemplate->getTemplateName() == "at_st" && callingPetTemplate->getTemplateName() == "at_st")) { player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call. return; } } else if (object->isDroidObject() && petType == PetManager::DROIDPET) { if (++currentlySpawned >= maxPets) { player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call. return; } } } } ManagedReference<TradeSession*> tradeContainer = player->getActiveSession(SessionFacadeType::TRADE).castTo<TradeSession*>(); if (tradeContainer != NULL) { server->getZoneServer()->getPlayerManager()->handleAbortTradeMessage(player); } if(player->getCurrentCamp() == NULL && player->getCityRegion() == NULL) { Reference<CallPetTask*> callPet = new CallPetTask(_this.getReferenceUnsafeStaticCast(), player, "call_pet"); StringIdChatParameter message("pet/pet_menu", "call_pet_delay"); // Calling pet in %DI seconds. Combat will terminate pet call. message.setDI(15); player->sendSystemMessage(message); player->addPendingTask("call_pet", callPet, 15 * 1000); if (petControlObserver == NULL) { petControlObserver = new PetControlObserver(_this.getReferenceUnsafeStaticCast()); petControlObserver->deploy(); } player->registerObserver(ObserverEventType::STARTCOMBAT, petControlObserver); } else { // Player is in a city or camp, spawn pet immediately if( player->getCooldownTimerMap() == NULL ) return; // Check cooldown if( !player->getCooldownTimerMap()->isPast("petCallOrStoreCooldown") ){ player->sendSystemMessage("@pet/pet_menu:cant_call_1sec"); //"You cannot CALL for 1 second." return; } spawnObject(player); // Set cooldown player->getCooldownTimerMap()->updateToCurrentAndAddMili("petCallOrStoreCooldown", 1000); // 1 sec } EnqueuePetCommand* enqueueCommand = new EnqueuePetCommand(pet, String("petFollow").toLowerCase().hashCode(), String::valueOf(player->getObjectID()), player->getObjectID(), 1); enqueueCommand->execute(); }
void Handler::spawnObject(int objectID, int _x, int _y) { spawnObject(objectID, ofVec2f(_x, _y)); }
void World::move(zf::Direction direction) { if (player and player->canMove()) { if (player->isGrabbing()) { auto mod = zf::getModifier(direction); auto playerTargetPosition = player->position + mod; bool canMove = true; if (inRange(playerTargetPosition)) { auto grabbed = player->getGrabbedObjects(); auto destinationObject = getObject(playerTargetPosition); if (!destinationObject || std::find(grabbed.begin(), grabbed.end(), destinationObject) != grabbed.end()) { for (auto object : grabbed) { if (!object->canGrabbed(direction, *player, grabbed)) { canMove = false; break; } } if (canMove) { moveObject(*player, player->position + mod); player->objectMoved(); for (auto object : grabbed) { moveObject (*object, object->position + mod); } player->doWork(game.balance.Player_MoveCost + grabbed.size() * game.balance.Player_GrabCost); } } } } else { auto mod = zf::getModifier(direction); auto targetPosition = player->position + mod; if (inRange(targetPosition)) { auto object = getObject(targetPosition); auto objectTargetPosition = targetPosition + mod; if (!object) { moveObject(*player, targetPosition); player->objectMoved(); player->doWork(game.balance.Player_MoveCost); } else if (object->type == WorldObject::ObjectType::FoodObject) { player->eat(); removeFromGrid(object); removeFromList(object); delete object; moveObject(*player, targetPosition); player->objectMoved(); } else if (inRange(objectTargetPosition)) { auto objectObstacle = getObject(objectTargetPosition); if (!object->isPushable()) { } else if (!objectObstacle) { moveObject(*player, targetPosition); player->objectMoved(); moveObject(*object, targetPosition + mod); player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost); } /// cant push, see if we can combine else if (object->type == WorldObject::ObjectType::SandObject && objectObstacle->type == WorldObject::ObjectType::SandObject) { // merge the sand object auto sandSource = static_cast<SandObject*>(object); auto sandTarget = static_cast<SandObject*>(objectObstacle); if (sandSource->count + sandTarget->count <= 4) { // can only merge if their total is < 4 sandTarget->count += sandSource->count; // respawn sandSource sandSource->count = 1; removeFromGrid(sandSource); removeFromList(sandSource); moveObject(*player, targetPosition); player->objectMoved(); if (spawnSand()) { spawnObject(sandSource); } else { delete sandSource; } } player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost); } else if (object->type == WorldObject::ObjectType::SandObject && objectObstacle->type == WorldObject::ObjectType::WaterObject) { auto sandSource = static_cast<SandObject*>(object); auto waterTarget = static_cast<WaterObject*>(objectObstacle); if (waterTarget->flood) { removeFromGrid(waterTarget); removeFromList(waterTarget); waterTarget->flood = false; waterTarget->floodMeter = 0; outputBlocks.push_back(waterTarget); sandSource->count-=1; if (sandSource->count <= 0) { removeFromGrid(sandSource); removeFromList(sandSource); delete sandSource; } else { moveObject(*sandSource, objectTargetPosition); } moveObject(*player, targetPosition); player->objectMoved(); } player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost); } else if (object->type == WorldObject::ObjectType::TreeObject && objectObstacle->type == WorldObject::ObjectType::WaterObject) { auto treeSource = static_cast<TreeObject*>(object); auto waterTarget = static_cast<WaterObject*>(objectObstacle); if (treeSource->grow()) { removeFromGrid(waterTarget); removeFromList(waterTarget); delete waterTarget; moveObject(*treeSource, objectTargetPosition); moveObject(*player, targetPosition); player->objectMoved(); } player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost); } else if (object->type == WorldObject::ObjectType::StoneObject && objectObstacle->type == WorldObject::ObjectType::VolcanoObject) { auto volcanoTarget = static_cast<VolcanoObject*>(objectObstacle); volcanoTarget->blocked = true; removeFromGrid(object); removeFromList(object); delete object; moveObject(*player, targetPosition); player->objectMoved(); player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost); } } } } } }
void VehicleControlDeviceImplementation::generateObject(CreatureObject* player) { if (player->isDead() || player->isIncapacitated()) return; if (!isASubChildOf(player)) return; if (player->getParent() != NULL || player->isInCombat()) { player->sendSystemMessage("@pet/pet_menu:cant_call_vehicle"); // You can only unpack vehicles while Outside and not in Combat. return; } ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get(); if (controlledObject == NULL) return; if (controlledObject->isInQuadTree()) return; ManagedReference<TradeSession*> tradeContainer = player->getActiveSession(SessionFacadeType::TRADE).castTo<TradeSession*>(); if (tradeContainer != NULL) { server->getZoneServer()->getPlayerManager()->handleAbortTradeMessage(player); } if(player->getPendingTask("call_mount") != NULL) { StringIdChatParameter waitTime("pet/pet_menu", "call_delay_finish_vehicle"); Time nextExecution; Core::getTaskManager()->getNextExecutionTime(player->getPendingTask("call_mount"), nextExecution); int timeLeft = (nextExecution.getMiliTime() / 1000) - System::getTime(); waitTime.setDI(timeLeft); player->sendSystemMessage(waitTime); return; } ManagedReference<SceneObject*> datapad = player->getSlottedObject("datapad"); if (datapad == NULL) return; int currentlySpawned = 0; for (int i = 0; i < datapad->getContainerObjectsSize(); ++i) { ManagedReference<SceneObject*> object = datapad->getContainerObject(i); if (object->isVehicleControlDevice()) { VehicleControlDevice* device = cast<VehicleControlDevice*>( object.get()); ManagedReference<SceneObject*> vehicle = device->getControlledObject(); if (vehicle != NULL && vehicle->isInQuadTree()) { if (++currentlySpawned > 2) player->sendSystemMessage("@pet/pet_menu:has_max_vehicle"); return; } } } if(player->getCurrentCamp() == NULL && player->getCityRegion() == NULL) { Reference<CallMountTask*> callMount = new CallMountTask(_this.getReferenceUnsafeStaticCast(), player, "call_mount"); StringIdChatParameter message("pet/pet_menu", "call_vehicle_delay"); message.setDI(15); player->sendSystemMessage(message); player->addPendingTask("call_mount", callMount, 15 * 1000); if (vehicleControlObserver == NULL) { vehicleControlObserver = new VehicleControlObserver(_this.getReferenceUnsafeStaticCast()); vehicleControlObserver->deploy(); } player->registerObserver(ObserverEventType::STARTCOMBAT, vehicleControlObserver); } else { Locker clocker(controlledObject, player); spawnObject(player); } }
void PetControlDeviceImplementation::callObject(CreatureObject* player) { if (player->isInCombat() || player->isDead() || player->isIncapacitated() || player->getPendingTask("tame_pet") != NULL) { player->sendSystemMessage("@pet/pet_menu:cant_call"); // You cannot call this pet right now. return; } if (player->isRidingMount()) { player->sendSystemMessage("@pet/pet_menu:mounted_call_warning"); // You cannot call a pet while mounted or riding a vehicle. return; } if (player->getParent() != NULL) { ManagedReference<SceneObject*> strongRef = player->getParentRecursively(SceneObjectType::BUILDING); ManagedReference<BuildingObject*> building; if (strongRef != NULL) building = strongRef.castTo<BuildingObject*>(); if (building == NULL || building->isPrivateStructure()) { player->sendSystemMessage("@pet/pet_menu:private_house"); // You cannot call pets in a private building. return; } } if (!isASubChildOf(player)) return; ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get(); if (controlledObject == NULL || !controlledObject->isAiAgent()) return; ManagedReference<AiAgent*> pet = cast<AiAgent*>(controlledObject.get()); ManagedReference<PlayerObject*> ghost = player->getPlayerObject(); if (ghost->hasActivePet(pet)) return; if (vitality <= 0) { player->sendSystemMessage("@pet/pet_menu:dead_pet"); // This pet is dead. Select DESTROY from the radial menu to delete this pet control device. return; } unsigned int petFaction = pet->getFaction(); if (petFaction != 0) { if (player->getFaction() == 0) { StringIdChatParameter message("@faction_perk:prose_be_declared"); // You must be declared to a faction to use %TT. message.setTT(pet->getDisplayedName()); player->sendSystemMessage(message); return; } if (player->getFaction() != petFaction || ghost->getFactionStatus() == FactionStatus::ONLEAVE) { StringIdChatParameter message("@faction_perk:prose_be_declared_faction"); // You must be a declared %TO to use %TT. message.setTO(pet->getFactionString()); message.setTT(pet->getDisplayedName()); player->sendSystemMessage(message); return; } } if(player->getPendingTask("call_pet") != NULL) { StringIdChatParameter waitTime("pet/pet_menu", "call_delay_finish_pet"); // Already calling a Pet: Call will be finished in %DI seconds. Time nextExecution; Core::getTaskManager()->getNextExecutionTime(player->getPendingTask("call_pet"), nextExecution); int timeLeft = (nextExecution.getMiliTime() / 1000) - System::getTime(); waitTime.setDI(timeLeft); player->sendSystemMessage(waitTime); return; } if (!growPet(player)) return; int currentlySpawned = 0; int spawnedLevel = 0; int maxPets = 1; int maxLevelofPets = 10; int level = pet->getLevel(); if (petType == PetManager::CREATUREPET) { bool ch = player->hasSkill("outdoors_creaturehandler_novice"); if (ch) { maxPets = player->getSkillMod("keep_creature"); maxLevelofPets = player->getSkillMod("tame_level"); } if (level > maxLevelofPets) { player->sendSystemMessage("@pet/pet_menu:control_exceeded"); // Calling this pet would exceed your Control Level ability. return; } ManagedReference<Creature*> creaturePet = cast<Creature*>(pet.get()); if (creaturePet != NULL && creaturePet->isVicious() && (player->getSkillMod("tame_aggro") <= 0 || !ch)) { player->sendSystemMessage("@pet/pet_menu:lack_skill"); // You lack the skill to call a pet of this type. return; } } else if (petType == PetManager::FACTIONPET){ maxPets = 3; } for (int i = 0; i < ghost->getActivePetsSize(); ++i) { ManagedReference<AiAgent*> object = ghost->getActivePet(i); if (object != NULL) { if (object->isCreature() && petType == PetManager::CREATUREPET) { if (++currentlySpawned >= maxPets) { player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call. return; } spawnedLevel += object->getLevel(); if ((spawnedLevel + level) > maxLevelofPets) { player->sendSystemMessage("@pet/pet_menu:control_exceeded"); // Calling this pet would exceed your Control Level ability. return; } } else if (object->isNonPlayerCreatureObject() && petType == PetManager::FACTIONPET) { if (++currentlySpawned >= maxPets) { player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call. return; } } else if (object->isDroidObject() && petType == PetManager::DROIDPET) { if (++currentlySpawned >= maxPets) { player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call. return; } } } } ManagedReference<TradeSession*> tradeContainer = player->getActiveSession(SessionFacadeType::TRADE).castTo<TradeSession*>(); if (tradeContainer != NULL) { server->getZoneServer()->getPlayerManager()->handleAbortTradeMessage(player); } if(player->getCurrentCamp() == NULL && player->getCityRegion() == NULL) { Reference<CallPetTask*> callPet = new CallPetTask(_this.get(), player, "call_pet"); StringIdChatParameter message("pet/pet_menu", "call_pet_delay"); // Calling pet in %DI seconds. Combat will terminate pet call. message.setDI(15); player->sendSystemMessage(message); player->addPendingTask("call_pet", callPet, 15 * 1000); if (petControlObserver == NULL) { petControlObserver = new PetControlObserver(_this.get()); petControlObserver->deploy(); } player->registerObserver(ObserverEventType::STARTCOMBAT, petControlObserver); } else { // Player is in a city or camp, spawn pet immediately if( player->getCooldownTimerMap() == NULL ) return; // Check cooldown if( !player->getCooldownTimerMap()->isPast("petCallOrStoreCooldown") ){ player->sendSystemMessage("@pet/pet_menu:cant_call_1sec"); //"You cannot CALL for 1 second." return; } Locker clocker(controlledObject, player); spawnObject(player); // Set cooldown player->getCooldownTimerMap()->updateToCurrentAndAddMili("petCallOrStoreCooldown", 1000); // 1 sec } }