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); } }
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); } }
void InstallationObjectImplementation::broadcastToOperators(BasePacket* packet) { for (int i = 0; i < operatorList.size(); ++i) { CreatureObject* player = operatorList.get(i); player->sendMessage(packet->clone()); } delete packet; }
void SuiManager::sendListBox(SceneObject* usingObject, SceneObject* player, const String& title, const String& text, const uint8& numOfButtons, const String& cancelButton, const String& otherButton, const String& okButton, LuaObject& options, 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<SuiListBox*> box = NULL; switch (numOfButtons) { case 1: box = new SuiListBox(creature, 0x00, SuiListBox::HANDLESINGLEBUTTON); box->setCancelButton(false, ""); box->setOtherButton(false, ""); box->setOkButton(true, okButton); break; case 2: box = new SuiListBox(creature, 0x00, SuiListBox::HANDLETWOBUTTON); box->setCancelButton(true, cancelButton); box->setOtherButton(false, ""); box->setOkButton(true, okButton); break; case 3: box = new SuiListBox(creature, 0x00, SuiListBox::HANDLETHREEBUTTON); box->setCancelButton(true, cancelButton); box->setOtherButton(true, otherButton); box->setOkButton(true, okButton); break; default: return; break; } if(options.isValidTable()){ for(int i = 1; i <= options.getTableSize(); ++i){ String optionString = options.getStringAt(i); box->addMenuItem(optionString); } options.pop(); } box->setCallback(new LuaSuiCallback(creature->getZoneServer(), screenplay, callback)); box->setPromptTitle(title); box->setPromptText(text); box->setUsingObject(usingObject); box->setForceCloseDistance(32.f); creature->sendMessage(box->generateMessage()); playerObject->addSuiBox(box); } }
void GroupObjectImplementation::broadcastMessage(BaseMessage* msg) { for (int i = 0; i < groupMembers.size(); i++) { CreatureObject* member = groupMembers.get(i).get().get(); if (member->isPlayerCreature()) member->sendMessage(msg->clone()); } delete msg; }
void GroupObjectImplementation::broadcastMessage(CreatureObject* player, BaseMessage* msg, bool sendSelf) { for (int i = 0; i < groupMembers.size(); i++) { CreatureObject* member = groupMembers.get(i).get().get(); if(!sendSelf && member == player) continue; if (member->isPlayerCreature()) member->sendMessage(msg->clone()); } delete msg; }
int DestroyStructureSessionImplementation::initializeSession() { //TODO: Temporary until CreatureObject* dependency removed. if (!creatureObject->isPlayerCreature()) return cancelSession(); creatureObject->addActiveSession(SessionFacadeType::DESTROYSTRUCTURE, _this.getReferenceUnsafeStaticCast()); Locker _lock(structureObject, creatureObject); CreatureObject* player = cast<CreatureObject*>( creatureObject.get()); String no = "\\#FF6347 @player_structure:can_redeed_no_suffix \\#."; String yes = "\\#32CD32 @player_structure:can_redeed_yes_suffix \\#."; String redeed = (structureObject->isRedeedable()) ? yes : no; StringBuffer maint; maint << "@player_structure:redeed_maintenance \\#" << ((structureObject->isRedeedable()) ? "32CD32 " : "FF6347 ") << structureObject->getSurplusMaintenance() << "/" << structureObject->getRedeedCost() << "\\#."; StringBuffer entry; entry << "@player_structure:confirm_destruction_d1 "; entry << "@player_structure:confirm_destruction_d2 \n\n"; entry << "@player_structure:confirm_destruction_d3a "; entry << "\\#32CD32 @player_structure:confirm_destruction_d3b \\#. "; entry << "@player_structure:confirm_destruction_d4 \n"; entry << "@player_structure:redeed_confirmation " << redeed; StringBuffer cond; cond << "@player_structure:redeed_condition \\#32CD32 " << (structureObject->getMaxCondition() - structureObject->getConditionDamage()) << "/" << structureObject->getMaxCondition() << "\\#."; ManagedReference<SuiListBox*> sui = new SuiListBox(player); sui->setCallback(new DestroyStructureRequestSuiCallback(creatureObject->getZoneServer())); sui->setCancelButton(true, "@no"); sui->setOkButton(true, "@yes"); sui->setUsingObject(structureObject); sui->setPromptTitle(structureObject->getDisplayedName()); sui->setPromptText(entry.toString()); sui->addMenuItem("@player_structure:can_redeed_alert " + redeed); sui->addMenuItem(cond.toString()); sui->addMenuItem(maint.toString()); player->getPlayerObject()->addSuiBox(sui); player->sendMessage(sui->generateMessage()); return 0; }
void SuiManager::sendTransferBox(SceneObject* usingObject, SceneObject* player, const String& title, const String& text, LuaObject& optionsAddFrom, LuaObject& optionsAddTo, 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<SuiTransferBox*> box = NULL; box = new SuiTransferBox(creature, 0x00); if(optionsAddFrom.isValidTable()){ String optionAddFromTextString = optionsAddFrom.getStringAt(1); String optionAddFromStartingString = optionsAddFrom.getStringAt(2); String optionAddFromRatioString = optionsAddFrom.getStringAt(3); box->addFrom(optionAddFromTextString, optionAddFromStartingString, optionAddFromStartingString, optionAddFromRatioString); optionsAddFrom.pop(); } if(optionsAddTo.isValidTable()){ String optionAddToTextString = optionsAddTo.getStringAt(1); String optionAddToStartingString = optionsAddTo.getStringAt(2); String optionAddToRatioString = optionsAddTo.getStringAt(3); box->addTo(optionAddToTextString, optionAddToStartingString, optionAddToStartingString, optionAddToRatioString); optionsAddTo.pop(); } box->setCallback(new LuaSuiCallback(creature->getZoneServer(), screenplay, callback)); box->setPromptTitle(title); box->setPromptText(text); box->setUsingObject(usingObject); box->setForceCloseDistance(32.f); creature->sendMessage(box->generateMessage()); playerObject->addSuiBox(box); } }
void MissionObjectImplementation::updateMissionLocation() { if (getMissionObjective() == NULL || getMissionObjective()->getPlayerOwner() == NULL) { return; } CreatureObject* playerCreature = getMissionObjective()->getPlayerOwner().castTo<CreatureObject*>(); ManagedReference<WaypointObject* > waypointToMission = this->waypointToMission; if (playerCreature != NULL && waypointToMission != NULL) { MissionObjectDeltaMessage3* dmiso3 = new MissionObjectDeltaMessage3(_this.get()); dmiso3->updateWaypoint(waypointToMission); dmiso3->close(); playerCreature->sendMessage(dmiso3); if (playerCreature->isGrouped() && playerCreature->getGroup() != NULL) { GroupObject* group = playerCreature->getGroup(); group->scheduleUpdateNearestMissionForGroup(playerCreature->getPlanetCRC()); } } }
void SuiManager::sendKeypadSui(SceneObject* keypad, SceneObject* creatureSceneObject, const String& play, const String& callback) { if (keypad == NULL) return; if (creatureSceneObject == NULL || !creatureSceneObject->isCreatureObject()) return; CreatureObject* creature = cast<CreatureObject*>(creatureSceneObject); PlayerObject* playerObject = creature->getPlayerObject(); if (playerObject != NULL) { ManagedReference<SuiKeypadBox*> keypadSui = new SuiKeypadBox(creature, 0x00); keypadSui->setCallback(new LuaSuiCallback(creature->getZoneServer(), play, callback)); keypadSui->setUsingObject(keypad); keypadSui->setForceCloseDisabled(); creature->sendMessage(keypadSui->generateMessage()); playerObject->addSuiBox(keypadSui); } }
int DestroyStructureSessionImplementation::sendDestroyCode() { //TODO: Temporary until CreatureObject* dependency removed. if (!creatureObject->isPlayerCreature()) return cancelSession(); Locker structureLock(structureObject); Locker _lock(creatureObject, structureObject); CreatureObject* player = cast<CreatureObject*>( creatureObject.get()); destroyCode = System::random(899999) + 100000; String no = "\\#FF6347 @player_structure:will_not_redeed_confirm \\#."; String yes = "\\#32CD32 @player_structure:will_redeed_confirm \\#."; String redeed = (structureObject->isRedeedable()) ? yes : no; StringBuffer entry; entry << "@player_structure:your_structure_prefix "; entry << redeed << " @player_structure:will_redeed_suffix \n\n"; entry << "Code: " << destroyCode; ManagedReference<SuiInputBox*> sui = new SuiInputBox(player); sui->setCallback(new DestroyStructureCodeSuiCallback(player->getZoneServer())); sui->setUsingObject(structureObject); sui->setPromptTitle("@player_structure:confirm_destruction_t"); //Confirm Structure Deletion sui->setPromptText(entry.toString()); sui->setCancelButton(true, "@cancel"); sui->setMaxInputSize(6); player->getPlayerObject()->addSuiBox(sui); player->sendMessage(sui->generateMessage()); return 0; }
void ChatManagerImplementation::broadcastMessage(CreatureObject* player, const UnicodeString& message, uint64 target, uint32 moodid, uint32 mood2) { Zone* zone = player->getZone(); PlayerObject* myGhost = NULL; bool godMode = false; if (zone == NULL) return; int language = 0; String firstName; if (player->isPlayerCreature() /*|| !((Player *)player)->isChatMuted() */) { CreatureObject* playerCreature = cast<CreatureObject*>(player); if (playerCreature) { firstName = playerCreature->getFirstName().toLowerCase(); myGhost = playerCreature->getPlayerObject(); } if (myGhost) language = myGhost->getLanguageID(); } if (myGhost) { if (myGhost->hasGodMode()) godMode = true; } StringIdChatParameter* param = NULL; if (message[0] == '@' && message.indexOf(":") != -1) { param = new StringIdChatParameter(message.toString()); } CloseObjectsVector* closeObjects = (CloseObjectsVector*) player->getCloseObjects(); SortedVector<QuadTreeEntry*> closeEntryObjects(200, 50); if (closeObjects != NULL) { closeObjects->safeCopyTo(closeEntryObjects); } else { player->info("Null closeobjects vector in ChatManager::broadcastMessage", true); zone->getInRangeObjects(player->getWorldPositionX(), player->getWorldPositionY(), 128, &closeEntryObjects, true); } float range = defaultSpatialChatDistance; float specialRange = spatialChatDistances.get(mood2); if (specialRange != -1) { range = specialRange; } try { for (int i = 0; i < closeEntryObjects.size(); ++i) { SceneObject* object = cast<SceneObject*>(closeEntryObjects.get(i)); if (player->isInRange(object, range)) { //Notify observers that are expecting spatial chat. if (object->getObserverCount(ObserverEventType::SPATIALCHATRECEIVED)) { ManagedReference<ChatMessage*> chatMessage = new ChatMessage(); chatMessage->setString(message.toString()); EXECUTE_TASK_3(object, chatMessage, player, { if (player_p == NULL || object_p == NULL) return; Locker locker(object_p); SortedVector<ManagedReference<Observer*> > observers = object_p->getObservers(ObserverEventType::SPATIALCHATRECEIVED); for (int oc = 0; oc < observers.size(); oc++) { Observer* observer = observers.get(oc); Locker clocker(observer, object_p); if (observer->notifyObserverEvent(ObserverEventType::SPATIALCHATRECEIVED, object_p, chatMessage_p, player_p->getObjectID()) == 1) object_p->dropObserver(ObserverEventType::SPATIALCHATRECEIVED, observer); } }); } if (object->isPlayerCreature()) { CreatureObject* creature = cast<CreatureObject*>(object); PlayerObject* ghost = creature->getPlayerObject(); if (ghost == NULL) continue; if (!ghost->isIgnoring(firstName) || godMode) { SpatialChat* cmsg = NULL; if (param == NULL) { cmsg = new SpatialChat(player->getObjectID(), creature->getObjectID(), message, target, moodid, mood2, language); } else { cmsg = new SpatialChat(player->getObjectID(), creature->getObjectID(), *param, target, moodid, mood2); } creature->sendMessage(cmsg); } } else if( object->isPet() ){ AiAgent* pet = cast<AiAgent*>(object); if (pet == NULL ) continue; if( pet->isDead() || pet->isIncapacitated() ) continue; PetManager* petManager = server->getPetManager(); Locker clocker(pet, player); petManager->handleChat( player, pet, message.toString() ); } } }
void ChatManagerImplementation::handleSocialInternalMessage(CreatureObject* sender, const UnicodeString& arguments) { if (sender->isPlayerCreature()) { ManagedReference<PlayerObject*> senderGhost = sender->getPlayerObject(); if (senderGhost == NULL) return; if (senderGhost->isMuted()) { String reason = senderGhost->getMutedReason(); if (reason != "") sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support for '" + reason + "'."); else sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support."); return; } } Zone* zone = sender->getZone(); if (zone == NULL) return; StringTokenizer tokenizer(arguments.toString()); uint64 targetid; uint32 emoteid, unkint, unkint2; try { targetid = tokenizer.getLongToken(); emoteid = tokenizer.getIntToken(); unkint = tokenizer.getIntToken(); unkint2 = tokenizer.getIntToken(); } catch (const Exception& e) { return; } //bool readlock = !zone->isLockedByCurrentThread(); bool showtext = true; if (unkint2 == 0) showtext = false; String firstName; if (sender->isPlayerCreature()) firstName = (cast<CreatureObject*>(sender))->getFirstName().toLowerCase(); CloseObjectsVector* vec = (CloseObjectsVector*) sender->getCloseObjects(); SortedVector<QuadTreeEntry* > closeEntryObjects(200, 50); if (vec != NULL) { vec->safeCopyTo(closeEntryObjects); } else { sender->info("Null closeobjects vector in ChatManager::handleSocialInternalMessage", true); zone->getInRangeObjects(sender->getWorldPositionX(), sender->getWorldPositionX(), 128, &closeEntryObjects, true); } float range = defaultSpatialChatDistance; for (int i = 0; i < closeEntryObjects.size(); ++i) { SceneObject* object = cast<SceneObject*>(closeEntryObjects.get(i)); if (object->isPlayerCreature()) { CreatureObject* creature = cast<CreatureObject*>(object); Reference<PlayerObject*> ghost = creature->getSlottedObject("ghost").castTo<PlayerObject*>(); if (ghost == NULL) continue; if (!ghost->isIgnoring(firstName) && creature->isInRange(sender, range)) { Emote* emsg = new Emote(creature, sender, targetid, emoteid, showtext); creature->sendMessage(emsg); } } } }
void ImageDesignSessionImplementation::updateImageDesign(CreatureObject* updater, uint64 designer, uint64 targetPlayer, uint64 tent, int type, const ImageDesignData& data) { ManagedReference<CreatureObject*> strongReferenceTarget = targetCreature.get(); ManagedReference<CreatureObject*> strongReferenceDesigner = designerCreature.get(); if (strongReferenceTarget == NULL || strongReferenceDesigner == NULL) return; Locker locker(strongReferenceDesigner); Locker clocker(strongReferenceTarget, strongReferenceDesigner); imageDesignData = data; CreatureObject* targetObject = NULL; if (updater == strongReferenceDesigner) targetObject = strongReferenceTarget; else targetObject = strongReferenceDesigner; //ManagedReference<SceneObject*> obj = targetObject->getParentRecursively(SceneObjectType::SALONBUILDING); //tent = obj != NULL ? obj->getObjectID() ImageDesignChangeMessage* message = new ImageDesignChangeMessage(targetObject->getObjectID(), designer, targetPlayer, tent, type); imageDesignData.insertToMessage(message); bool commitChanges = false; if (imageDesignData.isAcceptedByDesigner()) { commitChanges = true; if (strongReferenceDesigner != strongReferenceTarget && !imageDesignData.isAcceptedByTarget()) { commitChanges = false; if (idTimeoutEvent == NULL) idTimeoutEvent = new ImageDesignTimeoutEvent(_this.get()); if (!idTimeoutEvent->isScheduled()) idTimeoutEvent->schedule(120000); //2 minutes } else { commitChanges = doPayment(); } } //System::out << h << endl; if (commitChanges) { //TODO: set XP Values int xpGranted = 0; // Minimum Image Design XP granted (base amount). //if (imageDesignData.mi) String hairTemplate = imageDesignData.getHairTemplate(); bool statMig = imageDesignData.isStatMigrationRequested(); if (statMig && strongReferenceDesigner->getParentRecursively(SceneObjectType::SALONBUILDING).get().get() && strongReferenceDesigner->getParentRecursively(SceneObjectType::SALONBUILDING).get().get() && strongReferenceDesigner != strongReferenceTarget) { ManagedReference<Facade*> facade = strongReferenceTarget->getActiveSession(SessionFacadeType::MIGRATESTATS); ManagedReference<MigrateStatsSession*> session = dynamic_cast<MigrateStatsSession*>(facade.get()); if (session != NULL) { session->migrateStats(); xpGranted = 2000; } } VectorMap<String, float>* bodyAttributes = imageDesignData.getBodyAttributesMap(); VectorMap<String, uint32>* colorAttributes = imageDesignData.getColorAttributesMap(); ImageDesignManager* imageDesignManager = ImageDesignManager::instance(); hairObject = strongReferenceTarget->getSlottedObject("hair").castTo<TangibleObject*>(); if (type == 1) { String oldCustomization; if (hairObject != NULL) hairObject->getCustomizationString(oldCustomization); hairObject = imageDesignManager->createHairObject(strongReferenceDesigner, strongReferenceTarget, imageDesignData.getHairTemplate(), imageDesignData.getHairCustomizationString()); if (hairObject != NULL) hairObject->setCustomizationString(oldCustomization); if (xpGranted < 100) xpGranted = 100; } if (bodyAttributes->size() > 0) { if (xpGranted < 300) xpGranted = 300; for (int i = 0; i < bodyAttributes->size(); ++i) { VectorMapEntry<String, float>* entry = &bodyAttributes->elementAt(i); imageDesignManager->updateCustomization(strongReferenceDesigner, entry->getKey(), entry->getValue(), strongReferenceTarget); } } if (colorAttributes->size() > 0) { if(xpGranted < 100) xpGranted = 100; for (int i = 0; i < colorAttributes->size(); ++i) { VectorMapEntry<String, uint32>* entry = &colorAttributes->elementAt(i); imageDesignManager->updateColorCustomization(strongReferenceDesigner, entry->getKey(), entry->getValue(), hairObject, strongReferenceTarget); } } imageDesignManager->updateHairObject(strongReferenceTarget, hairObject); // Add holo emote String holoemote = imageDesignData.getHoloEmote(); if( !holoemote.isEmpty() ){ PlayerObject* ghost = strongReferenceTarget->getPlayerObject(); ghost->setInstalledHoloEmote( holoemote ); // Also resets number of uses available strongReferenceTarget->sendSystemMessage("@image_designer:new_holoemote"); //"Congratulations! You have purchased a new Holo-Emote generator. Type '/holoemote help' for instructions." if(xpGranted < 100) xpGranted = 100; } // Drop the Session for both the designer and the targetCreature; strongReferenceDesigner->dropActiveSession(SessionFacadeType::IMAGEDESIGN); strongReferenceTarget->dropActiveSession(SessionFacadeType::IMAGEDESIGN); // Award XP. PlayerManager* playerManager = strongReferenceDesigner->getZoneServer()->getPlayerManager(); if (playerManager != NULL && xpGranted > 0) { if(strongReferenceDesigner == strongReferenceTarget) xpGranted /= 2; playerManager->awardExperience(strongReferenceDesigner, "imagedesigner", xpGranted, true); } if (idTimeoutEvent != NULL && idTimeoutEvent->isScheduled()) dequeueIdTimeoutEvent(); } targetObject->sendMessage(message); }