diff --git a/scripts/equipment/slot_protection.py b/scripts/equipment/slot_protection.py index 3e16a86c..e6de1f33 100644 --- a/scripts/equipment/slot_protection.py +++ b/scripts/equipment/slot_protection.py @@ -1,7 +1,7 @@ import sys def chest2(): - return "35.71" + return "35.70" def pants1(): return "21.43" diff --git a/src/services/DevService.java b/src/services/DevService.java index 7fcb2d5e..efe65147 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -114,7 +114,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 81, "Ithorian Guardian"); suiOptions.put((long) 82, "Kashyyykian Ceremonial"); break; - case 9: // [Items] Reconnaissance Armor + case 9: // [Items] Jedi Items suiOptions.put((long) 90, "(Light) Jedi Robe"); suiOptions.put((long) 91, "(Dark) Jedi Robe"); suiOptions.put((long) 92, "Belt of Master Bodo Baas"); diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index 00795fe9..3edd96f7 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -45,6 +45,7 @@ import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; import services.equipment.BonusSetTemplate; import services.spawn.MobileTemplate; @@ -126,40 +127,57 @@ public class EquipmentService implements INetworkDispatch { return result; } - private float calculateArmorProtection (float protection, String slotName) { - return protection *= (Float.parseFloat(core.scriptService.getMethod("scripts/equipment/", "slot_protection", slotName).__call__().asString()) / 100); + private void calculateArmorProtection(CreatureObject creature, boolean equipping)//float protection, String slotName) + { + int wornArmourPieces = 0; + Map protection = new TreeMap(); + + for(SWGObject item : creature.getEquipmentList()) + { + Map attributes = new TreeMap(item.getAttributes()); + //if(attributes.containsKey("")) wornArmourPieces++; + boolean incPieceCount = false; + + for(Entry e : attributes.entrySet()) + { + if(e.getKey().startsWith("cat_armor_standard_protection")) + { + String protectionType = e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""); + float modifier = Float.parseFloat(core.scriptService.getMethod("scripts/equipment/", "slot_protection", creature.getSlotNameForObject(item)).__call__().asString()) / 100; + Float protectionAmount = Float.parseFloat((String) e.getValue()) * modifier; + + if(protection.containsKey(protectionType)) protection.replace(protectionType, protection.get(protectionType) + protectionAmount); + else protection.put(protectionType, protectionAmount); + incPieceCount = true; + } + else if(e.getKey().startsWith("cat_armor_special_protection")) + { + String protectionType = e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""); + float modifier = Float.parseFloat(core.scriptService.getMethod("scripts/equipment/", "slot_protection", creature.getSlotNameForObject(item)).__call__().asString()) / 100; + Float protectionAmount = Float.parseFloat((String) e.getValue()) * modifier; + + if(protection.containsKey(protectionType)) protection.replace(protectionType, protection.get(protectionType) + protectionAmount); + else protection.put(protectionType, protectionAmount); + incPieceCount = true; + } + } + if(incPieceCount) wornArmourPieces++; + } + + //if(wornArmourPieces >= 3) + //{ + for(Entry e : protection.entrySet()) + { + System.out.println("ProtectionType: " + e.getKey()); + System.out.println("ProtectionAmount: " + e.getValue()); + + core.skillModService.deductSkillMod(creature, e.getKey(), creature.getSkillModBase(e.getKey())); + core.skillModService.addSkillMod(creature, e.getKey(), (int) e.getValue().floatValue()); + } + //} + } - - private void addArmorProtection(CreatureObject actor, String protectionType, float protection, String slotName) { - actor.addSkillMod(protectionType, (int) Math.ceil(calculateArmorProtection(protection, slotName))); - } - - private void deductArmorProtection(CreatureObject actor, String protectionType, float protection, String slotName) { - actor.deductSkillMod(protectionType, (int) calculateArmorProtection(protection, slotName)); - } - - private void addForceProtection(CreatureObject actor, SWGObject item) { - actor.addSkillMod("kinetic", getForceProtection(item)); - actor.addSkillMod("energy", getForceProtection(item)); - actor.addSkillMod("heat", getForceProtection(item)); - actor.addSkillMod("cold", getForceProtection(item)); - actor.addSkillMod("acid", getForceProtection(item)); - actor.addSkillMod("electricity", getForceProtection(item)); - } - - private void deductForceProtection(CreatureObject actor, SWGObject item) { - actor.deductSkillMod("kinetic", getForceProtection(item)); - actor.deductSkillMod("energy", getForceProtection(item)); - actor.deductSkillMod("heat", getForceProtection(item)); - actor.deductSkillMod("cold", getForceProtection(item)); - actor.deductSkillMod("acid", getForceProtection(item)); - actor.deductSkillMod("electricity", getForceProtection(item)); - } - - private int getForceProtection(SWGObject item) { - return core.scriptService.getMethod("scripts/equipment/", "force_protection", item.getAttachment("type") + "_" + item.getStringAttribute("protection_level")).__call__().asInt(); - } - + public void equip(CreatureObject actor, SWGObject item) { String template = ((item.getAttachment("customServerTemplate") == null) ? item.getTemplate() : (item.getTemplate().split("shared_")[0] + "shared_" + ((String) item.getAttachment("customServerTemplate")) + ".iff")); @@ -202,12 +220,14 @@ public class EquipmentService implements INetworkDispatch { { Map attributes = new TreeMap(item.getAttributes()); + calculateArmorProtection(creature, equipping); + if(equipping) { if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) creature.addSkillMod("display_only_critical", getWeaponCriticalChance(creature, item)); if(item.getStringAttribute("protection_level") != null) addForceProtection(creature, item); if(item.getStringAttribute("proc_name") != null) core.buffService.addBuffToCreature(creature, item.getStringAttribute("proc_name").replace("@ui_buff:", ""), creature); - + for(Entry e : attributes.entrySet()) { if(e.getKey().startsWith("cat_skill_mod_bonus.@stat_n:")) @@ -220,7 +240,7 @@ public class EquipmentService implements INetworkDispatch { core.skillModService.addSkillMod(creature, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); } - if(e.getKey().startsWith("cat_armor_standard_protection")) + /*if(e.getKey().startsWith("cat_armor_standard_protection")) { addArmorProtection(creature, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); } @@ -228,7 +248,7 @@ public class EquipmentService implements INetworkDispatch { if(e.getKey().startsWith("cat_armor_special_protection")) { addArmorProtection(creature, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); - } + } */ if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) { @@ -259,7 +279,7 @@ public class EquipmentService implements INetworkDispatch { core.skillModService.deductSkillMod(creature, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); } - if(e.getKey().startsWith("cat_armor_standard_protection")) + /*if(e.getKey().startsWith("cat_armor_standard_protection")) { deductArmorProtection(creature, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); } @@ -267,7 +287,7 @@ public class EquipmentService implements INetworkDispatch { if(e.getKey().startsWith("cat_armor_special_protection")) { deductArmorProtection(creature, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); - } + } */ if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) { @@ -294,17 +314,42 @@ public class EquipmentService implements INetworkDispatch { public void loadBonusSets() { Path p = Paths.get("scripts/equipment/bonus_sets/"); - FileVisitor fv = new SimpleFileVisitor() { + FileVisitor fv = new SimpleFileVisitor() + { @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException + { core.scriptService.callScript("scripts/equipment/bonus_sets/", file.getFileName().toString().replace(".py", ""), "addBonusSet", core); return FileVisitResult.CONTINUE; } }; - try { + try + { Files.walkFileTree(p, fv); - } catch (IOException e) { - e.printStackTrace(); - } + } + catch (IOException e) { e.printStackTrace(); } + } + + // Need to refactor below + private void addForceProtection(CreatureObject actor, SWGObject item) { + actor.addSkillMod("kinetic", getForceProtection(item)); + actor.addSkillMod("energy", getForceProtection(item)); + actor.addSkillMod("heat", getForceProtection(item)); + actor.addSkillMod("cold", getForceProtection(item)); + actor.addSkillMod("acid", getForceProtection(item)); + actor.addSkillMod("electricity", getForceProtection(item)); + } + + private void deductForceProtection(CreatureObject actor, SWGObject item) { + actor.deductSkillMod("kinetic", getForceProtection(item)); + actor.deductSkillMod("energy", getForceProtection(item)); + actor.deductSkillMod("heat", getForceProtection(item)); + actor.deductSkillMod("cold", getForceProtection(item)); + actor.deductSkillMod("acid", getForceProtection(item)); + actor.deductSkillMod("electricity", getForceProtection(item)); + } + + private int getForceProtection(SWGObject item) { + return core.scriptService.getMethod("scripts/equipment/", "force_protection", item.getAttachment("type") + "_" + item.getStringAttribute("protection_level")).__call__().asInt(); } }