bool CreatureManagerImplementation::addWearableItem(CreatureObject* creature, TangibleObject* clothing) { if (!clothing->isWearableObject() && !clothing->isWeaponObject()) return false; ChatManager* chatMan = zoneServer->getChatManager(); SharedTangibleObjectTemplate* tanoData = dynamic_cast<SharedTangibleObjectTemplate*>(clothing->getObjectTemplate()); Vector<uint32>* races = tanoData->getPlayerRaces(); String race = creature->getObjectTemplate()->getFullTemplateString(); if(clothing->isWearableObject()) { if (!races->contains(race.hashCode())) { UnicodeString message; if(creature->getObjectTemplate()->getFullTemplateString().contains("ithorian")) message = "@player_structure:wear_not_ithorian"; else message = "@player_structure:wear_no"; chatMan->broadcastMessage(creature, message, clothing->getObjectID(), creature->getMoodID(), 0); return false; } } ManagedReference<SceneObject*> clothingParent = clothing->getParent(); if (clothingParent == NULL) return false; for (int i = 0; i < clothing->getArrangementDescriptorSize(); ++i) { Vector<String> descriptors = clothing->getArrangementDescriptor(i); for (int j = 0; j < descriptors.size(); ++j) { ManagedReference<SceneObject*> slot = creature->getSlottedObject(descriptors.get(j)); if (slot != NULL) { slot->destroyObjectFromWorld(true); slot->destroyObjectFromDatabase(true); } } } creature->transferObject(clothing, 4, false); creature->doAnimation("pose_proudly"); creature->broadcastObject(clothing, true); UnicodeString message; if(clothing->isWeaponObject()) message = "@player_structure:wear_yes_weapon"; else message = "@player_structure:wear_yes"; chatMan->broadcastMessage(creature, message, clothing->getObjectID(), creature->getMoodID(), 0); return true; }
int LuaAiAgent::spatialChat(lua_State* L) { ZoneServer* zoneServer = ServerCore::getZoneServer(); if (zoneServer == NULL) return 0; ChatManager* chatManager = zoneServer->getChatManager(); if (lua_islightuserdata(L, -1)) { StringIdChatParameter* message = (StringIdChatParameter*)lua_touserdata(L, -1); if (realObject != NULL && message != NULL) { chatManager->broadcastMessage(realObject, *message, 0, 0, 0); } } else { String message = lua_tostring(L, -1); if (realObject != NULL) { chatManager->broadcastMessage(realObject, message, 0, 0, 0); } } return 0; }
void CreatureManagerImplementation::tame(Creature* creature, CreatureObject* player, bool force) { Zone* zone = creature->getZone(); if (zone == NULL || !creature->isCreature()) return; if(player->getPendingTask("tame_pet") != NULL) { player->sendSystemMessage("You are already taming a pet"); return; } if(player->getPendingTask("call_pet") != NULL) { player->sendSystemMessage("You cannot tame a pet while another is being called"); return; } if (!creature->canTameMe(player) || !creature->isAttackableBy(player)) { player->sendSystemMessage("@pet/pet_menu:sys_cant_tame"); // You can't tame that return; } CreatureTemplate* creatureTemplate = creature->getCreatureTemplate(); if (creatureTemplate == NULL) return; int templateLevel = creatureTemplate->getLevel(); int maxLevelofPets = player->getSkillMod("tame_level"); if (!player->hasSkill("outdoors_creaturehandler_novice") || (templateLevel > maxLevelofPets)) { player->sendSystemMessage("@pet/pet_menu:sys_lack_skill"); // You lack the skill to be able to tame that creature. return; } if ((creature->isVicious() && player->getSkillMod("tame_aggro") < 1) || creature->getChanceToTame(player) <= 0) { player->sendSystemMessage("@pet/pet_menu:sys_lack_skill"); // You lack the skill to be able to tame that creature. return; } ManagedReference<SceneObject*> datapad = player->getSlottedObject("datapad"); if (datapad == NULL) return; if (datapad->getContainerObjectsSize() >= datapad->getContainerVolumeLimit()) { player->sendSystemMessage("@faction_recruiter:datapad_full"); // Your datapad is full. You must first free some space. return; } ManagedReference<PlayerManager*> playerManager = zoneServer->getPlayerManager(); int numberStored = 0; int maxStoredPets = playerManager->getBaseStoredCreaturePets() + player->getSkillMod("stored_pets"); for (int i = 0; i < datapad->getContainerObjectsSize(); ++i) { ManagedReference<SceneObject*> object = datapad->getContainerObject(i); if (object != NULL && object->isPetControlDevice()) { PetControlDevice* device = cast<PetControlDevice*>( object.get()); if (device->getPetType() == PetManager::CREATUREPET) { if (++numberStored >= maxStoredPets) { player->sendSystemMessage("@pet/pet_menu:sys_too_many_stored"); // There are too many pets stored in this container. Release some of them to make room for more. return; } } } } ManagedReference<PlayerObject*> ghost = player->getPlayerObject(); int currentlySpawned = 0; int spawnedLevel = 0; int level = creature->getLevel(); int maxPets = player->getSkillMod("keep_creature"); for (int i = 0; i < ghost->getActivePetsSize(); ++i) { ManagedReference<AiAgent*> object = ghost->getActivePet(i); if (object != NULL) { ManagedReference<PetControlDevice*> pcd = object->getControlDevice().get().castTo<PetControlDevice*>(); if (pcd == NULL || pcd->getPetType() != PetManager::CREATUREPET) { continue; } if (++currentlySpawned >= maxPets) { player->sendSystemMessage("@pet/pet_menu:too_many"); // You can't control any more pets. Store one first return; } spawnedLevel += object->getLevel(); if ((spawnedLevel + level) >= maxLevelofPets) { player->sendSystemMessage("Taming this pet would exceed your control level ability."); return; } } } if (force && !ghost->isPrivileged()) force = false; ChatManager* chatManager = player->getZoneServer()->getChatManager(); chatManager->broadcastMessage(player, "@hireling/hireling:taming_1"); // Easy. Locker clocker(creature); int mask = creature->getPvpStatusBitmask(); creature->setPvpStatusBitmask(0, true); if (creature->isAiAgent()) { AiAgent* agent = cast<AiAgent*>(creature); agent->activateLoad("wait"); } ManagedReference<TameCreatureTask*> task = new TameCreatureTask(creature, player, mask, force); player->addPendingTask("tame_pet", task, 8000); }
bool FactionRecruiterContainerComponent::transferObject(SceneObject* sceneObject, SceneObject* object, int containmentType, bool notifyClient, bool allowOverflow) { CoaMessageDataComponent* data = object->getDataObjectComponent()->castTo<CoaMessageDataComponent*>(); if (data == NULL) { return false; } CreatureObject* player = object->getParentRecursively(SceneObjectType::PLAYERCREATURE).get().castTo<CreatureObject*>(); if (player == NULL) { return false; } ZoneServer* zoneServer = player->getZoneServer(); PlayerObject* ghost = player->getPlayerObject(); if (zoneServer == NULL || ghost == NULL) { return false; } if (!sceneObject->isAiAgent()) { return false; } AiAgent* recruiter = cast<AiAgent*>(sceneObject); String recruiterFaction = recruiter->getFactionString().toLowerCase(); bool hasBadge = ghost->hasBadge(Badge::EVENT_PROJECT_DEAD_EYE_1); String faction = data->getFaction().toLowerCase(); StringBuffer response; response << "@encoded_disk/message_fragment:response_event"; if (faction == "rebel") { response << "reb1_"; } else if (faction == "imperial") { response << "imp1_"; } response << recruiterFaction; ChatManager* chatManager = zoneServer->getChatManager(); if (chatManager == NULL) { return false; } Locker locker(recruiter); chatManager->broadcastMessage(recruiter,response.toString(), 0, 0, 0); object->destroyObjectFromWorld(true); object->destroyObjectFromDatabase(); int credits = System::random(500) + 500; player->sendSystemMessage("You receive " + String::valueOf(credits) + " credits."); player->addCashCredits(credits, true); if (!hasBadge) { ghost->awardBadge(Badge::EVENT_PROJECT_DEAD_EYE_1); ghost->increaseFactionStanding(recruiterFaction, 500); } return true; }