void PetDeedImplementation::updateCraftingValues(CraftingValues* values, bool firstUpdate) {
	ManagedReference<ManufactureSchematic*> manufact = values->getManufactureSchematic();
	float clFactor = 0;
	for (int i = 0; i < manufact->getSlotCount(); ++i) {
		// Dna Component Slots
		Reference<IngredientSlot* > iSlot = manufact->getSlot(i);
		if (iSlot->isComponentSlot()) {
			ComponentSlot* cSlot = cast<ComponentSlot*>(iSlot.get());
			ManagedReference<TangibleObject*> tano = cSlot->getPrototype();
			ManagedReference<GeneticComponent*> component = cast<GeneticComponent*>( tano.get());
			// Now we can suck in the values
			clFactor = component->getLevel();
			quality = component->getQuality();
			chanceHit = component->getHit();
			attackSpeed = component->getSpeed();
			damageMin = component->getMinDamage();
			damageMax = component->getMaxDamage();
			armor = component->getArmor();
			kinResist = round(component->getKinetic());
			energyResist = round(component->getEnergy());
			blastResist = round(component->getBlast());
			coldResist = round(component->getCold());
			heatResist = round(component->getHeat());
			elecResist = round(component->getElectrical());
			acidResist = round(component->getAcid());
			stunResist = round(component->getStun());
			saberResist = round(component->getSaber());
			health = component->getHealth();
			action = component->getAction();
			mind = component->getMind();
			special1 = component->getSpecial1();
			special2 = component->getSpecial2();
			ranged = component->getRanged();
			cleverness = component->getCleverness();
			endurance = component->getEndurance();
			fierceness = component->getFierceness();
			power = component->getPower();
			intelligence = component->getIntelligence();
			courage = component->getCourage();
			dependency = component->getDependency();
			dexterity = component->getDexterity();
			fortitude = component->getFortitude();
			hardiness = component->getHardiness();
			if (component->isSpecialResist(WeaponObject::KINETIC))
				setSpecialResist(WeaponObject::KINETIC);
			if (component->isSpecialResist(WeaponObject::ELECTRICITY))
				setSpecialResist(WeaponObject::ELECTRICITY);
			if (component->isSpecialResist(WeaponObject::ENERGY))
				setSpecialResist(WeaponObject::ENERGY);
			if (component->isSpecialResist(WeaponObject::ACID))
				setSpecialResist(WeaponObject::ACID);
			if (component->isSpecialResist(WeaponObject::BLAST))
				setSpecialResist(WeaponObject::BLAST);
			if (component->isSpecialResist(WeaponObject::COLD))
				setSpecialResist(WeaponObject::COLD);
			if (component->isSpecialResist(WeaponObject::HEAT))
				setSpecialResist(WeaponObject::HEAT);
			if (component->isSpecialResist(WeaponObject::LIGHTSABER))
				setSpecialResist(WeaponObject::LIGHTSABER);
			if (component->isSpecialResist(WeaponObject::STUN))
				setSpecialResist(WeaponObject::STUN);
			level = Genetics::calculatePetLevel(component);
		}
	}
	CreatureTemplateManager* creatureTemplateManager = CreatureTemplateManager::instance();
	ManagedReference<CreatureTemplate*> petTemplate =  creatureTemplateManager->getTemplate( mobileTemplate.hashCode() );
	if (petTemplate != NULL) {
		// get min CL from the template
		int skinFactor = petTemplate->getLevel();
		if (level > 75) {
			level = 75;
		}
		if (level < skinFactor) {
			level = skinFactor;
		}
	}
	// setup attack map
	setupAttacks();
}
예제 #2
0
bool ResourceLabratory::applyComponentStats(TangibleObject* prototype, ManufactureSchematic* manufactureSchematic) {

	if(manufactureSchematic == NULL || manufactureSchematic->getDraftSchematic() == NULL)
		return false;

	float max, min, currentvalue, propertyvalue;
	int precision;
	bool modified = false;
	bool hidden;
	String experimentalTitle, property;

	CraftingValues* craftingValues = manufactureSchematic->getCraftingValues();
	ManagedReference<DraftSchematic* > draftSchematic = manufactureSchematic->getDraftSchematic();

	for (int i = 0; i < manufactureSchematic->getSlotCount(); ++i) {

		Reference<IngredientSlot* > ingredientSlot = manufactureSchematic->getSlot(i);
		Reference<DraftSlot* > draftSlot = draftSchematic->getDraftSlot(i);

		if(ingredientSlot == NULL || !ingredientSlot->isComponentSlot() || !ingredientSlot->isFull())
			continue;

		ComponentSlot* compSlot = cast<ComponentSlot*>(ingredientSlot.get());

		if(compSlot == NULL)
			continue;

		ManagedReference<TangibleObject*> tano = compSlot->getPrototype();

		if (tano == NULL || !tano->isComponent())
			continue;

		ManagedReference<Component*> component = cast<Component*>( tano.get());

		if (prototype->isWearableObject() && !prototype->isArmorObject()) {

			if (component->getObjectTemplate()->getObjectName() == "@craft_clothing_ingredients_n:reinforced_fiber_panels" || component->getObjectTemplate()->getObjectName() == "@craft_clothing_ingredients_n:synthetic_cloth"){

				for (int k = 0; k < component->getPropertyCount(); ++k) {
					const String property = component->getProperty(k);

					if (property == "" || property == "null") {
						continue;
					}

					String key = checkBioSkillMods(property);

					if (key == "") {
						continue;
					} else {
						currentvalue = component->getAttributeValue(property);
						precision = component->getAttributePrecision(property);
						int preciseValue = Math::getPrecision(currentvalue, precision);
						WearableObject* clothing = cast<WearableObject*>(prototype);
						VectorMap<String, int>* clothingMods = clothing->getWearableSkillMods();

						int existingValue = 0;
						if(clothingMods->contains(key)) {
							existingValue = clothingMods->get(key);
						}
						preciseValue += existingValue;
						if (preciseValue > 25)
							preciseValue = 25;
						clothing->addSkillMod(SkillModManager::WEARABLE, key, preciseValue);
					}
				}
			}
		} else {

			for (int j = 0; j < component->getPropertyCount(); ++j) {

				property = component->getProperty(j); // charges
				modified = true;
				if (craftingValues->hasProperty(property)) {
					max = craftingValues->getMaxValue(property);
					min = craftingValues->getMinValue(property);
					hidden = craftingValues->isHidden(property);
					currentvalue = craftingValues->getCurrentValue(property);
					propertyvalue = component->getAttributeValue(property) * draftSlot->getContribution();
					short combineType = craftingValues->getCombineType(property);

					switch(combineType) {
					case CraftingManager::LINEARCOMBINE:
						currentvalue += propertyvalue;
						min += propertyvalue;
						max += propertyvalue;

						craftingValues->setMinValue(property, min);
						craftingValues->setMaxValue(property, max);

						craftingValues->setCurrentValue(property, currentvalue);
						break;
					case CraftingManager::PERCENTAGECOMBINE:
						currentvalue += propertyvalue;
						min += propertyvalue;
						max += propertyvalue;

						craftingValues->setMinValue(property, min);
						craftingValues->setMaxValue(property, max);

						craftingValues->setCurrentPercentage(property, currentvalue);
						break;
					case CraftingManager::BITSETCOMBINE:
						currentvalue = (int)currentvalue | (int)propertyvalue;

						craftingValues->setCurrentValue(property , currentvalue);
						break;
					case CraftingManager::OVERRIDECOMBINE:
						// Do nothing because the values should override whatever is
						// on the component
						break;
					default:
						break;
					}

				} else {

					currentvalue = component->getAttributeValue(property);
					precision = component->getAttributePrecision(property);
					experimentalTitle = component->getAttributeTitle(property);

					craftingValues->addExperimentalProperty(experimentalTitle, property,
						currentvalue, currentvalue, precision, component->getAttributeHidden(property), CraftingManager::LINEARCOMBINE);
					craftingValues->setCurrentPercentage(property, 0);
					craftingValues->setMaxPercentage(property, 0);
					craftingValues->setCurrentValue(property, currentvalue);
				}
			}
		}
	}
	return modified;
}
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);
	//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);

	for (int i = 0; i < manufactureSchematic->getSlotCount(); ++i) {

		ComponentSlot* compSlot = cast<ComponentSlot*>(manufactureSchematic->getSlot(i));
		if (compSlot == NULL)
			continue;

		ManagedReference<TangibleObject*> tano = compSlot->getPrototype();
		if (tano == NULL)
			continue;

		// we know that we can only have one component per hardpoint slot, so don't worry about checking them
		ComponentMapEntry entry = ComponentMap::instance()->get(tano->getClientObjectCRC());
		if (entry.getId() > 0)
			prototype->addVisibleComponent(entry.getId(), false);
	}

	if (prototype->getVisibleComponents() != NULL && prototype->getVisibleComponents()->size() > 0) {
		prototype->sendDestroyTo(crafter);
		prototype->sendTo(crafter, true);
	}

	// 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());
	}
}
void DroidDeedImplementation::updateCraftingValues(CraftingValues* values, bool firstUpdate) {
	/*
	 * Values available:	Range:
	 *
	 */
	String key;
	ManagedReference<DroidComponent*> comp = NULL;
	HashTableIterator<String, ManagedReference<DroidComponent*> > iterator = modules.iterator();
	for(int i = 0; i < modules.size(); ++i) {
		iterator.getNextKeyAndValue(key, comp);
		if (comp) {
			comp->destroyObjectFromWorld(true);
			comp->destroyObjectFromDatabase(true);
		}
	}
	modules.removeAll();

	overallQuality = values->getCurrentPercentage("power_level"); // effectiveness
	if (overallQuality < 0)
		overallQuality = 0.1;

	combatRating = values->getCurrentValue("cmbt_module");
	if (combatRating < 0)
		combatRating = 0;
	// @TODO Add crafting values, this should adjust toHit and Speed based on droid ham, also

	// we need to stack modules if they are stackable.
	// walk all components and ensure we have all modules that are stackable there.

	ManagedReference<ManufactureSchematic*> manufact = values->getManufactureSchematic();
	for (int i = 0; i < manufact->getSlotCount(); ++i) {
		// Droid Component Slots
		Reference<IngredientSlot* > iSlot = manufact->getSlot(i);
		if (iSlot->isComponentSlot()) {
			ComponentSlot* cSlot = cast<ComponentSlot*>(iSlot.get());
			ManagedReference<TangibleObject*> tano = cSlot->getPrototype();
			ManagedReference<DroidComponent*> component = cast<DroidComponent*>( tano.get());
			// only check modules
			if (component != NULL) {
				if (component->isSocketCluster()) {
					// pull out the objects
					ManagedReference<SceneObject*> craftingComponents = component->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);
							if (sceno != NULL) {
								// now we have the componet used in this socket item
								ManagedReference<DroidComponent*> sub = cast<DroidComponent*>( sceno.get());
								if (sub != NULL) {
									DataObjectComponentReference* data = sub->getDataObjectComponent();
									BaseDroidModuleComponent* module = NULL;
									if(data != NULL && data->get() != NULL && data->get()->isDroidModuleData() ){
										module = cast<BaseDroidModuleComponent*>(data->get());
									}
									if (module == NULL) {
										continue;
									}
									processModule(module,sceno->getServerObjectCRC());
								}
							}
						}
					}
				} else {
					DataObjectComponentReference* data = component->getDataObjectComponent();
					BaseDroidModuleComponent* module = NULL;
					if(data != NULL && data->get() != NULL && data->get()->isDroidModuleData() ){
						module = cast<BaseDroidModuleComponent*>(data->get());
					}
					if (module == NULL) {
						continue;
					}
					processModule(module,tano->getServerObjectCRC());
				}
			}
		}
	}
	// module stacking is completed!
}
예제 #5
0
void GeneticLabratory::setInitialCraftingValues(TangibleObject* prototype, ManufactureSchematic* manufactureSchematic, int assemblySuccess) {

    if(manufactureSchematic == NULL || manufactureSchematic->getDraftSchematic() == NULL)
        return;
    ManagedReference<DraftSchematic* > draftSchematic = manufactureSchematic->getDraftSchematic();
    CraftingValues* craftingValues = manufactureSchematic->getCraftingValues();
    float value, maxPercentage, currentPercentage, weightedSum;
    String itemName;
    // These 2 values are pretty standard, adding these
    itemName = "xp";
    value = float(draftSchematic->getXpAmount());
    craftingValues->addExperimentalProperty("", itemName, value, value, 0, true, CraftingManager::OVERRIDECOMBINE);
    itemName = "complexity";
    value = manufactureSchematic->getComplexity();
    craftingValues->addExperimentalProperty("", itemName, value, value, 0, true, CraftingManager::OVERRIDECOMBINE);
    float modifier = calculateAssemblyValueModifier(assemblySuccess);
    // Cast component to genetic
    if (!prototype->isComponent())
        return;

    GeneticComponent* genetic = cast<GeneticComponent*>(prototype);
    HashTable<String, ManagedReference<DnaComponent*> > slots;
    for (int i = 0; i < manufactureSchematic->getSlotCount(); ++i) {
        // Dna Component Slots
        Reference<IngredientSlot* > iSlot = manufactureSchematic->getSlot(i);
        ComponentSlot* cSlot = cast<ComponentSlot*>(iSlot.get());
        ManagedReference<TangibleObject*> tano = cSlot->getPrototype();
        ManagedReference<DnaComponent*> component = cast<DnaComponent*>( tano.get());
        slots.put(cSlot->getSlotName(),component);
    }
    // At this point we have all the DNA slots. Update the craftingvalue accordingly
    DnaComponent* phy = slots.get("physique_profile").get();
    DnaComponent* pro = slots.get("prowess_profile").get();
    DnaComponent* men = slots.get("mental_profile").get();
    DnaComponent* psy = slots.get("psychological_profile").get();
    DnaComponent* agr = slots.get("aggression_profile").get();

    uint32 harMax, fortMax, endMax,intMax, dexMax,cleMax,depMax,couMax,fieMax,powMax;

    fortMax = applyFormula(phy->getForititude(),pro->getForititude(),men->getForititude(),psy->getForititude(),agr->getForititude(),PHYSIQUE);
    harMax = applyFormula(phy->getHardiness(),pro->getHardiness(),men->getHardiness(),psy->getHardiness(),agr->getHardiness(),PHYSIQUE);
    dexMax = applyFormula(phy->getDexterity(),pro->getDexterity(),men->getDexterity(),psy->getDexterity(),agr->getDexterity(),PROWESS);
    endMax = applyFormula(phy->getEndurance(),pro->getEndurance(),men->getEndurance(),psy->getEndurance(),agr->getEndurance(),PROWESS);
    intMax = applyFormula(phy->getIntellect(),pro->getIntellect(),men->getIntellect(),psy->getIntellect(),agr->getIntellect(),MENTAL);
    cleMax = applyFormula(phy->getCleverness(),pro->getCleverness(),men->getCleverness(),psy->getCleverness(),agr->getCleverness(),MENTAL);
    depMax = applyFormula(phy->getDependency(),pro->getDependency(),men->getDependency(),psy->getDependency(),agr->getDependency(),PHYSCHOLOGICAL);
    couMax = applyFormula(phy->getCourage(),pro->getCourage(),men->getCourage(),psy->getCourage(),agr->getCourage(),PHYSCHOLOGICAL);
    fieMax = applyFormula(phy->getFierceness(),pro->getFierceness(),men->getFierceness(),psy->getFierceness(),agr->getFierceness(),AGRESSION);
    powMax = applyFormula(phy->getPower(),pro->getPower(),men->getPower(),psy->getPower(),agr->getPower(),AGRESSION);

    uint32 fortMin,endMin,harMin,intMin,dexMin,cleMin,depMin,couMin,fieMin,powMin;
    fortMin = calcMin(fortMax);
    harMin = calcMin(harMax);
    dexMin = calcMin(dexMax);
    endMin = calcMin(endMax);
    intMin = calcMin(intMax);
    cleMin = calcMin(cleMax);
    depMin = calcMin(depMax);
    couMin = calcMin(couMax);
    fieMin = calcMin(fieMax);
    powMin = calcMin(powMax);

    float blast, energy, kinetic,heat,cold,electric,acid,stun,saber;
    blast = applyFormula(phy->getBlast(),pro->getBlast(),men->getBlast(),psy->getBlast(),agr->getBlast(),PHYSIQUE);
    kinetic = applyFormula(phy->getKinetic(),pro->getKinetic(),men->getKinetic(),psy->getKinetic(),agr->getKinetic(),PHYSIQUE);
    energy = applyFormula(phy->getEnergy(),pro->getEnergy(),men->getEnergy(),psy->getEnergy(),agr->getEnergy(),PHYSIQUE);
    heat = applyFormula(phy->getHeat(),pro->getHeat(),men->getHeat(),psy->getHeat(),agr->getHeat(),PHYSIQUE);
    cold = applyFormula(phy->getCold(),pro->getCold(),men->getCold(),psy->getCold(),agr->getCold(),PHYSIQUE);
    electric = applyFormula(phy->getElectric(),pro->getElectric(),men->getElectric(),psy->getElectric(),agr->getElectric(),PHYSIQUE);
    acid = applyFormula(phy->getAcid(),pro->getAcid(),men->getAcid(),psy->getAcid(),agr->getAcid(),PHYSIQUE);
    stun = applyFormula(phy->getStun(),pro->getStun(),men->getStun(),psy->getStun(),agr->getStun(),PHYSIQUE);
    saber = applyFormula(phy->getSaber(),pro->getSaber(),men->getSaber(),psy->getSaber(),agr->getSaber(),PHYSIQUE);

    craftingValues->addExperimentalProperty("expPhysiqueProfile","fortitude",fortMin,fortMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expPhysiqueProfile","hardiness",harMin,harMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expProwessProfile","dexterity",dexMin,dexMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expProwessProfile","endurance",endMin,endMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expMentalProfile","intellect",intMin,intMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expMentalProfile","cleverness",cleMin,cleMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expPsychologicalProfile","dependability",depMin,depMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expPsychologicalProfile","courage",couMin,couMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expAggressionProfile","fierceness",fieMin,fieMax,0,false,CraftingManager::LINEARCOMBINE);
    craftingValues->addExperimentalProperty("expAggressionProfile","power",powMin,powMax,0,false,CraftingManager::LINEARCOMBINE);

    craftingValues->addExperimentalProperty("","dna_comp_armor_kinetic",calcResistMin(kinetic,modifier),kinetic,0,true,CraftingManager::OVERRIDECOMBINE);
    craftingValues->addExperimentalProperty("","dna_comp_armor_blast",calcResistMin(blast,modifier),blast,0,true,CraftingManager::OVERRIDECOMBINE);
    craftingValues->addExperimentalProperty("","dna_comp_armor_energy",calcResistMin(energy,modifier),energy,0,true,CraftingManager::OVERRIDECOMBINE);
    craftingValues->addExperimentalProperty("","dna_comp_armor_heat",calcResistMin(heat,modifier),heat,0,true,CraftingManager::OVERRIDECOMBINE);
    craftingValues->addExperimentalProperty("","dna_comp_armor_cold",calcResistMin(cold,modifier),cold,0,true,CraftingManager::OVERRIDECOMBINE);
    craftingValues->addExperimentalProperty("","dna_comp_armor_electric",calcResistMin(electric,modifier),electric,0,true,CraftingManager::OVERRIDECOMBINE);
    craftingValues->addExperimentalProperty("","dna_comp_armor_acid",calcResistMin(acid,modifier),acid,0,true,CraftingManager::OVERRIDECOMBINE);
    craftingValues->addExperimentalProperty("","dna_comp_armor_stun",calcResistMin(stun,modifier),stun,0,true,CraftingManager::OVERRIDECOMBINE);
    craftingValues->addExperimentalProperty("","dna_comp_armor_saber",calcResistMin(saber,modifier),saber,0,true,CraftingManager::OVERRIDECOMBINE);

    craftingValues->setMaxPercentage("dna_comp_armor_kinetic",kinetic/100);
    craftingValues->setMaxPercentage("dna_comp_armor_blast",blast/100);
    craftingValues->setMaxPercentage("dna_comp_armor_energy",energy/100);
    craftingValues->setMaxPercentage("dna_comp_armor_heat",heat/100);
    craftingValues->setMaxPercentage("dna_comp_armor_cold",cold/100);
    craftingValues->setMaxPercentage("dna_comp_armor_electric",electric/100);
    craftingValues->setMaxPercentage("dna_comp_armor_acid",acid/100);
    craftingValues->setMaxPercentage("dna_comp_armor_stun",stun/100);
    craftingValues->setMaxPercentage("dna_comp_armor_saber",saber/100);

    if (kinetic > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_kinetic",calcResistMin(kinetic,modifier)/kinetic);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_kinetic",kinetic/100);
    if (blast > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_blast",calcResistMin(blast,modifier)/blast);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_blast",blast/100);
    if (energy > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_energy",calcResistMin(energy,modifier)/energy);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_energy",energy/100);
    if (heat > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_heat",calcResistMin(heat,modifier)/heat);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_heat",heat/100);
    if (cold > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_cold",calcResistMin(cold,modifier)/cold);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_cold",cold/100);
    if (electric > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_electric",calcResistMin(electric,modifier)/electric);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_electric",electric/100);
    if (acid > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_acid",calcResistMin(acid,modifier)/acid);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_acid",acid/100);
    if (stun > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_stun",calcResistMin(stun,modifier)/stun);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_stun",stun/100);
    if (saber > 0)
        craftingValues->setCurrentPercentage("dna_comp_armor_saber",calcResistMin(saber,modifier)/saber);
    else
        craftingValues->setCurrentPercentage("dna_comp_armor_saber",saber/100);


    // Calc the max Percentage, vs Min Percentage
    craftingValues->setMaxPercentage("fortitude",calcMaxPercentage(fortMax));
    craftingValues->setCurrentPercentage("fortitude", getAssemblyPercentage(fortMin) * modifier);

    craftingValues->setMaxPercentage("hardiness",calcMaxPercentage(harMax));
    craftingValues->setCurrentPercentage("hardiness", getAssemblyPercentage(harMin) * modifier);

    craftingValues->setMaxPercentage("dexterity",calcMaxPercentage(dexMax));
    craftingValues->setCurrentPercentage("dexterity", getAssemblyPercentage(dexMin) * modifier);

    craftingValues->setMaxPercentage("endurance",calcMaxPercentage(endMax));
    craftingValues->setCurrentPercentage("endurance", getAssemblyPercentage(endMin) * modifier);

    craftingValues->setMaxPercentage("intellect",calcMaxPercentage(intMax));
    craftingValues->setCurrentPercentage("intellect", getAssemblyPercentage(intMin) * modifier);

    craftingValues->setMaxPercentage("cleverness",calcMaxPercentage(cleMax));
    craftingValues->setCurrentPercentage("cleverness", getAssemblyPercentage(cleMin) * modifier);

    craftingValues->setMaxPercentage("dependability",calcMaxPercentage(depMax));
    craftingValues->setCurrentPercentage("dependability", getAssemblyPercentage(depMin) * modifier);

    craftingValues->setMaxPercentage("courage",calcMaxPercentage(couMax));
    craftingValues->setCurrentPercentage("courage",getAssemblyPercentage(couMin) * modifier);

    craftingValues->setMaxPercentage("fierceness",calcMaxPercentage(fieMax));
    craftingValues->setCurrentPercentage("fierceness",getAssemblyPercentage(fieMin) * modifier);

    craftingValues->setMaxPercentage("power",calcMaxPercentage(powMax));
    craftingValues->setCurrentPercentage("power", getAssemblyPercentage(powMin) * modifier);

    // Figure out the min percentage of the stats

    int quality = (phy->getQuality() + pro->getQuality() + men->getQuality() + psy->getQuality() + agr->getQuality()) / 5;
    bool ranged = false;
    int odds = 0;
    float menQual = 7 - men->getQuality();
    float psyQual = 7 - psy->getQuality();
    if (men->isRanged() || psy->isRanged()) {
        int chance = System::random(100 - (assemblySuccess * 10)); // so amazing success 100, critical falure is 20
        // did you roll exceed (7 - Quality) * 10 (VHQ is 0) so always works
        if (chance > (menQual * 10) || chance > (psyQual * 10))
            ranged = true;
    }
    odds = men->getQuality() * 100;
    // check for specials here, then we have base assemble work completed.
    // update crafting values, and/or experimentRow should handle resist calc changes. update crafting values should determine armor setup
    String sp1 = pickSpecialAttack(agr->getSpecialAttackOne(),psy->getSpecialAttackOne(),phy->getSpecialAttackOne(),men->getSpecialAttackOne(),pro->getSpecialAttackOne(),odds);
    String sp2 = pickSpecialAttack(psy->getSpecialAttackTwo(),pro->getSpecialAttackTwo(),agr->getSpecialAttackTwo(),men->getSpecialAttackTwo(),phy->getSpecialAttackTwo(),odds);
    genetic->setSpecialAttackOne(sp1);
    genetic->setSpecialAttackTwo(sp2);
    genetic->setRanged(ranged);
    genetic->setQuality(quality);
    // determine avg sample levels to choose a level of this template for output generation
    int level = (phy->getLevel() + pro->getLevel() + men->getLevel() + psy->getLevel() + agr->getLevel()) / 5;
    genetic->setLevel(level);
    craftingValues->recalculateValues(true);
}
예제 #6
0
void GeneticLabratory::setInitialCraftingValues(TangibleObject* prototype, ManufactureSchematic* manufactureSchematic, int assemblySuccess) {

	if(manufactureSchematic == NULL || manufactureSchematic->getDraftSchematic() == NULL)
		return;
	ManagedReference<DraftSchematic* > draftSchematic = manufactureSchematic->getDraftSchematic();
	CraftingValues* craftingValues = manufactureSchematic->getCraftingValues();
	float value, maxPercentage, currentPercentage, weightedSum;
	String itemName;
	// These 2 values are pretty standard, adding these
	itemName = "xp";
	value = float(draftSchematic->getXpAmount());
	craftingValues->addExperimentalProperty("", itemName, value, value, 0, true, CraftingManager::OVERRIDECOMBINE);
	itemName = "complexity";
	value = manufactureSchematic->getComplexity();
	craftingValues->addExperimentalProperty("", itemName, value, value, 0, true, CraftingManager::OVERRIDECOMBINE);
	float modifier = calculateAssemblyValueModifier(assemblySuccess);
	// Cast component to genetic
	if (!prototype->isComponent())
		return;

	GeneticComponent* genetic = cast<GeneticComponent*>(prototype);
	HashTable<String, ManagedReference<DnaComponent*> > slots;
	for (int i = 0; i < manufactureSchematic->getSlotCount(); ++i) {
		// Dna Component Slots
		Reference<IngredientSlot* > iSlot = manufactureSchematic->getSlot(i);
		ComponentSlot* cSlot = cast<ComponentSlot*>(iSlot.get());
		ManagedReference<TangibleObject*> tano = cSlot->getPrototype();
		ManagedReference<DnaComponent*> component = cast<DnaComponent*>( tano.get());
		slots.put(cSlot->getSlotName(),component);
	}
	// At this point we have all the DNA slots. Update the craftingvalue accordingly
	DnaComponent* phy = slots.get("physique_profile").get();
	DnaComponent* pro = slots.get("prowess_profile").get();
	DnaComponent* men = slots.get("mental_profile").get();
	DnaComponent* psy = slots.get("psychological_profile").get();
	DnaComponent* agr = slots.get("aggression_profile").get();
	// REVAMP FROM HERE DOWN.
	// STEP 1. Determine Attributes
	uint32 harMax, fortMax, endMax,intMax, dexMax,cleMax,depMax,couMax,fieMax,powMax;
	// Calculate the max values i.e. the weighter resource avergae.
	fortMax = Genetics::physiqueFormula(phy->getForititude(),pro->getForititude(),men->getForititude(),psy->getForititude(),agr->getForititude());
	harMax = Genetics::physiqueFormula(phy->getHardiness(),pro->getHardiness(),men->getHardiness(),psy->getHardiness(),agr->getHardiness());
	dexMax = Genetics::prowessFormula(phy->getDexterity(),pro->getDexterity(),men->getDexterity(),psy->getDexterity(),agr->getDexterity());
	endMax = Genetics::prowessFormula(phy->getEndurance(),pro->getEndurance(),men->getEndurance(),psy->getEndurance(),agr->getEndurance());
	intMax = Genetics::mentalFormula(phy->getIntellect(),pro->getIntellect(),men->getIntellect(),psy->getIntellect(),agr->getIntellect());
	cleMax = Genetics::mentalFormula(phy->getCleverness(),pro->getCleverness(),men->getCleverness(),psy->getCleverness(),agr->getCleverness());
	depMax = Genetics::physchologicalFormula(phy->getDependency(),pro->getDependency(),men->getDependency(),psy->getDependency(),agr->getDependency());
	couMax = Genetics::physchologicalFormula(phy->getCourage(),pro->getCourage(),men->getCourage(),psy->getCourage(),agr->getCourage());
	fieMax = Genetics::aggressionFormula(phy->getFierceness(),pro->getFierceness(),men->getFierceness(),psy->getFierceness(),agr->getFierceness());
	powMax = Genetics::aggressionFormula(phy->getPower(),pro->getPower(),men->getPower(),psy->getPower(),agr->getPower());
	// acknowledge any specials found in the experimentation line. this means specials will not modify later by experimentaiton as its an overlay value.
	bool spBlast = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::BLAST);
	bool spKinetic = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::KINETIC);
	bool spEnergy = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::ENERGY);
	bool spHeat = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::HEAT);
	bool spCold = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::COLD);
	bool spElectric = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::ELECTRICITY);
	bool spAcid = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::ACID);
	bool spStun = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::STUN);
	bool spSaber = Genetics::hasASpecial(phy,pro,men,psy,agr,WeaponObject::LIGHTSABER);
	// Calculate resists
	// 1 percent: (1000 - 0) / 100.0f;
	float blastMax, energyMax, kineticMax,heatMax,coldMax,electricMax,acidMax,stunMax,saberMax;
	blastMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::BLAST,100.0f);
	kineticMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::KINETIC,60.0f);
	energyMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::ENERGY,60.0f);
	heatMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::HEAT,100.0f);
	coldMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::COLD,100.0f);
	electricMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::ELECTRICITY,100.0f);
	acidMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::ACID,100.0f);
	stunMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::STUN,100.0f);
	saberMax = Genetics::resistanceFormula(phy,pro,men,psy,agr,WeaponObject::LIGHTSABER,100.0f);
	// lets clear the special bit if it moved to effective range.
	if(saberMax == 0) {
		spSaber = false;
		saberMax = 100;
	}
	if (blastMax == 0) {
		spBlast = false;
		blastMax = 100;
	}
	if (kineticMax == 0) {
		spKinetic = false;
		kineticMax = 60;
	}
	if (energyMax == 0) {
		spEnergy = false;
		energyMax = 60;
	}
	if (heatMax == 0) {
		spHeat = false;
		heatMax = 100;
	}
	if (coldMax == 0) {
		spCold = false;
		coldMax = 100;
	}
	if (electricMax == 0) {
		spElectric = false;
		electricMax = 100;
	}
	if(acidMax == 0) {
		spAcid = false;
		acidMax = 100;
	}
	if(stunMax == 0) {
		spStun = false;
		stunMax = 100;
	}

	// Step 2. At this point we know the max values for all stats and we have calculated any armor specials needed
	// So now we need to setup the min and initial values of stats and define the experimental attributes. // Ranges are 0 to 100 for any one of these
	// set current value to be 70% less than max calculated as the experimentation range. i.e.
	craftingValues->addExperimentalProperty("expPhysiqueProfile","fortitude",0,fortMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expPhysiqueProfile","hardiness",0,harMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expProwessProfile","dexterity",0,dexMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expProwessProfile","endurance",0,endMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expMentalProfile","intellect",0,intMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expMentalProfile","cleverness",0,cleMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expPsychologicalProfile","dependability",0,depMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expPsychologicalProfile","courage",0,couMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expAggressionProfile","fierceness",0,fieMax,0,false,CraftingManager::LINEARCOMBINE);
	craftingValues->addExperimentalProperty("expAggressionProfile","power",0,powMax,0,false,CraftingManager::LINEARCOMBINE);
	String title;
	int armorBase = 0;
	int effectiveness = 0;
	for(int i=0;i<craftingValues->getExperimentalPropertySubtitleSize();i++) {
		title = craftingValues->getExperimentalPropertySubtitle(i);
		if (craftingValues->isHidden(title))
			continue;
		// We need to accoutn for assembly percentage. do some swapping around as well.
		float maxValue = craftingValues->getMaxValue(title);
		float initialValue = Genetics::initialValue(craftingValues->getMaxValue(title));
		// determine max percentage
		craftingValues->setMaxPercentage(title, maxValue/1000.0f);
		craftingValues->setMaxValue(title,1000);
		// using assembly to accoutn for a 1 +% increase
		currentPercentage = getAssemblyPercentage(initialValue) * modifier;
		//craftingValues->setMaxPercentage(title, maxPercentage);
		craftingValues->setCurrentPercentage(title, currentPercentage);
		if (title == "fortitude") {
			armorBase = craftingValues->getCurrentValue(title);
		}
	}
	int armorValue = armorBase/500;
	effectiveness = (int)(((armorBase - (armorValue * 500)) / 50) * 5);
	// Store off armor data
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_kinetic",spKinetic ? kineticMax : kineticMax < 0 ? -1 : effectiveness,kineticMax,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_blast",spBlast ? blastMax : blastMax < 0 ? -1 : effectiveness, blastMax,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_energy",spEnergy ? energyMax : energyMax < 0 ? -1 : effectiveness, energyMax,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_heat",spHeat ? heatMax : heatMax < 0 ? -1 :  effectiveness ,heatMax,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_cold",spCold ? coldMax : coldMax < 0 ? -1 : effectiveness ,coldMax,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_electric",spElectric ? electricMax : electricMax < 0 ? -1 : effectiveness ,electricMax,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_acid",spAcid ? acidMax : acidMax < 0 ? -1 : effectiveness ,acidMax,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_stun",spStun ? stunMax : stunMax < 0 ? -1 : effectiveness ,stunMax,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("resists","dna_comp_armor_saber",spSaber ? saberMax : saberMax < 0 ? -1 : effectiveness ,saberMax,0,true,CraftingManager::OVERRIDECOMBINE);
	// Store off special information
	craftingValues->addExperimentalProperty("specials","kineticeffectiveness",spKinetic ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("specials","blasteffectiveness",spBlast ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("specials","energyeffectiveness",spEnergy ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("specials","heateffectiveness",spHeat ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("specials","coldeffectiveness",spCold ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("specials","electricityeffectiveness",spElectric ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("specials","acideffectiveness",spAcid ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("specials","stuneffectiveness",spStun ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	craftingValues->addExperimentalProperty("specials","lightsabereffectiveness",spSaber ? 1: 0,1,0,true,CraftingManager::OVERRIDECOMBINE);
	int quality = ( ((float)phy->getQuality() * 0.2)+ ((float)pro->getQuality()*0.2) + ((float)men->getQuality()*0.2) + ((float)psy->getQuality()*0.2) + ((float)agr->getQuality()*0.2));
	bool ranged = false;
	int odds = 0;
	float menQual = men->getQuality() - 1;
	float psyQual = psy->getQuality() - 1;
	if (men->isRanged() || psy->isRanged()) {
		int chance = System::random(100-(assemblySuccess * 10)); // so amazing success 100, critical falure is 20
		// did you roll exceed (7 - Quality) * 10 (VHQ is 0) so always works
		if (chance >= (menQual * 10) || chance >= (psyQual * 10))
			ranged = true;
	}
	odds = quality * 100;
	// check for specials here, then we have base assemble work completed.
	// update crafting values, and/or experimentRow should handle resist calc changes. update crafting values should determine armor setup
	String sp1 = pickSpecialAttack(agr->getSpecialAttackOne(),psy->getSpecialAttackOne(),phy->getSpecialAttackOne(),men->getSpecialAttackOne(),pro->getSpecialAttackOne(),odds,"defaultattack");
	String sp2 = pickSpecialAttack(psy->getSpecialAttackTwo(),pro->getSpecialAttackTwo(),agr->getSpecialAttackTwo(),men->getSpecialAttackTwo(),phy->getSpecialAttackTwo(),odds,sp1);
	genetic->setSpecialAttackOne(sp1);
	genetic->setSpecialAttackTwo(sp2);
	genetic->setRanged(ranged);
	genetic->setQuality(quality);
	// determine avg sample levels to choose a level of this template for output generation
	int level = Genetics::physchologicalFormula(phy->getLevel(),pro->getLevel(),men->getLevel(), psy->getLevel() ,agr->getLevel());
	genetic->setLevel(level);
	craftingValues->recalculateValues(true);
}