Updated to SinduskLibrary 1.6

Minor bugfixes
This commit is contained in:
Sindusk
2018-06-24 07:15:59 -04:00
parent e756f954a0
commit 46b3c42c51
6 changed files with 68 additions and 76 deletions

View File

@@ -10,7 +10,7 @@ repositories {
} }
dependencies { dependencies {
compile 'com.github.Sindusk:sindusklibrary:v1.3' compile 'com.github.Sindusk:sindusklibrary:v1.5'
} }
jar { jar {

View File

@@ -1,4 +1,4 @@
classname=mod.sin.armoury.ArmouryMod classname=ArmouryMod
classpath=Armoury.jar classpath=Armoury.jar
depend.import=SinduskLibrary depend.import=SinduskLibrary
depend.suggests=ServerTweaks depend.suggests=ServerTweaks
@@ -100,8 +100,8 @@ armourEffectiveness-2:dragonscale;burn,1.10
#> Armour Glance Rates < # #> Armour Glance Rates < #
#armourGlanceRate: Adjust the glance rate of an armour type against a wound type. #armourGlanceRate: Adjust the glance rate of an armour type against a wound type.
armourGlanceRate-1:dragonscale,crush,0.20 armourGlanceRate-1:dragonscale;crush,0.20
armourGlanceRate-2:drake,slash,0.30 armourGlanceRate-2:drake;slash,0.30
# > Custom Item ID Overrides < # # > Custom Item ID Overrides < #
#These are used to override the damage reduction calculation per item ID. #These are used to override the damage reduction calculation per item ID.

View File

@@ -8,6 +8,7 @@ import javassist.ClassPool;
import javassist.CtClass; import javassist.CtClass;
import javassist.NotFoundException; import javassist.NotFoundException;
import mod.sin.lib.Util; import mod.sin.lib.Util;
import mod.sin.lib.WoundAssist;
import org.gotti.wurmunlimited.modloader.ReflectionUtil; import org.gotti.wurmunlimited.modloader.ReflectionUtil;
import org.gotti.wurmunlimited.modloader.classhooks.HookManager; import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
@@ -183,7 +184,7 @@ public class ArmourTweaks {
woundTypes.add((byte) 7); // Water woundTypes.add((byte) 7); // Water
woundTypes.add((byte) 9); // Internal woundTypes.add((byte) 9); // Internal
}else{ }else{
woundTypes.add(ArmouryMod.parseWoundType(split[i])); woundTypes.add(WoundAssist.getWoundType(split[i]));
} }
i++; i++;
} }
@@ -426,7 +427,6 @@ public class ArmourTweaks {
Util.setBodyDeclared(thisClass, ctArmourTypes, "getMaterialMovementModifier", replace); Util.setBodyDeclared(thisClass, ctArmourTypes, "getMaterialMovementModifier", replace);
} }
loadDefaultGlanceRates();
} catch (NotFoundException e) { } catch (NotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -434,6 +434,7 @@ public class ArmourTweaks {
public static void onItemTemplatesCreated(){ public static void onItemTemplatesCreated(){
createArmourTemplateLists(); createArmourTemplateLists();
loadDefaultGlanceRates();
try { try {
if(ArmouryMod.enableArmourMovementModifications){ if(ArmouryMod.enableArmourMovementModifications){
logger.info("Starting armour movement modifications..."); logger.info("Starting armour movement modifications...");

View File

@@ -4,6 +4,7 @@ import com.wurmonline.server.creatures.CreatureTemplate;
import com.wurmonline.server.creatures.CreatureTemplateFactory; import com.wurmonline.server.creatures.CreatureTemplateFactory;
import com.wurmonline.server.items.Materials; import com.wurmonline.server.items.Materials;
import mod.sin.lib.Prop; import mod.sin.lib.Prop;
import mod.sin.lib.WoundAssist;
import org.gotti.wurmunlimited.modloader.interfaces.*; import org.gotti.wurmunlimited.modloader.interfaces.*;
import java.util.HashMap; import java.util.HashMap;
@@ -68,13 +69,6 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
return Integer.parseInt(str); 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){ public static byte parseMaterialType(String str){
byte mat = Materials.convertMaterialStringIntoByte(str); byte mat = Materials.convertMaterialStringIntoByte(str);
if(mat > 0){ if(mat > 0){
@@ -90,7 +84,6 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
// Initialization sequences // Initialization sequences
MaterialTweaks.initializeMaterialMaps(); MaterialTweaks.initializeMaterialMaps();
WoundAssist.initializeWoundMaps();
ArmourTweaks.initializeArmourMaps(); ArmourTweaks.initializeArmourMaps();
WeaponTweaks.initializeWeaponMaps(); WeaponTweaks.initializeWeaponMaps();
@@ -348,10 +341,7 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
} }
HashMap<Byte, Float> woundMap = ArmourTweaks.armourEffectiveness.get(armourType); HashMap<Byte, Float> woundMap = ArmourTweaks.armourEffectiveness.get(armourType);
for(byte woundType : woundMap.keySet()){ for(byte woundType : woundMap.keySet()){
String wound = String.valueOf(woundType); String wound = WoundAssist.getWoundName(woundType);
if(WoundAssist.woundTypeToName.containsKey(woundType)){
wound = WoundAssist.woundTypeToName.get(woundType);
}
logger.info(String.format("Effectiveness for armour %s against %s: %.2f%%", name, wound, woundMap.get(woundType)*100f)); 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) +"%"); //logger.info("Effectiveness for "+name+" against "+woundType+": "+(woundMap.get(woundType)*100f) +"%");
} }
@@ -364,10 +354,7 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
} }
HashMap<Byte, Float> woundMap = ArmourTweaks.armourGlanceRates.get(armourType); HashMap<Byte, Float> woundMap = ArmourTweaks.armourGlanceRates.get(armourType);
for(byte woundType : woundMap.keySet()){ for(byte woundType : woundMap.keySet()){
String wound = String.valueOf(woundType); String wound = WoundAssist.getWoundName(woundType);
if(WoundAssist.woundTypeToName.containsKey(woundType)){
wound = WoundAssist.woundTypeToName.get(woundType);
}
logger.info(String.format("Glance rate for armour %s against %s: %.2f%%", name, wound, woundMap.get(woundType)*100f)); 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) +"%"); //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()){ for(byte material : ArmourTweaks.materialEffectiveness.keySet()){
HashMap<Byte, Float> woundMap = ArmourTweaks.materialEffectiveness.get(material); HashMap<Byte, Float> woundMap = ArmourTweaks.materialEffectiveness.get(material);
for(byte woundType : woundMap.keySet()){ for(byte woundType : woundMap.keySet()){
String wound = String.valueOf(woundType); String wound = WoundAssist.getWoundName(woundType);
if(WoundAssist.woundTypeToName.containsKey(woundType)){
wound = WoundAssist.woundTypeToName.get(woundType);
}
logger.info(String.format("Effectiveness for material %s against %s: %.2f%%", MaterialTweaks.getMaterialName(material), wound, woundMap.get(woundType)*100f)); 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); //String name = materialNameReference.containsKey(material) ? materialNameReference.get(material) : String.valueOf(material);
HashMap<Byte, Float> woundMap = ArmourTweaks.materialGlanceRate.get(material); HashMap<Byte, Float> woundMap = ArmourTweaks.materialGlanceRate.get(material);
for(byte woundType : woundMap.keySet()){ for(byte woundType : woundMap.keySet()){
String wound = String.valueOf(woundType); String wound = WoundAssist.getWoundName(woundType);
if(WoundAssist.woundTypeToName.containsKey(woundType)){
wound = WoundAssist.woundTypeToName.get(woundType);
}
logger.info(String.format("Glance Rate for material %s against %s: %.2f%%", MaterialTweaks.getMaterialName(material), wound, woundMap.get(woundType)*100f)); logger.info(String.format("Glance Rate for material %s against %s: %.2f%%", MaterialTweaks.getMaterialName(material), wound, woundMap.get(woundType)*100f));
} }
} }

View File

@@ -1,22 +1,21 @@
package mod.sin.armoury; package mod.sin.armoury;
import java.util.HashMap; import com.wurmonline.server.combat.Weapon;
import java.util.Map;
import java.util.logging.Logger;
import com.wurmonline.server.items.Item; 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 com.wurmonline.server.items.Materials;
import javassist.ClassPool; import javassist.ClassPool;
import javassist.CtClass; import javassist.CtClass;
import javassist.NotFoundException; import javassist.NotFoundException;
import mod.sin.lib.Util; import mod.sin.lib.Util;
import org.gotti.wurmunlimited.modloader.ReflectionUtil; 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 org.gotti.wurmunlimited.modloader.classhooks.HookManager;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
public class WeaponTweaks { public class WeaponTweaks {
public static Logger logger = Logger.getLogger(WeaponTweaks.class.getName()); public static Logger logger = Logger.getLogger(WeaponTweaks.class.getName());
@@ -100,15 +99,54 @@ public class WeaponTweaks {
if(wt == null){ if(wt == null){
logger.warning("Null weapon template for id "+i); logger.warning("Null weapon template for id "+i);
}else{ }else{
logger.info("Weapon \""+wt.sizeString+wt.getName()+"\" (ID "+i+") stats: ["+ String str = "Weapon \""+wt.sizeString+wt.getName()+"\" (ID "+i+") stats: ";
ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "damage"))+" damage], ["+ str += "["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "damage"))+" damage]";
ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "speed"))+" speed], ["+ str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "speed"))+" speed]";
ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "critchance"))+" critchance], ["+ str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "critchance"))+" critchance]";
ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "reach"))+" reach], ["+ str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "reach"))+" reach]";
ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "weightGroup"))+" weightGroup], ["+ str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "weightGroup"))+" weightGroup]";
ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "parryPercent"))+" parryPercent], ["+ str += ", ["+ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "parryPercent"))+" parryPercent]";
ReflectionUtil.getPrivateField(cw, ReflectionUtil.getField(cw.getClass(), "skillPenalty"))+" skillPenalty]" 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) { } catch (IllegalArgumentException | IllegalAccessException | ClassCastException | NoSuchFieldException e) {
@@ -370,7 +408,7 @@ public class WeaponTweaks {
editWeaponStats(); editWeaponStats();
//printWeapons(); // For debugging/information purposes printWeapons(); // For debugging/information purposes
} catch (IllegalArgumentException | IllegalAccessException | ClassCastException | NoSuchFieldException e) { } catch (IllegalArgumentException | IllegalAccessException | ClassCastException | NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -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<String, Byte> woundNameToType = new HashMap<>();
public static HashMap<Byte, String> 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);
}
}
}