diff --git a/mods/WyvernMods.properties b/mods/WyvernMods.properties index b5cea90..baa3cd3 100644 --- a/mods/WyvernMods.properties +++ b/mods/WyvernMods.properties @@ -763,6 +763,172 @@ knowledgeInfoTileCooldown=14400000 ## >> END MEDITATION MODULE << ## +## >> TITAN MODULE << ## +## The Titan Module handles the implementation of Titans, "raid boss" style creatures with unique mechanics. +## These titans are designed to be completely impossible by small groups of players and must be tackled in a sizable group. +enableTitanModule=true + +#disableTitanNaturalRegeneration: Disables the natural health regeneration of titans. +disableTitanNaturalRegeneration=true +#pollTitanSpawnTime: Amount of time, in milliseconds, to poll the new spawn of a titan. +# This is not the time for a new titan to spawn, just how frequently the server will check to see if a new one should spawn. +# Default is 120000, or 2 minutes. +pollTitanSpawnTime=120000 +#pollTitanTime: Amount of time, in milliseconds, to poll mechanics on the titan. +# This is how frequently it will check to do mechanics during a titan fight. The less frequent the polling, the less often mechanics will occur. +# Default is 1000, or 1 second. +pollTitanTime=1000 +#titanRespawnTime: Amount of time, in milliseconds, between spawns of new titans. +# There can only be one titan active on a server at a time. This timer will determine how long after the previous spawn a new one should be spawned. +# Default is 288000000, or 80 hours (3 days 8 hours) +titanRespawnTime=288000000 +#TODO: Add additional configurations for which titans should be allowed to spawn, their loot, mechanics, and more. + +## >> END TITAN MODULE << ## + +## >> RARE SPAWN MODULE << ## +## The Rare Spawn Module handles the spawning of new creatures which are designed to be stronger than trolls but weaker than legendary creatures. +## This helps fill the gap for small hunting parties, allowing groups of 2-5 slay challenging creatures. +enableRareSpawnModule=true + +#pollRareSpawnTime: Amount of time, in milliseconds, to check spawning of a new rare spawn. +# Rare spawns occur if no other rare spawn is found on the server. As soon as one dies, another replaces it. +pollRareSpawnTime=300000 +#TODO: Add additional configurations for which rare spawns should be allowed to spawn, their loot, additional creature spawns, and more. + +## >> END RARE SPAWN MODULE << ## + +## >> MISSION MODULE << ## +## The Mission Module adds additional features to the existing epic mission features. +## It also helps integrate them more easily into PvE environments by making them more frequent and rewarding. +## Finally, it also helps clear up some bugs which prevent them from occurring properly under some scenarios. +enableMissionModule=true + +# > NEW MISSION CREATOR < # +# New Mission Creator is a system that's independent of the natural mission creation system. +# This handles the creation of new missions in a more precise way than the vanilla handling, which sometimes doesn't function as intended. +# Instead of creation of a mission at random, it will always create a new mission on a timer (set below). +# The only case where it will not create a new missions is if there is already the maximum amount of missions available (1 per entity). +# When missions expire in the default system, there are generally issues with removal of those missions to make room for more. +# This system also double-checks all active missions when the poll occurs, removing any missions which have been expired or completed. +# The process helps open up new slots for missions to be created in a more timely and clean manner. +enableNewMissionCreator=true + +#pollMissionCreatorTime: Amount of time, in milliseconds, to poll the creation of new missions using the New Mission Creator. +# This handles how frequently new missions are added to the system. If you want a new mission every day, set to 1 day worth of milliseconds. +# Default is 14400000, or 4 hours. +pollMissionCreatorTime=14400000 +#useValreiEntities: Whether to use Valrei Entities as the creators for some missions. +# This option extends the default system to include entities such as Walnut, Jackal, and Scavenger to add new missions. +# Using the New Mission Creator, this will allow up to 11 missions to be active at a time instead of the default 4. +useValreiEntities=true +#TODO: Add additional options for control over what missions are created. + +# > END NEW MISSION CREATOR < # + +#addMissionCurrencyReward: Adds a 20-40 copper reward at random for players who participated in the completion of a mission. +addMissionCurrencyReward=true +#TODO: Allow configuration of the currency reward. +#preventMissionOceanSpawns: Prevents mission creatures from spawning in water. +preventMissionOceanSpawns=true +#additionalHerbivoreChecks: Adds additional checks when the system attempts to spawn a herbivore epic creature. +# This prevents legendary creatures, titans, and rare spawns from being used in epic missions which shouldn't allow them. +additionalHerbivoreChecks=true +#additionalMissionSlayableChecks: Adds additional checks when the system attempts to spawn an epic mission slayable creature. +# This prevents legendary creatures, titans, and rare spawns from being used in epic missions which shouldn't allow them. +additionalMissionSlayableChecks=true +#disableEpicMissionTypes: Disables the Ritual, Destroy Guard Tower, and Slay Tower Guards mission types from the system. +# This helps prevent missions from occurring which can be annoying or impossible to complete in some enviornments. +disableEpicMissionTypes=true +#TODO: Allow configuration of which types of missions to disable. + +## >> END MISSION MODULE << ## + +## >> MOUNTED MODULE << ## +## The Mounted Module handles various changes to mounts such as horses. +## It does not affect vehicle speeds, and strictly relates to creature mounts. +enableMountedModule=true +#newMountSpeedScaling: Changes the way hunger and health affects the mounted speed of a creature. Explanation: +# Mount speed has been completely redone from the ground up, using new formulas and different weights. +# Mount speed now scales from all the variables used to calculate speed. +# The thresholds for damage and hunger have been removed and replaced by a formula with a smoothed function to calculate the new speeds. +# Equipment on mounts now scale the speed multiplicatively instead of additively. +# - This means that well-equipped mounts will no longer be able to run decently fast when extremely hurt. +# - If they're low on health, they move slow, period. +# Barding now has a multiplicative speed reduction. Cloth offers the lowest penalty, while chain incurs the largest penalty. +# Traits remain additive to the hunger and health modifiers, but are now scaled multiplicatively by gear and other effects. +# Oakshell now has an slowing effect on the speed of a mount depending on power. +# - This effect is more severe than the epic iteration of the spell, applying a multiplicative slow to the creature. +# Old chart: https://i.imgur.com/bgVY8ne.png +# New chart: https://i.imgur.com/2IYEsA1.png +newMountSpeedScaling=true +#TODO: Add additional options for scaling of WoA/BoTD effects, QL scaling, etc. +#updateMountSpeedOnDamage: Forces a mount's speed to update instantaneously when it takes damage. +# In the vanilla system, there is a random factor where dealing damage to a mount can take a random amount of time to update. +# Through testing, this could take up to 20 seconds or even longer, since the update was random. +# This setting prevents that from happening, and hard-forces the server to update the mount speed immediately when the mount takes damage. +updateMountSpeedOnDamage=true +#allowBisonMounts: Allows Bison to be mounted, just like a horse. If it can pull a wagon, why not hold a person? +allowBisonMounts=true +#TODO: Enable configuration of bison mount speeds. In the meantime, might be able to be adjusted through bdew's movement mod. + +## >> END MOUNTED MODULE << ## + +## >> TELEPORT MODULE << ## +## The Teleport Module handles custom teleportation between two servers with additional features. +## Instead of requiring one server to always give the exact location where the player should arrive on the other side, +## the Teleport Module uses a new method which allows the player to land at either their village token or random location. +enableTeleportModule=true + +#useArenaTeleportMethod: Uses a special method when specific coordinates are given on a server to either randomize location +# place them at their village token on the new server. +# ! Most of this system is hardcoded and will not function well on a server that is not Revenant ! +useArenaTeleportMethod=true +#TODO: Expand this system and make it more configurable. Document more clearly. + +## >> END TELEPORT MODULE << ## + +## >> ECONOMY MODULE << ## +## The Economy Module handles pricing of items and various mechanics involving currency and traders. +enableEconomyModule=true + +#adjustSealedMapValue: The Sealed Map is a custom item which creates a Treasure Map (from TreasureHunting mod) when unsealed. +# This option adjusts their value so it is not static, and instead scaled based on the QL of the sealed map. +adjustSealedMapValue=true +#TODO: Add additional options to adjust the price of sealed maps. +#disableTraderRefill: Disables Traders from refilling their currency from the king's coffers at random. +# Other methods of refilling their currency will be required if you disable this. +disableTraderRefill=true +#voidTraderMoney: When players buy items from traders, by default all the money goes into the trader to be extracted again. +# This option voids 80% of the currency that gets traded to traders, preventing players from simply draining their spent currency out immediately. +voidTraderMoney=true + +## >> END ECONOMY MODULE << ## + +## >> SUPPLY DEPOT MODULE << ## +## The Supply Depot Module implements a new system where supply depots are spawned randomly on the map to be claimed by players. +## These depots will reward the player if they manage to stand near the depot without interruption for a certain amount of time. +## On PvP servers, these can create interesting combat scenarios in locations that are unexpected. +enableSupplyDepotModule=true + +#useSupplyDepotLights: Whether or not to use the "rift beam" light to mark the locations of depots for all players on the map. +useSupplyDepotLights=true +#pollDepotTime: Amount of time, in milliseconds, to poll supply depots. +# This is not the amount of time before new ones spawn, but just how often it checks if they should be spawned, cleared, and similar. +# Default is 60000, or 1 minute. +pollDepotTime=60000 +#captureMessageInterval: Amount of time, in milliseconds, to wait before allowing another global capture message to occur. +# This prevents players from spamming the capture action to create global messages for players. +# Default is 180000, or 3 minutes. +captureMessageInterval=180000 +#depotRespawnTime: Amount of time, in milliseconds, between spawns of depots. +# This is calculated from the last spawn of a depot, not the last capture. +# Default is 39600000, or 11 hours. +depotRespawnTime=39600000 +#TODO: Allow configuration of rewards from depots and other options. + +## >> END SUPPLY DEPOT MODULE << ## + ## >> TREASURE CHEST LOOT MODULE << ## ## The Treasure Chest Loot Module affects the vanilla treasure chests. ## By default, treasure chests can spawn randomly in the wild. This module reconfigures the loot that spawns in them. diff --git a/src/main/java/mod/sin/wyvern/Bloodlust.java b/src/main/java/mod/sin/wyvern/Bloodlust.java index 38299d7..6715968 100644 --- a/src/main/java/mod/sin/wyvern/Bloodlust.java +++ b/src/main/java/mod/sin/wyvern/Bloodlust.java @@ -5,10 +5,6 @@ import com.wurmonline.server.TimeConstants; import com.wurmonline.server.creatures.Creature; import com.wurmonline.server.creatures.Creatures; import javassist.ClassPool; -import javassist.CtClass; -import javassist.NotFoundException; -import javassist.bytecode.Descriptor; -import mod.sin.lib.Util; import org.gotti.wurmunlimited.modloader.classhooks.HookException; import org.gotti.wurmunlimited.modloader.classhooks.HookManager; diff --git a/src/main/java/mod/sin/wyvern/Bounty.java b/src/main/java/mod/sin/wyvern/Bounty.java index 23b0e68..2b5ab5a 100644 --- a/src/main/java/mod/sin/wyvern/Bounty.java +++ b/src/main/java/mod/sin/wyvern/Bounty.java @@ -91,34 +91,13 @@ public class Bounty { try { ClassPool classPool = HookManager.getInstance().getClassPool(); final Class thisClass = Bounty.class; + String replace; CtClass ctCreature = classPool.get("com.wurmonline.server.creatures.Creature"); - /*CtMethod ctCheckBounty = CtMethod.make((String) - "public void checkBounty(com.wurmonline.server.players.Player player, com.wurmonline.server.creatures.Creature mob){" - + " if(!mod.sin.wyvernmods.bounty.MethodsBounty.isCombatant(this.attackers, player.getWurmId()) || mob.isPlayer() || mob.isReborn()){" - + " return;" - + " }" - + (mod.bDebug ? "logger.info(player.getName()+\" killed \"+mob.getName());" : "") - + " mod.sin.wyvernmods.bounty.MethodsBounty.checkPlayerReward(player, mob);" - + "}", ctCreature); - ctCreature.addMethod(ctCheckBounty);*/ - String replace; - replace = "" - //+ "mod.sin.wyvern.bounty.MethodsBounty.checkBounty(player, this);" - + PlayerBounty.class.getName()+".checkPlayerBounty(player, this);" + replace = PlayerBounty.class.getName()+".checkPlayerBounty(player, this);" + "$_ = $proceed($$);"; Util.instrumentDeclared(thisClass, ctCreature, "modifyFightSkill", "checkCoinAward", replace); - /*ctCreature.getDeclaredMethod("modifyFightSkill").instrument(new ExprEditor(){ - public void edit(MethodCall m) throws CannotCompileException { - if (m.getMethodName().equals("checkCoinAward")) { - m.replace("mod.sin.wyvern.bounty.MethodsBounty.checkBounty(player, this);" - + "$_ = $proceed($$);"); - logger.info("Instrumented checkCoinAward to call checkBounty as well."); - return; - } - } - });*/ // Die method description CtClass ctString = classPool.get("java.lang.String"); @@ -130,19 +109,8 @@ public class Bounty { String desc1 = Descriptor.ofMethod(CtClass.voidType, params1); replace = "$_ = $proceed($$);" - //+ "mod.sin.wyvern.bounty.MethodsBounty.checkLootTable(this, corpse);"; + LootBounty.class.getName()+".checkLootTable(this, corpse);"; Util.instrumentDescribed(thisClass, ctCreature, "die", desc1, "setRotation", replace); - /*ctCreature.getDeclaredMethod("die").instrument(new ExprEditor(){ - public void edit(MethodCall m) throws CannotCompileException { - if (m.getMethodName().equals("setRotation")) { - m.replace("$_ = $proceed($$);" - + "mod.sin.wyvern.bounty.MethodsBounty.checkLootTable(this, corpse);"); - logger.info("Instrumented setRotation to call insertCorpseItems as well."); - return; - } - } - });*/ // doNew(int templateid, boolean createPossessions, float aPosX, float aPosY, float aRot, int layer, String name, byte gender, byte kingdom, byte ctype, boolean reborn, byte age) CtClass[] params2 = { @@ -161,56 +129,48 @@ public class Bounty { CtClass.intType }; String desc2 = Descriptor.ofMethod(ctCreature, params2); - Util.insertBeforeDescribed(thisClass, ctCreature, "doNew", desc2, "logger.info(\"Creating new creature: \"+templateid+\" - \"+(aPosX/4)+\", \"+(aPosY/4)+\" [\"+com.wurmonline.server.creatures.CreatureTemplateFactory.getInstance().getTemplate(templateid).getName()+\"]\");"); - // Debugging to show all new creatures created. - //CtMethod ctDoNew = ctCreature.getMethod("doNew", "(IZFFFILjava/lang/String;BBBZB)Lcom/wurmonline/server/creatures/Creature;"); - //ctDoNew.insertBefore("logger.info(\"Creating new creature: \"+templateid+\" - \"+(aPosX/4)+\", \"+(aPosY/4)+\" [\"+com.wurmonline.server.creatures.CreatureTemplateFactory.getInstance().getTemplate(templateid).getName()+\"]\");"); - // Modify new creatures + + Util.setReason("Log new creature spawns."); + replace = "logger.info(\"Creating new creature: \"+templateid+\" - \"+(aPosX/4)+\", \"+(aPosY/4)+\" [\"+com.wurmonline.server.creatures.CreatureTemplateFactory.getInstance().getTemplate(templateid).getName()+\"]\");"; + Util.insertBeforeDescribed(thisClass, ctCreature, "doNew", desc2, replace); + + Util.setReason("Modify newly created creatures."); replace = "$_ = $proceed($$);" //+ "mod.sin.wyvern.bestiary.MethodsBestiary.modifyNewCreature($1);"; + MethodsBestiary.class.getName()+".modifyNewCreature($1);"; Util.instrumentDescribed(thisClass, ctCreature, "doNew", desc2, "sendToWorld", replace); - /*ctDoNew.instrument(new ExprEditor(){ - public void edit(MethodCall m) throws CannotCompileException { - if (m.getMethodName().equals("sendToWorld")) { - m.replace("$_ = $proceed($$);" - + "mod.sin.wyvern.bestiary.MethodsBestiary.modifyNewCreature($1);"); - return; - } - } - });*/ - // -- Enable adjusting size for creatures -- // - CtClass ctCreatureStatus = classPool.get("com.wurmonline.server.creatures.CreatureStatus"); - Util.setBodyDeclared(thisClass, ctCreatureStatus, "getSizeMod", "{return "+MethodsBestiary.class.getName()+".getAdjustedSizeMod(this);}"); - //ctCreatureStatus.getDeclaredMethod("getSizeMod").setBody("{return mod.sin.wyvern.bestiary.MethodsBestiary.getAdjustedSizeMod(this);}"); + // -- Enable adjusting size for creatures -- // + CtClass ctCreatureStatus = classPool.get("com.wurmonline.server.creatures.CreatureStatus"); + Util.setBodyDeclared(thisClass, ctCreatureStatus, "getSizeMod", "{return "+MethodsBestiary.class.getName()+".getAdjustedSizeMod(this);}"); + //ctCreatureStatus.getDeclaredMethod("getSizeMod").setBody("{return mod.sin.wyvern.bestiary.MethodsBestiary.getAdjustedSizeMod(this);}"); - // -- Enable adjusting color for creatures -- // - /*CtClass ctCreatureTemplate = classPool.get("com.wurmonline.server.creatures.CreatureTemplate"); - replace = "if("+MethodsBestiary.class.getName()+".checkColorTemplate(this)){" + // -- Enable adjusting color for creatures -- // + /*CtClass ctCreatureTemplate = classPool.get("com.wurmonline.server.creatures.CreatureTemplate"); + replace = "if("+MethodsBestiary.class.getName()+".checkColorTemplate(this)){" + " return "+MethodsBestiary.class.getName()+".getCreatureColorRed(this);" + "}"; - Util.insertBeforeDeclared(thisClass, ctCreatureTemplate, "getColorRed", replace); - replace = "if("+MethodsBestiary.class.getName()+".checkColorTemplate(this)){" + Util.insertBeforeDeclared(thisClass, ctCreatureTemplate, "getColorRed", replace); + replace = "if("+MethodsBestiary.class.getName()+".checkColorTemplate(this)){" + " return "+MethodsBestiary.class.getName()+".getCreatureColorGreen(this);" + "}"; - Util.insertBeforeDeclared(thisClass, ctCreatureTemplate, "getColorGreen", replace); - replace = "if("+MethodsBestiary.class.getName()+".checkColorTemplate(this)){" + Util.insertBeforeDeclared(thisClass, ctCreatureTemplate, "getColorGreen", replace); + replace = "if("+MethodsBestiary.class.getName()+".checkColorTemplate(this)){" + " return "+MethodsBestiary.class.getName()+".getCreatureColorBlue(this);" + "}"; - Util.insertBeforeDeclared(thisClass, ctCreatureTemplate, "getColorBlue", replace);*/ - /*ctCreatureTemplate.getDeclaredMethod("getColorRed").insertBefore("if(mod.sin.wyvern.bestiary.MethodsBestiary.checkColorTemplate(this)){" + Util.insertBeforeDeclared(thisClass, ctCreatureTemplate, "getColorBlue", replace);*/ + /*ctCreatureTemplate.getDeclaredMethod("getColorRed").insertBefore("if(mod.sin.wyvern.bestiary.MethodsBestiary.checkColorTemplate(this)){" + " return mod.sin.wyvern.bestiary.MethodsBestiary.getCreatureColorRed(this);" + "}"); - ctCreatureTemplate.getDeclaredMethod("getColorGreen").insertBefore("if(mod.sin.wyvern.bestiary.MethodsBestiary.checkColorTemplate(this)){" + ctCreatureTemplate.getDeclaredMethod("getColorGreen").insertBefore("if(mod.sin.wyvern.bestiary.MethodsBestiary.checkColorTemplate(this)){" + " return mod.sin.wyvern.bestiary.MethodsBestiary.getCreatureColorGreen(this);" + "}"); - ctCreatureTemplate.getDeclaredMethod("getColorBlue").insertBefore("if(mod.sin.wyvern.bestiary.MethodsBestiary.checkColorTemplate(this)){" + ctCreatureTemplate.getDeclaredMethod("getColorBlue").insertBefore("if(mod.sin.wyvern.bestiary.MethodsBestiary.checkColorTemplate(this)){" + " return mod.sin.wyvern.bestiary.MethodsBestiary.getCreatureColorBlue(this);" + "}");*/ - // -- When a creature takes damage, track the damage taken -- // - /*CtClass[] params2 = { + // -- When a creature takes damage, track the damage taken -- // + /*CtClass[] params2 = { ctCreature, ctCreature, CtClass.byteType, @@ -223,18 +183,18 @@ public class Bounty { CtClass.floatType, CtClass.booleanType, CtClass.booleanType - }; - String desc2 = Descriptor.ofMethod(CtClass.booleanType, params2); - CtClass ctCombatEngine = classPool.get("com.wurmonline.server.combat.CombatEngine"); - replace = "if($1 != null && $2 != null){" + }; + String desc2 = Descriptor.ofMethod(CtClass.booleanType, params2); + CtClass ctCombatEngine = classPool.get("com.wurmonline.server.combat.CombatEngine"); + replace = "if($1 != null && $2 != null){" + " "+Bounty.class.getName()+".addDealtDamage($2.getWurmId(), $1.getWurmId(), $5);" + "}"; - Util.insertBeforeDescribed(thisClass, ctCombatEngine, "addWound", desc2, replace);*/ - //ctCombatEngine.getMethod("addWound", desc2).insertBefore("if($1 != null && $2 != null){mod.sin.wyvern.bounty.MethodsBounty.addDealtDamage($2.getWurmId(), $1.getWurmId(), $5);}"); + Util.insertBeforeDescribed(thisClass, ctCombatEngine, "addWound", desc2, replace);*/ + //ctCombatEngine.getMethod("addWound", desc2).insertBefore("if($1 != null && $2 != null){mod.sin.wyvern.bounty.MethodsBounty.addDealtDamage($2.getWurmId(), $1.getWurmId(), $5);}"); - } - catch (NotFoundException e) { - throw new HookException(e); - } + } + catch (NotFoundException e) { + throw new HookException(e); + } } } diff --git a/src/main/java/mod/sin/wyvern/EconomicChanges.java b/src/main/java/mod/sin/wyvern/EconomicChanges.java index c62fe88..94647e8 100644 --- a/src/main/java/mod/sin/wyvern/EconomicChanges.java +++ b/src/main/java/mod/sin/wyvern/EconomicChanges.java @@ -87,6 +87,10 @@ public class EconomicChanges { final Class thisClass = EconomicChanges.class; String replace; + CtClass ctItem = classPool.get("com.wurmonline.server.items.Item"); + CtClass ctCreature = classPool.get("com.wurmonline.server.creatures.Creature"); + CtClass ctTrade = classPool.get("com.wurmonline.server.items.Trade"); + /* [2/4/19] Disabled - Likely causing issues with upkeep fluctuation. Util.setReason("Increase deed upkeep by modifying the amount of tiles it thinks it has."); CtClass ctGuardPlan = classPool.get("com.wurmonline.server.villages.GuardPlan"); @@ -107,23 +111,26 @@ public class EconomicChanges { replace = "{ return "+EconomicChanges.class.getName()+".getNewDisbandMoney(this, this.getVillage()); }"; Util.setBodyDeclared(thisClass, ctGuardPlan, "getDisbandMoneyLeft", replace);*/ - Util.setReason("Adjust value for certain items."); - CtClass ctItem = classPool.get("com.wurmonline.server.items.Item"); - replace = "int newVal = "+EconomicChanges.class.getName()+".getNewValue(this);" - + "if(newVal > 0){" - + " return newVal;" - + "}"; - Util.insertBeforeDeclared(thisClass, ctItem, "getValue", replace); + if (WyvernMods.adjustSealedMapValue) { + Util.setReason("Adjust value for certain items."); + replace = "int newVal = " + EconomicChanges.class.getName() + ".getNewValue(this);" + + "if(newVal > 0){" + + " return newVal;" + + "}"; + Util.insertBeforeDeclared(thisClass, ctItem, "getValue", replace); + } - Util.setReason("Remove trader refilling off kings coffers."); - CtClass ctCreature = classPool.get("com.wurmonline.server.creatures.Creature"); - replace = "$_ = 1;"; - Util.instrumentDeclared(thisClass, ctCreature, "removeRandomItems", "nextInt", replace); + if (WyvernMods.disableTraderRefill) { + Util.setReason("Remove trader refilling off kings coffers."); + replace = "$_ = 1;"; + Util.instrumentDeclared(thisClass, ctCreature, "removeRandomItems", "nextInt", replace); + } - Util.setReason("Void 80% of all currency put into traders."); - CtClass ctTrade = classPool.get("com.wurmonline.server.items.Trade"); - replace = "$1 = "+EconomicChanges.class.getName()+".getNewShopDiff($0, $1, $0.shopDiff);"; - Util.insertBeforeDeclared(thisClass, ctTrade, "addShopDiff", replace); + if (WyvernMods.voidTraderMoney) { + Util.setReason("Void 80% of all currency put into traders."); + replace = "$1 = " + EconomicChanges.class.getName() + ".getNewShopDiff($0, $1, $0.shopDiff);"; + Util.insertBeforeDeclared(thisClass, ctTrade, "addShopDiff", replace); + } } catch ( NotFoundException | IllegalArgumentException | ClassCastException e) { throw new HookException(e); diff --git a/src/main/java/mod/sin/wyvern/MissionCreator.java b/src/main/java/mod/sin/wyvern/MissionCreator.java index 0aa658e..76b2097 100644 --- a/src/main/java/mod/sin/wyvern/MissionCreator.java +++ b/src/main/java/mod/sin/wyvern/MissionCreator.java @@ -23,8 +23,14 @@ public class MissionCreator { public static void pollMissions(){ int[] deityNums = { 1, 2, 3, 4, // Original Gods + }; + int[] epicEntityNums = { + 1, 2, 3, 4, // Original Gods 6, 7, 8, 9, 10, 11, 12 // Valrei Entities }; + if (WyvernMods.useValreiEntities){ + deityNums = epicEntityNums; + } EpicServerStatus es = new EpicServerStatus(); EpicMission[] missions = EpicServerStatus.getCurrentEpicMissions(); int i = 0; @@ -43,19 +49,18 @@ public class MissionCreator { i++; } if(EpicServerStatus.getCurrentEpicMissions().length >= deityNums.length){ - logger.info("All entities already have a mission. Aborting."); + logger.info("All entities already have a mission, so no new missions need to be created."); return; } i = 10; int number = 1; while(i > 0) { number = deityNums[Server.rand.nextInt(deityNums.length)]; - logger.info("Testing number "+number); if(EpicServerStatus.getEpicMissionForEntity(number) == null){ - logger.info("Has no mission, breaking loop."); + logger.info("Entity "+number+" has no mission, beginning to ."); break; }else{ - logger.info("Has mission, finding new number."); + logger.info("Entity "+number+" has a mission, finding new entity."); } i++; if(i == 0){ @@ -63,9 +68,8 @@ public class MissionCreator { return; } } - logger.info("Entity number = "+number); String entityName = Deities.getDeityName(number); - logger.info("Entity name = "+entityName); + logger.info("Creating new mission for entity "+entityName); int time = 604800; logger.info("Current epic missions: "+EpicServerStatus.getCurrentEpicMissions().length); if (EpicServerStatus.getCurrentScenario() != null) { @@ -118,35 +122,49 @@ public class MissionCreator { final Class thisClass = MissionCreator.class; String replace; - Util.setReason("Give players currency for completing a mission."); CtClass ctTriggerEffect = classPool.get("com.wurmonline.server.tutorial.TriggerEffect"); - replace = "$_ = $proceed($$);" + - MissionCreator.class.getName()+".awardMissionBonus($0);"; - Util.instrumentDeclared(thisClass, ctTriggerEffect, "effect", "addToSleep", replace); - - Util.setReason("Prevent mission creatures from spawning in water."); CtClass ctEpicServerStatus = classPool.get("com.wurmonline.server.epic.EpicServerStatus"); - replace = "$_ = false;"; - Util.instrumentDeclared(thisClass, ctEpicServerStatus, "spawnSingleCreature", "isSwimming", replace); - - Util.setReason("Modify which templates are allowed to spawn on herbivore-only epic missions."); - replace = "$_ = "+MissionCreator.class.getName()+".isMissionOkayHerbivore($0);"; - Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSlayCreatureMission", "isHerbivore", replace); - Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSlayTraitorMission", "isHerbivore", replace); - Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSacrificeCreatureMission", "isHerbivore", replace); - - Util.setReason("Modify which templates are allowed to spawn on slay missions."); - replace = "$_ = "+MissionCreator.class.getName()+".isMissionOkaySlayable($0);"; - Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSlayCreatureMission", "isEpicMissionSlayable", replace); - Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSacrificeCreatureMission", "isEpicMissionSlayable", replace); - - Util.setReason("Adjust which epic missions are available.."); CtClass ctEpicMissionEnum = classPool.get("com.wurmonline.server.epic.EpicMissionEnum"); - replace = "{ if($0.getMissionType() == 108 || $0.getMissionType() == 120 || $0.getMissionType() == 124){" + - " return 0;" + - "}" + - "return $0.missionChance; }"; - Util.setBodyDeclared(thisClass, ctEpicMissionEnum, "getMissionChance", replace); + + if (WyvernMods.addMissionCurrencyReward) { + Util.setReason("Give players currency for completing a mission."); + replace = "$_ = $proceed($$);" + + MissionCreator.class.getName() + ".awardMissionBonus($0);"; + Util.instrumentDeclared(thisClass, ctTriggerEffect, "effect", "addToSleep", replace); + } + + if (WyvernMods.preventMissionOceanSpawns) { + Util.setReason("Prevent mission creatures from spawning in water."); + replace = "$_ = false;"; + Util.instrumentDeclared(thisClass, ctEpicServerStatus, "spawnSingleCreature", "isSwimming", replace); + } + + if (WyvernMods.additionalHerbivoreChecks) { + Util.setReason("Modify which templates are allowed to spawn on herbivore-only epic missions."); + replace = "$_ = " + MissionCreator.class.getName() + ".isMissionOkayHerbivore($0);"; + Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSlayCreatureMission", "isHerbivore", replace); + Util.setReason("Modify which templates are allowed to spawn on herbivore-only epic missions."); + Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSlayTraitorMission", "isHerbivore", replace); + Util.setReason("Modify which templates are allowed to spawn on herbivore-only epic missions."); + Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSacrificeCreatureMission", "isHerbivore", replace); + } + + if (WyvernMods.additionalMissionSlayableChecks) { + Util.setReason("Modify which templates are allowed to spawn on slay missions."); + replace = "$_ = " + MissionCreator.class.getName() + ".isMissionOkaySlayable($0);"; + Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSlayCreatureMission", "isEpicMissionSlayable", replace); + Util.setReason("Modify which templates are allowed to spawn on slay missions."); + Util.instrumentDeclared(thisClass, ctEpicServerStatus, "createSacrificeCreatureMission", "isEpicMissionSlayable", replace); + } + + if (WyvernMods.disableEpicMissionTypes) { + Util.setReason("Adjust which epic missions are available."); + replace = "{ if($0.getMissionType() == 108 || $0.getMissionType() == 120 || $0.getMissionType() == 124){" + + " return 0;" + + "}" + + "return $0.missionChance; }"; + Util.setBodyDeclared(thisClass, ctEpicMissionEnum, "getMissionChance", replace); + } } catch ( NotFoundException | IllegalArgumentException | ClassCastException e) { throw new HookException(e); diff --git a/src/main/java/mod/sin/wyvern/MountedChanges.java b/src/main/java/mod/sin/wyvern/MountedChanges.java index d3eeecb..62a40b6 100644 --- a/src/main/java/mod/sin/wyvern/MountedChanges.java +++ b/src/main/java/mod/sin/wyvern/MountedChanges.java @@ -114,14 +114,19 @@ public class MountedChanges { final Class thisClass = MountedChanges.class; String replace; - Util.setReason("Scaling horse speed."); CtClass ctCreature = classPool.get("com.wurmonline.server.creatures.Creature"); - replace = "{ return "+MountedChanges.class.getName()+".newMountSpeedMultiplier(this, $1); }"; - Util.setBodyDeclared(thisClass, ctCreature, "getMountSpeedPercent", replace); - Util.setReason("Force mount speed change check on damage."); - replace = "forceMountSpeedChange();"; - Util.insertBeforeDeclared(thisClass, ctCreature, "setWounded", replace); + if (WyvernMods.newMountSpeedScaling) { + Util.setReason("New mount speed scaling."); + replace = "{ return " + MountedChanges.class.getName() + ".newMountSpeedMultiplier(this, $1); }"; + Util.setBodyDeclared(thisClass, ctCreature, "getMountSpeedPercent", replace); + } + + if (WyvernMods.updateMountSpeedOnDamage) { + Util.setReason("Force mount speed change check on damage."); + replace = "forceMountSpeedChange();"; + Util.insertBeforeDeclared(thisClass, ctCreature, "setWounded", replace); + } } catch ( NotFoundException | IllegalArgumentException | ClassCastException e) { throw new HookException(e); diff --git a/src/main/java/mod/sin/wyvern/RareSpawns.java b/src/main/java/mod/sin/wyvern/RareSpawns.java index 8baa2c5..190a06a 100644 --- a/src/main/java/mod/sin/wyvern/RareSpawns.java +++ b/src/main/java/mod/sin/wyvern/RareSpawns.java @@ -99,60 +99,4 @@ public class RareSpawns { } } } - - public static void preInit(){ - try { - ClassPool classPool = HookManager.getInstance().getClassPool(); - Class thisClass = RareSpawns.class; - String replace; - - /*Util.setReason("Disable casting Smite on titans."); - CtClass ctSmite = classPool.get("com.wurmonline.server.spells.Smite"); - replace = "if("+RareSpawns.class.getName()+".isRareCreature($3)){" - + " $2.getCommunicator().sendNormalServerMessage(\"This creature is immune to Smite.\");" - + " return false;" - + "}"; - Util.insertBeforeDeclared(thisClass, ctSmite, "precondition", replace);*/ - - Util.setReason("Disable casting Worm Brains on titans."); - CtClass ctWormBrains = classPool.get("com.wurmonline.server.spells.WormBrains"); - replace = "if("+RareSpawns.class.getName()+".isRareCreature($3)){" - + " $2.getCommunicator().sendNormalServerMessage(\"This creature is immune to Worm Brains.\");" - + " return false;" - + "}"; - Util.insertBeforeDeclared(thisClass, ctWormBrains, "precondition", replace); - - /* Disabled in Wurm Unlimited 1.9 - No longer necessary while using DUSKombat. - - Util.setReason("Increase titan extra damage to pets."); - CtClass ctCreature = classPool.get("com.wurmonline.server.creatures.Creature"); - CtClass ctString = classPool.get("java.lang.String"); - CtClass ctBattle = classPool.get("com.wurmonline.server.combat.Battle"); - CtClass ctCombatEngine = classPool.get("com.wurmonline.server.combat.CombatEngine"); - // @Nullable Creature performer, Creature defender, byte type, int pos, double damage, float armourMod, - // String attString, @Nullable Battle battle, float infection, float poison, boolean archery, boolean alreadyCalculatedResist - CtClass[] params1 = { - ctCreature, - ctCreature, - CtClass.byteType, - CtClass.intType, - CtClass.doubleType, - CtClass.floatType, - ctString, - ctBattle, - CtClass.floatType, - CtClass.floatType, - CtClass.booleanType, - CtClass.booleanType - }; - String desc1 = Descriptor.ofMethod(CtClass.booleanType, params1); - replace = "if($2.isDominated() && $1 != null && "+RareSpawns.class.getName()+".isRareCreature($1)){" + - //" logger.info(\"Detected rare spawn hit on a pet. Adding damage.\");" + - " $5 = $5 * 2d;" + - "}"; - Util.insertBeforeDescribed(thisClass, ctCombatEngine, "addWound", desc1, replace);*/ - }catch (NotFoundException e) { - throw new HookException(e); - } - } } diff --git a/src/main/java/mod/sin/wyvern/SupplyDepots.java b/src/main/java/mod/sin/wyvern/SupplyDepots.java index 48b113f..b8f2390 100644 --- a/src/main/java/mod/sin/wyvern/SupplyDepots.java +++ b/src/main/java/mod/sin/wyvern/SupplyDepots.java @@ -1,5 +1,26 @@ package mod.sin.wyvern; +import com.wurmonline.mesh.Tiles; +import com.wurmonline.server.*; +import com.wurmonline.server.creatures.Creature; +import com.wurmonline.server.creatures.Creatures; +import com.wurmonline.server.economy.Economy; +import com.wurmonline.server.items.Item; +import com.wurmonline.server.items.ItemFactory; +import com.wurmonline.server.items.ItemList; +import com.wurmonline.server.items.NoSuchTemplateException; +import com.wurmonline.server.players.Player; +import com.wurmonline.server.zones.Zones; +import javassist.ClassPool; +import javassist.CtClass; +import javassist.NotFoundException; +import mod.sin.items.ArenaSupplyDepot; +import mod.sin.items.caches.*; +import mod.sin.lib.Util; +import mod.sin.wyvern.util.ItemUtil; +import org.gotti.wurmunlimited.modloader.classhooks.HookManager; +import org.gotti.wurmunlimited.modsupport.ModSupportDb; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -7,41 +28,10 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.logging.Logger; -import com.wurmonline.server.economy.Economy; -import mod.sin.items.SorceryFragment; -import org.gotti.wurmunlimited.modloader.classhooks.HookException; -import org.gotti.wurmunlimited.modloader.classhooks.HookManager; - -import com.wurmonline.mesh.Tiles; -import com.wurmonline.server.FailedException; -import com.wurmonline.server.Items; -import com.wurmonline.server.Players; -import com.wurmonline.server.Server; -import com.wurmonline.server.Servers; -import com.wurmonline.server.TimeConstants; -import com.wurmonline.server.creatures.Creature; -import com.wurmonline.server.creatures.Creatures; -import com.wurmonline.server.items.Item; -import com.wurmonline.server.items.ItemFactory; -import com.wurmonline.server.items.ItemList; -import com.wurmonline.server.items.NoSuchTemplateException; -import com.wurmonline.server.players.Player; -import com.wurmonline.server.zones.Zones; - -import javassist.CannotCompileException; -import javassist.ClassPool; -import javassist.CtClass; -import javassist.NotFoundException; -import mod.sin.items.ArenaSupplyDepot; -import mod.sin.items.caches.*; -import mod.sin.wyvern.util.ItemUtil; -import org.gotti.wurmunlimited.modsupport.ModSupportDb; - public class SupplyDepots { private static Logger logger = Logger.getLogger(SupplyDepots.class.getName()); public static ArrayList depots = new ArrayList<>(); public static Creature host = null; - public static final long depotRespawnTime = TimeConstants.HOUR_MILLIS*11L; public static long lastSpawnedDepot = 0; protected static boolean initalizedSupplyDepot = false; @@ -90,6 +80,9 @@ public class SupplyDepots { } } public static void sendDepotEffect(Player player, Item depot){ + if (!WyvernMods.useSupplyDepotLights){ + return; + } player.getCommunicator().sendAddEffect(depot.getWurmId(), (byte) 25, depot.getPosX(), depot.getPosY(), depot.getPosZ(), (byte) 0); } public static void sendDepotEffectsToPlayer(Player player){ @@ -150,7 +143,7 @@ public class SupplyDepots { MiscChanges.sendGlobalFreedomChat(host, "Greetings! I'll be your host, informing you of the next depot to appear over here on the Arena!", 255, 128, 0); } } - if(System.currentTimeMillis() > lastSpawnedDepot + depotRespawnTime){ + if(System.currentTimeMillis() > lastSpawnedDepot + WyvernMods.depotRespawnTime){ logger.info("No Depots were found, and the timer has expired. Spawning a new one."); boolean spawned = false; int i = 0; @@ -191,7 +184,7 @@ public class SupplyDepots { logger.warning("Could not find a valid location within 20 tries for a supply depot."); } }else if(host != null){ - long timeleft = (lastSpawnedDepot + depotRespawnTime) - System.currentTimeMillis(); + long timeleft = (lastSpawnedDepot + WyvernMods.depotRespawnTime) - System.currentTimeMillis(); long minutesLeft = timeleft/TimeConstants.MINUTE_MILLIS; if(minutesLeft > 0){ if(minutesLeft == 4){ @@ -209,13 +202,12 @@ public class SupplyDepots { } public static long lastAttemptedDepotCapture = 0; - public static final long captureMessageInterval = TimeConstants.MINUTE_MILLIS*3L; public static void broadcastCapture(Creature performer){ MiscChanges.sendServerTabMessage("arena", performer.getName()+" has claimed an Arena depot!", 255, 128, 0); MiscChanges.sendGlobalFreedomChat(performer, performer.getName()+" has claimed an Arena depot!", 255, 128, 0); } public static void maybeBroadcastOpen(Creature performer){ - if(System.currentTimeMillis() > lastAttemptedDepotCapture + captureMessageInterval){ + if(System.currentTimeMillis() > lastAttemptedDepotCapture + WyvernMods.captureMessageInterval){ MiscChanges.sendServerTabMessage("arena", performer.getName()+" is beginning to capture an Arena depot!", 255, 128, 0); MiscChanges.sendGlobalFreedomChat(performer, performer.getName()+" is beginning to capture an Arena depot!", 255, 128, 0); lastAttemptedDepotCapture = System.currentTimeMillis(); @@ -285,13 +277,20 @@ public class SupplyDepots { public static void preInit(){ try{ ClassPool classPool = HookManager.getInstance().getClassPool(); - - // - Add light effects for the supply depots, since they are unique - // + Class thisClass = SupplyDepots.class; + String replace; + CtClass ctPlayers = classPool.get("com.wurmonline.server.Players"); - ctPlayers.getDeclaredMethod("sendAltarsToPlayer").insertBefore("mod.sin.wyvern.SupplyDepots.sendDepotEffectsToPlayer($1);"); + + if (WyvernMods.useSupplyDepotLights) { + Util.setReason("Add depot lights for players."); + replace = "mod.sin.wyvern.SupplyDepots.sendDepotEffectsToPlayer($1);"; + Util.insertBeforeDeclared(thisClass, ctPlayers, "sendAltarsToPlayer", replace); + //ctPlayers.getDeclaredMethod("sendAltarsToPlayer").insertBefore("mod.sin.wyvern.SupplyDepots.sendDepotEffectsToPlayer($1);"); + } - }catch (CannotCompileException | NotFoundException e) { - throw new HookException(e); + }catch (NotFoundException e) { + e.printStackTrace(); } } } diff --git a/src/main/java/mod/sin/wyvern/TeleportHandler.java b/src/main/java/mod/sin/wyvern/TeleportHandler.java index 7d213b5..e008c57 100644 --- a/src/main/java/mod/sin/wyvern/TeleportHandler.java +++ b/src/main/java/mod/sin/wyvern/TeleportHandler.java @@ -104,15 +104,18 @@ public class TeleportHandler { final Class thisClass = TeleportHandler.class; String replace; - Util.setReason("Custom teleportation system for Arena teleport/escape."); CtClass ctPlayerMetaData = classPool.get("com.wurmonline.server.players.PlayerMetaData"); - replace = "logger.info(\"posx = \"+this.posx+\", posy = \"+this.posy);" + - "if(this.posx >= 4000f && this.posx <= 4050f && this.posy >= 4000f && this.posy <= 4050f){" + - " this.posx = "+TeleportHandler.class.getName()+".getTeleportPosX(this.wurmid);" + - " this.posy = "+TeleportHandler.class.getName()+".getTeleportPosY(this.wurmid);" + - "}" + - "$_ = $proceed($$);"; - Util.instrumentDeclared(thisClass, ctPlayerMetaData, "save", "getPosition", replace); + + if (WyvernMods.useArenaTeleportMethod) { + Util.setReason("Custom teleportation system for Arena teleport/escape."); + replace = "logger.info(\"posx = \"+this.posx+\", posy = \"+this.posy);" + + "if(this.posx >= 4000f && this.posx <= 4050f && this.posy >= 4000f && this.posy <= 4050f){" + + " this.posx = " + TeleportHandler.class.getName() + ".getTeleportPosX(this.wurmid);" + + " this.posy = " + TeleportHandler.class.getName() + ".getTeleportPosY(this.wurmid);" + + "}" + + "$_ = $proceed($$);"; + Util.instrumentDeclared(thisClass, ctPlayerMetaData, "save", "getPosition", replace); + } } catch ( NotFoundException | IllegalArgumentException | ClassCastException e) { throw new HookException(e); diff --git a/src/main/java/mod/sin/wyvern/Titans.java b/src/main/java/mod/sin/wyvern/Titans.java index 1cf104f..aa6369a 100644 --- a/src/main/java/mod/sin/wyvern/Titans.java +++ b/src/main/java/mod/sin/wyvern/Titans.java @@ -716,9 +716,7 @@ public class Titans { } public static ArrayList titans = new ArrayList<>(); - public static long lastPolledTitanSpawn = 0; public static long lastSpawnedTitan = 0; - public static final long titanRespawnTime = TimeConstants.HOUR_MILLIS*80L; public static void addTitan(Creature mob){ if(isTitan(mob) && !titans.contains(mob)){ titans.add(mob); @@ -755,7 +753,7 @@ public class Titans { } } if(titans.isEmpty()){ - if(lastSpawnedTitan + titanRespawnTime < System.currentTimeMillis()){ + if(lastSpawnedTitan + WyvernMods.titanRespawnTime < System.currentTimeMillis()){ logger.info("No Titan was found, and the timer has expired. Spawning a new one."); boolean found = false; int spawnX = 2048; @@ -803,7 +801,6 @@ public class Titans { for(Creature c : titans){ c.healRandomWound(1000); } - lastPolledTitanSpawn = System.currentTimeMillis(); } } @@ -813,68 +810,20 @@ public class Titans { Class thisClass = Titans.class; String replace; - Util.setReason("Disable natural regeneration on titans."); CtClass ctWound = classPool.get("com.wurmonline.server.bodys.Wound"); - replace = "if(!"+Titans.class.getName()+".isTitan(this.creature)){" - + " $_ = $proceed($$);" - + "}"; - Util.instrumentDeclared(thisClass, ctWound, "poll", "modifySeverity", replace); - Util.instrumentDeclared(thisClass, ctWound, "poll", "checkInfection", replace); - Util.instrumentDeclared(thisClass, ctWound, "poll", "checkPoison", replace); - - /*Util.setReason("Disable casting Smite on titans."); - CtClass ctSmite = classPool.get("com.wurmonline.server.spells.Smite"); - replace = "if("+Titans.class.getName()+".isTitan($3)){" - + " $2.getCommunicator().sendNormalServerMessage(\"You cannot smite a Titan!\");" - + " return false;" - + "}"; - Util.insertBeforeDeclared(thisClass, ctSmite, "precondition", replace);*/ - - /* Disabled in Wurm Unlimited 1.9 - No longer necessary as spells are balanced. - - Util.setReason("Disable casting Worm Brains on titans."); - CtClass ctWormBrains = classPool.get("com.wurmonline.server.spells.WormBrains"); - replace = "if("+Titans.class.getName()+".isTitan($3)){" - + " $2.getCommunicator().sendNormalServerMessage(\"Titans are immune to that spell.\");" - + " return false;" - + "}"; - Util.insertBeforeDeclared(thisClass, ctWormBrains, "precondition", replace);*/ - CtClass ctCreature = classPool.get("com.wurmonline.server.creatures.Creature"); - Util.setReason("Add spell resistance to titans."); - replace = "if("+Titans.class.getName()+".isTitan(this)){" + - " return 0.05f;" + - "}"; - Util.insertBeforeDeclared(thisClass, ctCreature, "addSpellResistance", replace); - /* Disabled in Wurm Unlimited 1.9 - No longer needed while using DUSKombat. - - Util.setReason("Increase titan extra damage to pets."); - CtClass ctString = classPool.get("java.lang.String"); - CtClass ctBattle = classPool.get("com.wurmonline.server.combat.Battle"); - CtClass ctCombatEngine = classPool.get("com.wurmonline.server.combat.CombatEngine"); - // @Nullable Creature performer, Creature defender, byte type, int pos, double damage, float armourMod, - // String attString, @Nullable Battle battle, float infection, float poison, boolean archery, boolean alreadyCalculatedResist - CtClass[] params1 = { - ctCreature, - ctCreature, - CtClass.byteType, - CtClass.intType, - CtClass.doubleType, - CtClass.floatType, - ctString, - ctBattle, - CtClass.floatType, - CtClass.floatType, - CtClass.booleanType, - CtClass.booleanType - }; - String desc1 = Descriptor.ofMethod(CtClass.booleanType, params1); - replace = "if($2.isDominated() && $1 != null && "+Titans.class.getName()+".isTitan($1)){" + - " logger.info(\"Detected titan hit on a pet. Adding damage.\");" + - " $5 = $5 * 2d;" + - "}"; - Util.insertBeforeDescribed(thisClass, ctCombatEngine, "addWound", desc1, replace);*/ + if (WyvernMods.disableTitanNaturalRegeneration) { + Util.setReason("Disable natural regeneration on titans."); + replace = "if(!" + Titans.class.getName() + ".isTitan(this.creature)){" + + " $_ = $proceed($$);" + + "}"; + Util.instrumentDeclared(thisClass, ctWound, "poll", "modifySeverity", replace); + Util.setReason("Disable natural regeneration on titans."); + Util.instrumentDeclared(thisClass, ctWound, "poll", "checkInfection", replace); + Util.setReason("Disable natural regeneration on titans."); + Util.instrumentDeclared(thisClass, ctWound, "poll", "checkPoison", replace); + } }catch (NotFoundException e) { throw new HookException(e); diff --git a/src/main/java/mod/sin/wyvern/WyvernMods.java b/src/main/java/mod/sin/wyvern/WyvernMods.java index 375756c..924ba91 100644 --- a/src/main/java/mod/sin/wyvern/WyvernMods.java +++ b/src/main/java/mod/sin/wyvern/WyvernMods.java @@ -220,6 +220,51 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea public static long knowledgeInfoCreatureCooldown = 64800000L; // 18 hours default public static long knowledgeInfoTileCooldown = 64800000L; // 18 hours default + // Titan Module Configuration + public static boolean enableTitanModule = true; + public static boolean disableTitanNaturalRegeneration = true; + public static long pollTitanSpawnTime = TimeConstants.MINUTE_MILLIS*2; + public static long pollTitanTime = TimeConstants.SECOND_MILLIS; + public static long titanRespawnTime = TimeConstants.HOUR_MILLIS*80L; + + // Rare Spawn Module Configuration + public static boolean enableRareSpawnModule = true; + public static long pollRareSpawnTime = TimeConstants.MINUTE_MILLIS*5; + + // Mission Module Configuration + public static boolean enableMissionModule = true; + public static boolean enableNewMissionCreator = true; + public static long pollMissionCreatorTime = TimeConstants.HOUR_MILLIS*4; + public static boolean useValreiEntities = true; + public static boolean addMissionCurrencyReward = true; + public static boolean preventMissionOceanSpawns = true; + public static boolean additionalHerbivoreChecks = true; + public static boolean additionalMissionSlayableChecks = true; + public static boolean disableEpicMissionTypes = true; + + // Mounted Module Configuration + public static boolean enableMountedModule = true; + public static boolean newMountSpeedScaling = true; + public static boolean updateMountSpeedOnDamage = true; + public static boolean allowBisonMounts = true; + + // Teleport Module Configuration + public static boolean enableTeleportModule = true; + public static boolean useArenaTeleportMethod = true; + + // Economic Module Configuration + public static boolean enableEconomyModule = true; + public static boolean adjustSealedMapValue = true; + public static boolean disableTraderRefill = true; + public static boolean voidTraderMoney = true; + + // Supply Depot Module Configuration + public static boolean enableSupplyDepotModule = true; + public static boolean useSupplyDepotLights = true; + public static long pollDepotTime = TimeConstants.MINUTE_MILLIS; + public static long captureMessageInterval = TimeConstants.MINUTE_MILLIS*3L; + public static long depotRespawnTime = TimeConstants.HOUR_MILLIS*11L; + // Treasure Chest Loot Module Configuration public static boolean enableTreasureChestLootModule = true; @@ -460,6 +505,51 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea knowledgeInfoCreatureCooldown = Prop.getLongProperty("knowledgeInfoCreatureCooldown", knowledgeInfoCreatureCooldown); knowledgeInfoTileCooldown = Prop.getLongProperty("knowledgeInfoTileCooldown", knowledgeInfoTileCooldown); + // Titan Module + enableTitanModule = Prop.getBooleanProperty("enableTitanModule", enableTitanModule); + disableTitanNaturalRegeneration = Prop.getBooleanProperty("disableTitanNaturalRegeneration", disableTitanNaturalRegeneration); + pollTitanSpawnTime = Prop.getLongProperty("pollTitanSpawnTime", pollTitanSpawnTime); + pollTitanTime = Prop.getLongProperty("pollTitanTime", pollTitanTime); + titanRespawnTime = Prop.getLongProperty("titanRespawnTime", titanRespawnTime); + + // Rare Spawn Module + enableRareSpawnModule = Prop.getBooleanProperty("enableRareSpawnModule", enableRareSpawnModule); + pollRareSpawnTime = Prop.getLongProperty("pollRareSpawnTime", pollRareSpawnTime); + + // Mission Module + enableMissionModule = Prop.getBooleanProperty("enableMissionModule", enableMissionModule); + enableNewMissionCreator = Prop.getBooleanProperty("enableNewMissionCreator", enableNewMissionCreator); + pollMissionCreatorTime = Prop.getLongProperty("pollMissionCreatorTime", pollMissionCreatorTime); + useValreiEntities = Prop.getBooleanProperty("useValreiEntities", useValreiEntities); + addMissionCurrencyReward = Prop.getBooleanProperty("addMissionCurrencyReward", addMissionCurrencyReward); + preventMissionOceanSpawns = Prop.getBooleanProperty("preventMissionOceanSpawns", preventMissionOceanSpawns); + additionalHerbivoreChecks = Prop.getBooleanProperty("additionalHerbivoreChecks", additionalHerbivoreChecks); + additionalMissionSlayableChecks = Prop.getBooleanProperty("additionalMissionSlayableChecks", additionalMissionSlayableChecks); + disableEpicMissionTypes = Prop.getBooleanProperty("disableEpicMissionTypes", disableEpicMissionTypes); + + // Mounted Module + enableMountedModule = Prop.getBooleanProperty("enableMountedModule", enableMountedModule); + newMountSpeedScaling = Prop.getBooleanProperty("newMountSpeedScaling", newMountSpeedScaling); + updateMountSpeedOnDamage = Prop.getBooleanProperty("updateMountSpeedOnDamage", updateMountSpeedOnDamage); + allowBisonMounts = Prop.getBooleanProperty("allowBisonMounts", allowBisonMounts); + + // Teleport Module + enableTeleportModule = Prop.getBooleanProperty("enableTeleportModule", enableTeleportModule); + useArenaTeleportMethod = Prop.getBooleanProperty("useArenaTeleportMethod", useArenaTeleportMethod); + + // Economy Module + enableEconomyModule = Prop.getBooleanProperty("enableEconomyModule", enableEconomyModule); + adjustSealedMapValue = Prop.getBooleanProperty("adjustSealedMapValue", adjustSealedMapValue); + disableTraderRefill = Prop.getBooleanProperty("disableTraderRefill", disableTraderRefill); + voidTraderMoney = Prop.getBooleanProperty("voidTraderMoney", voidTraderMoney); + + // Supply Depot Module + enableSupplyDepotModule = Prop.getBooleanProperty("enableSupplyDepotModule", enableSupplyDepotModule); + useSupplyDepotLights = Prop.getBooleanProperty("useSupplyDepotLights", useSupplyDepotLights); + pollDepotTime = Prop.getLongProperty("pollDepotTime", pollDepotTime); + captureMessageInterval = Prop.getLongProperty("captureMessageInterval", captureMessageInterval); + depotRespawnTime = Prop.getLongProperty("depotRespawnTime", depotRespawnTime); + // Treasure Chest Loot Module enableTreasureChestLootModule = Prop.getBooleanProperty("enableTreasureChestLootModule", enableTreasureChestLootModule); @@ -785,9 +875,61 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea } } - logger.info("Treasure Chest Loot Module: "+enableTreasureChestLootModule); + logger.info("Titan Module: "+enableTitanModule); + if (enableTitanModule){ + logger.info("Disable Titan Natural Regeneration: "+disableTitanNaturalRegeneration); + logger.info("Poll Titan Spawn Timer: "+pollTitanSpawnTime); + logger.info("Poll Titan Timer: "+pollTitanTime); + logger.info("Titan Respawn Timer: "+titanRespawnTime); + } - //this.logger.log(Level.INFO, "Property: " + this.somevalue); + logger.info("Rare Spawn Module: "+enableRareSpawnModule); + if (enableRareSpawnModule){ + logger.info("Poll Rare Spawn Timer: "+pollRareSpawnTime); + } + + logger.info("Mission Module: "+enableMissionModule); + if (enableMissionModule){ + logger.info("New Mission Creator: "+enableNewMissionCreator); + if (enableNewMissionCreator){ + logger.info("New Mission Creator Timer: " + pollMissionCreatorTime); + logger.info("Use Valrei Entities: "+useValreiEntities); + } + logger.info("Add Mission Currency Reward: "+addMissionCurrencyReward); + logger.info("Prevent Ocean Mission Spawns: "+preventMissionOceanSpawns); + logger.info("Additional Herbivore Checks: "+additionalHerbivoreChecks); + logger.info("Additional Mission Slayable Checks: "+additionalMissionSlayableChecks); + logger.info("Disable Epic Mission Types: "+disableEpicMissionTypes); + } + + logger.info("Mounted Module: "+enableMountedModule); + if (enableMountedModule){ + logger.info("New Mount Speed Scaling: "+newMountSpeedScaling); + logger.info("Update Mount Speed On Damage: "+updateMountSpeedOnDamage); + logger.info("Allow Bison Mounts: "+allowBisonMounts); + } + + logger.info("Teleport Module: "+enableTeleportModule); + if (enableTeleportModule){ + logger.info("Use Arena Teleport Method: "+useArenaTeleportMethod); + } + + logger.info("Economy Module: "+enableEconomyModule); + if (enableEconomyModule){ + logger.info("Adjust Sealed Map Value: "+adjustSealedMapValue); + logger.info("Disable Trader Refill: "+disableTraderRefill); + logger.info("Void Trader Money: "+voidTraderMoney); + } + + logger.info("Supply Depot Module: "+enableSupplyDepotModule); + if (enableSupplyDepotModule){ + logger.info("Use Supply Depot Lights: "+useSupplyDepotLights); + logger.info("Poll Depot Timer: "+pollDepotTime); + logger.info("Capture Message Interval: "+captureMessageInterval); + logger.info("Depot Respawn Timer: "+depotRespawnTime); + } + + logger.info("Treasure Chest Loot Module: "+enableTreasureChestLootModule); } public static void handleExamine(Creature performer, Item target) { @@ -842,27 +984,54 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea Mastercraft.preInit(); } + // Skill Module Pre-Init if (enableSkillModule) { SkillChanges.preInit(); } + // Meditation Module Pre-Init if (enableMeditationModule) { MeditationPerks.preInit(); } + // Titan Module Pre-Init + if (enableTitanModule) { + Titans.preInit(); + } + + // Mission Module Pre-Init + if (enableMissionModule) { + MissionCreator.preInit(); + } + + // Mounted Module Pre-Init + if (enableMountedModule) { + MountedChanges.preInit(); + } + + // Teleport Module Pre-Init + if (enableTeleportModule) { + TeleportHandler.preInit(); + } + + // Economy Module Pre-Init + if (enableEconomyModule) { + EconomicChanges.preInit(); + } + + // Supply Depot Module Pre-Init + if (enableSupplyDepotModule) { + SupplyDepots.preInit(); + } + // Treasure Chest Loot Module Pre-Init if (enableTreasureChestLootModule) { TreasureChests.preInit(); } - Titans.preInit(); - RareSpawns.preInit(); - TeleportHandler.preInit(); MethodsBestiary.preInit(); - MissionCreator.preInit(); - MountedChanges.preInit(); - EconomicChanges.preInit(); - SupplyDepots.preInit(); + + // Only clears responses, doesn't have any effect. Harmless to run even if key fragments are not used. KeyEvent.preInit(); // Bloodlust might no longer be necessary. Code remains for reference. @@ -907,7 +1076,10 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea // Vanilla: logger.info("Registering Vanilla creature changes."); - ModCreatures.addCreature(new Bison()); + if (enableMountedModule && allowBisonMounts) { + logger.info("Allowing Bison to be mounted."); + ModCreatures.addCreature(new Bison()); + } // Epic: logger.info("Registering Epic creatures."); @@ -1054,19 +1226,15 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea public static long lastSecondPolled = 0; public static long lastPolledTitanSpawn = 0; - public static final long pollTitanSpawnTime = TimeConstants.MINUTE_MILLIS*2; public static long lastPolledTitans = 0; - public static final long pollTitanTime = TimeConstants.SECOND_MILLIS; public static long lastPolledDepots = 0; - public static final long pollDepotTime = TimeConstants.MINUTE_MILLIS; public static long lastPolledRareSpawns = 0; - public static final long pollRareSpawnTime = TimeConstants.MINUTE_MILLIS*5; public static long lastPolledEternalReservoirs = 0; public static final long pollEternalReservoirTime = TimeConstants.MINUTE_MILLIS*10; public static long lastPolledMissionCreator = 0; - public static final long pollMissionCreatorTime = TimeConstants.HOUR_MILLIS*4; + /* Disabled for now, might need to be revisited. public static long lastPolledBloodlust = 0; - public static final long pollBloodlustTime = TimeConstants.MINUTE_MILLIS; + public static final long pollBloodlustTime = TimeConstants.MINUTE_MILLIS;*/ public static long lastPolledUniqueRegeneration = 0; public static final long pollUniqueRegenerationTime = TimeConstants.SECOND_MILLIS; public static long lastPolledUniqueCollection = 0; @@ -1076,19 +1244,19 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea @Override public void onServerPoll() { if((lastSecondPolled + TimeConstants.SECOND_MILLIS) < System.currentTimeMillis()){ - if(lastPolledDepots + pollDepotTime < System.currentTimeMillis()){ + if(enableSupplyDepotModule && lastPolledDepots + pollDepotTime < System.currentTimeMillis()){ SupplyDepots.pollDepotSpawn(); lastPolledDepots += pollDepotTime; } - if(lastPolledTitanSpawn + pollTitanSpawnTime < System.currentTimeMillis()){ + if(enableTitanModule && lastPolledTitanSpawn + pollTitanSpawnTime < System.currentTimeMillis()){ Titans.pollTitanSpawn(); lastPolledTitanSpawn += pollTitanSpawnTime; } - if(lastPolledTitans + pollTitanTime < System.currentTimeMillis()){ + if(enableTitanModule && lastPolledTitans + pollTitanTime < System.currentTimeMillis()){ Titans.pollTitans(); lastPolledTitans += pollTitanTime; } - if(lastPolledRareSpawns + pollRareSpawnTime < System.currentTimeMillis()){ + if(enableRareSpawnModule && lastPolledRareSpawns + pollRareSpawnTime < System.currentTimeMillis()){ RareSpawns.pollRareSpawns(); lastPolledRareSpawns += pollRareSpawnTime; } @@ -1096,14 +1264,15 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea Soulstealing.pollSoulForges(); lastPolledEternalReservoirs += pollEternalReservoirTime; } - if(lastPolledMissionCreator + pollMissionCreatorTime < System.currentTimeMillis()){ + if(enableMissionModule && enableNewMissionCreator && lastPolledMissionCreator + pollMissionCreatorTime < System.currentTimeMillis()){ MissionCreator.pollMissions(); lastPolledMissionCreator += pollMissionCreatorTime; } + /* Disabled for now, might need to be revisited. if(lastPolledBloodlust + pollBloodlustTime < System.currentTimeMillis()){ Bloodlust.pollLusts(); lastPolledBloodlust += pollBloodlustTime; - } + }*/ if(WyvernMods.useStaticLegendaryRegeneration && lastPolledUniqueRegeneration + pollUniqueRegenerationTime < System.currentTimeMillis()){ CombatChanges.pollUniqueRegeneration(); lastPolledUniqueRegeneration += pollUniqueRegenerationTime; @@ -1129,7 +1298,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea lastPolledRareSpawns = System.currentTimeMillis(); lastPolledEternalReservoirs = System.currentTimeMillis(); lastPolledMissionCreator = System.currentTimeMillis(); - lastPolledBloodlust = System.currentTimeMillis(); + //lastPolledBloodlust = System.currentTimeMillis(); lastPolledUniqueRegeneration = System.currentTimeMillis(); lastPolledUniqueCollection = System.currentTimeMillis(); lastPolledTerrainSmooth = System.currentTimeMillis();