include library.utils; include library.sui; include library.temp_schematic; include library.space_crafting; include library.create; include library.xp; const string_id LOOT_LIST = new string_id("sui", "analyze_loot"); const string LOOT = "datatables/space_loot/reverse_engineering/reverse_loot.iff"; const string LOOT_LOOKUP = "datatables/space_loot/reverse_engineering/reverse_loot_lookup.iff"; const string SCRIPTVAR_ANALYZE_SUI = "analyzer.sui"; const string SCRIPTVAR_ANALYZE_IDS = "analyzer.ids"; const string STF = "component_analyzer"; const string ANALYZE_TITLE = "@" + STF + ":analyze_title"; const string ANALYZE_PROMPT = "@" + STF + ":analyze_prompt"; const string NO_ITEMS_PROMPT = "@" + STF + ":no_items"; const string BTN_ANALYZE = "@" + STF + ":analyze"; trigger OnAttach() { return SCRIPT_CONTINUE; } trigger OnInitialize() { return SCRIPT_CONTINUE; } trigger OnAboutToReceiveItem(obj_id srcContainer, obj_id transferer, obj_id item) { // for CTS, allow all contained item(s) to be unpacked if (utils.hasLocalVar(self, "ctsBeingUnpacked")) { return SCRIPT_CONTINUE; } //is it a valid ship component or firespray schematic? if (!hasObjVar(item, "firespray_schematic.part")) { if (space_crafting.isValidShipComponent(item) == false) { string_id errormessage2 = new string_id(space_crafting.STF_COMPONENT_TOOL, "wrong_component_type"); sendSystemMessage(transferer, errormessage2); return SCRIPT_OVERRIDE; } } // does it have a flag saying it can't be re'd? if (hasObjVar(item, "ship_comp.flags")) { int flags = getIntObjVar(item, "ship_comp.flags"); boolean isBitSet = (flags & ship_component_flags.SCF_reverse_engineered) != 0; if (isBitSet == true) { string_id errormessage = new string_id(space_crafting.STF_COMPONENT_TOOL, "already_engineered"); sendSystemMessage(transferer, errormessage); return SCRIPT_OVERRIDE; } } // check existing contents of tool, if any, and verify you're loading like types with like types - script re-arranged to fix a Firespray schematic exploit - 7/21/05 RcT obj_id[] toolContents = getContents(self); if (toolContents != null && toolContents.length > 0) { if (isIdValid(toolContents[0])) { if (hasObjVar(toolContents[0], "firespray_schematic.part")) { if (hasObjVar(item, "firespray_schematic.part")) { return SCRIPT_CONTINUE; } else { string_id errormessage = new string_id(space_crafting.STF_COMPONENT_TOOL, "invalid"); sendSystemMessage(transferer, errormessage); return SCRIPT_OVERRIDE; } } string componentType = space_crafting.getShipComponentStringType(toolContents[0]); int level = space_crafting.getReverseEngineeringLevel(toolContents[0]); if (hasObjVar(item, "firespray_schematic.part") || space_crafting.getShipComponentStringType(item) != componentType || space_crafting.getReverseEngineeringLevel(item) != level) { string_id errormessage = new string_id(space_crafting.STF_COMPONENT_TOOL, "invalid"); sendSystemMessage(transferer, errormessage); return SCRIPT_OVERRIDE; } } // is it a valid ship component return SCRIPT_CONTINUE; } return SCRIPT_CONTINUE; } trigger OnGetAttributes( obj_id player, string[] names, string[] attribs ) { int idx = utils.getValidAttributeIndex(names); if (idx == -1) { return SCRIPT_CONTINUE; } if (hasObjVar(self, "reverse_engineering.charges")) { int value = getIntObjVar(self, "reverse_engineering.charges"); names[idx] = "charges"; attribs[idx] = Integer.toString(value); idx++; } return SCRIPT_CONTINUE; } trigger OnObjectMenuRequest(obj_id player, menu_info mi) { if ( !utils.isNestedWithin(self, player) ) return SCRIPT_CONTINUE; int lootList = mi.addRootMenu(menu_info_types.SERVER_MENU1, LOOT_LIST); if ( lootList > -1 && (( getContainedBy(self) != getOwner(self) ) || isGod(player)) ) { string template = utils.getTemplateFilenameNoPath(self); } return SCRIPT_CONTINUE; } trigger OnObjectMenuSelect(obj_id player, int item) { if ( !utils.isNestedWithin(self, player) ) return SCRIPT_CONTINUE; string template = utils.getTemplateFilenameNoPath(self); boolean giveFiresprayPiece = false; obj_id newComponent = null; if ( item == menu_info_types.SERVER_MENU1 ) { int charges = getIntObjVar(self, "reverse_engineering.charges"); obj_id[] toolContents = getContents(self); obj_id playerInv = utils.getInventoryContainer(player); string temp = ""; if (toolContents == null || toolContents.length <= 0) { return SCRIPT_CONTINUE; } else { if (toolContents[0] != null) { int level = space_crafting.getReverseEngineeringLevel(toolContents[0]); if (hasObjVar(toolContents[0], "firespray_schematic.part")) level = 8; // warn player if too few components used if (level > toolContents.length) { string_id errortoomany = new string_id(space_crafting.STF_COMPONENT_TOOL, "too_few"); sendSystemMessage(player, errortoomany); return SCRIPT_OVERRIDE; } // warn player if too many components used if (level < toolContents.length) { string_id errortoomany = new string_id(space_crafting.STF_COMPONENT_TOOL, "too_many"); sendSystemMessage(player, errortoomany); return SCRIPT_OVERRIDE; } string componentType = space_crafting.getShipComponentStringType(toolContents[0]); giveFiresprayPiece = calculateFiresprayGrant(toolContents, player); if (hasObjVar(toolContents[0], "firespray_schematic.part")) componentType = "firespray_schematic"; if (componentType == "armor") { newComponent = reverseEngineerArmor(toolContents, player, level); if (newComponent != null) { charges--; setObjVar(self, "reverse_engineering.charges" ,charges); int flags = getIntObjVar(newComponent, "ship_comp.flags"); flags |= ship_component_flags.SCF_reverse_engineered; setObjVar(newComponent, "ship_comp.flags", flags); } } else if (componentType == "booster") { newComponent = reverseEngineerBooster(toolContents, player, level); if (newComponent != null) { charges--; setObjVar(self, "reverse_engineering.charges" ,charges); int flags = getIntObjVar(newComponent, "ship_comp.flags"); flags |= ship_component_flags.SCF_reverse_engineered; setObjVar(newComponent, "ship_comp.flags", flags); } } else if (componentType == "capacitor") { newComponent = reverseEngineerCapacitor(toolContents, player, level); if (newComponent != null) { charges--; setObjVar(self, "reverse_engineering.charges" ,charges); int flags = getIntObjVar(newComponent, "ship_comp.flags"); flags |= ship_component_flags.SCF_reverse_engineered; setObjVar(newComponent, "ship_comp.flags", flags); } } else if (componentType == "droid_interface") { newComponent = reverseEngineerDroidInterface(toolContents, player, level); if (newComponent != null) { charges--; setObjVar(self, "reverse_engineering.charges" ,charges); int flags = getIntObjVar(newComponent, "ship_comp.flags"); flags |= ship_component_flags.SCF_reverse_engineered; setObjVar(newComponent, "ship_comp.flags", flags); } } else if (componentType == "engine") { newComponent = reverseEngineerEngine(toolContents, player, level); if (newComponent != null) { charges--; setObjVar(self, "reverse_engineering.charges" ,charges); int flags = getIntObjVar(newComponent, "ship_comp.flags"); flags |= ship_component_flags.SCF_reverse_engineered; setObjVar(newComponent, "ship_comp.flags", flags); } } else if (componentType == "reactor") { newComponent = reverseEngineerReactor(toolContents, player, level); if (newComponent != null) { charges--; setObjVar(self, "reverse_engineering.charges" ,charges); int flags = getIntObjVar(newComponent, "ship_comp.flags"); flags |= ship_component_flags.SCF_reverse_engineered; setObjVar(newComponent, "ship_comp.flags", flags); } } else if (componentType == "shield") { newComponent = reverseEngineerShield(toolContents, player, level); if (newComponent != null) { charges--; setObjVar(self, "reverse_engineering.charges" ,charges); int flags = getIntObjVar(newComponent, "ship_comp.flags"); flags |= ship_component_flags.SCF_reverse_engineered; setObjVar(newComponent, "ship_comp.flags", flags); } } else if (componentType == "weapon") { newComponent = reverseEngineerWeapon(toolContents, player, level); if (newComponent != null) { charges--; setObjVar(self, "reverse_engineering.charges" ,charges); int flags = getIntObjVar(newComponent, "ship_comp.flags"); flags |= ship_component_flags.SCF_reverse_engineered; setObjVar(newComponent, "ship_comp.flags", flags); } } else if (componentType == "firespray_schematic") { if (toolContents.length != 8) { string_id notEnough = new string_id(space_crafting.STF_COMPONENT_TOOL, "not_enough"); sendSystemMessage(player, notEnough); return SCRIPT_CONTINUE; } boolean[] allPieces = new boolean[8]; allPieces[0] = false; allPieces[1] = false; allPieces[2] = false; allPieces[3] = false; allPieces[4] = false; allPieces[5] = false; allPieces[6] = false; allPieces[7] = false; for (int i = 0; i < toolContents.length; i++) { int piece = utils.getIntObjVar(toolContents[i], "firespray_schematic.part"); allPieces[piece-1] = true; } if (allPieces[0] == true && allPieces[1] == true && allPieces[2] == true && allPieces[3] == true && allPieces[4] == true && allPieces[5] == true && allPieces[6] == true && allPieces[7] == true) { obj_id schematic= create.object("object/tangible/space/special_loot/firespray_schematic.iff", playerInv, false, false); string_id gotSchematic = new string_id(space_crafting.STF_COMPONENT_TOOL, "gotschematic"); sendSystemMessage(player, gotSchematic); for (int i = 0; i < toolContents.length; i++) { destroyObject(toolContents[i]); } return SCRIPT_CONTINUE; } else { string_id notUniquePieces = new string_id(space_crafting.STF_COMPONENT_TOOL, "notunique"); sendSystemMessage(player, notUniquePieces); return SCRIPT_CONTINUE; } } else { string_id sysmessage = new string_id(space_crafting.STF_COMPONENT_TOOL, "not_a_component"); sendSystemMessage(player, sysmessage); return SCRIPT_OVERRIDE; } } } if (giveFiresprayPiece == true) { if (isIdValid(newComponent)) { int pieceNum = rand(1, 8); //obj_id schematicPiece= create.object("object/tangible/space/special_loot/firespray_schematic_part"+pieceNum+".iff", playerInv, false, false); obj_id schematicPiece = createObjectOverloaded("object/tangible/space/special_loot/firespray_schematic_part"+pieceNum+".iff", playerInv); string_id gotPiece = new string_id(space_crafting.STF_COMPONENT_TOOL, "gotpiece"); sendSystemMessage(player, gotPiece); } } if (charges <=0) { string_id outofcharges = new string_id(space_crafting.STF_COMPONENT_TOOL, "out_of_charges"); sendSystemMessage(player, outofcharges); destroyObject(self); } } return SCRIPT_CONTINUE; } boolean calculateFiresprayGrant(obj_id[] contents, obj_id player) { int numKuat = 0; for (int i = 0; i < contents.length; i++) { string template = utils.getTemplateName(contents[i]); int isKuat = dataTableGetInt(LOOT, template, "isKuat"); if (isKuat == 1) numKuat++; } int pctChance = 0; if (numKuat == 1 || numKuat == 2) pctChance = 1; if (numKuat == 3 || numKuat == 4) pctChance = 2; if (numKuat == 5 || numKuat == 6) pctChance = 3; if (numKuat == 7 || numKuat == 8 || numKuat == 9) pctChance = 4; if (numKuat == 10) pctChance = 5; int roll = rand(0, 100); if (roll <= pctChance) { return true; } else return false; } float getReverseEngineeringExpertiseBonus(obj_id player) { float skillMod = getEnhancedSkillStatisticModifier(player, "expertise_reverse_engineering_bonus"); if(skillMod > 10) { skillMod = 10.0f; } return skillMod; } float getLevelBonus(obj_id player, int level) { float fltBonus = 0; if (level == 1) { fltBonus = .01f; } else if (level == 2 || level == 3) { fltBonus = .02f; } else if (level == 4 || level == 5) { fltBonus = .03f; } else if (level == 6 || level == 7) { fltBonus = .04f; } else if (level == 8 || level == 9) { fltBonus = .05f; } else if (level == 10) { fltBonus = .06f; } fltBonus += Math.round(getReverseEngineeringExpertiseBonus(player)) * 0.001; return fltBonus; } obj_id createLegendaryLoot(obj_id player, obj_id tool, string category) { string[] items = dataTableGetStringColumn(LOOT_LOOKUP, category); int pick = rand(0, items.length-1); string rare = dataTableGetString(LOOT_LOOKUP, pick, category); string msg = dataTableGetString(LOOT_LOOKUP, pick, (category+"_strings")); //obj_id newLoot = createSpecialLoot(player, rare); string_id sysmessage = new string_id(space_crafting.STF_COMPONENT_TOOL, msg); sendSystemMessage(player, sysmessage); destroyObject(tool); return null ; } obj_id reverseEngineerArmor(obj_id[] objComponents, obj_id player, int level) { int revSkill = getSkillStatisticModifier(player, "engineering_reverse"); if (level > revSkill) { string_id insufficientLevel = new string_id (space_crafting.STF_COMPONENT_TOOL, "level"); sendSystemMessage(player, insufficientLevel); return null; } float fltArmorHpAverage = space_crafting.getComponentMaximumArmorHitpoints(objComponents[0]); float fltHpAverage = space_crafting.getComponentMaximumHitpoints(objComponents[0]); float fltMassAverage = space_crafting.getComponentMass(objComponents[0]); for (int i = 0; i < objComponents.length; i++) { float armor = space_crafting.getComponentMaximumArmorHitpoints(objComponents[i]); if (armor > fltArmorHpAverage) fltArmorHpAverage = armor; float hp = space_crafting.getComponentMaximumHitpoints(objComponents[i]); if (hp > fltHpAverage) fltHpAverage = hp; float mass = space_crafting.getComponentMass(objComponents[i]); if (mass < fltMassAverage && mass > 0) fltMassAverage = mass; } float fltBonus = getLevelBonus(player, level); float fltMass = fltMassAverage - (fltMassAverage*fltBonus); float fltArmorHp = fltArmorHpAverage + (fltArmorHpAverage*fltBonus); float fltHp = fltHpAverage + (fltHpAverage*fltBonus); string template = utils.getTemplateFilenameNoPath(objComponents[0]); obj_id playerInv = utils.getInventoryContainer(player); obj_id newComponent = create.object("object/tangible/ship/components/armor/"+template, playerInv, false, false); if (isIdValid(newComponent)) { space_crafting.setComponentMaximumArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentCurrentArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentMaximumHitpoints(newComponent, fltHp); space_crafting.setComponentCurrentHitpoints(newComponent, fltHp); space_crafting.setComponentMass(newComponent, fltMass); string entries[] = new string[3]; string strMassAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "massavg")); string strHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "hpavg")); string strArmorHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "armorhpavg")); string strFinalOutput = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "finaloutput")); string strBonusApplied = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "bonusapplied")); entries[0] = strMassAvg + " " + fltMassAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " +fltMass; entries[1] = strHpAvg + " " + fltHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltHp; entries[2] = strArmorHpAvg + " " + fltArmorHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltArmorHp; finishReverseEngineering(newComponent, player, objComponents, entries); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "invfull"); sendSystemMessage(player, error); return null; } return newComponent; } obj_id reverseEngineerBooster(obj_id[] objComponents, obj_id player, int level) { int revSkill = getSkillStatisticModifier(player, "propulsion_reverse"); if (level > revSkill) { string_id insufficientLevel = new string_id (space_crafting.STF_COMPONENT_TOOL, "level"); sendSystemMessage(player, insufficientLevel); return null; } float fltMassAverage = space_crafting.getComponentMass(objComponents[0]); float fltArmorHpAverage = space_crafting.getComponentMaximumArmorHitpoints(objComponents[0]); float fltHpAverage = space_crafting.getComponentMaximumHitpoints(objComponents[0]); float fltBoosterEnergyAverage = space_crafting.getBoosterMaximumEnergy(objComponents[0]); float fltBoosterRechargeAverage = space_crafting.getBoosterEnergyRechargeRate(objComponents[0]); float fltBoosterConsumptionAverage = space_crafting.getboosterEnergyConsumptionRate(objComponents[0]); float fltBoosterAccelAverage = space_crafting.getBoosterAcceleration(objComponents[0]); float fltBoosterSpeedAverage = space_crafting.getBoosterMaximumSpeed(objComponents[0]); float fltEnergyMaintenance = space_crafting.getComponentEnergyMaintenance(objComponents[0]); for (int i = 0; i < objComponents.length; i++) { float armor = space_crafting.getComponentMaximumArmorHitpoints(objComponents[i]); if (armor > fltArmorHpAverage) fltArmorHpAverage = armor; float hp = space_crafting.getComponentMaximumHitpoints(objComponents[i]); if (hp > fltHpAverage) fltHpAverage = hp; float mass = space_crafting.getComponentMass(objComponents[i]); if (mass < fltMassAverage) fltMassAverage = mass; float energy = space_crafting.getBoosterMaximumEnergy(objComponents[i]); if (energy > fltBoosterEnergyAverage) fltBoosterEnergyAverage = energy; float recharge = space_crafting.getBoosterEnergyRechargeRate(objComponents[i]); if (recharge > fltBoosterRechargeAverage) fltBoosterRechargeAverage = recharge; float consumption = space_crafting.getboosterEnergyConsumptionRate(objComponents[i]); if (consumption < fltBoosterConsumptionAverage) fltBoosterConsumptionAverage = consumption; float accel = space_crafting.getBoosterAcceleration(objComponents[i]); if (accel > fltBoosterAccelAverage) fltBoosterAccelAverage = accel; float speed = space_crafting.getBoosterMaximumSpeed(objComponents[i]); if (speed > fltBoosterSpeedAverage) fltBoosterSpeedAverage = speed; float maintenance = space_crafting.getComponentEnergyMaintenance(objComponents[i]); if (maintenance < fltEnergyMaintenance) fltEnergyMaintenance = maintenance; } float fltBonus = getLevelBonus(player, level); float fltMass = fltMassAverage - (fltMassAverage*fltBonus); float fltArmorHp = fltArmorHpAverage + (fltArmorHpAverage*fltBonus); float fltHp = fltHpAverage + (fltHpAverage*fltBonus); float fltBoosterEnergy = fltBoosterEnergyAverage + (fltBoosterEnergyAverage*fltBonus); float fltBoosterRecharge = fltBoosterRechargeAverage + (fltBoosterRechargeAverage*fltBonus); float fltBoosterConsumption = fltBoosterConsumptionAverage - (fltBoosterConsumptionAverage*fltBonus); float fltBoosterAccel = fltBoosterAccelAverage + (fltBoosterAccelAverage*fltBonus); float fltBoosterSpeed = fltBoosterSpeedAverage + (fltBoosterSpeedAverage*fltBonus); float fltEnergyMaintenanceFinal = fltEnergyMaintenance - (fltEnergyMaintenance*fltBonus); string template = utils.getTemplateFilenameNoPath(objComponents[0]); obj_id playerInv = utils.getInventoryContainer(player); obj_id newComponent = create.object("object/tangible/ship/components/booster/"+template, playerInv, false, false); if (isIdValid(newComponent)) { space_crafting.setComponentMaximumArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentCurrentArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentMaximumHitpoints(newComponent, fltHp); space_crafting.setComponentCurrentHitpoints(newComponent, fltHp); space_crafting.setComponentMass(newComponent, fltMass); space_crafting.setComponentEnergyMaintenance(newComponent, fltEnergyMaintenanceFinal); space_crafting.setBoosterCurrentEnergy(newComponent, fltBoosterEnergy); space_crafting.setBoosterMaximumEnergy(newComponent, fltBoosterEnergy); space_crafting.setBoosterEnergyRechargeRate(newComponent, fltBoosterRecharge); space_crafting.setBoosterEnergyConsumptionRate(newComponent, fltBoosterConsumption); space_crafting.setBoosterAcceleration(newComponent, fltBoosterAccel); space_crafting.setBoosterMaximumSpeed(newComponent, fltBoosterSpeed); string entries[] = new string[9]; string strMassAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "massavg")); string strHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "hpavg")); string strArmorHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "armorhpavg")); string strEnergyMaintenance = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "energymaintenance")); string strFinalOutput = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "finaloutput")); string strBonusApplied = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "bonusapplied")); string strBoosterEnergy = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "boosterenergy")); string strBoosterRecharge = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "boosterrecharge")); string strBoosterConsumption= utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "boosterconsumption")); string strBoosterAccel = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "boosteraccel")); string strBoosterSpeed = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "boosterspeed")); entries[0] = strMassAvg + " " + fltMassAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " +fltMass; entries[1] = strHpAvg + " " + fltHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltHp; entries[2] = strArmorHpAvg + " " + fltArmorHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltArmorHp; entries[3] = strEnergyMaintenance + " " + fltEnergyMaintenance + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEnergyMaintenanceFinal; entries[4] = strBoosterEnergy + " " + fltBoosterEnergyAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltBoosterEnergy; entries[5] = strBoosterRecharge + " " + fltBoosterRechargeAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltBoosterRecharge; entries[6] = strBoosterConsumption + " " + fltBoosterConsumptionAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltBoosterConsumption; entries[7] = strBoosterAccel + " " + fltBoosterAccelAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltBoosterAccel; entries[8] = strBoosterSpeed + " " + fltBoosterSpeedAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltBoosterSpeed; finishReverseEngineering(newComponent, player, objComponents, entries); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "invfull"); sendSystemMessage(player, error); return null; } return newComponent; } obj_id reverseEngineerCapacitor(obj_id[] objComponents, obj_id player, int level) { int revSkill = getSkillStatisticModifier(player, "systems_reverse"); if (level > revSkill) { string_id insufficientLevel = new string_id (space_crafting.STF_COMPONENT_TOOL, "level"); sendSystemMessage(player, insufficientLevel); return null; } float fltMassAverage = space_crafting.getComponentMass(objComponents[0]); float fltArmorHpAverage = space_crafting.getComponentMaximumArmorHitpoints(objComponents[0]); float fltHpAverage = space_crafting.getComponentMaximumHitpoints(objComponents[0]); float fltEnergyMaintenance = space_crafting.getComponentEnergyMaintenance(objComponents[0]); float fltCapEnergyAverage = space_crafting.getWeaponCapacitorMaximumEnergy(objComponents[0]); float fltCapRechargeAverage = space_crafting.getWeaponCapacitorRechargeRate(objComponents[0]); for (int i = 0; i < objComponents.length; i++) { float armor = space_crafting.getComponentMaximumArmorHitpoints(objComponents[i]); if (armor > fltArmorHpAverage) fltArmorHpAverage = armor; float hp = space_crafting.getComponentMaximumHitpoints(objComponents[i]); if (hp > fltHpAverage) fltHpAverage = hp; float mass = space_crafting.getComponentMass(objComponents[i]); if (mass < fltMassAverage) fltMassAverage = mass; float maintenance = space_crafting.getComponentEnergyMaintenance(objComponents[i]); if (maintenance < fltEnergyMaintenance) fltEnergyMaintenance = maintenance; float energy = space_crafting.getWeaponCapacitorMaximumEnergy(objComponents[i]); if (energy > fltCapEnergyAverage) fltCapEnergyAverage = energy; float recharge = space_crafting.getWeaponCapacitorRechargeRate(objComponents[i]); if (recharge > fltCapRechargeAverage) fltCapRechargeAverage = recharge; } float fltBonus = getLevelBonus(player, level); float fltMass = fltMassAverage - (fltMassAverage*fltBonus); float fltArmorHp = fltArmorHpAverage + (fltArmorHpAverage*fltBonus); float fltHp = fltHpAverage + (fltHpAverage*fltBonus); float fltEnergyMaintenanceFinal = fltEnergyMaintenance - (fltEnergyMaintenance*fltBonus); float fltCapEnergy = fltCapEnergyAverage + (fltCapEnergyAverage*fltBonus); float fltCapRecharge = fltCapRechargeAverage + (fltCapRechargeAverage*fltBonus); string template = utils.getTemplateFilenameNoPath(objComponents[0]); obj_id playerInv = utils.getInventoryContainer(player); obj_id newComponent = create.object("object/tangible/ship/components/weapon_capacitor/"+template, playerInv, false, false); if (isIdValid(newComponent)) { space_crafting.setComponentMaximumArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentCurrentArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentMaximumHitpoints(newComponent, fltHp); space_crafting.setComponentCurrentHitpoints(newComponent, fltHp); space_crafting.setComponentMass(newComponent, fltMass); space_crafting.setComponentEnergyMaintenance(newComponent, fltEnergyMaintenanceFinal); space_crafting.setWeaponCapacitorRechargeRate(newComponent, fltCapRecharge); space_crafting.setWeaponCapacitorMaximumEnergy(newComponent, fltCapEnergy); space_crafting.setWeaponCapacitorCurrentEnergy(newComponent, fltCapEnergy); string entries[] = new string[6]; string strMassAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "massavg")); string strHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "hpavg")); string strArmorHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "armorhpavg")); string strEnergyMaintenance = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "energymaintenance")); string strFinalOutput = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "finaloutput")); string strBonusApplied = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "bonusapplied")); string strCapEnergy = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "capenergy")); string strCapRecharge = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "caprecharge")); entries[0] = strMassAvg + " " + fltMassAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " +fltMass; entries[1] = strHpAvg + " " + fltHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltHp; entries[2] = strArmorHpAvg + " " + fltArmorHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltArmorHp; entries[3] = strEnergyMaintenance + " " + fltEnergyMaintenance + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEnergyMaintenanceFinal; entries[4] = strCapEnergy + " " + fltCapEnergyAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltCapEnergy; entries[5] = strCapRecharge + " " + fltCapRechargeAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltCapRecharge; finishReverseEngineering(newComponent, player, objComponents, entries); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "invfull"); sendSystemMessage(player, error); return null; } return newComponent; } obj_id reverseEngineerDroidInterface(obj_id[] objComponents, obj_id player, int level) { int revSkill = getSkillStatisticModifier(player, "systems_reverse"); if (level > revSkill) { string_id insufficientLevel = new string_id (space_crafting.STF_COMPONENT_TOOL, "level"); sendSystemMessage(player, insufficientLevel); return null; } float fltMassAverage = space_crafting.getComponentMass(objComponents[0]); float fltArmorHpAverage = space_crafting.getComponentMaximumArmorHitpoints(objComponents[0]); float fltHpAverage = space_crafting.getComponentMaximumHitpoints(objComponents[0]); float fltEnergyMaintenance = space_crafting.getComponentEnergyMaintenance(objComponents[0]); float fltDroidInterfaceSpeedAverage = space_crafting.getDroidInterfaceCommandSpeed(objComponents[0]); for (int i = 0; i < objComponents.length; i++) { float armor = space_crafting.getComponentMaximumArmorHitpoints(objComponents[i]); if (armor > fltArmorHpAverage) fltArmorHpAverage = armor; float hp = space_crafting.getComponentMaximumHitpoints(objComponents[i]); if (hp > fltHpAverage) fltHpAverage = hp; float mass = space_crafting.getComponentMass(objComponents[i]); if (mass < fltMassAverage) fltMassAverage = mass; float maintenance = space_crafting.getComponentEnergyMaintenance(objComponents[i]); if (maintenance < fltEnergyMaintenance) fltEnergyMaintenance = maintenance; float speed = space_crafting.getDroidInterfaceCommandSpeed(objComponents[i]); if (speed < fltDroidInterfaceSpeedAverage) fltDroidInterfaceSpeedAverage = speed; } float fltBonus = getLevelBonus(player, level); float fltMass = fltMassAverage - (fltMassAverage*fltBonus); float fltArmorHp = fltArmorHpAverage + (fltArmorHpAverage*fltBonus); float fltHp = fltHpAverage + (fltHpAverage*fltBonus); float fltEnergyMaintenanceFinal = fltEnergyMaintenance - (fltEnergyMaintenance*fltBonus); float fltDroidInterfaceSpeed = fltDroidInterfaceSpeedAverage - (fltDroidInterfaceSpeedAverage*fltBonus); string template = utils.getTemplateFilenameNoPath(objComponents[0]); obj_id playerInv = utils.getInventoryContainer(player); obj_id newComponent = create.object("object/tangible/ship/components/droid_interface/"+template, playerInv, false, false); if (isIdValid(newComponent)) { space_crafting.setComponentMaximumArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentCurrentArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentMaximumHitpoints(newComponent, fltHp); space_crafting.setComponentCurrentHitpoints(newComponent, fltHp); space_crafting.setComponentMass(newComponent, fltMass); space_crafting.setComponentEnergyMaintenance(newComponent, fltEnergyMaintenanceFinal); space_crafting.setDroidInterfaceCommandSpeed(newComponent, fltDroidInterfaceSpeed); string entries[] = new string[5]; string strMassAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "massavg")); string strHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "hpavg")); string strArmorHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "armorhpavg")); string strEnergyMaintenance = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "energymaintenance")); string strFinalOutput = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "finaloutput")); string strBonusApplied = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "bonusapplied")); string strDroidInterfaceSpeed = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "commandspeed")); entries[0] = strMassAvg + " " + fltMassAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " +fltMass; entries[1] = strHpAvg + " " + fltHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltHp; entries[2] = strArmorHpAvg + " " + fltArmorHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltArmorHp; entries[3] = strEnergyMaintenance + " " + fltEnergyMaintenance + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEnergyMaintenanceFinal; entries[4] = strDroidInterfaceSpeed + " " + fltDroidInterfaceSpeedAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltDroidInterfaceSpeed; finishReverseEngineering(newComponent, player, objComponents, entries); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "invfull"); sendSystemMessage(player, error); return null; } return newComponent; } obj_id reverseEngineerEngine(obj_id[] objComponents, obj_id player, int level) { int revSkill = getSkillStatisticModifier(player, "propulsion_reverse"); if (level > revSkill) { string_id insufficientLevel = new string_id (space_crafting.STF_COMPONENT_TOOL, "level"); sendSystemMessage(player, insufficientLevel); return null; } float fltMassAverage = space_crafting.getComponentMass(objComponents[0]); float fltArmorHpAverage = space_crafting.getComponentMaximumArmorHitpoints(objComponents[0]); float fltHpAverage = space_crafting.getComponentMaximumHitpoints(objComponents[0]); float fltEnergyMaintenance = space_crafting.getComponentEnergyMaintenance(objComponents[0]); float fltEngineAccelAvg = space_crafting.getEngineAcceleration(objComponents[0]); float fltEngineDecelAvg = space_crafting.getEngineDeceleration(objComponents[0]); float fltEnginePitchAvg = space_crafting.getEngineMaximumPitch(objComponents[0]); float fltEngineYawAvg = space_crafting.getEngineMaximumYaw(objComponents[0]); float fltEngineRollAvg = space_crafting.getEngineMaximumRoll(objComponents[0]); float fltEngineSpeedAvg = space_crafting.getEngineMaximumSpeed(objComponents[0]); for (int i = 0; i < objComponents.length; i++) { float armor = space_crafting.getComponentMaximumArmorHitpoints(objComponents[i]); if (armor > fltArmorHpAverage) fltArmorHpAverage = armor; float hp = space_crafting.getComponentMaximumHitpoints(objComponents[i]); if (hp > fltHpAverage) fltHpAverage = hp; float mass = space_crafting.getComponentMass(objComponents[i]); if (mass < fltMassAverage) fltMassAverage = mass; float maintenance = space_crafting.getComponentEnergyMaintenance(objComponents[i]); if (maintenance < fltEnergyMaintenance) fltEnergyMaintenance = maintenance; float accel = space_crafting.getEngineAcceleration(objComponents[i]); if (accel > fltEngineAccelAvg) fltEngineAccelAvg = accel; float decel = space_crafting.getEngineDeceleration(objComponents[i]); if (decel > fltEngineDecelAvg) fltEngineDecelAvg = decel; float pitch = space_crafting.getEngineMaximumPitch(objComponents[i]); if (pitch > fltEnginePitchAvg) fltEnginePitchAvg = pitch; float yaw = space_crafting.getEngineMaximumYaw(objComponents[i]); if (yaw > fltEngineYawAvg) fltEngineYawAvg = yaw; float roll = space_crafting.getEngineMaximumRoll(objComponents[i]); if (roll > fltEngineRollAvg) fltEngineRollAvg = roll; float speed = space_crafting.getEngineMaximumSpeed(objComponents[i]); if (speed > fltEngineSpeedAvg) fltEngineSpeedAvg = speed; } float fltBonus = getLevelBonus(player, level); float fltMass = fltMassAverage - (fltMassAverage*fltBonus); float fltArmorHp = fltArmorHpAverage + (fltArmorHpAverage*fltBonus); float fltHp = fltHpAverage + (fltHpAverage*fltBonus); float fltEngineAccel = fltEngineAccelAvg + (fltEngineAccelAvg*fltBonus); float fltEngineDecel = fltEngineDecelAvg + (fltEngineDecelAvg*fltBonus); float fltEnginePitch = fltEnginePitchAvg + (fltEnginePitchAvg*fltBonus); float fltEngineYaw = fltEngineYawAvg + (fltEngineYawAvg*fltBonus); float fltEngineRoll = fltEngineRollAvg + (fltEngineRollAvg*fltBonus); float fltEngineSpeed = fltEngineSpeedAvg + (fltEngineSpeedAvg*fltBonus); float fltEnergyMaintenanceFinal = fltEnergyMaintenance - (fltEnergyMaintenance*fltBonus); string template = utils.getTemplateFilenameNoPath(objComponents[0]); obj_id playerInv = utils.getInventoryContainer(player); obj_id newComponent = create.object("object/tangible/ship/components/engine/"+template, playerInv, false, false); if (isIdValid(newComponent)) { space_crafting.setComponentMaximumArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentCurrentArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentMaximumHitpoints(newComponent, fltHp); space_crafting.setComponentCurrentHitpoints(newComponent, fltHp); space_crafting.setComponentMass(newComponent, fltMass); space_crafting.setComponentEnergyMaintenance(newComponent, fltEnergyMaintenanceFinal); space_crafting.setEngineAcceleration(newComponent, fltEngineAccel); space_crafting.setEngineDeceleration(newComponent, fltEngineDecel); space_crafting.setEngineMaximumPitch(newComponent, fltEnginePitch); space_crafting.setEngineMaximumYaw(newComponent, fltEngineYaw); space_crafting.setEngineMaximumRoll(newComponent, fltEngineRoll); space_crafting.setEngineMaximumSpeed(newComponent, fltEngineSpeed); string entries[] = new string[8]; string strMassAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "massavg")); string strHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "hpavg")); string strArmorHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "armorhpavg")); string strFinalOutput = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "finaloutput")); string strBonusApplied = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "bonusapplied")); string strEnergyMaintenance = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "energymaintenance")); string strEnginePitch = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "engpitch")); string strEngineYaw = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "engyaw")); string strEngineRoll = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "engroll")); string strEngineSpeed = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "engspeed")); entries[0] = strMassAvg + " " + fltMassAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " +fltMass; entries[1] = strHpAvg + " " + fltHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltHp; entries[2] = strArmorHpAvg + " " + fltArmorHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltArmorHp; entries[3] = strEnergyMaintenance + " " + fltEnergyMaintenance + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEnergyMaintenanceFinal; entries[4] = strEnginePitch + " " + fltEnginePitchAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEnginePitch; entries[5] = strEngineYaw + " " + fltEngineYawAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEngineYaw; entries[6] = strEngineRoll + " " + fltEngineRollAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEngineRoll; entries[7] = strEngineSpeed + " " + fltEngineSpeedAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEngineSpeed; finishReverseEngineering(newComponent, player, objComponents, entries); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "invfull"); sendSystemMessage(player, error); return null; } return newComponent; } obj_id reverseEngineerReactor(obj_id[] objComponents, obj_id player, int level) { int revSkill = getSkillStatisticModifier(player, "systems_reverse"); if (level > revSkill) { string_id insufficientLevel = new string_id (space_crafting.STF_COMPONENT_TOOL, "level"); sendSystemMessage(player, insufficientLevel); return null; } float fltMassAverage = space_crafting.getComponentMass(objComponents[0]); float fltArmorHpAverage = space_crafting.getComponentMaximumArmorHitpoints(objComponents[0]); float fltHpAverage = space_crafting.getComponentMaximumHitpoints(objComponents[0]); float fltReactorEnergyAvg = space_crafting.getReactorEnergyGeneration(objComponents[0]); for (int i = 0; i < objComponents.length; i++) { float armor = space_crafting.getComponentMaximumArmorHitpoints(objComponents[i]); if (armor > fltArmorHpAverage) fltArmorHpAverage = armor; float hp = space_crafting.getComponentMaximumHitpoints(objComponents[i]); if (hp > fltHpAverage) fltHpAverage = hp; float mass = space_crafting.getComponentMass(objComponents[i]); if (mass < fltMassAverage) fltMassAverage = mass; float energy = space_crafting.getReactorEnergyGeneration(objComponents[i]); if (energy > fltReactorEnergyAvg) fltReactorEnergyAvg = energy; } float fltBonus = getLevelBonus(player, level); float fltMass = fltMassAverage - (fltMassAverage*fltBonus); float fltArmorHp = fltArmorHpAverage + (fltArmorHpAverage*fltBonus); float fltHp = fltHpAverage + (fltHpAverage*fltBonus); float fltReactorEnergy = fltReactorEnergyAvg + (fltReactorEnergyAvg*fltBonus); string template = utils.getTemplateFilenameNoPath(objComponents[0]); obj_id playerInv = utils.getInventoryContainer(player); obj_id newComponent = create.object("object/tangible/ship/components/reactor/"+template, playerInv, false, false); if (isIdValid(newComponent)) { space_crafting.setComponentMaximumArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentCurrentArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentMaximumHitpoints(newComponent, fltHp); space_crafting.setComponentCurrentHitpoints(newComponent, fltHp); space_crafting.setComponentMass(newComponent, fltMass); space_crafting.setReactorEnergyGeneration(newComponent, fltReactorEnergy); string entries[] = new string[4]; string strMassAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "massavg")); string strHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "hpavg")); string strArmorHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "armorhpavg")); string strFinalOutput = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "finaloutput")); string strBonusApplied = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "bonusapplied")); string strReactorEnergy = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "reactorenergy")); entries[0] = strMassAvg + " " + fltMassAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " +fltMass; entries[1] = strHpAvg + " " + fltHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltHp; entries[2] = strArmorHpAvg + " " + fltArmorHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltArmorHp; entries[3] = strReactorEnergy + " " + fltReactorEnergyAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltReactorEnergy; finishReverseEngineering(newComponent, player, objComponents, entries); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "invfull"); sendSystemMessage(player, error); return null; } return newComponent; } obj_id reverseEngineerShield(obj_id[] objComponents, obj_id player, int level) { int revSkill = getSkillStatisticModifier(player, "defense_reverse"); if (level > revSkill) { string_id insufficientLevel = new string_id (space_crafting.STF_COMPONENT_TOOL, "level"); sendSystemMessage(player, insufficientLevel); return null; } float fltMassAverage = space_crafting.getComponentMass(objComponents[0]); float fltArmorHpAverage = space_crafting.getComponentMaximumArmorHitpoints(objComponents[0]); float fltHpAverage = space_crafting.getComponentMaximumHitpoints(objComponents[0]); float fltEnergyMaintenance = space_crafting.getComponentEnergyMaintenance(objComponents[0]); float fltShdBackHpAvg = space_crafting.getShieldGeneratorMaximumBackHitpoints(objComponents[0]); float fltShdFrontHpAvg = space_crafting.getShieldGeneratorMaximumFrontHitpoints(objComponents[0]); float fltShdRechargeAvg = space_crafting.getShieldGeneratorRechargeRate(objComponents[0]); for (int i = 0; i < objComponents.length; i++) { float armor = space_crafting.getComponentMaximumArmorHitpoints(objComponents[i]); if (armor > fltArmorHpAverage) fltArmorHpAverage = armor; float hp = space_crafting.getComponentMaximumHitpoints(objComponents[i]); if (hp > fltHpAverage) fltHpAverage = hp; float mass = space_crafting.getComponentMass(objComponents[i]); if (mass < fltMassAverage) fltMassAverage = mass; float maintenance = space_crafting.getComponentEnergyMaintenance(objComponents[i]); if (maintenance < fltEnergyMaintenance) fltEnergyMaintenance = maintenance; float back = space_crafting.getShieldGeneratorMaximumBackHitpoints(objComponents[i]); if (back > fltShdBackHpAvg) fltShdBackHpAvg = back; float front = space_crafting.getShieldGeneratorMaximumFrontHitpoints(objComponents[i]); if (front > fltShdFrontHpAvg) fltShdFrontHpAvg = front; float recharge = space_crafting.getShieldGeneratorRechargeRate(objComponents[i]); if (recharge > fltShdRechargeAvg) fltShdRechargeAvg = recharge; } float fltBonus = getLevelBonus(player, level); float fltMass = fltMassAverage - (fltMassAverage*fltBonus); float fltArmorHp = fltArmorHpAverage + (fltArmorHpAverage*fltBonus); float fltHp = fltHpAverage + (fltHpAverage*fltBonus); float fltEnergyMaintenanceFinal = fltEnergyMaintenance - (fltEnergyMaintenance*fltBonus); float fltShdBackHp = fltShdBackHpAvg + (fltShdBackHpAvg*fltBonus); float fltShdFrontHp = fltShdFrontHpAvg + (fltShdFrontHpAvg*fltBonus); float fltShdRecharge = fltShdRechargeAvg + (fltShdRechargeAvg*fltBonus); string template = utils.getTemplateFilenameNoPath(objComponents[0]); obj_id playerInv = utils.getInventoryContainer(player); obj_id newComponent = create.object("object/tangible/ship/components/shield_generator/"+template, playerInv, false, false); if(isIdValid(newComponent)) { space_crafting.setComponentMaximumArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentCurrentArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentMaximumHitpoints(newComponent, fltHp); space_crafting.setComponentCurrentHitpoints(newComponent, fltHp); space_crafting.setComponentMass(newComponent, fltMass); space_crafting.setComponentEnergyMaintenance(newComponent, fltEnergyMaintenanceFinal); space_crafting.setShieldGeneratorMaximumFrontHitpoints(newComponent, fltShdFrontHp); space_crafting.setShieldGeneratorCurrentFrontHitpoints(newComponent, fltShdFrontHp); space_crafting.setShieldGeneratorMaximumBackHitpoints(newComponent, fltShdBackHp); space_crafting.setShieldGeneratorCurrentBackHitpoints(newComponent, fltShdBackHp); space_crafting.setShieldGeneratorRechargeRate(newComponent, fltShdRecharge); string entries[] = new string[7]; string strMassAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "massavg")); string strHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "hpavg")); string strArmorHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "armorhpavg")); string strFinalOutput = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "finaloutput")); string strBonusApplied = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "bonusapplied")); string strEnergyMaintenance = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "energymaintenance")); string strShdBackHp = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "shdbackhp")); string strShdFrontHp = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "shdfronthp")); string strShdRecharge = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "shdrecharge")); entries[0] = strMassAvg + " " + fltMassAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " +fltMass; entries[1] = strHpAvg + " " + fltHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltHp; entries[2] = strArmorHpAvg + " " + fltArmorHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltArmorHp; entries[3] = strEnergyMaintenance + " " + fltEnergyMaintenance + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEnergyMaintenanceFinal; entries[4] = strShdBackHp + " " + fltShdBackHpAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltShdBackHp; entries[5] = strShdFrontHp + " " + fltShdFrontHpAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltShdFrontHp; entries[6] = strShdRecharge + " " + fltShdRechargeAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltShdRecharge; finishReverseEngineering(newComponent, player, objComponents, entries); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "invfull"); sendSystemMessage(player, error); return null; } return newComponent; } obj_id reverseEngineerWeapon(obj_id[] objComponents, obj_id player, int level) { int revSkill = getSkillStatisticModifier(player, "defense_reverse"); if (level > revSkill) { string_id insufficientLevel = new string_id (space_crafting.STF_COMPONENT_TOOL, "level"); sendSystemMessage(player, insufficientLevel); return null; } float fltMassAverage = space_crafting.getComponentMass(objComponents[0]); float fltArmorHpAverage = space_crafting.getComponentMaximumArmorHitpoints(objComponents[0]); float fltHpAverage = space_crafting.getComponentMaximumHitpoints(objComponents[0]); float fltEnergyMaintenance = space_crafting.getComponentEnergyMaintenance(objComponents[0]); float fltWpnMaxDamageAvg = space_crafting.getWeaponMaximumDamage(objComponents[0]); float fltWpnMinDamageAvg = space_crafting.getWeaponMinimumDamage(objComponents[0]); float fltWpnShdEffectivenessAvg = space_crafting.getWeaponShieldEffectiveness(objComponents[0]); float fltWpnArmEffectivenessAvg = space_crafting.getWeaponArmorEffectiveness(objComponents[0]); float fltWpnEnergyPerShotAvg = space_crafting.getWeaponEnergyPerShot(objComponents[0]); float fltWpnRefireRateAvg = space_crafting.getWeaponRefireRate(objComponents[0]); for (int i = 0; i < objComponents.length; i++) { float armor = space_crafting.getComponentMaximumArmorHitpoints(objComponents[i]); if (armor > fltArmorHpAverage) fltArmorHpAverage = armor; float hp = space_crafting.getComponentMaximumHitpoints(objComponents[i]); if (hp > fltHpAverage) fltHpAverage = hp; float mass = space_crafting.getComponentMass(objComponents[i]); if (mass < fltMassAverage) fltMassAverage = mass; float maintenance = space_crafting.getComponentEnergyMaintenance(objComponents[i]); if (maintenance < fltEnergyMaintenance) fltEnergyMaintenance = maintenance; float max = space_crafting.getWeaponMaximumDamage(objComponents[i]); if (max > fltWpnMaxDamageAvg) fltWpnMaxDamageAvg = max; float min = space_crafting.getWeaponMinimumDamage(objComponents[i]); if (min > fltWpnMinDamageAvg) fltWpnMinDamageAvg = min; float shd = space_crafting.getWeaponShieldEffectiveness(objComponents[i]); if (shd > fltWpnShdEffectivenessAvg) fltWpnShdEffectivenessAvg = shd; float arm = space_crafting.getWeaponArmorEffectiveness(objComponents[i]); if (arm > fltWpnArmEffectivenessAvg) fltWpnArmEffectivenessAvg = arm; float energy = space_crafting.getWeaponEnergyPerShot(objComponents[i]); if (energy < fltWpnEnergyPerShotAvg) fltWpnEnergyPerShotAvg = energy; float refire = space_crafting.getWeaponRefireRate(objComponents[i]); if (refire < fltWpnRefireRateAvg) fltWpnRefireRateAvg = refire; } float fltBonus = getLevelBonus(player, level); float fltMass = fltMassAverage - (fltMassAverage*fltBonus); float fltArmorHp = fltArmorHpAverage + (fltArmorHpAverage*fltBonus); float fltHp = fltHpAverage + (fltHpAverage*fltBonus); float fltEnergyMaintenanceFinal = fltEnergyMaintenance - (fltEnergyMaintenance*fltBonus); float fltWpnMaxDamage = fltWpnMaxDamageAvg + (fltWpnMaxDamageAvg*fltBonus); float fltWpnMinDamage = fltWpnMinDamageAvg + (fltWpnMinDamageAvg*fltBonus); float fltWpnShdEffectiveness = fltWpnShdEffectivenessAvg + (fltWpnShdEffectivenessAvg*fltBonus); float fltWpnArmEffectiveness = fltWpnArmEffectivenessAvg + (fltWpnArmEffectivenessAvg*fltBonus); float fltWpnEnergyPerShot = fltWpnEnergyPerShotAvg - (fltWpnEnergyPerShotAvg*fltBonus); float fltWpnRefireRate = fltWpnRefireRateAvg - (fltWpnRefireRateAvg*fltBonus); string template = utils.getTemplateFilenameNoPath(objComponents[0]); obj_id playerInv = utils.getInventoryContainer(player); obj_id newComponent = create.object("object/tangible/ship/components/weapon/"+template, playerInv, false, false); if (isIdValid(newComponent)) { space_crafting.setComponentMaximumArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentCurrentArmorHitpoints(newComponent, fltArmorHp); space_crafting.setComponentMaximumHitpoints(newComponent, fltHp); space_crafting.setComponentCurrentHitpoints(newComponent, fltHp); space_crafting.setComponentMass(newComponent, fltMass); space_crafting.setComponentEnergyMaintenance(newComponent, fltEnergyMaintenanceFinal); space_crafting.setWeaponMaximumDamage(newComponent, fltWpnMaxDamage); space_crafting.setWeaponMinimumDamage(newComponent, fltWpnMinDamage); space_crafting.setWeaponShieldEffectiveness(newComponent, fltWpnShdEffectiveness); space_crafting.setWeaponArmorEffectiveness(newComponent, fltWpnArmEffectiveness); space_crafting.setWeaponEnergyPerShot(newComponent, fltWpnEnergyPerShot); space_crafting.setWeaponRefireRate(newComponent, fltWpnRefireRate); string entries[] = new string[10]; string strMassAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "massavg")); string strHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "hpavg")); string strArmorHpAvg = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "armorhpavg")); string strFinalOutput = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "finaloutput")); string strBonusApplied = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "bonusapplied")); string strEnergyMaintenance = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "energymaintenance")); string strWpnMaxDamage = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "wpnmaxdmg")); string strWpnMinDamage = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "wpnmindmg")); string strWpnShdEffectiveness = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "wpnshdeff")); string strWpnArmEffectiveness = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "wpnarmeff")); string strWpnEnergyPerShot= utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "wpnenergypershot")); string strWpnRefireRate = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "wpnrate")); entries[0] = strMassAvg + " " + fltMassAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " +fltMass; entries[1] = strHpAvg + " " + fltHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltHp; entries[2] = strArmorHpAvg + " " + fltArmorHpAverage + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltArmorHp; entries[3] = strEnergyMaintenance + " " + fltEnergyMaintenance + " --- " + strBonusApplied + " " + (int)(fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltEnergyMaintenanceFinal; entries[4] = strWpnMaxDamage + " " + fltWpnMaxDamageAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltWpnMaxDamage; entries[5] = strWpnMinDamage + " " + fltWpnMinDamageAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltWpnMinDamage;; entries[6] = strWpnShdEffectiveness + " " + fltWpnShdEffectivenessAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltWpnShdEffectiveness; entries[7] = strWpnArmEffectiveness + " " + fltWpnArmEffectivenessAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltWpnArmEffectiveness; entries[8] = strWpnEnergyPerShot + " " + fltWpnEnergyPerShotAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltWpnEnergyPerShot; entries[9] = strWpnRefireRate + " " + fltWpnRefireRateAvg + " --- " + strBonusApplied + " " + (fltBonus*100)+"%" + " --- " + strFinalOutput + " " + fltWpnRefireRate; finishReverseEngineering(newComponent, player, objComponents, entries); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "invfull"); sendSystemMessage(player, error); return null; } return newComponent; } void finishReverseEngineering (obj_id newComponent, obj_id player, obj_id[] objComponents, string[] entries) { string prompt = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "prompt")); string title = utils.packStringId(new string_id(space_crafting.STF_COMPONENT_TOOL, "title")); if (!hasScript(newComponent, space_crafting.SCRIPT_COMPONENT_NAME_HANDLER)) { attachScript(newComponent, space_crafting.SCRIPT_COMPONENT_NAME_HANDLER); } int pid = sui.listbox(newComponent, player, prompt, sui.OK_ONLY, title, entries, "handleComponentNameSui", false, false); if (pid > -1) { showSUIPage(pid); } else { string_id error = new string_id(space_crafting.STF_COMPONENT_TOOL, "bad_data"); sendSystemMessage(player, error); } for (int i = 0; i < objComponents.length; i++) { destroyObject(objComponents[i]); } }