diff --git a/build.gradle b/build.gradle index 068d99d..8f197fe 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ repositories { } dependencies { - compile 'com.github.Sindusk:sindusklibrary:v1.3' + compile 'com.github.Sindusk:sindusklibrary:v1.5' } jar { diff --git a/mods/Armoury.properties b/mods/Armoury.properties index 3c67b8e..28a60ac 100644 --- a/mods/Armoury.properties +++ b/mods/Armoury.properties @@ -1,4 +1,4 @@ -classname=mod.sin.armoury.ArmouryMod +classname=ArmouryMod classpath=Armoury.jar depend.import=SinduskLibrary depend.suggests=ServerTweaks @@ -100,8 +100,8 @@ armourEffectiveness-2:dragonscale;burn,1.10 #> Armour Glance Rates < # #armourGlanceRate: Adjust the glance rate of an armour type against a wound type. -armourGlanceRate-1:dragonscale,crush,0.20 -armourGlanceRate-2:drake,slash,0.30 +armourGlanceRate-1:dragonscale;crush,0.20 +armourGlanceRate-2:drake;slash,0.30 # > Custom Item ID Overrides < # #These are used to override the damage reduction calculation per item ID. diff --git a/src/main/java/mod/sin/armoury/ArmourTweaks.java b/src/main/java/mod/sin/armoury/ArmourTweaks.java index e63ed07..f2fee13 100644 --- a/src/main/java/mod/sin/armoury/ArmourTweaks.java +++ b/src/main/java/mod/sin/armoury/ArmourTweaks.java @@ -8,6 +8,7 @@ import javassist.ClassPool; import javassist.CtClass; import javassist.NotFoundException; import mod.sin.lib.Util; +import mod.sin.lib.WoundAssist; import org.gotti.wurmunlimited.modloader.ReflectionUtil; import org.gotti.wurmunlimited.modloader.classhooks.HookManager; @@ -183,7 +184,7 @@ public class ArmourTweaks { woundTypes.add((byte) 7); // Water woundTypes.add((byte) 9); // Internal }else{ - woundTypes.add(ArmouryMod.parseWoundType(split[i])); + woundTypes.add(WoundAssist.getWoundType(split[i])); } i++; } @@ -426,7 +427,6 @@ public class ArmourTweaks { Util.setBodyDeclared(thisClass, ctArmourTypes, "getMaterialMovementModifier", replace); } - loadDefaultGlanceRates(); } catch (NotFoundException e) { e.printStackTrace(); } @@ -434,6 +434,7 @@ public class ArmourTweaks { public static void onItemTemplatesCreated(){ createArmourTemplateLists(); + loadDefaultGlanceRates(); try { if(ArmouryMod.enableArmourMovementModifications){ logger.info("Starting armour movement modifications..."); diff --git a/src/main/java/mod/sin/armoury/ArmouryMod.java b/src/main/java/mod/sin/armoury/ArmouryMod.java index 21c2d8b..9299dfc 100644 --- a/src/main/java/mod/sin/armoury/ArmouryMod.java +++ b/src/main/java/mod/sin/armoury/ArmouryMod.java @@ -4,6 +4,7 @@ import com.wurmonline.server.creatures.CreatureTemplate; import com.wurmonline.server.creatures.CreatureTemplateFactory; import com.wurmonline.server.items.Materials; import mod.sin.lib.Prop; +import mod.sin.lib.WoundAssist; import org.gotti.wurmunlimited.modloader.interfaces.*; import java.util.HashMap; @@ -68,13 +69,6 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene return Integer.parseInt(str); } - public static byte parseWoundType(String str){ - if(WoundAssist.woundNameToType.containsKey(str.toLowerCase())){ - return WoundAssist.woundNameToType.get(str.toLowerCase()); - } - return Byte.parseByte(str); - } - public static byte parseMaterialType(String str){ byte mat = Materials.convertMaterialStringIntoByte(str); if(mat > 0){ @@ -90,7 +84,6 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene // Initialization sequences MaterialTweaks.initializeMaterialMaps(); - WoundAssist.initializeWoundMaps(); ArmourTweaks.initializeArmourMaps(); WeaponTweaks.initializeWeaponMaps(); @@ -348,10 +341,7 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene } HashMap woundMap = ArmourTweaks.armourEffectiveness.get(armourType); for(byte woundType : woundMap.keySet()){ - String wound = String.valueOf(woundType); - if(WoundAssist.woundTypeToName.containsKey(woundType)){ - wound = WoundAssist.woundTypeToName.get(woundType); - } + String wound = WoundAssist.getWoundName(woundType); logger.info(String.format("Effectiveness for armour %s against %s: %.2f%%", name, wound, woundMap.get(woundType)*100f)); //logger.info("Effectiveness for "+name+" against "+woundType+": "+(woundMap.get(woundType)*100f) +"%"); } @@ -364,10 +354,7 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene } HashMap woundMap = ArmourTweaks.armourGlanceRates.get(armourType); for(byte woundType : woundMap.keySet()){ - String wound = String.valueOf(woundType); - if(WoundAssist.woundTypeToName.containsKey(woundType)){ - wound = WoundAssist.woundTypeToName.get(woundType); - } + String wound = WoundAssist.getWoundName(woundType); logger.info(String.format("Glance rate for armour %s against %s: %.2f%%", name, wound, woundMap.get(woundType)*100f)); //logger.info("Effectiveness for "+name+" against "+woundType+": "+(woundMap.get(woundType)*100f) +"%"); } @@ -382,10 +369,7 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene for(byte material : ArmourTweaks.materialEffectiveness.keySet()){ HashMap woundMap = ArmourTweaks.materialEffectiveness.get(material); for(byte woundType : woundMap.keySet()){ - String wound = String.valueOf(woundType); - if(WoundAssist.woundTypeToName.containsKey(woundType)){ - wound = WoundAssist.woundTypeToName.get(woundType); - } + String wound = WoundAssist.getWoundName(woundType); logger.info(String.format("Effectiveness for material %s against %s: %.2f%%", MaterialTweaks.getMaterialName(material), wound, woundMap.get(woundType)*100f)); } } @@ -394,10 +378,7 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene //String name = materialNameReference.containsKey(material) ? materialNameReference.get(material) : String.valueOf(material); HashMap woundMap = ArmourTweaks.materialGlanceRate.get(material); for(byte woundType : woundMap.keySet()){ - String wound = String.valueOf(woundType); - if(WoundAssist.woundTypeToName.containsKey(woundType)){ - wound = WoundAssist.woundTypeToName.get(woundType); - } + String wound = WoundAssist.getWoundName(woundType); logger.info(String.format("Glance Rate for material %s against %s: %.2f%%", MaterialTweaks.getMaterialName(material), wound, woundMap.get(woundType)*100f)); } } diff --git a/src/main/java/mod/sin/armoury/WeaponTweaks.java b/src/main/java/mod/sin/armoury/WeaponTweaks.java index 4e75ccb..6438b25 100644 --- a/src/main/java/mod/sin/armoury/WeaponTweaks.java +++ b/src/main/java/mod/sin/armoury/WeaponTweaks.java @@ -1,22 +1,21 @@ package mod.sin.armoury; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Logger; - +import com.wurmonline.server.combat.Weapon; import com.wurmonline.server.items.Item; +import com.wurmonline.server.items.ItemTemplate; +import com.wurmonline.server.items.ItemTemplateFactory; import com.wurmonline.server.items.Materials; import javassist.ClassPool; import javassist.CtClass; import javassist.NotFoundException; import mod.sin.lib.Util; import org.gotti.wurmunlimited.modloader.ReflectionUtil; - -import com.wurmonline.server.combat.Weapon; -import com.wurmonline.server.items.ItemTemplate; -import com.wurmonline.server.items.ItemTemplateFactory; import org.gotti.wurmunlimited.modloader.classhooks.HookManager; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + public class WeaponTweaks { public static Logger logger = Logger.getLogger(WeaponTweaks.class.getName()); @@ -100,15 +99,54 @@ public class WeaponTweaks { if(wt == null){ logger.warning("Null weapon template for id "+i); }else{ - logger.info("Weapon \""+wt.sizeString+wt.getName()+"\" (ID "+i+") stats: ["+ - ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "damage"))+" damage], ["+ - ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "speed"))+" speed], ["+ - ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "critchance"))+" critchance], ["+ - ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "reach"))+" reach], ["+ - ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "weightGroup"))+" weightGroup], ["+ - ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "parryPercent"))+" parryPercent], ["+ - ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "skillPenalty"))+" skillPenalty]" - ); + String str = "Weapon \""+wt.sizeString+wt.getName()+"\" (ID "+i+") stats: "; + str += "["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "damage"))+" damage]"; + str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "speed"))+" speed]"; + str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "critchance"))+" critchance]"; + str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "reach"))+" reach]"; + str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "weightGroup"))+" weightGroup]"; + str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "parryPercent"))+" parryPercent]"; + str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "skillPenalty"))+" skillPenalty]"; + str += ", [TYPES: "; + String typeString = ""; + if(wt.isWeaponAxe()){ + typeString += "Axe"; + } + if(wt.isWeaponCrush()){ + if(!typeString.isEmpty()){ typeString += ", "; } + typeString += "Crush"; + } + if(wt.isWeaponKnife()){ + if(!typeString.isEmpty()){ typeString += ", "; } + typeString += "Knife"; + } + if(wt.isWeaponMelee()){ + if(!typeString.isEmpty()){ typeString += ", "; } + typeString += "Melee"; + } + if(wt.isWeaponMisc()){ + if(!typeString.isEmpty()){ typeString += ", "; } + typeString += "Misc"; + } + if(wt.isWeaponPierce()){ + if(!typeString.isEmpty()){ typeString += ", "; } + typeString += "Pierce"; + } + if(wt.isWeaponPolearm()){ + if(!typeString.isEmpty()){ typeString += ", "; } + typeString += "Polearm"; + } + if(wt.isWeaponSlash()){ + if(!typeString.isEmpty()){ typeString += ", "; } + typeString += "Slash"; + } + if(wt.isWeaponSword()){ + if(!typeString.isEmpty()){ typeString += ", "; } + typeString += "Sword"; + } + str += typeString; + str += "]"; + logger.info(str); } } } catch (IllegalArgumentException | IllegalAccessException | ClassCastException | NoSuchFieldException e) { @@ -370,7 +408,7 @@ public class WeaponTweaks { editWeaponStats(); - //printWeapons(); // For debugging/information purposes + printWeapons(); // For debugging/information purposes } catch (IllegalArgumentException | IllegalAccessException | ClassCastException | NoSuchFieldException e) { e.printStackTrace(); diff --git a/src/main/java/mod/sin/armoury/WoundAssist.java b/src/main/java/mod/sin/armoury/WoundAssist.java deleted file mode 100644 index 34fa75e..0000000 --- a/src/main/java/mod/sin/armoury/WoundAssist.java +++ /dev/null @@ -1,28 +0,0 @@ -package mod.sin.armoury; - -import java.util.HashMap; -import java.util.logging.Logger; - -public class WoundAssist { - public static Logger logger = Logger.getLogger(WoundAssist.class.getName()); - - public static HashMap woundNameToType = new HashMap<>(); - public static HashMap woundTypeToName = new HashMap<>(); - - public static void initializeWoundMaps(){ - woundNameToType.put("crush", (byte) 0); - woundNameToType.put("slash", (byte) 1); - woundNameToType.put("pierce", (byte) 2); - woundNameToType.put("bite", (byte) 3); - woundNameToType.put("burn", (byte) 4); - woundNameToType.put("poison", (byte) 5); - woundNameToType.put("infection", (byte) 6); - woundNameToType.put("water", (byte) 7); - woundNameToType.put("cold", (byte) 8); - woundNameToType.put("internal", (byte) 9); - woundNameToType.put("acid", (byte) 10); - for(String name : woundNameToType.keySet()){ - woundTypeToName.put(woundNameToType.get(name), name); - } - } -}