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

@@ -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...");

View File

@@ -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<Byte, Float> 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<Byte, Float> 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<Byte, Float> 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<Byte, Float> 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));
}
}

View File

@@ -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();

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);
}
}
}