void GeneticComponentImplementation::updateCraftingValues(CraftingValues* values, bool firstUpdate) {
	ComponentImplementation::updateCraftingValues(values, firstUpdate);
	fortitude = values->getCurrentValue("fortitude");
	endurance = values->getCurrentValue("endurance");
	cleverness = values->getCurrentValue("cleverness");
	courage = values->getCurrentValue("courage");
	dexterity = values->getCurrentValue("dexterity");
	dependency = values->getCurrentValue("dependability");
	fierceness = values->getCurrentValue("fierceness");
	intelligence = values->getCurrentValue("intellect");
	power = values->getCurrentValue("power");
	hardiness = values->getCurrentValue("hardiness");
	kinResist = values->getCurrentValue("dna_comp_armor_kinetic");
	energyResist = values->getCurrentValue("dna_comp_armor_energy");
	blastResist = values->getCurrentValue("dna_comp_armor_blast");
	heatResist = values->getCurrentValue("dna_comp_armor_heat");
	coldResist = values->getCurrentValue("dna_comp_armor_cold");
	elecResist = values->getCurrentValue("dna_comp_armor_electric");
	acidResist = values->getCurrentValue("dna_comp_armor_acid");
	stunResist = values->getCurrentValue("dna_comp_armor_stun");
	saberResist = values->getCurrentValue("dna_comp_armor_saber");
	if (values->getCurrentValue("kineticeffectiveness") > 0)
		setSpecialResist(WeaponObject::KINETIC);
	if (values->getCurrentValue("blasteffectiveness") > 0)
		setSpecialResist(WeaponObject::BLAST);
	if (values->getCurrentValue("energyeffectiveness") > 0)
		setSpecialResist(WeaponObject::ENERGY);
	if (values->getCurrentValue("heateffectiveness") > 0)
		setSpecialResist(WeaponObject::HEAT);
	if (values->getCurrentValue("coldeffectiveness") > 0)
		setSpecialResist(WeaponObject::COLD);
	if (values->getCurrentValue("electricityeffectiveness") > 0)
		setSpecialResist(WeaponObject::ELECTRICITY);
	if (values->getCurrentValue("acideffectiveness") > 0)
		setSpecialResist(WeaponObject::ACID);
	if (values->getCurrentValue("stuneffectiveness") > 0)
		setSpecialResist(WeaponObject::STUN);
	if (values->getCurrentValue("lightsabereffectiveness") > 0)
		setSpecialResist(WeaponObject::LIGHTSABER);

	if (fortitude > 500) {
		armorRating = 1;
	}
	// min - max values
	if (fortitude > 1000) {
		fortitude = 1000;
	}
	if (fortitude < 0)
		fortitude = 1;

	if (endurance > 1000){
		endurance = 1000;
	}
	if (endurance < 0)
		endurance = 1;

	if (cleverness > 1000){
		cleverness = 1000;
	}
	if (cleverness < 0)
		cleverness = 1;

	if (courage > 1000){
		courage = 1000;
	}
	if (courage < 0)
		courage = 1;

	if (dependency > 1000){
		dependency = 1000;
	}
	if (dependency < 0)
		dependency = 1;

	if (dexterity > 1000) {
		dexterity = 1000;
	}
	if (dexterity < 0)
		dexterity = 1;

	if (fierceness > 1000){
		fierceness = 1000;
	}
	if (fierceness < 0)
		fierceness = 1;
	if (hardiness > 1000) {
		hardiness = 1000;
	}
	if (hardiness < 0)
		hardiness = 1;
	if (intelligence > 1000){
		intelligence = 1000;
	}
	if (intelligence < 0)
		intelligence = 1;

	if (power > 1000) {
		power = 1000;
	}
	if (power < 0)
		power = 1;
	// max on resists
	if (kinResist > 60)
		kinResist = 60;
	if (energyResist > 60)
		energyResist = 60;
	if (blastResist > 100)
		blastResist = 100;
	if (heatResist > 100)
		heatResist = 100;
	if (coldResist > 100)
		coldResist = 100;
	if (elecResist > 100)
		elecResist = 100;
	if (acidResist > 100)
		acidResist = 100;
	if (stunResist > 100)
		stunResist = 100;
	if (saberResist > 100)
		saberResist = 100;
	// Determine other factors
	// HAM, attack speed, min/max damage toHit
	// Health: har,dex
	// Constitution: har,fort
	// Action: dex,int
	// Stamina: dex,endurance
	// Mind: int, har
	// Will: int,cle
	// Focus: int, dep
	// Strength: har,dep
	// Quickness: dex,dep

	health = (hardiness * 15)    + (dexterity * 3);
	action = (dexterity * 15)    + (intelligence * 3);
	mind   = (intelligence * 15) + (hardiness * 3);
	stamina = (dexterity*15)     + (endurance * 3);
	willPower = (intelligence * 15) + (cleverness * 3);
	constitution = (hardiness * 15)    + (fortitude * 3);
	focus = (intelligence * 15) + (dependency * 3);
	strength = (hardiness * 15)    + (dependency * 3);
	quickness = (dexterity * 15)    + (dependency * 3);
	hit = 0.19 + (0.55 * ((float)cleverness/1000.0));
	// dps of pet use to determien min and max value.
	int dps = ceil((ceil(15.0 + (775.0 * ( ((float)power)/1000.0))))/3.5);
	speed = 2.5-((ceil(((float)courage)/10)*10)/1000);
	maxDam = round(((float)dps * speed) * 1.5);
	//minDam = round(((float)dps * speed) * 0.5);
  	// round maxDam down to the closest multiple of 5
	maxDam = maxDam - (maxDam % 5);
  	// subtract either 5 or 10 from maxDam to get the minDam
	minDam = maxDam - ((System::random(1) + 1) * 5);
}
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();
}