Fix for armour limit factors no longer working.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
|
|
||||||
group "mod.sin"
|
group "mod.sin"
|
||||||
version "4.0"
|
version "4.1"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -53,6 +53,18 @@ armourEffectiveness-1:cloth;bite,0.90
|
|||||||
# Syntax identical to effectiveness settings.
|
# Syntax identical to effectiveness settings.
|
||||||
armourGlanceRate-1:leather;bite,0.30
|
armourGlanceRate-1:leather;bite,0.30
|
||||||
|
|
||||||
|
# > Armour Limit Factor < #
|
||||||
|
#These values are meant to determine the bonus or reduction to spellcasting and archery while wearing armour.
|
||||||
|
# ** Valid values are between -0.99 and 0.3 only. Anything lower than -0.99 risks damaging the calculations in the game. Anything over 0.3 will simply apply as 0.3.
|
||||||
|
# I personally do not like the original setup of them, and will only leave a commented out "vanilla" setup, then using my own below.
|
||||||
|
armourLimitFactor-1:cloth,0.3
|
||||||
|
armourLimitFactor-2:leather,0.3
|
||||||
|
armourLimitFactor-3:studded,0.0
|
||||||
|
armourLimitFactor-4:chain,-0.15
|
||||||
|
armourLimitFactor-5:plate,-0.3
|
||||||
|
armourLimitFactor-6:drake,-0.3
|
||||||
|
armourLimitFactor-7:dragonscale,-0.3
|
||||||
|
|
||||||
# -- Item Material Configuration -- #
|
# -- Item Material Configuration -- #
|
||||||
#enableItemMaterialChanges: Enables or disables the whole item material configuration section.
|
#enableItemMaterialChanges: Enables or disables the whole item material configuration section.
|
||||||
enableItemMaterialChanges=true
|
enableItemMaterialChanges=true
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.wurmonline.server.items.ItemTemplate;
|
|||||||
import com.wurmonline.server.items.ItemTemplateFactory;
|
import com.wurmonline.server.items.ItemTemplateFactory;
|
||||||
import mod.sin.lib.ArmourAssist;
|
import mod.sin.lib.ArmourAssist;
|
||||||
import mod.sin.lib.WoundAssist;
|
import mod.sin.lib.WoundAssist;
|
||||||
|
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -18,6 +19,7 @@ public class ArmourTemplateTweaks {
|
|||||||
public static HashMap<Byte, HashMap<Byte, Float>> armourEffectiveness = new HashMap<>();
|
public static HashMap<Byte, HashMap<Byte, Float>> armourEffectiveness = new HashMap<>();
|
||||||
public static HashMap<Byte, HashMap<Byte, Float>> armourGlanceRates = new HashMap<>();
|
public static HashMap<Byte, HashMap<Byte, Float>> armourGlanceRates = new HashMap<>();
|
||||||
public static HashMap<String, Float> armourMovement = new HashMap<>();
|
public static HashMap<String, Float> armourMovement = new HashMap<>();
|
||||||
|
public static HashMap<Byte, Float> armourLimitFactors = new HashMap<>();
|
||||||
|
|
||||||
protected static ArrayList<Byte> getWoundTypes(String[] split){
|
protected static ArrayList<Byte> getWoundTypes(String[] split){
|
||||||
ArrayList<Byte> woundTypes = new ArrayList<>();
|
ArrayList<Byte> woundTypes = new ArrayList<>();
|
||||||
@@ -85,6 +87,10 @@ public class ArmourTemplateTweaks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addArmourLimitFactor(byte armourType, float limitFactor){
|
||||||
|
armourLimitFactors.put(armourType, limitFactor);
|
||||||
|
}
|
||||||
|
|
||||||
public static void addArmourMovement(String itemTemplateName, float movementPenalty){
|
public static void addArmourMovement(String itemTemplateName, float movementPenalty){
|
||||||
armourMovement.put(itemTemplateName, movementPenalty);
|
armourMovement.put(itemTemplateName, movementPenalty);
|
||||||
}
|
}
|
||||||
@@ -120,6 +126,14 @@ public class ArmourTemplateTweaks {
|
|||||||
ArmourTemplate armourTemplate = ArmourTemplate.getArmourTemplate(template.getTemplateId());
|
ArmourTemplate armourTemplate = ArmourTemplate.getArmourTemplate(template.getTemplateId());
|
||||||
armourTemplate.setMoveModifier(armourMovement.get(armourName)); // Set the new movement speed.
|
armourTemplate.setMoveModifier(armourMovement.get(armourName)); // Set the new movement speed.
|
||||||
}
|
}
|
||||||
|
for (byte atype : armourLimitFactors.keySet()){
|
||||||
|
try {
|
||||||
|
ArmourTemplate.ArmourType armourType = ArmourAssist.getArmourType(atype);
|
||||||
|
ReflectionUtil.setPrivateField(armourType, ReflectionUtil.getField(armourType.getClass(), "limitFactor"), armourLimitFactors.get(atype));
|
||||||
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
|
logger.warning("Failed to set armour limit factor for type "+atype);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
|
|||||||
byte armourType = parseArmourType(split[0]);
|
byte armourType = parseArmourType(split[0]);
|
||||||
String[] split2 = split[1].split(",");
|
String[] split2 = split[1].split(",");
|
||||||
ArmourTemplateTweaks.addArmourGlanceRate(armourType, split2);
|
ArmourTemplateTweaks.addArmourGlanceRate(armourType, split2);
|
||||||
|
} else if (name.startsWith("armourLimitFactor")) {
|
||||||
|
String[] split = value.split(",");
|
||||||
|
byte armourType = parseArmourType(split[0]);
|
||||||
|
float reduction = Float.parseFloat(split[1]);
|
||||||
|
ArmourTemplateTweaks.addArmourLimitFactor(armourType, reduction);
|
||||||
} else if (name.startsWith("armourMovement")) {
|
} else if (name.startsWith("armourMovement")) {
|
||||||
String[] split = value.split(",");
|
String[] split = value.split(",");
|
||||||
String itemTemplate = split[0];
|
String itemTemplate = split[0];
|
||||||
@@ -276,6 +281,10 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
|
|||||||
logger.info(String.format("Glance rate for armour %s against %s: %.2f%%", ArmourAssist.getArmourName(armourType), wound, woundMap.get(woundType)*100f));
|
logger.info(String.format("Glance rate for armour %s against %s: %.2f%%", ArmourAssist.getArmourName(armourType), wound, woundMap.get(woundType)*100f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.info("> Armour Limit Factor Settings <");
|
||||||
|
for(byte armourType : ArmourTemplateTweaks.armourLimitFactors.keySet()){
|
||||||
|
logger.info(String.format("Limit factor for armour %s: %.2f%%", ArmourAssist.getArmourName(armourType), ArmourTemplateTweaks.armourLimitFactors.get(armourType)*100f));
|
||||||
|
}
|
||||||
logger.info("> Armour Movement Rate Changes <");
|
logger.info("> Armour Movement Rate Changes <");
|
||||||
for(String armourName : ArmourTemplateTweaks.armourMovement.keySet()){
|
for(String armourName : ArmourTemplateTweaks.armourMovement.keySet()){
|
||||||
logger.info(String.format("Movement penalty for armour %s changed to %.2f%%", armourName, ArmourTemplateTweaks.armourMovement.get(armourName)*100f));
|
logger.info(String.format("Movement penalty for armour %s changed to %.2f%%", armourName, ArmourTemplateTweaks.armourMovement.get(armourName)*100f));
|
||||||
|
|||||||
Reference in New Issue
Block a user