Repair armour modification systems and update to version 4.0.

This commit is contained in:
Sindusk
2019-02-03 19:14:48 -05:00
parent 3091da69f3
commit 08ea7c61fc
8 changed files with 465 additions and 167 deletions

View File

@@ -1,17 +1,18 @@
apply plugin: 'java' apply plugin: 'java'
group "mod.sin" group "mod.sin"
version "3.0" version "4.0"
repositories { repositories {
mavenCentral() mavenCentral()
maven { url "http://gotti.no-ip.org/maven/repository" } mavenLocal()
maven { url "https://dl.bdew.net/agorepo/" }
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
} }
dependencies { dependencies {
compile 'org.gotti.wurmunlimited:server-modlauncher:0.39-beta1' compile 'org.gotti.wurmunlimited:server-modlauncher:0.40'
compile 'com.github.Sindusk:sindusklibrary:v1.7' compile 'com.github.Sindusk:sindusklibrary:v2.1'
} }
jar { jar {

View File

@@ -4,14 +4,70 @@ depend.import=SinduskLibrary
depend.suggests=ServerTweaks depend.suggests=ServerTweaks
sharedClassLoader=true sharedClassLoader=true
# -- Mod configuration section -- # # -- Armour configuration section -- #
#enableNonPlayerCrits: Allows critical strikes against non-player characters. In vanilla Wurm, creatures can only deal critical strikes against players. #enableArmourReductionModifications: Enable to enable the whole armour configuration section and material configuration section.
# Note: this will allow creatures to crit creatures as well, so tamed/charmed/dominated creatures can also be critically hit by aggressive mobs. # Disabling this will eliminate almost everything that Armoury does to armour.
enableNonPlayerCrits=true enableArmourModifications=true
# > Custom Item ID Overrides < # #Armour types:
#These are used to override the damage reduction calculation per item ID. # Leather = 1 ; Studded = 2 ; Chain = 3 ; Plate = 4 ; *Ring = 5
# If you want to add challenge helms, masks, and similar here, you are welcome to do so and have their DR work. # Cloth = 6 ; *Scale = 7 ; *Splint = 8 ; Drake = 9 ; Dragonscale = 10
# Note: Types marked with * do not have an in-game armour associated with them.
# These values can be useful for the creation of custom armours, though.
#armourDamageReduction: Adjust the base DR of certain armour types
# Syntax: armourDamageReduction-##:material,reduction
# Example: armourDamageReduction-1:cloth,0.40
# The example sets cloth (6) armour to have 40% damage reduction at 100QL.
# Quality scales the damage reduction
#Default configuration:
armourDamageReduction-6:cloth,0.40
armourDamageReduction-1:leather,0.60
armourDamageReduction-2:studded,0.625
armourDamageReduction-3:chain,0.625
armourDamageReduction-4:plate,0.65
armourDamageReduction-9:drake,0.65
armourDamageReduction-10:dragonscale,0.70
# Unused armour types
armourDamageReduction-5:5,0.55
armourDamageReduction-7:7,0.50
armourDamageReduction-8:8,0.60
# > Armour Effectiveness < #
#armourEffectiveness: Adjust the effectiveness of an armour type against a wound type.
# Wound Types:
# Crush = 0 ; Slash = 1 ; Pierce = 2 ; Bite = 3 ; Burn = 4 ; Poison = 5
# Infection = 6 ; Water = 7 ; Cold = 8 ; Internal = 9 ; Acid = 10
# Syntax: armourEffectiveness-##:armourtype;woundtype,effectiveness
# Example: armourEffectiveness-1:9;8,1.05
# The example sets drake (9) armour to have 105% effectiveness (+5% more DR) against cold (8)
# Alternative to wound types, you can also use the keys "physical" "elemental" and "other"
# Physical: Crush (0), Slash (1), Pierce (2), Bite (3)
# Elemental: Burn (4), Cold (8), Acid (10)
# Other: Poison (5), Infection (6), Water (7), Internal (9)
armourEffectiveness-1:cloth;bite,0.90
#> Armour Glance Rates < #
#armourGlanceRate: Adjust the glance rate of an armour type against a wound type.
# Syntax identical to effectiveness settings.
armourGlanceRate-1:leather;bite,0.30
# -- Item Material Configuration -- #
#enableItemMaterialChanges: Enables or disables the whole item material configuration section.
enableItemMaterialChanges=true
#> Damage Reduction
# Additive damage reduction if the armour is created from this material. This is very specifically what it says after the item.
# Example: "chain jacket, iron" would use the iron modifier (11). Even if the armour type is different, the material is still used.
# Example 2: "dragonscale jacket, glimmersteel" would use the dragonscale base armour value and add the glimmersteel property below.
#materialDamageReduction: Additional percentage of damage reduction from material.
# For example, adamantine by default gives 0.05, meaning 5% damage reduction on top the 70% that plate gives.
# Adamantine plate would give 75% damage reduction at 100QL with this setting.
# Note that if no value is set, the default wurm values will be used.
# If you want to remove the DR penalty for lead armour, you'll have to use materialDamageReduction-##:12,0.00
# Ensure that each property has it's own unique identifier number and none of them clash.
materialDamageReduction-1:adamantine,0.05
#materialGlanceRate: Adjust the glance rate of an armour against a certain wound type if created from a specified material. #materialGlanceRate: Adjust the glance rate of an armour against a certain wound type if created from a specified material.
# This is a multiplier on the base glance rate. # This is a multiplier on the base glance rate.
@@ -41,10 +97,6 @@ materialWeaponParry-1:glimmersteel,0.95
# Lower values cause less damage, higher values cause more damage. 1.10 = 10% more damage to the armour. 0.90 = 10% less damage to the armour. # Lower values cause less damage, higher values cause more damage. 1.10 = 10% more damage to the armour. 0.90 = 10% less damage to the armour.
materialWeaponArmourDamage-1:adamantine,1.05 materialWeaponArmourDamage-1:adamantine,1.05
# -- Item Material Configuration -- #
#enableItemMaterialChanges: Enables or disables the whole item material configuration section.
enableItemMaterialChanges=true
#materialDamageModifier: Adjust how much damage the item takes when receiving non-decay damage (when used). #materialDamageModifier: Adjust how much damage the item takes when receiving non-decay damage (when used).
# This is a multiplier on how much damage the item takes. # This is a multiplier on how much damage the item takes.
# Lower values reduce damage taken, higher values increase damage taken. 1.10 = 10% more damage taken. 0.90 = 10% less damage taken. # Lower values reduce damage taken, higher values increase damage taken. 1.10 = 10% more damage taken. 0.90 = 10% less damage taken.

View File

@@ -0,0 +1,125 @@
package mod.sin.armoury;
import com.wurmonline.server.combat.ArmourTemplate;
import com.wurmonline.server.items.ItemTemplate;
import com.wurmonline.server.items.ItemTemplateFactory;
import mod.sin.lib.ArmourAssist;
import mod.sin.lib.WoundAssist;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Logger;
public class ArmourTemplateTweaks {
public static Logger logger = Logger.getLogger(ArmourTemplateTweaks.class.getName());
// Maps for variable changes to armour
public static HashMap<Byte, Float> armourDamageReduction = 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<String, Float> armourMovement = new HashMap<>();
protected static ArrayList<Byte> getWoundTypes(String[] split){
ArrayList<Byte> woundTypes = new ArrayList<>();
int i = 0;
while(i < split.length-1){
if(split[i].equalsIgnoreCase("all")){
byte x = 0;
while(x <= 10){
woundTypes.add(x);
x++;
}
}else if(split[i].equalsIgnoreCase("physical")){
woundTypes.add((byte) 0); // Crush
woundTypes.add((byte) 1); // Slash
woundTypes.add((byte) 2); // Pierce
woundTypes.add((byte) 3); // Bite
}else if(split[i].equalsIgnoreCase("elemental")){
woundTypes.add((byte) 4); // Burn
woundTypes.add((byte) 8); // Cold
woundTypes.add((byte) 10); // Acid
}else if(split[i].equalsIgnoreCase("other")){
woundTypes.add((byte) 5); // Poison
woundTypes.add((byte) 6); // Infection
woundTypes.add((byte) 7); // Water
woundTypes.add((byte) 9); // Internal
}else{
woundTypes.add(WoundAssist.getWoundType(split[i]));
}
i++;
}
return woundTypes;
}
public static void addArmourDamageReduction(byte armourType, float reduction){
armourDamageReduction.put(armourType, reduction);
}
public static void addArmourEffectiveness(byte armourType, String[] split){
float reduction = Float.parseFloat(split[split.length-1]);
ArrayList<Byte> woundTypes = getWoundTypes(split);
for(byte woundType : woundTypes) {
HashMap<Byte, Float> map;
if (armourEffectiveness.containsKey(armourType)) {
map = armourEffectiveness.get(armourType);
} else {
map = new HashMap<>();
}
map.put(woundType, reduction);
armourEffectiveness.put(armourType, map);
}
}
public static void addArmourGlanceRate(byte armourType, String[] split){
float glance = Float.parseFloat(split[split.length-1]);
ArrayList<Byte> woundTypes = getWoundTypes(split);
for(byte woundType : woundTypes) {
HashMap<Byte, Float> map;
if (armourGlanceRates.containsKey(armourType)) {
map = armourGlanceRates.get(armourType);
} else {
map = new HashMap<>();
}
map.put(woundType, glance);
armourGlanceRates.put(armourType, map);
}
}
public static void addArmourMovement(String itemTemplateName, float movementPenalty){
armourMovement.put(itemTemplateName, movementPenalty);
}
public static void onServerStarted(){
if (ArmouryModMain.enableArmourModifications){
for (byte atype : armourDamageReduction.keySet()){
ArmourTemplate.ArmourType armourType = ArmourAssist.getArmourType(atype);
armourType.setBaseDR(armourDamageReduction.get(atype));
}
for (byte atype : armourEffectiveness.keySet()){
ArmourTemplate.ArmourType armourType = ArmourAssist.getArmourType(atype);
HashMap<Byte,Float> woundMap = armourEffectiveness.get(atype);
for (byte woundType : woundMap.keySet()){
armourType.setEffectiveness(woundType, woundMap.get(woundType));
}
}
for (byte atype : armourGlanceRates.keySet()){
ArmourTemplate.ArmourType armourType = ArmourAssist.getArmourType(atype);
HashMap<Byte,Float> woundMap = armourGlanceRates.get(atype);
for (byte woundType : woundMap.keySet()){
armourType.setGlanceRate(woundType, woundMap.get(woundType));
}
}
for (String armourName : armourMovement.keySet()){
// Get the ItemTemplate instance for the armour name
ItemTemplate template = ItemTemplateFactory.getInstance().getTemplate(armourName);
if (template == null){
logger.warning(String.format("Could not find a valid template for armour %s to adjust movement penalty. Skipping...", armourName));
continue;
}
// Obtain the ArmourTemplate instance based on the ItemTemplate
ArmourTemplate armourTemplate = ArmourTemplate.getArmourTemplate(template.getTemplateId());
armourTemplate.setMoveModifier(armourMovement.get(armourName)); // Set the new movement speed.
}
}
}
}

View File

@@ -1,7 +1,9 @@
package mod.sin.armoury; package mod.sin.armoury;
import com.wurmonline.server.items.Materials; import com.wurmonline.server.items.Materials;
import mod.sin.lib.ArmourAssist;
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;
@@ -13,19 +15,19 @@ public class ArmouryModMain
implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListener, ServerStartedListener { implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListener, ServerStartedListener {
public static Logger logger = Logger.getLogger(ArmouryModMain.class.getName()); public static Logger logger = Logger.getLogger(ArmouryModMain.class.getName());
// Configuration options // - Armour Configuration - //
public static boolean enableNonPlayerCrits = true; public static boolean enableArmourModifications = true;
// - Shield configuration -- // // - Shield Configuration -- //
public static boolean enableShieldDamageEnchants = true; public static boolean enableShieldDamageEnchants = true;
public static boolean enableShieldSpeedEnchants = true; public static boolean enableShieldSpeedEnchants = true;
// -- Weapon configuration -- // // -- Weapon Configuration -- //
public static float minimumSwingTime = 3.0f; public static float minimumSwingTime = 3.0f;
public static boolean raresReduceSwingTime = true; public static boolean raresReduceSwingTime = true;
public static float rareSwingSpeedReduction = 0.2f; public static float rareSwingSpeedReduction = 0.2f;
public static boolean fixSavedSwingTimer = true; public static boolean fixSavedSwingTimer = true;
public static boolean betterDualWield = true; // HIGHLY EXPERIMENTAL public static boolean betterDualWield = false; // HIGHLY EXPERIMENTAL
public static boolean enableWeaponMaterialChanges = true; public static boolean enableWeaponMaterialChanges = true;
public static boolean enableItemMaterialChanges = true; public static boolean enableItemMaterialChanges = true;
// Weapon variable changes // Weapon variable changes
@@ -37,6 +39,9 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
public static HashMap<Integer, Float> weaponParryPercent = new HashMap<>(); public static HashMap<Integer, Float> weaponParryPercent = new HashMap<>();
public static HashMap<Integer, Double> weaponSkillPenalty = new HashMap<>(); public static HashMap<Integer, Double> weaponSkillPenalty = new HashMap<>();
public static byte parseArmourType(String str){
return (byte) ArmourAssist.getArmourByte(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){
@@ -51,25 +56,20 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
Prop.properties = properties; Prop.properties = properties;
// Initialization sequences // Initialization sequences
MaterialTweaks.initializeMaterialMaps(); MaterialsTweaks.initializeMaterialMaps();
WeaponTweaks.initializeWeaponMaps(); WeaponsTweaks.initializeWeaponMaps();
// Base configuration options // Armour Configuration
enableNonPlayerCrits = Prop.getBooleanProperty("enableNonPlayerCrits", enableNonPlayerCrits); enableArmourModifications = Prop.getBooleanProperty("enableArmourModifications", enableArmourModifications);
/*if(enableArmourModifications){ // Shield Configuration
ArmourTweaks.configure();
}*/
//adamantineMaterialMod = Float.parseFloat(properties.getProperty("adamantineMaterialMod", Float.toString(adamantineMaterialMod)));
//glimmersteelMaterialMod = Float.parseFloat(properties.getProperty("glimmersteelMaterialMod", Float.toString(glimmersteelMaterialMod)));
//seryllMaterialMod = Float.parseFloat(properties.getProperty("seryllMaterialMod", Float.toString(seryllMaterialMod)));
// Shield configuration
enableShieldDamageEnchants = Boolean.parseBoolean(properties.getProperty("enableShieldDamageEnchants", Boolean.toString(enableShieldDamageEnchants))); enableShieldDamageEnchants = Boolean.parseBoolean(properties.getProperty("enableShieldDamageEnchants", Boolean.toString(enableShieldDamageEnchants)));
// Weapon configuration // Weapon Configuration
minimumSwingTime = Float.parseFloat(properties.getProperty("minimumSwingTime", Float.toString(minimumSwingTime))); minimumSwingTime = Float.parseFloat(properties.getProperty("minimumSwingTime", Float.toString(minimumSwingTime)));
raresReduceSwingTime = Boolean.parseBoolean(properties.getProperty("raresReduceSwingTime", Boolean.toString(raresReduceSwingTime))); raresReduceSwingTime = Boolean.parseBoolean(properties.getProperty("raresReduceSwingTime", Boolean.toString(raresReduceSwingTime)));
rareSwingSpeedReduction = Float.parseFloat(properties.getProperty("rareSwingSpeedReduction", Float.toString(rareSwingSpeedReduction))); rareSwingSpeedReduction = Float.parseFloat(properties.getProperty("rareSwingSpeedReduction", Float.toString(rareSwingSpeedReduction)));
fixSavedSwingTimer = Boolean.parseBoolean(properties.getProperty("fixSavedSwingTimer", Boolean.toString(fixSavedSwingTimer))); fixSavedSwingTimer = Boolean.parseBoolean(properties.getProperty("fixSavedSwingTimer", Boolean.toString(fixSavedSwingTimer)));
betterDualWield = Boolean.parseBoolean(properties.getProperty("betterDualWield", Boolean.toString(betterDualWield))); betterDualWield = Boolean.parseBoolean(properties.getProperty("betterDualWield", Boolean.toString(betterDualWield)));
enableWeaponMaterialChanges = Prop.getBooleanProperty("enableWeaponMaterialChanges", enableWeaponMaterialChanges); enableWeaponMaterialChanges = Prop.getBooleanProperty("enableWeaponMaterialChanges", enableWeaponMaterialChanges);
enableItemMaterialChanges = Prop.getBooleanProperty("enableItemMaterialChanges", enableItemMaterialChanges); enableItemMaterialChanges = Prop.getBooleanProperty("enableItemMaterialChanges", enableItemMaterialChanges);
for (String name : properties.stringPropertyNames()) { for (String name : properties.stringPropertyNames()) {
@@ -83,97 +83,132 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
case "depend.import": case "depend.import":
case "depend.suggests": case "depend.suggests":
break; //ignore break; //ignore
case "minimumSwingTime":
case "rareSwingSpeedReduction":
case "fixedSavedSwingTimer":
case "betterDualWield":
break; // ignore properties that are already configured
default: default:
if (name.startsWith("materialWeaponDamage")) { if (name.startsWith("armourDamageReduction")) {
String[] split = value.split(",");
byte armourType = parseArmourType(split[0]);
float reduction = Float.parseFloat(split[1]);
ArmourTemplateTweaks.addArmourDamageReduction(armourType, reduction);
} else if (name.startsWith("armourEffectiveness")) {
String[] split = value.split(";");
byte armourType = parseArmourType(split[0]);
String[] split2 = split[1].split(",");
ArmourTemplateTweaks.addArmourEffectiveness(armourType, split2);
} else if (name.startsWith("armourGlanceRate")) {
String[] split = value.split(";");
byte armourType = parseArmourType(split[0]);
String[] split2 = split[1].split(",");
ArmourTemplateTweaks.addArmourGlanceRate(armourType, split2);
} else if (name.startsWith("armourMovement")) {
String[] split = value.split(",");
String itemTemplate = split[0];
float movementPenalty = Float.parseFloat(split[1]);
ArmourTemplateTweaks.addArmourMovement(itemTemplate, movementPenalty);
} else if (name.startsWith("materialDamageReduction")) {
String[] split = value.split(",");
byte material = parseMaterialType(split[0]);
float reduction = Float.parseFloat(split[1]);
MaterialsTweaks.addMaterialDamageReduction(material, reduction);
} else if (name.startsWith("materialMovementModifier")) {
String[] split = value.split(",");
byte material = parseMaterialType(split[0]);
float modifier = Float.parseFloat(split[1]);
MaterialsTweaks.addMaterialMovementModifier(material, modifier);
} else if (name.startsWith("materialWeaponDamage")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
double mult = Double.parseDouble(split[1]); double mult = Double.parseDouble(split[1]);
WeaponTweaks.addMaterialWeaponDamage(material, mult); WeaponsTweaks.addMaterialWeaponDamage(material, mult);
} else if (name.startsWith("materialWeaponSpeed")) { } else if (name.startsWith("materialWeaponSpeed")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float mult = Float.parseFloat(split[1]); float mult = Float.parseFloat(split[1]);
WeaponTweaks.addMaterialWeaponSpeed(material, mult); WeaponsTweaks.addMaterialWeaponSpeed(material, mult);
} else if (name.startsWith("materialWeaponParry")) { } else if (name.startsWith("materialWeaponParry")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float mult = Float.parseFloat(split[1]); float mult = Float.parseFloat(split[1]);
WeaponTweaks.addMaterialWeaponParry(material, mult); WeaponsTweaks.addMaterialWeaponParry(material, mult);
} else if (name.startsWith("materialWeaponArmourDamage")) { } else if (name.startsWith("materialWeaponArmourDamage")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
double mult = Double.parseDouble(split[1]); double mult = Double.parseDouble(split[1]);
WeaponTweaks.addMaterialWeaponArmourDamage(material, mult); WeaponsTweaks.addMaterialWeaponArmourDamage(material, mult);
} else if (name.startsWith("materialDamageModifier")) { } else if (name.startsWith("materialDamageModifier")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float mult = Float.parseFloat(split[1]); float mult = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialDamageModifier(material, mult); MaterialsTweaks.addMaterialDamageModifier(material, mult);
} else if (name.startsWith("materialDecayModifier")) { } else if (name.startsWith("materialDecayModifier")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float mult = Float.parseFloat(split[1]); float mult = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialDecayModifier(material, mult); MaterialsTweaks.addMaterialDecayModifier(material, mult);
} else if (name.startsWith("materialCreationBonus")) { } else if (name.startsWith("materialCreationBonus")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float bonus = Float.parseFloat(split[1]); float bonus = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialCreationBonus(material, bonus); MaterialsTweaks.addMaterialCreationBonus(material, bonus);
} else if (name.startsWith("materialImproveBonus")) { } else if (name.startsWith("materialImproveBonus")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float bonus = Float.parseFloat(split[1]); float bonus = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialImproveBonus(material, bonus); MaterialsTweaks.addMaterialImproveBonus(material, bonus);
} else if (name.startsWith("materialShatterResistance")) { } else if (name.startsWith("materialShatterResistance")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float resistance = Float.parseFloat(split[1]); float resistance = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialShatterResistance(material, resistance); MaterialsTweaks.addMaterialShatterResistance(material, resistance);
} else if (name.startsWith("materialLockpickBonus")) { } else if (name.startsWith("materialLockpickBonus")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float bonus = Float.parseFloat(split[1]); float bonus = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialLockpickBonus(material, bonus); MaterialsTweaks.addMaterialLockpickBonus(material, bonus);
} else if (name.startsWith("materialAnchorBonus")) { } else if (name.startsWith("materialAnchorBonus")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float bonus = Float.parseFloat(split[1]); float bonus = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialAnchorBonus(material, bonus); MaterialsTweaks.addMaterialAnchorBonus(material, bonus);
} else if (name.startsWith("materialPendulumEffect")) { } else if (name.startsWith("materialPendulumEffect")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float bonus = Float.parseFloat(split[1]); float bonus = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialPendulumEffect(material, bonus); MaterialsTweaks.addMaterialPendulumEffect(material, bonus);
} else if (name.startsWith("materialRepairSpeed")) { } else if (name.startsWith("materialRepairSpeed")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float mult = Float.parseFloat(split[1]); float mult = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialRepairSpeed(material, mult); MaterialsTweaks.addMaterialRepairSpeed(material, mult);
} else if (name.startsWith("materialBashModifier")) { } else if (name.startsWith("materialBashModifier")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
double mult = Double.parseDouble(split[1]); double mult = Double.parseDouble(split[1]);
MaterialTweaks.addMaterialBashModifier(material, mult); MaterialsTweaks.addMaterialBashModifier(material, mult);
} else if (name.startsWith("materialSpellEffectModifier")) { } else if (name.startsWith("materialSpellEffectModifier")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
float mult = Float.parseFloat(split[1]); float mult = Float.parseFloat(split[1]);
MaterialTweaks.addMaterialSpellEffectModifier(material, mult); MaterialsTweaks.addMaterialSpellEffectModifier(material, mult);
} else if (name.startsWith("materialSpecificSpellEffectModifier")) { } else if (name.startsWith("materialSpecificSpellEffectModifier")) {
String[] split = value.split(";"); String[] split = value.split(";");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
String[] split2 = split[1].split(","); String[] split2 = split[1].split(",");
MaterialTweaks.addMaterialSpecificSpellEffectModifier(material, split2); MaterialsTweaks.addMaterialSpecificSpellEffectModifier(material, split2);
} else if (name.startsWith("materialDifficultyModifier")) { } else if (name.startsWith("materialDifficultyModifier")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
double mult = Double.parseDouble(split[1]); double mult = Double.parseDouble(split[1]);
MaterialTweaks.addMaterialDifficultyModifier(material, mult); MaterialsTweaks.addMaterialDifficultyModifier(material, mult);
} else if (name.startsWith("materialActionSpeedModifier")) { } else if (name.startsWith("materialActionSpeedModifier")) {
String[] split = value.split(","); String[] split = value.split(",");
byte material = parseMaterialType(split[0]); byte material = parseMaterialType(split[0]);
double mult = Double.parseDouble(split[1]); double mult = Double.parseDouble(split[1]);
MaterialTweaks.addMaterialActionSpeedModifier(material, mult); MaterialsTweaks.addMaterialActionSpeedModifier(material, mult);
} else if (name.startsWith("weaponDamage")) { } else if (name.startsWith("weaponDamage")) {
String[] split = value.split(","); String[] split = value.split(",");
int weaponId = Integer.parseInt(split[0]); int weaponId = Integer.parseInt(split[0]);
@@ -218,85 +253,117 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
e.printStackTrace(); e.printStackTrace();
} }
} }
// Print values of main.java.armoury.mod configuration // Print configuration values
logger.info(" -- Mod Configuration -- "); logger.info(" -- Armour Configuration -- ");
logger.log(Level.INFO, "enableNonPlayerCrits: " + enableNonPlayerCrits); logger.info("enableArmourModifications: " + enableArmourModifications);
logger.info("> Armour Damage Reduction Settings <");
for(byte armourType : ArmourTemplateTweaks.armourDamageReduction.keySet()){
logger.info(String.format("Damage reduction for armour %s: %.2f%%", ArmourAssist.getArmourName(armourType), ArmourTemplateTweaks.armourDamageReduction.get(armourType)*100f));
}
logger.info("> Armour Effectiveness Settings <");
for(byte armourType : ArmourTemplateTweaks.armourEffectiveness.keySet()){
HashMap<Byte, Float> woundMap = ArmourTemplateTweaks.armourEffectiveness.get(armourType);
for(byte woundType : woundMap.keySet()){
String wound = WoundAssist.getWoundName(woundType);
logger.info(String.format("Effectiveness for armour %s against %s: %.2f%%", ArmourAssist.getArmourName(armourType), wound, woundMap.get(woundType)*100f));
}
}
logger.info("> Armour Glance Rate Settings <");
for(byte armourType : ArmourTemplateTweaks.armourGlanceRates.keySet()){
HashMap<Byte, Float> woundMap = ArmourTemplateTweaks.armourGlanceRates.get(armourType);
for(byte woundType : woundMap.keySet()){
String wound = WoundAssist.getWoundName(woundType);
logger.info(String.format("Glance rate for armour %s against %s: %.2f%%", ArmourAssist.getArmourName(armourType), wound, woundMap.get(woundType)*100f));
}
}
logger.info("> Armour Movement Rate Changes <");
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(" -- Material Configuration -- "); logger.info(" -- Material Configuration -- ");
logger.info("> Armour Material Damage Reduction Settings <");
for(byte material : MaterialsTweaks.materialDamageReduction.keySet()){
logger.info(String.format("Base DR modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialDamageReduction.get(material)*100f));
}
logger.info("> Armour Material Movement Modifier Settings <");
for(byte material : MaterialsTweaks.materialMovementModifier.keySet()){
logger.info(String.format("Movement Speed modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialMovementModifier.get(material)*100f));
}
logger.info("> Weapon Material Damage Settings <"); logger.info("> Weapon Material Damage Settings <");
for(byte material : WeaponTweaks.materialWeaponDamage.keySet()){ for(byte material : WeaponsTweaks.materialWeaponDamage.keySet()){
logger.info(String.format("Damage modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), WeaponTweaks.materialWeaponDamage.get(material)*100f)); logger.info(String.format("Damage modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), WeaponsTweaks.materialWeaponDamage.get(material)*100f));
} }
logger.info("> Weapon Material Speed Settings <"); logger.info("> Weapon Material Speed Settings <");
for(byte material : WeaponTweaks.materialWeaponSpeed.keySet()){ for(byte material : WeaponsTweaks.materialWeaponSpeed.keySet()){
logger.info(String.format("Speed modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), WeaponTweaks.materialWeaponSpeed.get(material)*100f)); logger.info(String.format("Speed modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), WeaponsTweaks.materialWeaponSpeed.get(material)*100f));
} }
logger.info("> Weapon Material Parry Settings <"); logger.info("> Weapon Material Parry Settings <");
for(byte material : WeaponTweaks.materialWeaponParry.keySet()){ for(byte material : WeaponsTweaks.materialWeaponParry.keySet()){
logger.info(String.format("Parry modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), WeaponTweaks.materialWeaponParry.get(material)*100f)); logger.info(String.format("Parry modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), WeaponsTweaks.materialWeaponParry.get(material)*100f));
} }
logger.info("> Weapon Material Armour Damage Settings <"); logger.info("> Weapon Material Armour Damage Settings <");
for(byte material : WeaponTweaks.materialWeaponArmourDamage.keySet()){ for(byte material : WeaponsTweaks.materialWeaponArmourDamage.keySet()){
logger.info(String.format("Armour Damage modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), WeaponTweaks.materialWeaponArmourDamage.get(material)*100f)); logger.info(String.format("Armour Damage modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), WeaponsTweaks.materialWeaponArmourDamage.get(material)*100f));
} }
logger.info("> Item Material Damage Modifier Settings <"); logger.info("> Item Material Damage Modifier Settings <");
for(byte material : MaterialTweaks.materialDamageModifier.keySet()){ for(byte material : MaterialsTweaks.materialDamageModifier.keySet()){
logger.info(String.format("Damage modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialDamageModifier.get(material)*100f)); logger.info(String.format("Damage modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialDamageModifier.get(material)*100f));
} }
logger.info("> Item Material Decay Modifier Settings <"); logger.info("> Item Material Decay Modifier Settings <");
for(byte material : MaterialTweaks.materialDecayModifier.keySet()){ for(byte material : MaterialsTweaks.materialDecayModifier.keySet()){
logger.info(String.format("Decay modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialDecayModifier.get(material)*100f)); logger.info(String.format("Decay modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialDecayModifier.get(material)*100f));
} }
logger.info("> Item Material Creation Bonus Settings <"); logger.info("> Item Material Creation Bonus Settings <");
for(byte material : MaterialTweaks.materialCreationBonus.keySet()){ for(byte material : MaterialsTweaks.materialCreationBonus.keySet()){
logger.info(String.format("Creation bonus for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialCreationBonus.get(material)*100f)); logger.info(String.format("Creation bonus for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialCreationBonus.get(material)*100f));
} }
logger.info("> Item Material Improve Bonus Settings <"); logger.info("> Item Material Improve Bonus Settings <");
for(byte material : MaterialTweaks.materialImproveBonus.keySet()){ for(byte material : MaterialsTweaks.materialImproveBonus.keySet()){
logger.info(String.format("Improve bonus for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialImproveBonus.get(material)*100f)); logger.info(String.format("Improve bonus for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialImproveBonus.get(material)*100f));
} }
logger.info("> Item Material Shatter Resistance Settings <"); logger.info("> Item Material Shatter Resistance Settings <");
for(byte material : MaterialTweaks.materialShatterResistance.keySet()){ for(byte material : MaterialsTweaks.materialShatterResistance.keySet()){
logger.info(String.format("Shatter resistance for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialShatterResistance.get(material)*100f)); logger.info(String.format("Shatter resistance for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialShatterResistance.get(material)*100f));
} }
logger.info("> Item Material Lockpick Bonus Settings <"); logger.info("> Item Material Lockpick Bonus Settings <");
for(byte material : MaterialTweaks.materialLockpickBonus.keySet()){ for(byte material : MaterialsTweaks.materialLockpickBonus.keySet()){
logger.info(String.format("Lockpick bonus for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialLockpickBonus.get(material)*100f)); logger.info(String.format("Lockpick bonus for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialLockpickBonus.get(material)*100f));
} }
logger.info("> Item Material Anchor Bonus Settings <"); logger.info("> Item Material Anchor Bonus Settings <");
for(byte material : MaterialTweaks.materialAnchorBonus.keySet()){ for(byte material : MaterialsTweaks.materialAnchorBonus.keySet()){
logger.info(String.format("Anchor bonus for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialAnchorBonus.get(material)*100f)); logger.info(String.format("Anchor bonus for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialAnchorBonus.get(material)*100f));
} }
logger.info("> Item Material Pendulum Effect Settings <"); logger.info("> Item Material Pendulum Effect Settings <");
for(byte material : MaterialTweaks.materialPendulumEffect.keySet()){ for(byte material : MaterialsTweaks.materialPendulumEffect.keySet()){
logger.info(String.format("Pendulum effect for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialPendulumEffect.get(material)*100f)); logger.info(String.format("Pendulum effect for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialPendulumEffect.get(material)*100f));
} }
logger.info("> Item Material Repair Speed Settings <"); logger.info("> Item Material Repair Speed Settings <");
for(byte material : MaterialTweaks.materialRepairSpeed.keySet()){ for(byte material : MaterialsTweaks.materialRepairSpeed.keySet()){
logger.info(String.format("Repair speed for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialRepairSpeed.get(material)*100f)); logger.info(String.format("Repair speed for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialRepairSpeed.get(material)*100f));
} }
logger.info("> Item Material Bash Modifier Settings <"); logger.info("> Item Material Bash Modifier Settings <");
for(byte material : MaterialTweaks.materialBashModifier.keySet()){ for(byte material : MaterialsTweaks.materialBashModifier.keySet()){
logger.info(String.format("Bash modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialBashModifier.get(material)*100f)); logger.info(String.format("Bash modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialBashModifier.get(material)*100f));
} }
logger.info("> Item Material Spell Effect Modifier Settings <"); logger.info("> Item Material Spell Effect Modifier Settings <");
for(byte material : MaterialTweaks.materialSpellEffectModifier.keySet()){ for(byte material : MaterialsTweaks.materialSpellEffectModifier.keySet()){
logger.info(String.format("Spell effect modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialSpellEffectModifier.get(material)*100f)); logger.info(String.format("Spell effect modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialSpellEffectModifier.get(material)*100f));
} }
logger.info("> Item Material Specific Spell Effect Modifier Settings <"); logger.info("> Item Material Specific Spell Effect Modifier Settings <");
for(byte material : MaterialTweaks.materialSpecificSpellEffectModifier.keySet()){ for(byte material : MaterialsTweaks.materialSpecificSpellEffectModifier.keySet()){
//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> enchantMap = MaterialTweaks.materialSpecificSpellEffectModifier.get(material); HashMap<Byte, Float> enchantMap = MaterialsTweaks.materialSpecificSpellEffectModifier.get(material);
for(byte enchant : enchantMap.keySet()){ for(byte enchant : enchantMap.keySet()){
logger.info(String.format("Spell Effect Power for material %s with enchant %s: %.2f%%", MaterialTweaks.getMaterialName(material), enchant, enchantMap.get(enchant)*100f)); logger.info(String.format("Spell Effect Power for material %s with enchant %s: %.2f%%", MaterialsTweaks.getMaterialName(material), enchant, enchantMap.get(enchant)*100f));
} }
} }
logger.info("> Item Material Difficulty Modifier Settings <"); logger.info("> Item Material Difficulty Modifier Settings <");
for(byte material : MaterialTweaks.materialDifficultyModifier.keySet()){ for(byte material : MaterialsTweaks.materialDifficultyModifier.keySet()){
logger.info(String.format("Difficulty modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialDifficultyModifier.get(material)*100f)); logger.info(String.format("Difficulty modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialDifficultyModifier.get(material)*100f));
} }
logger.info("> Item Material Action Speed Modifier Settings <"); logger.info("> Item Material Action Speed Modifier Settings <");
for(byte material : MaterialTweaks.materialActionSpeedModifier.keySet()){ for(byte material : MaterialsTweaks.materialActionSpeedModifier.keySet()){
logger.info(String.format("Action Speed modifier for material %s: %.2f%%", MaterialTweaks.getMaterialName(material), MaterialTweaks.materialActionSpeedModifier.get(material)*100f)); logger.info(String.format("Action Speed modifier for material %s: %.2f%%", MaterialsTweaks.getMaterialName(material), MaterialsTweaks.materialActionSpeedModifier.get(material)*100f));
} }
logger.info(" -- Shield Configuration -- "); logger.info(" -- Shield Configuration -- ");
logger.log(Level.INFO, "enableShieldDamageEnchants: " + enableShieldDamageEnchants); logger.log(Level.INFO, "enableShieldDamageEnchants: " + enableShieldDamageEnchants);
@@ -311,10 +378,10 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
@Override @Override
public void preInit(){ public void preInit(){
CombatTweaks.preInit(); CombatsTweaks.preInit();
ShieldTweaks.preInit(); ShieldsTweaks.preInit();
WeaponTweaks.preInit(); WeaponsTweaks.preInit();
MaterialTweaks.preInit(); MaterialsTweaks.preInit();
} }
@Override @Override
@@ -324,6 +391,7 @@ implements WurmServerMod, Configurable, PreInitable, ItemTemplatesCreatedListene
@Override @Override
public void onServerStarted(){ public void onServerStarted(){
WeaponTweaks.onServerStarted(); WeaponsTweaks.onServerStarted();
ArmourTemplateTweaks.onServerStarted();
} }
} }

View File

@@ -10,7 +10,7 @@ import mod.sin.lib.Util;
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;
public class CombatTweaks { public class CombatsTweaks {
public static Item handleDualWieldAttack(CombatHandler handler, Creature opponent, float delta){ public static Item handleDualWieldAttack(CombatHandler handler, Creature opponent, float delta){
try { try {
Creature performer = ReflectionUtil.getPrivateField(handler, ReflectionUtil.getField(handler.getClass(), "creature")); Creature performer = ReflectionUtil.getPrivateField(handler, ReflectionUtil.getField(handler.getClass(), "creature"));
@@ -33,9 +33,10 @@ public class CombatTweaks {
public static void preInit(){ public static void preInit(){
try { try {
ClassPool classPool = HookManager.getInstance().getClassPool(); ClassPool classPool = HookManager.getInstance().getClassPool();
Class<CombatTweaks> thisClass = CombatTweaks.class; Class<CombatsTweaks> thisClass = CombatsTweaks.class;
// - Allow critical hits on creatures as well as players - // - Allow critical hits on creatures as well as players -
/* [3.1] Disabled - No longer working properly.
ArmouryModMain.enableNonPlayerCrits = false; // Disabled for now as it's not working. ArmouryModMain.enableNonPlayerCrits = false; // Disabled for now as it's not working.
if(ArmouryModMain.enableNonPlayerCrits){ if(ArmouryModMain.enableNonPlayerCrits){
CtClass ctCombatHandler = classPool.get("com.wurmonline.server.creatures.CombatHandler"); CtClass ctCombatHandler = classPool.get("com.wurmonline.server.creatures.CombatHandler");
@@ -47,14 +48,7 @@ public class CombatTweaks {
String desc = Descriptor.ofMethod(CtPrimitiveType.booleanType, attackParams1); String desc = Descriptor.ofMethod(CtPrimitiveType.booleanType, attackParams1);
Util.setReason("Enable player critical strikes on creatures."); Util.setReason("Enable player critical strikes on creatures.");
Util.instrumentDescribed(thisClass, ctCombatHandler, "attack", desc, "isPlayer", "$_ = true"); Util.instrumentDescribed(thisClass, ctCombatHandler, "attack", desc, "isPlayer", "$_ = true");
/*ctCombatHandler.getMethod("attack", Descriptor.ofMethod(CtPrimitiveType.booleanType, attackParams1)).instrument(new ExprEditor(){
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("isPlayer")) {
m.replace("$_ = true;");
return;
}
}
});*/
CtClass[] attackParams2 = { CtClass[] attackParams2 = {
classPool.get("com.wurmonline.server.creatures.Creature"), classPool.get("com.wurmonline.server.creatures.Creature"),
classPool.get("com.wurmonline.server.creatures.AttackAction") classPool.get("com.wurmonline.server.creatures.AttackAction")
@@ -62,15 +56,7 @@ public class CombatTweaks {
desc = Descriptor.ofMethod(CtPrimitiveType.booleanType, attackParams2); desc = Descriptor.ofMethod(CtPrimitiveType.booleanType, attackParams2);
Util.setReason("Enable player critical strikes on creatures."); Util.setReason("Enable player critical strikes on creatures.");
Util.instrumentDescribed(thisClass, ctCombatHandler, "attack", desc, "isPlayer", "$_ = true"); Util.instrumentDescribed(thisClass, ctCombatHandler, "attack", desc, "isPlayer", "$_ = true");
/*ctCombatHandler.getMethod("attack", Descriptor.ofMethod(CtPrimitiveType.booleanType, attackParams2)).instrument(new ExprEditor(){ }*/
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("isPlayer")) {
m.replace("$_ = true;");
return;
}
}
});*/
}
// - Change the minimum swing timer - // // - Change the minimum swing timer - //
if(ArmouryModMain.minimumSwingTime != 3.0f){ if(ArmouryModMain.minimumSwingTime != 3.0f){
@@ -143,7 +129,7 @@ public class CombatTweaks {
}; };
String desc = Descriptor.ofMethod(CtClass.booleanType, params1); String desc = Descriptor.ofMethod(CtClass.booleanType, params1);
String replace = "if(this.creature.isPlayer()){" String replace = "if(this.creature.isPlayer()){"
+ " com.wurmonline.server.items.Item weapon = "+CombatTweaks.class.getName()+".handleDualWieldAttack(this, opponent, delta);" + " com.wurmonline.server.items.Item weapon = "+CombatsTweaks.class.getName()+".handleDualWieldAttack(this, opponent, delta);"
+ " if(weapon != null){" + " if(weapon != null){"
+ " lDead = attack(opponent, weapon, true);" + " lDead = attack(opponent, weapon, true);"
+ " }" + " }"
@@ -155,7 +141,7 @@ public class CombatTweaks {
public void edit(MethodCall m) throws CannotCompileException { public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("getSecondaryWeapons")) { if (m.getMethodName().equals("getSecondaryWeapons")) {
m.replace("if(this.creature.isPlayer()){" m.replace("if(this.creature.isPlayer()){"
+ " com.wurmonline.server.items.Item weapon = CombatTweaks.handleDualWieldAttack(this, opponent, delta);" + " com.wurmonline.server.items.Item weapon = CombatsTweaks.handleDualWieldAttack(this, opponent, delta);"
+ " if(weapon != null){" + " if(weapon != null){"
+ " lDead = attack(opponent, weapon, true);" + " lDead = attack(opponent, weapon, true);"
+ " }" + " }"

View File

@@ -16,9 +16,12 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
public class MaterialTweaks { public class MaterialsTweaks {
public static Logger logger = Logger.getLogger(MaterialTweaks.class.getName()); public static Logger logger = Logger.getLogger(MaterialsTweaks.class.getName());
// Material Modifier Maps
public static HashMap<Byte, Float> materialDamageReduction = new HashMap<>();
public static HashMap<Byte, Float> materialMovementModifier = new HashMap<>();
public static HashMap<Byte, Float> materialDamageModifier = new HashMap<>(); public static HashMap<Byte, Float> materialDamageModifier = new HashMap<>();
public static HashMap<Byte, Float> materialDecayModifier = new HashMap<>(); public static HashMap<Byte, Float> materialDecayModifier = new HashMap<>();
public static HashMap<Byte, Float> materialCreationBonus = new HashMap<>(); public static HashMap<Byte, Float> materialCreationBonus = new HashMap<>();
@@ -34,10 +37,26 @@ public class MaterialTweaks {
public static HashMap<Byte, Double> materialDifficultyModifier = new HashMap<>(); public static HashMap<Byte, Double> materialDifficultyModifier = new HashMap<>();
public static HashMap<Byte, Double> materialActionSpeedModifier = new HashMap<>(); public static HashMap<Byte, Double> materialActionSpeedModifier = new HashMap<>();
public static float newGetMaterialDamageReduction(byte material){
if(materialDamageReduction.containsKey(material)){
//logger.info(String.format("Modifying damage by %.2f%% due to material type %s.", materialDamageModifier.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialDamageReduction.get(material);
}
return 0.0f;
}
public static float newGetMaterialMovementModifier(byte armourMaterial){
if(materialMovementModifier.containsKey(armourMaterial)){
//logger.info(String.format("Adjusting movement speed to %.2f%% because of material %s", materialMovementModifier.get(armourMaterial)*100f, armourMaterial));
return materialMovementModifier.get(armourMaterial);
}
return 1.0f;
}
public static float newGetMaterialDamageModifier(Item item){ public static float newGetMaterialDamageModifier(Item item){
byte material = item.getMaterial(); byte material = item.getMaterial();
if(materialDamageModifier.containsKey(material)){ if(materialDamageModifier.containsKey(material)){
//logger.info(String.format("Modifying damage by %.2f%% due to material type %s.", materialDamageModifier.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying damage by %.2f%% due to material type %s.", materialDamageModifier.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialDamageModifier.get(material); return materialDamageModifier.get(material);
} }
return 1.0f; return 1.0f;
@@ -46,7 +65,7 @@ public class MaterialTweaks {
public static float newGetMaterialDecayModifier(Item item){ public static float newGetMaterialDecayModifier(Item item){
byte material = item.getMaterial(); byte material = item.getMaterial();
if(materialDecayModifier.containsKey(material)){ if(materialDecayModifier.containsKey(material)){
//logger.info(String.format("Modifying decay by %.2f%% due to material type %s.", materialDecayModifier.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying decay by %.2f%% due to material type %s.", materialDecayModifier.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialDecayModifier.get(material); return materialDecayModifier.get(material);
} }
return 1.0f; return 1.0f;
@@ -54,7 +73,7 @@ public class MaterialTweaks {
public static float newGetMaterialCreationBonus(byte material){ public static float newGetMaterialCreationBonus(byte material){
if(materialCreationBonus.containsKey(material)){ if(materialCreationBonus.containsKey(material)){
//logger.info(String.format("Modifying creation bonus by %.2f%% due to material type %s.", materialCreationBonus.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying creation bonus by %.2f%% due to material type %s.", materialCreationBonus.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialCreationBonus.get(material); return materialCreationBonus.get(material);
} }
return 0.0f; return 0.0f;
@@ -63,7 +82,7 @@ public class MaterialTweaks {
public static float newGetMaterialImpBonus(Item item){ public static float newGetMaterialImpBonus(Item item){
byte material = item.getMaterial(); byte material = item.getMaterial();
if(materialImproveBonus.containsKey(material)){ if(materialImproveBonus.containsKey(material)){
//logger.info(String.format("Modifying improve bonus by %.2f%% due to material type %s.", materialImproveBonus.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying improve bonus by %.2f%% due to material type %s.", materialImproveBonus.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialImproveBonus.get(material); return materialImproveBonus.get(material);
} }
return 1.0f; return 1.0f;
@@ -71,7 +90,7 @@ public class MaterialTweaks {
public static float newGetMaterialShatterMod(byte material){ public static float newGetMaterialShatterMod(byte material){
if(materialShatterResistance.containsKey(material)){ if(materialShatterResistance.containsKey(material)){
//logger.info(String.format("Modifying shatter resistance by %.2f%% due to material type %s.", materialShatterResistance.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying shatter resistance by %.2f%% due to material type %s.", materialShatterResistance.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialShatterResistance.get(material); return materialShatterResistance.get(material);
} }
return 0.0f; return 0.0f;
@@ -79,7 +98,7 @@ public class MaterialTweaks {
public static float newGetMaterialLockpickBonus(byte material){ public static float newGetMaterialLockpickBonus(byte material){
if(materialLockpickBonus.containsKey(material)){ if(materialLockpickBonus.containsKey(material)){
//logger.info(String.format("Modifying lockpick bonus by %.2f%% due to material type %s.", materialLockpickBonus.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying lockpick bonus by %.2f%% due to material type %s.", materialLockpickBonus.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialLockpickBonus.get(material); return materialLockpickBonus.get(material);
} }
return 0.0f; return 0.0f;
@@ -87,7 +106,7 @@ public class MaterialTweaks {
public static float newGetMaterialAnchorBonus(byte material){ public static float newGetMaterialAnchorBonus(byte material){
if(materialAnchorBonus.containsKey(material)){ if(materialAnchorBonus.containsKey(material)){
//logger.info(String.format("Modifying anchor bonus by %.2f%% due to material type %s.", materialAnchorBonus.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying anchor bonus by %.2f%% due to material type %s.", materialAnchorBonus.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialAnchorBonus.get(material); return materialAnchorBonus.get(material);
} }
return 1.0f; return 1.0f;
@@ -95,7 +114,7 @@ public class MaterialTweaks {
public static float newGetMaterialPendulumModifier(byte material){ public static float newGetMaterialPendulumModifier(byte material){
if(materialPendulumEffect.containsKey(material)){ if(materialPendulumEffect.containsKey(material)){
//logger.info(String.format("Modifying pendulum effect by %.2f%% due to material type %s.", materialPendulumEffect.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying pendulum effect by %.2f%% due to material type %s.", materialPendulumEffect.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialPendulumEffect.get(material); return materialPendulumEffect.get(material);
} }
return 1.0f; return 1.0f;
@@ -104,7 +123,7 @@ public class MaterialTweaks {
public static float newGetMaterialRepairTimeMod(Item item){ public static float newGetMaterialRepairTimeMod(Item item){
byte material = item.getMaterial(); byte material = item.getMaterial();
if(materialRepairSpeed.containsKey(material)){ if(materialRepairSpeed.containsKey(material)){
//logger.info(String.format("Modifying repair speed by %.2f%% due to material type %s.", materialRepairSpeed.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying repair speed by %.2f%% due to material type %s.", materialRepairSpeed.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialRepairSpeed.get(material); return materialRepairSpeed.get(material);
} }
return 1.0f; return 1.0f;
@@ -112,7 +131,7 @@ public class MaterialTweaks {
public static double newGetMaterialBashModifier(byte material){ public static double newGetMaterialBashModifier(byte material){
if(materialBashModifier.containsKey(material)){ if(materialBashModifier.containsKey(material)){
//logger.info(String.format("Modifying bash by %.2f%% due to material type %s.", materialBashModifier.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying bash by %.2f%% due to material type %s.", materialBashModifier.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialBashModifier.get(material); return materialBashModifier.get(material);
} }
return 1.0f; return 1.0f;
@@ -127,11 +146,11 @@ public class MaterialTweaks {
byte material = item.getMaterial(); byte material = item.getMaterial();
if(materialSpellEffectModifier.containsKey(material)) { if(materialSpellEffectModifier.containsKey(material)) {
newPower *= materialSpellEffectModifier.get(material); newPower *= materialSpellEffectModifier.get(material);
//logger.info(String.format("Modifying spell power by %.2f%% due to material type %s. [%s]", materialSpellEffectModifier.get(material) * 100d, MaterialTweaks.getMaterialName(material), newPower)); //logger.info(String.format("Modifying spell power by %.2f%% due to material type %s. [%s]", materialSpellEffectModifier.get(material) * 100d, MaterialsTweaks.getMaterialName(material), newPower));
} }
if(materialSpecificSpellEffectModifier.containsKey(material) && materialSpecificSpellEffectModifier.get(material).containsKey(aEnchantment)) { if(materialSpecificSpellEffectModifier.containsKey(material) && materialSpecificSpellEffectModifier.get(material).containsKey(aEnchantment)) {
newPower *= materialSpecificSpellEffectModifier.get(material).get(aEnchantment); newPower *= materialSpecificSpellEffectModifier.get(material).get(aEnchantment);
//logger.info(String.format("Modifying spell power of enchant %s by %.2f%% due to material type %s. [%s]", aEnchantment, materialSpecificSpellEffectModifier.get(material).get(aEnchantment) * 100d, MaterialTweaks.getMaterialName(material), newPower)); //logger.info(String.format("Modifying spell power of enchant %s by %.2f%% due to material type %s. [%s]", aEnchantment, materialSpecificSpellEffectModifier.get(material).get(aEnchantment) * 100d, MaterialsTweaks.getMaterialName(material), newPower));
} }
return newPower; return newPower;
} }
@@ -144,7 +163,7 @@ public class MaterialTweaks {
byte material = item.getMaterial(); byte material = item.getMaterial();
if(materialDifficultyModifier.containsKey(material)){ if(materialDifficultyModifier.containsKey(material)){
diff *= materialDifficultyModifier.get(material); diff *= materialDifficultyModifier.get(material);
//logger.info(String.format("Modifying difficulty by %.2f%% due to material type %s. [%s]", materialDifficultyModifier.get(material) * 100d, MaterialTweaks.getMaterialName(material), diff)); //logger.info(String.format("Modifying difficulty by %.2f%% due to material type %s. [%s]", materialDifficultyModifier.get(material) * 100d, MaterialsTweaks.getMaterialName(material), diff));
} }
} }
return diff; return diff;
@@ -154,13 +173,21 @@ public class MaterialTweaks {
if(item != null){ if(item != null){
byte material = item.getMaterial(); byte material = item.getMaterial();
if(materialActionSpeedModifier.containsKey(material)){ if(materialActionSpeedModifier.containsKey(material)){
//logger.info(String.format("Modifying action speed by %.2f%% due to material type %s.", materialActionSpeedModifier.get(material) * 100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying action speed by %.2f%% due to material type %s.", materialActionSpeedModifier.get(material) * 100d, MaterialsTweaks.getMaterialName(material)));
return materialActionSpeedModifier.get(material); return materialActionSpeedModifier.get(material);
} }
} }
return 1.0f; return 1.0f;
} }
public static void addMaterialDamageReduction(byte material, float reduction){
materialDamageReduction.put(material, reduction);
}
public static void addMaterialMovementModifier(byte material, float speed){
materialMovementModifier.put(material, speed);
}
public static void addMaterialDamageModifier(byte material, float mult){ public static void addMaterialDamageModifier(byte material, float mult){
materialDamageModifier.put(material, mult); materialDamageModifier.put(material, mult);
} }
@@ -263,6 +290,32 @@ public class MaterialTweaks {
} }
protected static void initializeMaterialMaps(){ protected static void initializeMaterialMaps(){
// Material damage reduction modifiers
materialDamageReduction.put(Materials.MATERIAL_GOLD, -0.01f);
materialDamageReduction.put(Materials.MATERIAL_SILVER, -0.0075f);
materialDamageReduction.put(Materials.MATERIAL_STEEL, 0.025f);
materialDamageReduction.put(Materials.MATERIAL_COPPER, -0.01f);
materialDamageReduction.put(Materials.MATERIAL_IRON, 0.0f);
materialDamageReduction.put(Materials.MATERIAL_LEAD, -0.025f);
materialDamageReduction.put(Materials.MATERIAL_ZINC, -0.02f);
materialDamageReduction.put(Materials.MATERIAL_BRASS, 0.01f);
materialDamageReduction.put(Materials.MATERIAL_BRONZE, 0.01f);
materialDamageReduction.put(Materials.MATERIAL_TIN, -0.0175f);
materialDamageReduction.put(Materials.MATERIAL_ADAMANTINE, 0.05f);
materialDamageReduction.put(Materials.MATERIAL_GLIMMERSTEEL, 0.05f);
materialDamageReduction.put(Materials.MATERIAL_SERYLL, 0.05f);
// Material movement modifiers
materialMovementModifier.put(Materials.MATERIAL_ADAMANTINE, 0.95f);
materialMovementModifier.put(Materials.MATERIAL_COPPER, 0.99f);
materialMovementModifier.put(Materials.MATERIAL_GLIMMERSTEEL, 0.90f);
materialMovementModifier.put(Materials.MATERIAL_GOLD, 1.05f);
materialMovementModifier.put(Materials.MATERIAL_LEAD, 1.025f);
materialMovementModifier.put(Materials.MATERIAL_SERYLL, 0.90f);
materialMovementModifier.put(Materials.MATERIAL_SILVER, 1.02f);
materialMovementModifier.put(Materials.MATERIAL_TIN, 0.98f);
materialMovementModifier.put(Materials.MATERIAL_ZINC, 0.975f);
// Material damage taken modifiers // Material damage taken modifiers
materialDamageModifier.put(Materials.MATERIAL_ADAMANTINE, 0.40f); materialDamageModifier.put(Materials.MATERIAL_ADAMANTINE, 0.40f);
materialDamageModifier.put(Materials.MATERIAL_BRASS, 0.95f); materialDamageModifier.put(Materials.MATERIAL_BRASS, 0.95f);
@@ -382,94 +435,107 @@ public class MaterialTweaks {
public static void preInit(){ public static void preInit(){
try { try {
ClassPool classPool = HookManager.getInstance().getClassPool(); ClassPool classPool = HookManager.getInstance().getClassPool();
final Class<MaterialTweaks> thisClass = MaterialTweaks.class; final Class<MaterialsTweaks> thisClass = MaterialsTweaks.class;
String replace; String replace;
if(ArmouryModMain.enableItemMaterialChanges){ if(ArmouryModMain.enableItemMaterialChanges){
Util.setReason("Enable material damage reduction modifications.");
CtClass ctArmourTemplate = classPool.get("com.wurmonline.server.combat.ArmourTemplate");
replace = "{"
+ " return "+MaterialsTweaks.class.getName()+".newGetMaterialDamageReduction($1);"
+ "}";
Util.setBodyDeclared(thisClass, ctArmourTemplate, "getArmourMatBonus", replace);
Util.setReason("Enable material movement modifications.");
replace = "{"
+ " return "+MaterialsTweaks.class.getName()+".newGetMaterialMovementModifier($1);"
+ "}";
Util.setBodyDeclared(thisClass, ctArmourTemplate, "getMaterialMovementModifier", replace);
Util.setReason("Enable material damage taken modifications."); Util.setReason("Enable material damage taken modifications.");
CtClass ctItem = classPool.get("com.wurmonline.server.items.Item"); CtClass ctItem = classPool.get("com.wurmonline.server.items.Item");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialDamageModifier($0);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialDamageModifier($0);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctItem, "getMaterialDamageModifier", replace); Util.setBodyDeclared(thisClass, ctItem, "getMaterialDamageModifier", replace);
Util.setReason("Enable material decay modifications."); Util.setReason("Enable material decay modifications.");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialDecayModifier($0);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialDecayModifier($0);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctItem, "getMaterialDecayModifier", replace); Util.setBodyDeclared(thisClass, ctItem, "getMaterialDecayModifier", replace);
Util.setReason("Enable material creation bonus modifications."); Util.setReason("Enable material creation bonus modifications.");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialCreationBonus($1);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialCreationBonus($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctItem, "getMaterialCreationBonus", replace); Util.setBodyDeclared(thisClass, ctItem, "getMaterialCreationBonus", replace);
Util.setReason("Enable material improvement bonus modifications."); Util.setReason("Enable material improvement bonus modifications.");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialImpBonus($0);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialImpBonus($0);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctItem, "getMaterialImpBonus", replace); Util.setBodyDeclared(thisClass, ctItem, "getMaterialImpBonus", replace);
Util.setReason("Enable material shatter resistance modifications."); Util.setReason("Enable material shatter resistance modifications.");
CtClass ctSpell = classPool.get("com.wurmonline.server.spells.Spell"); CtClass ctSpell = classPool.get("com.wurmonline.server.spells.Spell");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialShatterMod($1);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialShatterMod($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctSpell, "getMaterialShatterMod", replace); Util.setBodyDeclared(thisClass, ctSpell, "getMaterialShatterMod", replace);
Util.setReason("Enable material lockpick bonus modifications."); Util.setReason("Enable material lockpick bonus modifications.");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialLockpickBonus($1);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialLockpickBonus($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctItem, "getMaterialLockpickBonus", replace); Util.setBodyDeclared(thisClass, ctItem, "getMaterialLockpickBonus", replace);
Util.setReason("Enable material anchor bonus modifications."); Util.setReason("Enable material anchor bonus modifications.");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialAnchorBonus($1);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialAnchorBonus($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctItem, "getMaterialAnchorBonus", replace); Util.setBodyDeclared(thisClass, ctItem, "getMaterialAnchorBonus", replace);
Util.setReason("Enable material pendulum effect modifications."); Util.setReason("Enable material pendulum effect modifications.");
CtClass ctLocates = classPool.get("com.wurmonline.server.behaviours.Locates"); CtClass ctLocates = classPool.get("com.wurmonline.server.behaviours.Locates");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialPendulumModifier($1);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialPendulumModifier($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctLocates, "getMaterialPendulumModifier", replace); Util.setBodyDeclared(thisClass, ctLocates, "getMaterialPendulumModifier", replace);
Util.setReason("Enable material repair speed modifications."); Util.setReason("Enable material repair speed modifications.");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialRepairTimeMod($0);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialRepairTimeMod($0);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctItem, "getMaterialRepairTimeMod", replace); Util.setBodyDeclared(thisClass, ctItem, "getMaterialRepairTimeMod", replace);
Util.setReason("Enable material bash modifications."); Util.setReason("Enable material bash modifications.");
CtClass ctWeapon = classPool.get("com.wurmonline.server.combat.Weapon"); CtClass ctWeapon = classPool.get("com.wurmonline.server.combat.Weapon");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetMaterialBashModifier($1);" + " return "+MaterialsTweaks.class.getName()+".newGetMaterialBashModifier($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctWeapon, "getMaterialBashModifier", replace); Util.setBodyDeclared(thisClass, ctWeapon, "getMaterialBashModifier", replace);
Util.setReason("Enable material spell power modifications."); Util.setReason("Enable material spell power modifications.");
replace = "{" replace = "{"
+ " return "+MaterialTweaks.class.getName()+".newGetBonusForSpellEffect($0, $1);" + " return "+MaterialsTweaks.class.getName()+".newGetBonusForSpellEffect($0, $1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctItem, "getBonusForSpellEffect", replace); Util.setBodyDeclared(thisClass, ctItem, "getBonusForSpellEffect", replace);
Util.setReason("Enable material skill difficulty modifications."); Util.setReason("Enable material skill difficulty modifications.");
CtClass ctSkill = classPool.get("com.wurmonline.server.skills.Skill"); CtClass ctSkill = classPool.get("com.wurmonline.server.skills.Skill");
replace = "$1 = "+MaterialTweaks.class.getName()+".getNewDifficulty(this, $1, $2);"; replace = "$1 = "+MaterialsTweaks.class.getName()+".getNewDifficulty(this, $1, $2);";
Util.insertBeforeDeclared(thisClass, ctSkill, "checkAdvance", replace); Util.insertBeforeDeclared(thisClass, ctSkill, "checkAdvance", replace);
Util.setReason("Enable material action speed modifications."); Util.setReason("Enable material action speed modifications.");
CtClass ctActions = classPool.get("com.wurmonline.server.behaviours.Actions"); CtClass ctActions = classPool.get("com.wurmonline.server.behaviours.Actions");
replace = "$_ = $proceed($$)*"+MaterialTweaks.class.getName()+".getMaterialSpeedModifier(source);"; replace = "$_ = $proceed($$)*"+MaterialsTweaks.class.getName()+".getMaterialSpeedModifier(source);";
Util.instrumentDeclared(thisClass, ctActions, "getStandardActionTime", "getStaminaModiferFor", replace); Util.instrumentDeclared(thisClass, ctActions, "getStandardActionTime", "getStaminaModiferFor", replace);
Util.instrumentDeclared(thisClass, ctActions, "getQuickActionTime", "getStaminaModiferFor", replace); Util.instrumentDeclared(thisClass, ctActions, "getQuickActionTime", "getStaminaModiferFor", replace);
Util.instrumentDeclared(thisClass, ctActions, "getVariableActionTime", "getStaminaModiferFor", replace); Util.instrumentDeclared(thisClass, ctActions, "getVariableActionTime", "getStaminaModiferFor", replace);
Util.instrumentDeclared(thisClass, ctActions, "getSlowActionTime", "getStaminaModiferFor", replace); Util.instrumentDeclared(thisClass, ctActions, "getSlowActionTime", "getStaminaModiferFor", replace);
Util.instrumentDeclared(thisClass, ctActions, "getPickActionTime", "getStaminaModiferFor", replace); Util.instrumentDeclared(thisClass, ctActions, "getPickActionTime", "getStaminaModiferFor", replace);
replace = "$_ = $proceed($$)*"+MaterialTweaks.class.getName()+".getMaterialSpeedModifier(realSource);"; replace = "$_ = $proceed($$)*"+MaterialsTweaks.class.getName()+".getMaterialSpeedModifier(realSource);";
Util.instrumentDeclared(thisClass, ctActions, "getItemCreationTime", "getStaminaModiferFor", replace); Util.instrumentDeclared(thisClass, ctActions, "getItemCreationTime", "getStaminaModiferFor", replace);
} }
} catch (NotFoundException e) { } catch (NotFoundException e) {

View File

@@ -16,8 +16,8 @@ import javassist.ClassPool;
import javassist.CtClass; import javassist.CtClass;
import javassist.NotFoundException; import javassist.NotFoundException;
public class ShieldTweaks { public class ShieldsTweaks {
public static Logger logger = Logger.getLogger(ShieldTweaks.class.getName()); public static Logger logger = Logger.getLogger(ShieldsTweaks.class.getName());
public static boolean checkShieldSpeed(Item shield){ public static boolean checkShieldSpeed(Item shield){
if ((shield != null)) { if ((shield != null)) {
@@ -59,17 +59,17 @@ public class ShieldTweaks {
public static void preInit(){ public static void preInit(){
try { try {
ClassPool classPool = HookManager.getInstance().getClassPool(); ClassPool classPool = HookManager.getInstance().getClassPool();
Class<ShieldTweaks> thisClass = ShieldTweaks.class; Class<ShieldsTweaks> thisClass = ShieldsTweaks.class;
if(ArmouryModMain.enableShieldDamageEnchants){ if(ArmouryModMain.enableShieldDamageEnchants){
CtClass ctCombatHandler = classPool.get("com.wurmonline.server.creatures.CombatHandler"); CtClass ctCombatHandler = classPool.get("com.wurmonline.server.creatures.CombatHandler");
String replace = ShieldTweaks.class.getName()+".doSharedPain(this.creature, defender, defShield);" String replace = ShieldsTweaks.class.getName()+".doSharedPain(this.creature, defender, defShield);"
+ "$_ = $proceed($$);"; + "$_ = $proceed($$);";
Util.setReason("Enable shield damage enchants."); Util.setReason("Enable shield damage enchants.");
Util.instrumentDeclared(thisClass, ctCombatHandler, "checkShield", "setDamage", replace); Util.instrumentDeclared(thisClass, ctCombatHandler, "checkShield", "setDamage", replace);
/*ctCombatHandler.getDeclaredMethod("checkShield").instrument(new ExprEditor(){ /*ctCombatHandler.getDeclaredMethod("checkShield").instrument(new ExprEditor(){
public void edit(MethodCall m) throws CannotCompileException { public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("setDamage")) { if (m.getMethodName().equals("setDamage")) {
m.replace(ShieldTweaks.class.getName()+".doSharedPain(this.creature, defender, defShield);" m.replace(ShieldsTweaks.class.getName()+".doSharedPain(this.creature, defender, defShield);"
+ "$_ = $proceed($$);"); + "$_ = $proceed($$);");
return; return;
} }
@@ -78,13 +78,13 @@ public class ShieldTweaks {
} }
if(ArmouryModMain.enableShieldSpeedEnchants){ if(ArmouryModMain.enableShieldSpeedEnchants){
CtClass ctCombatHandler = classPool.get("com.wurmonline.server.creatures.CombatHandler"); CtClass ctCombatHandler = classPool.get("com.wurmonline.server.creatures.CombatHandler");
String insert = "if("+ShieldTweaks.class.getName()+".checkShieldSpeed(defender.getShield())){" String insert = "if("+ShieldsTweaks.class.getName()+".checkShieldSpeed(defender.getShield())){"
+ " defender.getCombatHandler().usedShieldThisRound--;" + " defender.getCombatHandler().usedShieldThisRound--;"
+ "}"; + "}";
Util.setReason("Enable shield speed enchants."); Util.setReason("Enable shield speed enchants.");
Util.insertBeforeDeclared(thisClass, ctCombatHandler, "checkShield", insert); Util.insertBeforeDeclared(thisClass, ctCombatHandler, "checkShield", insert);
/*ctCombatHandler.getDeclaredMethod("checkShield").insertBefore("" /*ctCombatHandler.getDeclaredMethod("checkShield").insertBefore(""
+ "if("+ShieldTweaks.class.getName()+".checkShieldSpeed(defender.getShield())){" + "if("+ShieldsTweaks.class.getName()+".checkShieldSpeed(defender.getShield())){"
+ " defender.getCombatHandler().usedShieldThisRound--;" + " defender.getCombatHandler().usedShieldThisRound--;"
+ "}");*/ + "}");*/
} }

View File

@@ -16,8 +16,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
public class WeaponTweaks { public class WeaponsTweaks {
public static Logger logger = Logger.getLogger(WeaponTweaks.class.getName()); public static Logger logger = Logger.getLogger(WeaponsTweaks.class.getName());
public static Map<Integer, Weapon> weapons; // Mirror of the Weapon class map public static Map<Integer, Weapon> weapons; // Mirror of the Weapon class map
@@ -28,7 +28,7 @@ public class WeaponTweaks {
public static double newGetMaterialDamageBonus(byte material){ public static double newGetMaterialDamageBonus(byte material){
if(materialWeaponDamage.containsKey(material)){ if(materialWeaponDamage.containsKey(material)){
//logger.info(String.format("Modifying damage by %.2f%% due to material type %s.", materialWeaponDamage.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying damage by %.2f%% due to material type %s.", materialWeaponDamage.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialWeaponDamage.get(material); return materialWeaponDamage.get(material);
} }
return 1.0d; return 1.0d;
@@ -46,7 +46,7 @@ public class WeaponTweaks {
byte material = weapon.getMaterial(); byte material = weapon.getMaterial();
if(materialWeaponSpeed.containsKey(material)){ if(materialWeaponSpeed.containsKey(material)){
speed *= materialWeaponSpeed.get(material); speed *= materialWeaponSpeed.get(material);
//logger.info(String.format("Found material %s, modifying speed by %.2f%%. New speed: %s", MaterialTweaks.getMaterialName(material), materialWeaponSpeed.get(material)*100f, speed)); //logger.info(String.format("Found material %s, modifying speed by %.2f%%. New speed: %s", MaterialsTweaks.getMaterialName(material), materialWeaponSpeed.get(material)*100f, speed));
} }
return speed; return speed;
} catch (IllegalAccessException | NoSuchFieldException e) { } catch (IllegalAccessException | NoSuchFieldException e) {
@@ -61,7 +61,7 @@ public class WeaponTweaks {
public static float newGetMaterialParryBonus(byte material){ public static float newGetMaterialParryBonus(byte material){
if(materialWeaponParry.containsKey(material)){ if(materialWeaponParry.containsKey(material)){
//logger.info(String.format("Modifying parry by %.2f%% due to material type %s.", materialWeaponParry.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying parry by %.2f%% due to material type %s.", materialWeaponParry.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialWeaponParry.get(material); return materialWeaponParry.get(material);
} }
return 1.0f; return 1.0f;
@@ -69,7 +69,7 @@ public class WeaponTweaks {
public static double newGetMaterialArmourDamageBonus(byte material){ public static double newGetMaterialArmourDamageBonus(byte material){
if(materialWeaponArmourDamage.containsKey(material)){ if(materialWeaponArmourDamage.containsKey(material)){
//logger.info(String.format("Modifying armour damage by %.2f%% due to material type %s.", materialWeaponArmourDamage.get(material)*100d, MaterialTweaks.getMaterialName(material))); //logger.info(String.format("Modifying armour damage by %.2f%% due to material type %s.", materialWeaponArmourDamage.get(material)*100d, MaterialsTweaks.getMaterialName(material)));
return materialWeaponArmourDamage.get(material); return materialWeaponArmourDamage.get(material);
} }
return 1.0d; return 1.0d;
@@ -365,32 +365,32 @@ public class WeaponTweaks {
public static void preInit(){ public static void preInit(){
try { try {
ClassPool classPool = HookManager.getInstance().getClassPool(); ClassPool classPool = HookManager.getInstance().getClassPool();
final Class<WeaponTweaks> thisClass = WeaponTweaks.class; final Class<WeaponsTweaks> thisClass = WeaponsTweaks.class;
String replace; String replace;
if(ArmouryModMain.enableWeaponMaterialChanges){ if(ArmouryModMain.enableWeaponMaterialChanges){
Util.setReason("Enable weapon material damage modifications."); Util.setReason("Enable weapon material damage modifications.");
CtClass ctWeapon = classPool.get("com.wurmonline.server.combat.Weapon"); CtClass ctWeapon = classPool.get("com.wurmonline.server.combat.Weapon");
replace = "{" replace = "{"
+ " return "+WeaponTweaks.class.getName()+".newGetMaterialDamageBonus($1);" + " return "+WeaponsTweaks.class.getName()+".newGetMaterialDamageBonus($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctWeapon, "getMaterialDamageBonus", replace); Util.setBodyDeclared(thisClass, ctWeapon, "getMaterialDamageBonus", replace);
Util.setReason("Enable weapon material speed modifications."); Util.setReason("Enable weapon material speed modifications.");
replace = "{" replace = "{"
+ " return "+WeaponTweaks.class.getName()+".newGetBaseSpeedForWeapon($1);" + " return "+WeaponsTweaks.class.getName()+".newGetBaseSpeedForWeapon($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctWeapon, "getBaseSpeedForWeapon", replace); Util.setBodyDeclared(thisClass, ctWeapon, "getBaseSpeedForWeapon", replace);
Util.setReason("Enable weapon material parry modifications."); Util.setReason("Enable weapon material parry modifications.");
replace = "{" replace = "{"
+ " return "+WeaponTweaks.class.getName()+".newGetMaterialParryBonus($1);" + " return "+WeaponsTweaks.class.getName()+".newGetMaterialParryBonus($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctWeapon, "getMaterialParryBonus", replace); Util.setBodyDeclared(thisClass, ctWeapon, "getMaterialParryBonus", replace);
Util.setReason("Enable weapon material armour damage modifications."); Util.setReason("Enable weapon material armour damage modifications.");
replace = "{" replace = "{"
+ " return "+WeaponTweaks.class.getName()+".newGetMaterialArmourDamageBonus($1);" + " return "+WeaponsTweaks.class.getName()+".newGetMaterialArmourDamageBonus($1);"
+ "}"; + "}";
Util.setBodyDeclared(thisClass, ctWeapon, "getMaterialArmourDamageBonus", replace); Util.setBodyDeclared(thisClass, ctWeapon, "getMaterialArmourDamageBonus", replace);
} }
@@ -401,7 +401,7 @@ public class WeaponTweaks {
public static void onServerStarted(){ public static void onServerStarted(){
try { try {
logger.info("Beginning WeaponTweaks initialization..."); logger.info("Beginning WeaponsTweaks initialization...");
weapons = ReflectionUtil.getPrivateField(Weapon.class, ReflectionUtil.getField(Weapon.class, "weapons")); weapons = ReflectionUtil.getPrivateField(Weapon.class, ReflectionUtil.getField(Weapon.class, "weapons"));
//printWeapons(); // For debugging/information purposes //printWeapons(); // For debugging/information purposes