void DnaManager::generateSample(Creature* creature, CreatureObject* player,int quality){ if (quality < 0 || quality > 7) { return; } Locker lock(creature,player); CreatureTemplate* creatureTemplate = dynamic_cast<CreatureTemplate*>(creature->getCreatureTemplate()); int ferocity = creatureTemplate->getFerocity(); int cl = creature->getLevel(); int cle = Genetics::hitChanceToValue(creature->getChanceHit(),quality); int cou = Genetics::meatTypeToValue(creature->getMeatType(),quality); int dep = Genetics::dietToValue(creature->getDiet(),quality); int dex = Genetics::hamToValue(creature->getMaxHAM(3),quality); int end = Genetics::accelerationToValue(creature->getWalkAcceleration(),quality); int fie = Genetics::ferocityToValue(ferocity,quality); int frt = Genetics::resistanceToValue(creature->getEffectiveResist(),creature->getArmor(),quality); int har = Genetics::hamToValue(creature->getMaxHAM(0),quality); int ite = Genetics::hamToValue(creature->getMaxHAM(6),quality); int pow = Genetics::damageToValue((creature->getDamageMax() + creature->getDamageMin())/2,quality); ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory"); if (inventory->hasFullContainerObjects()) { StringIdChatParameter err("survey", "no_inv_space"); player->sendSystemMessage(err); player->setPosture(CreaturePosture::UPRIGHT, true); return; } // We should now have enough to generate a sample ManagedReference<DnaComponent*> prototype = player->getZoneServer()->createObject(qualityTemplates.get(quality), 1).castTo<DnaComponent*>(); if (prototype == NULL) { return; } Locker clocker(prototype); // Check Here for unique npcs StringId* nameId = creature->getObjectName(); if (nameId->getFile().isEmpty() || nameId->getStringID().isEmpty()) { prototype->setSource(creature->getCreatureName().toString()); } else { prototype->setSource(nameId->getFullPath()); } prototype->setQuality(quality); prototype->setLevel(cl); String serial = player->getZoneServer()->getCraftingManager()->generateSerial(); prototype->setSerialNumber(serial); prototype->setStats(cle,end,fie,pow,ite,cou,dep,dex,frt,har); prototype->setStun(creatureTemplate->getStun()); prototype->setKinetic(creatureTemplate->getKinetic()); prototype->setEnergy(creatureTemplate->getEnergy()); prototype->setBlast(creatureTemplate->getBlast()); prototype->setHeat(creatureTemplate->getHeat()); prototype->setCold(creatureTemplate->getCold()); prototype->setElectric(creatureTemplate->getElectricity()); prototype->setAcid(creatureTemplate->getAcid()); prototype->setSaber(creatureTemplate->getLightSaber()); prototype->setRanged(creatureTemplate->getWeapons().size() > 0); prototype->setArmorRating(creatureTemplate->getArmor()); if (creatureTemplate->isSpecialProtection(WeaponObject::STUN)) prototype->setSpecialResist(WeaponObject::STUN); if (creatureTemplate->isSpecialProtection(WeaponObject::KINETIC)) prototype->setSpecialResist(WeaponObject::KINETIC); if (creatureTemplate->isSpecialProtection(WeaponObject::ENERGY)) prototype->setSpecialResist(WeaponObject::ENERGY); if (creatureTemplate->isSpecialProtection(WeaponObject::BLAST)) prototype->setSpecialResist(WeaponObject::BLAST); if (creatureTemplate->isSpecialProtection(WeaponObject::HEAT)) prototype->setSpecialResist(WeaponObject::HEAT); if (creatureTemplate->isSpecialProtection(WeaponObject::COLD)) prototype->setSpecialResist(WeaponObject::COLD); if (creatureTemplate->isSpecialProtection(WeaponObject::ELECTRICITY)) prototype->setSpecialResist(WeaponObject::ELECTRICITY); if (creatureTemplate->isSpecialProtection(WeaponObject::ACID)) prototype->setSpecialResist(WeaponObject::ACID); if (creatureTemplate->isSpecialProtection(WeaponObject::LIGHTSABER)) prototype->setSpecialResist(WeaponObject::LIGHTSABER); CreatureAttackMap* attackMap = creatureTemplate->getAttacks(); if (attackMap->size() > 0) { prototype->setSpecialAttackOne(String(attackMap->getCommand(0))); if(attackMap->size() > 1) { prototype->setSpecialAttackTwo(String(attackMap->getCommand(1))); } } Locker locker(inventory); if (inventory->transferObject(prototype, -1, true, false)) { inventory->broadcastObject(prototype, true); } else { prototype->destroyObjectFromDatabase(true); } }
void DnaManager::generateSample(Creature* creature, CreatureObject* player,int quality){ if (quality < 0 || quality > 7) { return; } Locker lock(creature,player); CreatureTemplate* creatureTemplate = dynamic_cast<CreatureTemplate*>(creature->getCreatureTemplate()); int ferocity = creatureTemplate->getFerocity(); int cl = creature->getLevel(); int cle = instance()->generateScoreFor(DnaManager::CLEVERNESS,cl,quality); int cou = instance()->generateScoreFor(DnaManager::COURAGE,cl,quality); int dep = instance()->generateScoreFor(DnaManager::DEPENDABILITY,cl,quality); int dex = instance()->generateScoreFor(DnaManager::DEXTERITY,cl,quality); int end = instance()->generateScoreFor(DnaManager::ENDURANCE,cl,quality); int fie = instance()->generateScoreFor(DnaManager::FIERCENESS,ferocity,quality); int frt = instance()->generateScoreFor(DnaManager::FORTITUDE,cl,quality); int har = instance()->generateScoreFor(DnaManager::HARDINESS,cl,quality); int ite = instance()->generateScoreFor(DnaManager::INTELLIGENCE,cl,quality); int pow = instance()->generateScoreFor(DnaManager::POWER,cl,quality); // We should now have enough to generate a sample ManagedReference<DnaComponent*> prototype = player->getZoneServer()->createObject(qualityTemplates.get(quality), 1).castTo<DnaComponent*>(); if (prototype == NULL) { return; } Locker clocker(prototype); // Check Here for unique npcs StringId* nameId = creature->getObjectName(); if (nameId->getFile().isEmpty() || nameId->getStringID().isEmpty()) { prototype->setSource(creature->getCreatureName().toString()); } else { prototype->setSource(nameId->getFullPath()); } prototype->setQuality(quality); prototype->setLevel(cl); String serial = player->getZoneServer()->getCraftingManager()->generateSerial(); prototype->setSerialNumber(serial); prototype->setStats(cle,end,fie,pow,ite,cou,dep,dex,frt,har); prototype->setStun(creatureTemplate->getStun()); prototype->setKinetic(creatureTemplate->getKinetic()); prototype->setEnergy(creatureTemplate->getEnergy()); prototype->setBlast(creatureTemplate->getBlast()); prototype->setHeat(creatureTemplate->getHeat()); prototype->setCold(creatureTemplate->getCold()); prototype->setElectric(creatureTemplate->getElectricity()); prototype->setAcid(creatureTemplate->getAcid()); prototype->setSaber(creatureTemplate->getLightSaber()); prototype->setRanged(creatureTemplate->getWeapons().size() > 0); prototype->setArmorRating(creatureTemplate->getArmor()); CreatureAttackMap* attackMap = creatureTemplate->getAttacks(); if (attackMap->size() > 0) { prototype->setSpecialAttackOne(String(attackMap->getCommand(0))); if(attackMap->size() > 1) { prototype->setSpecialAttackTwo(String(attackMap->getCommand(1))); } } ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory"); if (inventory->hasFullContainerObjects()) { StringIdChatParameter err("survey", "no_inv_space"); player->sendSystemMessage(err); player->setPosture(CreaturePosture::UPRIGHT, true); return; } Locker locker(inventory); inventory->transferObject(prototype, -1, true,false); inventory->broadcastObject(prototype, true); }