diff --git a/scripts/equipment/slot_protection.py b/scripts/equipment/slot_protection.py new file mode 100644 index 00000000..3e16a86c --- /dev/null +++ b/scripts/equipment/slot_protection.py @@ -0,0 +1,23 @@ +import sys + +def chest2(): + return "35.71" + +def pants1(): + return "21.43" + +def hat(): + return "14.27" + +def bracer_upper_l(): + return "7.15" + +def bracer_upper_r(): + return "7.15" + +def bicep_l(): + return "7.15" + +def bicep_r(): + return "7.15" + \ No newline at end of file diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index c130d46d..afe5b694 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -56,7 +56,7 @@ public class EquipmentService implements INetworkDispatch { private int getWeaponCriticalChance(CreatureObject actor, SWGObject item) { int weaponCriticalChance = 0; - String weaponCriticalSkillMod = (core.scriptService.getMethod("scripts/equipment/", "weapon_critical", item.getStringAttribute("cat_wpn_damage.wpn_category")/*.replace(" ", "").replace("-", "") + "_" */).__call__().asString()); + String weaponCriticalSkillMod = (core.scriptService.getMethod("scripts/equipment/", "weapon_critical", item.getStringAttribute("cat_wpn_damage.wpn_category")).__call__().asString()); if(weaponCriticalSkillMod.contains(" ")) weaponCriticalSkillMod.replace(" ", ""); @@ -65,7 +65,7 @@ public class EquipmentService implements INetworkDispatch { weaponCriticalSkillMod.replace("-", ""); if(actor.getSkillMod(weaponCriticalSkillMod) != null) - weaponCriticalChance = actor.getSkillModBase((core.scriptService.getMethod("scripts/equipment/", "weapon_critical", item.getStringAttribute("cat_wpn_damage.wpn_category").replace(" ", "").replace("-", "") + "_" ).__call__().asString())); + weaponCriticalChance = actor.getSkillModBase(weaponCriticalSkillMod); return weaponCriticalChance; } @@ -132,12 +132,34 @@ 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 addArmorProtection(CreatureObject actor, String protectionType, float protection, String slotName) { + actor.addSkillMod(protectionType, (int) (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("expertise_innate_protection_all", getForceProtection(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("expertise_innate_protection_all", getForceProtection(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) { @@ -163,8 +185,7 @@ public class EquipmentService implements INetworkDispatch { // TODO: bio-link (assign it by objectID with setAttachment and then just display the customName for that objectID). if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) - if (actor.getSlotNameForObject(item).contentEquals("hold_r") == true) - addWeaponCriticalChance(actor, item); + addWeaponCriticalChance(actor, item); Map attributes = new TreeMap(item.getAttributes()); @@ -177,6 +198,14 @@ public class EquipmentService implements INetworkDispatch { core.skillModService.addSkillMod(actor, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); } + if(e.getKey().startsWith("cat_armor_standard_protection")) { + addArmorProtection(actor, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), actor.getSlotNameForObject(item)); + } + + if(e.getKey().startsWith("cat_armor_special_protection")) { + addArmorProtection(actor, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), actor.getSlotNameForObject(item)); + } + if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) { actor.setMaxHealth(actor.getMaxHealth() + Integer.parseInt((String) e.getValue())); } @@ -184,6 +213,7 @@ public class EquipmentService implements INetworkDispatch { if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_action")) { actor.setMaxAction(actor.getMaxAction() + Integer.parseInt((String) e.getValue())); } + } if(!actor.getEquipmentList().contains(item)) @@ -215,6 +245,15 @@ public class EquipmentService implements INetworkDispatch { if(e.getKey().startsWith("cat_stat_mod_bonus.@stat_n:")) { core.skillModService.deductSkillMod(actor, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); } + + if(e.getKey().startsWith("cat_armor_standard_protection")) { + deductArmorProtection(actor, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), actor.getSlotNameForObject(item)); + } + + if(e.getKey().startsWith("cat_armor_special_protection")) { + deductArmorProtection(actor, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), actor.getSlotNameForObject(item)); + } + if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) { actor.setMaxHealth(actor.getMaxHealth() - Integer.parseInt((String) e.getValue())); }