VectorMap<String, int>* TangibleObjectImplementation::getTemplateSkillMods() { SharedTangibleObjectTemplate* tano = dynamic_cast<SharedTangibleObjectTemplate*>(templateObject.get()); if (tano == NULL) return NULL; return tano->getSkillMods(); }
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; }
Reference<FactoryCrate*> TangibleObjectImplementation::createFactoryCrate(bool insertSelf) { String file; uint32 type = getGameObjectType(); if(type & SceneObjectType::ARMOR) file = "object/factory/factory_crate_armor.iff"; else if(type == SceneObjectType::CHEMICAL || type == SceneObjectType::PHARMACEUTICAL || type == SceneObjectType::PETMEDECINE) file = "object/factory/factory_crate_chemicals.iff"; else if(type & SceneObjectType::CLOTHING) file = "object/factory/factory_crate_clothing.iff"; else if(type == SceneObjectType::ELECTRONICS) file = "object/factory/factory_crate_electronics.iff"; else if(type == SceneObjectType::FOOD || type == SceneObjectType::DRINK) file = "object/factory/factory_crate_food.iff"; else if(type == SceneObjectType::FURNITURE) file = "object/factory/factory_crate_furniture.iff"; else if(type & SceneObjectType::INSTALLATION) file = "object/factory/factory_crate_installation.iff"; else if(type & SceneObjectType::WEAPON) file = "object/factory/factory_crate_weapon.iff"; else file = "object/factory/factory_crate_generic_items.iff"; ObjectManager* objectManager = ObjectManager::instance(); Reference<FactoryCrate*> crate = (getZoneServer()->createObject(file.hashCode(), 2)).castTo<FactoryCrate*>(); if (crate == NULL) return NULL; SharedTangibleObjectTemplate* tanoData = dynamic_cast<SharedTangibleObjectTemplate*>(templateObject.get()); if (tanoData == NULL) return NULL; crate->setMaxCapacity(tanoData->getFactoryCrateSize()); if (insertSelf) { crate->transferObject(_this.get(), -1, false); } else { ManagedReference<TangibleObject*> protoclone = cast<TangibleObject*>( objectManager->cloneObject(_this.get())); if (protoclone == NULL) return NULL; protoclone->setParent(NULL); crate->transferObject(protoclone, -1, false); } crate->setCustomObjectName(getCustomObjectName(), false); crate->setUseCount(1); return crate; }
void TangibleObjectImplementation::loadTemplateData(SharedObjectTemplate* templateData) { SceneObjectImplementation::loadTemplateData(templateData); SharedTangibleObjectTemplate* tanoData = dynamic_cast<SharedTangibleObjectTemplate*>(templateData); if (tanoData == NULL) return; targetable = tanoData->getTargetable(); maxCondition = tanoData->getMaxCondition(); invisible = tanoData->isInvisible(); useCount = tanoData->getUseCount(); optionsBitmask = tanoData->getOptionsBitmask(); pvpStatusBitmask = tanoData->getPvpStatusBitmask(); sliceable = tanoData->getSliceable(); faction = tanoData->getFaction(); threatMap = NULL; }
void TangibleObjectImplementation::removeTemplateSkillMods(TangibleObject* targetObject) { SharedTangibleObjectTemplate* tano = dynamic_cast<SharedTangibleObjectTemplate*>(templateObject.get()); if (tano == NULL) return; VectorMap<String, int>* mods = tano->getSkillMods(); for (int i = 0; i < mods->size(); ++i) { VectorMapEntry<String, int> entry = mods->elementAt(i); targetObject->removeSkillMod(SkillModManager::TEMPLATE, entry.getKey(), entry.getValue()); } }
void LootManagerImplementation::setInitialObjectStats(LootItemTemplate* templateObject, CraftingValues* craftingValues, TangibleObject* prototype) { SharedTangibleObjectTemplate* tanoTemplate = dynamic_cast<SharedTangibleObjectTemplate*>(prototype->getObjectTemplate()); if (tanoTemplate != NULL) { Vector<String>* titles = tanoTemplate->getExperimentalGroupTitles(); Vector<String>* props = tanoTemplate->getExperimentalSubGroupTitles(); Vector<float>* mins = tanoTemplate->getExperimentalMin(); Vector<float>* maxs = tanoTemplate->getExperimentalMax(); Vector<short>* prec = tanoTemplate->getExperimentalPrecision(); for (int i = 0; i < props->size(); ++i) { String title = titles->get(i); String property = props->get(i); if (craftingValues->hasProperty(property)) continue; craftingValues->addExperimentalProperty(property, property, mins->get(i), maxs->get(i), prec->get(i), false, CraftingManager::LINEARCOMBINE); if (title == "null") craftingValues->setHidden(property); } } Vector<String>* customizationData = templateObject->getCustomizationStringNames(); Vector<Vector<int> >* customizationValues = templateObject->getCustomizationValues(); for (int i = 0; i < customizationData->size(); ++i) { String customizationString = customizationData->get(i); Vector<int>* values = &customizationValues->get(i); if (values->size() > 0) { int randomValue = values->get(System::random(values->size() - 1)); prototype->setCustomizationVariable(customizationString, randomValue, false); } } }
int PlayerContainerComponent::canAddObject(SceneObject* sceneObject, SceneObject* object, int containmentType, String& errorDescription) { CreatureObject* creo = dynamic_cast<CreatureObject*>(sceneObject); if (object->isTangibleObject() && containmentType == 4) { TangibleObject* wearable = cast<TangibleObject*>( object); SharedTangibleObjectTemplate* tanoData = dynamic_cast<SharedTangibleObjectTemplate*>(wearable->getObjectTemplate()); Vector<uint32>* races = tanoData->getPlayerRaces(); String race = creo->getObjectTemplate()->getFullTemplateString(); if (!races->contains(race.hashCode())) { errorDescription = "You lack the necessary requirements to wear this object"; return TransferErrorCode::PLAYERUSEMASKERROR; } if (creo->isPlayerCreature()) { if (!wearable->isNeutral()) { ManagedReference<PlayerObject*> playerObject = creo->getPlayerObject(); if (wearable->isImperial() && (playerObject->getFactionStatus() == FactionStatus::ONLEAVE || !creo->isImperial())) { errorDescription = "You lack the necessary requirements to wear this object"; return TransferErrorCode::PLAYERUSEMASKERROR; } if (wearable->isRebel() && (playerObject->getFactionStatus() == FactionStatus::ONLEAVE || !creo->isRebel())) { errorDescription = "You lack the necessary requirements to wear this object"; return TransferErrorCode::PLAYERUSEMASKERROR; } } } } if (object->isArmorObject() && containmentType == 4) { PlayerManager* playerManager = sceneObject->getZoneServer()->getPlayerManager(); if (!playerManager->checkEncumbrancies(dynamic_cast<CreatureObject*>(sceneObject), cast<ArmorObject*>( object))) { errorDescription = "You lack the necessary secondary stats to equip this item"; return TransferErrorCode::NOTENOUGHENCUMBRANCE; } } if (object->isRobeObject() && containmentType == 4) { ManagedReference<RobeObject*> robe = cast<RobeObject*>( object); String skillRequired = robe->getSkillRequired(); if (!creo->hasSkill(skillRequired) && skillRequired != ""){ errorDescription = "You are not eligible to wear this robe."; return TransferErrorCode::PLAYERUSEMASKERROR; } } if (object->isWeaponObject() && containmentType == 4) { ManagedReference<WeaponObject*> weapon = cast<WeaponObject*>( object); int bladeColor = weapon->getBladeColor(); if (weapon->isJediWeapon()){ if (bladeColor == 31) { errorDescription = "@jedi_spam:lightsaber_no_color"; return TransferErrorCode::PLAYERUSEMASKERROR; } if (weapon->getCraftersName() != creo->getFirstName()) { errorDescription = "@jedi_spam:not_your_lightsaber"; return TransferErrorCode::PLAYERUSEMASKERROR; } } } return ContainerComponent::canAddObject(sceneObject, object, containmentType, errorDescription); }
int PlayerContainerComponent::canAddObject(SceneObject* sceneObject, SceneObject* object, int containmentType, String& errorDescription) { CreatureObject* creo = dynamic_cast<CreatureObject*>(sceneObject); if (object->isTangibleObject() && containmentType == 4) { TangibleObject* wearable = cast<TangibleObject*>( object); SharedTangibleObjectTemplate* tanoData = dynamic_cast<SharedTangibleObjectTemplate*>(wearable->getObjectTemplate()); Vector<uint32>* races = tanoData->getPlayerRaces(); String race = creo->getObjectTemplate()->getFullTemplateString(); if (!races->contains(race.hashCode())) { errorDescription = "You lack the necessary requirements to wear this object"; return TransferErrorCode::PLAYERUSEMASKERROR; } if (creo->isPlayerCreature()) { if (!wearable->isNeutral()) { ManagedReference<PlayerObject*> playerObject = creo->getPlayerObject(); if (wearable->isImperial() && (playerObject->getFactionStatus() == FactionStatus::ONLEAVE || !creo->isImperial())) { errorDescription = "You lack the necessary requirements to wear this object"; return TransferErrorCode::PLAYERUSEMASKERROR; } if (wearable->isRebel() && (playerObject->getFactionStatus() == FactionStatus::ONLEAVE || !creo->isRebel())) { errorDescription = "You lack the necessary requirements to wear this object"; return TransferErrorCode::PLAYERUSEMASKERROR; } } } } if (object->isArmorObject() && containmentType == 4) { PlayerManager* playerManager = sceneObject->getZoneServer()->getPlayerManager(); if (!playerManager->checkEncumbrancies(dynamic_cast<CreatureObject*>(sceneObject), cast<ArmorObject*>( object))) { errorDescription = "You lack the necessary secondary stats to equip this item"; return TransferErrorCode::NOTENOUGHENCUMBRANCE; } } if (object->isWearableObject() && containmentType == 4) { ManagedReference<WearableObject*> wearable = cast<WearableObject*>( object); SharedTangibleObjectTemplate* wearableData = dynamic_cast<SharedTangibleObjectTemplate*>(wearable->getObjectTemplate()); Vector<String> skillsRequired = wearableData->getCertificationsRequired(); if (skillsRequired.size() > 0) { bool hasSkill = false; for (int i = 0; i < skillsRequired.size(); i++) { String skill = skillsRequired.get(i); if (!skill.isEmpty() && creo->hasSkill(skill)) { hasSkill = true; break; } } if (!hasSkill) { errorDescription = "@error_message:insufficient_skill"; // You lack the skill to use this item. return TransferErrorCode::PLAYERUSEMASKERROR; } } } if (object->isWeaponObject() && containmentType == 4) { ManagedReference<WeaponObject*> weapon = cast<WeaponObject*>( object); int bladeColor = weapon->getBladeColor(); if (weapon->isJediWeapon()){ if (bladeColor == 31) { errorDescription = "@jedi_spam:lightsaber_no_color"; return TransferErrorCode::PLAYERUSEMASKERROR; } if (weapon->getCraftersName() != creo->getFirstName()) { errorDescription = "@jedi_spam:not_your_lightsaber"; return TransferErrorCode::PLAYERUSEMASKERROR; } } } return ContainerComponent::canAddObject(sceneObject, object, containmentType, errorDescription); }
void CraftingSessionImplementation::initialAssembly(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(); // Get the appropriate number of Experimentation points from Skill ManagedReference<DraftSchematic*> draftSchematic = manufactureSchematic->getDraftSchematic(); // Set crafter manufactureSchematic->setCrafter(crafter); String expskill = draftSchematic->getExperimentationSkill(); experimentationPointsTotal = int(crafter->getSkillMod(expskill) / 10); experimentationPointsUsed = 0; // Calculate exp failure for red bars int experimentalFailureRate = craftingManager.get()->calculateExperimentationFailureRate(crafter, manufactureSchematic, 0); // Get the level of customization String custskill = draftSchematic->getCustomizationSkill(); int custpoints = int(crafter->getSkillMod(custskill)); // Determine the outcome of the craft, Amazing through Critical assemblyResult = craftingManager.get()->calculateAssemblySuccess(crafter, draftSchematic, craftingTool->getEffectiveness()); Locker locker(prototype); Locker schLock(manufactureSchematic); //Set initial crafting percentages craftingManager.get()->setInitialCraftingValues(prototype,manufactureSchematic,assemblyResult); //prototype->setInitialCraftingValues(manufactureSchematic, assemblyResult); Reference<CraftingValues*> craftingValues = manufactureSchematic->getCraftingValues(); craftingValues->setManufactureSchematic(manufactureSchematic); craftingValues->setPlayer(crafter); // Flag to get the experimenting window if (craftingStation != NULL && (craftingValues->getVisibleExperimentalPropertyTitleSize() > 0 || manufactureSchematic->allowFactoryRun())) // Assemble with Experimenting state = 3; else // Assemble without Experimenting state = 4; // Start DPLAY9 *********************************************************** // Updates the stage of crafting, sets the number of experimentation points PlayerObjectDeltaMessage9* dplay9 = new PlayerObjectDeltaMessage9(crafter->getPlayerObject()); dplay9->setCraftingState(state); // 3 If Experimenting is active, 4 if already experimented/ No experimenting dplay9->setExperimentationPoints(experimentationPointsTotal); dplay9->close(); crafter->sendMessage(dplay9); // End DPLAY9 ************************************************************* // Set Crafter name and generate serial number String name = crafter->getFirstName(); prototype->setCraftersName(name); String serial = craftingManager.get()->generateSerial(); prototype->setSerialNumber(serial); // Update the prototype with new values prototype->updateCraftingValues(craftingValues, true); addSkillMods(); addWeaponDots(); // Set default customization SharedTangibleObjectTemplate* templateData = cast<SharedTangibleObjectTemplate*>(prototype->getObjectTemplate()); if (templateData == NULL) { error("No template for: " + String::valueOf(prototype->getServerObjectCRC())); return; } AssetCustomizationManagerTemplate::instance()->getCustomizationVariables(templateData->getAppearanceFilename().hashCode(), variables, true); for (int i = 0; i < variables.size(); ++i) { Reference<RangedIntCustomizationVariable*> var = cast<RangedIntCustomizationVariable*>(variables.get(i).get()); if(var != NULL) { prototype->setCustomizationVariable(variables.elementAt(i).getKey(), var->getDefaultValue()); } } prototype->setComplexity(manufactureSchematic->getComplexity()); // Start DMSCO3 *********************************************************** // Sends the updated values to the crafting screen ManufactureSchematicObjectDeltaMessage3* dMsco3 = new ManufactureSchematicObjectDeltaMessage3(manufactureSchematic); dMsco3->updateCraftingValues(manufactureSchematic); dMsco3->updateComplexity(manufactureSchematic->getComplexity()); dMsco3->close(); crafter->sendMessage(dMsco3); // End DMSCO3 ************************************************************* // Start DMSCO7 *********************************************************** // Sends the experimental properties and experimental percentages ManufactureSchematicObjectDeltaMessage7* dMsco7 = new ManufactureSchematicObjectDeltaMessage7(manufactureSchematic); dMsco7->updateForAssembly(manufactureSchematic, experimentalFailureRate); if (custpoints > 0) dMsco7->updateCustomizationOptions(&variables, custpoints); dMsco7->close(); crafter->sendMessage(dMsco7); // End DMSCO7 ************************************************************* // Start DTANO3 *********************************************************** // Updates the Complexity and the condition TangibleObjectDeltaMessage3* dtano3 = new TangibleObjectDeltaMessage3( prototype); dtano3->updateComplexity(); dtano3->updateMaxCondition(); dtano3->close(); crafter->sendMessage(dtano3); // End DTANO3 ************************************************************* // Start Object Controller ******************************************* // Send the results ObjectControllerMessage* objMsg = new ObjectControllerMessage( crafter->getObjectID(), 0x1B, 0x01BE); objMsg->insertInt(0x109); objMsg->insertInt(assemblyResult); // Assembly Results objMsg->insertByte(clientCounter); crafter->sendMessage(objMsg); // End Object Controller ****************************************** crafter->notifyObservers(ObserverEventType::CRAFTINGASSEMBLY, crafter, 0); // Remove all resources - Not recovering them if (assemblyResult == CraftingManager::CRITICALFAILURE) { createPrototypeObject(draftSchematic); state = 2; // re-setup the slots and ingredients manufactureSchematic->synchronizedUIListen(crafter, 0); // Start Dplay9 ************************************** // Reset crafting state PlayerObjectDeltaMessage9* dplay9 = new PlayerObjectDeltaMessage9( crafter->getPlayerObject()); dplay9->setExperimentationPoints(0xFFFFFFFF); dplay9->setCraftingState(state); dplay9->close(); crafter->sendMessage(dplay9); // End DPLAY9 **************************************** } else { crafterGhost->decreaseSchematicUseCount(draftSchematic); } if(crafterGhost != NULL && crafterGhost->getDebug()) { crafter->sendSystemMessage(craftingValues->toString()); } }