Latest Updates.

This commit is contained in:
Sindusk
2018-06-22 17:08:29 -04:00
parent 76681b6b0e
commit f59852c91b
44 changed files with 2595 additions and 299 deletions

View File

@@ -0,0 +1,325 @@
package mod.sin.wyvern;
import com.wurmonline.server.players.Achievement;
import com.wurmonline.server.players.AchievementTemplate;
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
public class AchievementChanges {
private static Logger logger = Logger.getLogger(AchievementChanges.class.getName());
public static HashMap<Integer, AchievementTemplate> goodAchievements = new HashMap<>();
public static ArrayList<Integer> blacklist = new ArrayList<>();
protected static int getNumber(String name){
AchievementTemplate temp = Achievement.getTemplate(name);
if(temp != null){
return temp.getNumber();
}
return -1;
}
protected static void blacklist(String name){
blacklist.add(getNumber(name));
}
protected static void blacklist(int number){
blacklist.add(number);
}
private static AchievementTemplate addAchievement(int id, String name, String description, String requirement, boolean isInvisible, int triggerOn, byte achievementType, boolean playUpdateSound, boolean isOneTimer) {
AchievementTemplate ach = new AchievementTemplate(id, name, isInvisible, triggerOn, achievementType, playUpdateSound, isOneTimer, requirement);
ach.setDescription(description);
try {
ReflectionUtil.callPrivateMethod(null, ReflectionUtil.getMethod(Achievement.class, "addTemplate", new Class<?>[]{AchievementTemplate.class}), ach);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
return ach;
}
protected static void generateBlacklist(){
blacklist("Adulterator");
blacklist("All Hell");
blacklist("Ambitious");
blacklist("Angry Sailor");
blacklist("Arachnophile");
blacklist("Arch Mage");
blacklist("Ascended");
blacklist("Backstabber");
blacklist("Barbarian");
blacklist("Braaains");
blacklist(299); // Brilliant!
blacklist(364); // Brilliant!
blacklist("Bumble Bee");
blacklist("Burglar");
blacklist("Cap'n");
blacklist("Caravel sailor");
blacklist("Chief Mate");
blacklist("Cog sailor");
blacklist("Corbita sailor");
blacklist("Cowboy");
blacklist("Deforestation");
blacklist("Demolition");
blacklist("Diabolist");
blacklist("Die by the Rift");
blacklist("Die by the Rift a gazillion times");
blacklist("Drake Spirits");
blacklist("Eagle Spirits");
blacklist("Environmental Hero");
blacklist("Epic finalizer");
blacklist(298); // Exquisite Gem
blacklist(363); // Exquisite Gem
blacklist("Fast Learner");
blacklist("Fine titles");
blacklist("Fo's Favourite");
blacklist("Ghost of the Rift Warmasters");
blacklist("Hedgehog");
blacklist("High Spirits");
blacklist("Hippie");
blacklist("Humanss!");
blacklist("Hunter Apprentice");
blacklist("Incarnated To Hell");
blacklist("Investigating the Rift");
blacklist("Jackal Hunter");
blacklist("Janitor");
blacklist("Johnny Appleseed");
blacklist("Joyrider");
blacklist("Juggernaut's demise");
blacklist("Kingdom Assault");
blacklist("Knarr sailor");
blacklist("Last Rope");
blacklist("Lord of War");
blacklist("Mage");
blacklist("Magician");
blacklist("Magus");
blacklist("Manifested No More");
blacklist("Master Bridgebuilder");
blacklist("Master Shipbuilder");
blacklist("Master Winemaker");
blacklist("Miner on Strike");
blacklist("Moby Dick");
blacklist("Mountain Goat");
blacklist("Moved a Mountain");
blacklist("Muffin Maker");
blacklist("Mussst kill");
blacklist("No Fuel for the Flame Of Udun");
blacklist("On the Way to the Moon");
blacklist("Out At Sea");
blacklist("Out, out, brief candle!");
blacklist("Own The Rift");
blacklist("Pasta maker");
blacklist("Pasta master");
blacklist("Peace of Mind");
blacklist("Pirate");
blacklist("Pizza maker");
blacklist("Pizza master");
blacklist("Planeswalker");
blacklist("Rider of the Apocalypse");
blacklist("Rift Beast Nemesis");
blacklist("Rift Ogre Hero");
blacklist("Rift Opener");
blacklist("Rift Specialist");
blacklist("Rift Surfer");
blacklist("Rowboat sailor");
blacklist("Ruler");
blacklist("Sailboat sailor");
blacklist("Settlement Assault");
blacklist("Sisyphos Says Hello");
blacklist("Shadow");
blacklist("Shadowmage");
blacklist("Shutting Down");
blacklist("Singing While Eating");
blacklist("Sneaky");
blacklist("Tastes like Chicken");
blacklist("Tears of the Unicorn");
blacklist("The Path of Vynora");
blacklist("The Smell of Freshly Baked Bread");
blacklist("The Smell of Freshly Made Muffins");
blacklist("Thin Air");
blacklist("Tree Hugger");
blacklist("Trucker");
blacklist("Truffle Pig");
blacklist("Vynora commands you");
blacklist("Waller");
blacklist("Wanderer");
blacklist("Went up a Hill");
blacklist("Wet Feet");
blacklist("You Beauty");
blacklist("You Cannot Pass");
blacklist("Zombie Hunter");
blacklist("around the world");
blacklist("brewed 1000 liters");
blacklist("brewed liters");
blacklist("distilled 1000 liters");
blacklist("distilled liters");
}
protected static void setRequirement(AchievementTemplate temp, String req){
try {
ReflectionUtil.setPrivateField(temp, ReflectionUtil.getField(temp.getClass(), "requirement"), req);
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
protected static void addRequirements(AchievementTemplate temp){
if(temp.getName().equals("Meoww!")){
setRequirement(temp, "Kill a Wild Cat");
}
if(temp.getName().equals("Treasure Hunter")){
setRequirement(temp, "Open a treasure chest");
}
if(temp.getName().equals("Mercykiller")){
setRequirement(temp, "Slay a Diseased creature");
}
if(temp.getName().equals("Slayer of the Meek")){
setRequirement(temp, "Slay a Scared creature");
}
if(temp.getName().equals("Willbreaker")){
setRequirement(temp, "Slay a Hardened creature");
}
if(temp.getName().equals("Crocodiles Killed")){
setRequirement(temp, "Kill a Crocodile");
}
if(temp.getName().equals("Tower Builder")){
setRequirement(temp, "Build a Guard Tower");
}
if(temp.getName().equals("Invisible:UseResStone")){
setRequirement(temp, "Use a Resurrection Stone");
}
if(temp.getName().equals("Invisible:ShakerOrbing")){
setRequirement(temp, "Use a Shaker Orb");
}
if(temp.getName().equals("Invisible:CutTree")){
setRequirement(temp, "Cut down a tree");
}
if(temp.getName().equals("Invisible:CatchFish")){
setRequirement(temp, "Catch a fish");
}
if(temp.getName().equals("Invisible:PlantFlower")){
setRequirement(temp, "Plant a flower");
}
if(temp.getName().equals("Invisible:Planting")){
setRequirement(temp, "Plant a tree");
}
if(temp.getName().equals("Invisible:PickLock")){
setRequirement(temp, "Pick a lock");
}
if(temp.getName().equals("Invisible:Stealth")){
setRequirement(temp, "Successfully hide");
}
if(temp.getName().equals("Invisible:ItemInTrash")){
setRequirement(temp, "Trash an item");
}
if(temp.getName().equals("Invisible:BulkBinDeposit")){
setRequirement(temp, "Deposit a bulk item");
}
if(temp.getName().equals("Invisible:Distancemoved")){
setRequirement(temp, "Walk one tile");
}
if(temp.getName().equals("Invisible:Hedges")){
setRequirement(temp, "Plant a hedge or flower bed");
}
if(temp.getName().equals("Invisible:MeditatingAction")){
setRequirement(temp, "Meditate");
}
if(temp.getName().equals("Invisible:PickMushroom")){
setRequirement(temp, "Pick a mushroom");
}
if(temp.getName().equals("Maintenance")){
setRequirement(temp, "Repair a fence, floor, or wall");
}
if(temp.getName().equals("Be Gentle Please")){
setRequirement(temp, "Win a spar");
}
if(temp.getName().equals("Rarity")){
setRequirement(temp, "Make the best quality of an item");
}
}
protected static void fixName(AchievementTemplate temp){
if(temp.getName().contains("Invisible:")){
temp.setName(temp.getName().replaceAll("Invisible:", ""));
}
if(temp.getName().equals("PlayerkillBow")){
temp.setName("Arrow To The Knee");
}
if(temp.getName().equals("PlayerkillSword")){
temp.setName("Pointing The Right Direction");
}
if(temp.getName().equals("PlayerkillMaul")){
temp.setName("Trip To The Maul");
}
if(temp.getName().equals("PlayerkillAxe")){
temp.setName("Can I Axe You A Question?");
}
if(temp.getName().equals("OuchThatHurt")){
temp.setName("Ouch That Hurt");
}
if(temp.getName().equals("UseResStone")){
temp.setName("No Risk No Reward");
}
if(temp.getName().equals("ShakerOrbing")){
temp.setName("This Mine Is Busted");
}
if(temp.getName().equals("CutTree")){
temp.setName("Getting Wood");
}
if(temp.getName().equals("CatchFish")){
temp.setName("Delicious Fish");
}
if(temp.getName().equals("PlantFlower")){
temp.setName("Gardening");
}
if(temp.getName().equals("Planting")){
temp.setName("Forester");
}
if(temp.getName().equals("PickLock")){
temp.setName("Vault Hunter");
}
if(temp.getName().equals("ItemInTrash")){
temp.setName("Another Mans Trash");
}
if(temp.getName().equals("Stealth")){
temp.setName("The Invisible Man");
}
if(temp.getName().equals("BulkBinDeposit")){
temp.setName("Bulk Hoarder");
}
if(temp.getName().equals("Distancemoved")){
temp.setName("Explorer");
}
if(temp.getName().equals("Hedges")){
temp.setName("Hedging Your Bets");
}
if(temp.getName().equals("MeditatingAction")){
temp.setName("One With The World");
}
if(temp.getName().equals("PickMushroom")){
temp.setName("Mushroom Collector");
}
}
public static void onServerStarted(){
try {
ConcurrentHashMap<Integer, AchievementTemplate> templates = ReflectionUtil.getPrivateField(Achievement.class, ReflectionUtil.getField(Achievement.class, "templates"));
generateBlacklist();
for(int i : templates.keySet()){
AchievementTemplate temp = templates.get(i);
addRequirements(temp);
if(!temp.getRequirement().equals("") && !temp.isForCooking() && !blacklist.contains(i)){
fixName(temp);
goodAchievements.put(i, temp);
logger.info(temp.getNumber()+": "+temp.getName()+" - "+temp.getDescription()+" ("+temp.getRequirement()+")");
}
}
logger.info("Total achievements loaded into system: "+goodAchievements.size());
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
}

View File

@@ -9,6 +9,7 @@ import com.wurmonline.server.items.*;
import com.wurmonline.server.players.Player;
import com.wurmonline.server.questions.NewSpawnQuestion;
import com.wurmonline.server.questions.SpawnQuestion;
import com.wurmonline.server.skills.Affinity;
import com.wurmonline.server.villages.Citizen;
import com.wurmonline.server.villages.Village;
import com.wurmonline.server.zones.Zone;
@@ -139,14 +140,14 @@ public class Arena {
statue.insertItem(sleepPowder, true);
}
for (x = 0; x < 5; ++x) {
lump = ItemFactory.createItem(ItemList.adamantineBar, Math.min(99, 50 + winStreak), null);
lump = ItemFactory.createItem(ItemList.adamantineBar, Math.min(99f, 60 + (winStreak*Server.rand.nextFloat()*1.5f)), null);
float baseWeight = lump.getWeightGrams();
float multiplier = 1f;//+(winStreak*0.4f*Server.rand.nextFloat());
lump.setWeight((int) (baseWeight*multiplier), true);
statue.insertItem(lump, true);
}
for (x = 0; x < 5; ++x) {
lump = ItemFactory.createItem(ItemList.glimmerSteelBar, Math.min(99, 50 + winStreak), null);
lump = ItemFactory.createItem(ItemList.glimmerSteelBar, Math.min(99f, 60 + (winStreak*Server.rand.nextFloat()*1.5f)), null);
float baseWeight = lump.getWeightGrams();
float multiplier = 1f;//+(winStreak*0.2f*Server.rand.nextFloat());
lump.setWeight((int) (baseWeight*multiplier), true);
@@ -163,8 +164,8 @@ public class Arena {
ArtifactCache.templateId,
CrystalCache.templateId, CrystalCache.templateId,
DragonCache.templateId, DragonCache.templateId, DragonCache.templateId,
GemCache.templateId,
RiftCache.templateId, RiftCache.templateId, RiftCache.templateId,
ToolCache.templateId,
TreasureMapCache.templateId
};
int i = 5+Server.rand.nextInt(4); // 5-8 caches.
@@ -180,9 +181,9 @@ public class Arena {
i--;
}
// Add 3-5 seryll lumps of medium ql
i = 3+Server.rand.nextInt(3); // 3-5 caches
i = 3+Server.rand.nextInt(3); // 3-5 lumps
while(i > 0){
Item seryll = ItemFactory.createItem(ItemList.seryllBar, 30f+(40f*Server.rand.nextFloat()), null);
Item seryll = ItemFactory.createItem(ItemList.seryllBar, 40f+(60f*Server.rand.nextFloat()), null);
statue.insertItem(seryll, true);
i--;
}
@@ -209,6 +210,10 @@ public class Arena {
}
}
public static Affinity[] getNullAffinities(){
return new Affinity[0];
}
public static void preInit(){
try {
ClassPool classPool = HookManager.getInstance().getClassPool();
@@ -688,13 +693,13 @@ public class Arena {
"}";
Util.instrumentDeclared(thisClass, ctCreature, "die", "getFavor", replace);
Util.setReason("Nerf resurrection stones.");
/*Util.setReason("Nerf resurrection stones.");
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER){" +
" $_ = com.wurmonline.server.Server.rand.nextInt(40) > 35;" +
"}else{" +
" $_ = $proceed($$);" +
"}";
Util.instrumentDeclared(thisClass, ctCreature, "die", "isDeathProtected", replace);
Util.instrumentDeclared(thisClass, ctCreature, "die", "isDeathProtected", replace);*/
Util.setReason("Adjust spawn question mechanics.");
CtClass ctSpawnQuestion = classPool.get("com.wurmonline.server.questions.SpawnQuestion");
@@ -770,6 +775,40 @@ public class Arena {
replace = "$_ = $0.getAttitude(this) == 1;";
Util.instrumentDeclared(thisClass, ctPlayer, "spreadCrownInfluence", "isFriendlyKingdom", replace);
Util.setReason("Disable item drops from players on Arena.");
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER && this.isPlayer()){" +
" this.getCommunicator().sendSafeServerMessage(\"You have died on the Arena server and your items are kept safe.\");" +
" keepItems = true;" +
"}" +
"$_ = $proceed($$);";
Util.instrumentDeclaredCount(thisClass, ctCreature, "die", "isOnCurrentServer", 1, replace);
Util.setReason("Disable player skill loss on Arena.");
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER && this.isPlayer() && this.isDeathProtected()){" +
" this.getCommunicator().sendSafeServerMessage(\"You have died on the Arena server with a Resurrection Stone and your knowledge is kept safe.\");" +
" return;" +
"}else if(com.wurmonline.server.Servers.localServer.PVPSERVER){" +
" this.getCommunicator().sendAlertServerMessage(\"You have died on the Arena server without a Resurrection Stone, resulting in some of your knowledge being lost.\");" +
"}";
Util.insertBeforeDeclared(thisClass, ctCreature, "punishSkills", replace);
Util.setReason("Disable player fight skill loss on Arena.");
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER && this.isPlayer() && this.isDeathProtected()){" +
" $_ = null;" +
"}else{" +
" $_ = $proceed($$);" +
"}";
Util.instrumentDeclaredCount(thisClass, ctCreature, "modifyFightSkill", "setKnowledge", 1, replace);
Util.setReason("Disable player affinity loss on Arena.");
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER && this.isPlayer() && this.isDeathProtected()){" +
" this.getCommunicator().sendSafeServerMessage(\"Your resurrection stone keeps your affinities safe from your slayers.\");" +
" $_ = "+Arena.class.getName()+".getNullAffinities();" +
"}else{" +
" $_ = $proceed($$);" +
"}";
Util.instrumentDeclared(thisClass, ctPlayer, "modifyRanking", "getAffinities", replace);
}catch (NotFoundException e) {
throw new HookException(e);

View File

@@ -55,10 +55,10 @@ public class Caches {
}
public static float getBaseQuality(float quality){
return quality*0.2f;
return quality*0.25f;
}
public static float getRandomQuality(float quality){
return quality*0.5f;
return quality*0.6f;
}
public static float getWeightMultiplier(int templateId, float quality){
if(templateId == DragonCache.templateId){
@@ -120,6 +120,7 @@ public class Caches {
ItemList.axeSmall, ItemList.axeMedium, ItemList.axeHuge,
ItemList.maulSmall, ItemList.maulMedium, ItemList.maulLarge,
ItemList.spearLong, ItemList.staffSteel, ItemList.halberd,
Club.templateId, BattleYoyo.templateId,
Knuckles.templateId, Warhammer.templateId
};
}else if(templateId == CrystalCache.templateId){
@@ -174,11 +175,52 @@ public class Caches {
ItemList.riftWood,
ItemList.riftStone
};
}else if(templateId == ToolCache.templateId){
return new int[]{
ItemList.hatchet,
ItemList.knifeCarving,
ItemList.pickAxe,
ItemList.saw,
ItemList.shovel,
ItemList.rake,
ItemList.hammerMetal,
ItemList.hammerWood,
ItemList.anvilSmall,
ItemList.cheeseDrill,
ItemList.knifeButchering,
ItemList.fishingRodIronHook,
ItemList.stoneChisel,
ItemList.spindle,
ItemList.anvilLarge,
ItemList.grindstone,
ItemList.needleIron,
ItemList.knifeFood,
ItemList.sickle,
ItemList.scythe,
ItemList.file,
ItemList.awl,
ItemList.leatherKnife,
ItemList.scissors,
ItemList.clayShaper,
ItemList.spatula,
ItemList.fruitpress,
ItemList.trowel,
ItemList.groomingBrush
};
}
return null;
}
public static void adjustBasicItem(int templateId, float quality, Item item){
if(templateId == ArmourCache.templateId){
if(Server.rand.nextInt(800) < quality){
if(item.getRarity() == 0){
if(Server.rand.nextInt(1800) < quality){
item.setRarity(MiscConstants.SUPREME);
}else{
item.setRarity(MiscConstants.RARE);
}
}
}
if(quality > 50){
if(quality > 95 && Server.rand.nextBoolean()){
ItemUtil.applyEnchant(item, Enchants.BUFF_SHARED_PAIN, quality*Server.rand.nextFloat()*0.7f);
@@ -218,7 +260,6 @@ public class Caches {
Materials.MATERIAL_STEEL
};
item.setMaterial(materials[Server.rand.nextInt(materials.length)]);
item.setQualityLevel(item.getQualityLevel());
if(Server.rand.nextInt(400) < quality){
if(item.getRarity() == 0){
if(Server.rand.nextInt(900) < quality){
@@ -233,8 +274,8 @@ public class Caches {
Enchants.BUFF_WIND_OF_AGES,
Enchants.BUFF_BLESSINGDARK
};
ItemUtil.applyEnchant(item, enchants[Server.rand.nextInt(enchants.length)], quality*Server.rand.nextFloat()*0.6f);
ItemUtil.applyEnchant(item, Enchants.BUFF_NIMBLENESS, quality*Server.rand.nextFloat()*0.7f);
ItemUtil.applyEnchant(item, enchants[Server.rand.nextInt(enchants.length)], quality*0.5f+(quality*0.5f*Server.rand.nextFloat()));
ItemUtil.applyEnchant(item, Enchants.BUFF_NIMBLENESS, quality*0.3f+(quality*0.7f*Server.rand.nextFloat()));
}else if(quality > 30){
ItemUtil.applyEnchant(item, Enchants.BUFF_LIFETRANSFER, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
}
@@ -242,7 +283,54 @@ public class Caches {
if(Server.rand.nextInt(500) < quality){
item.setRarity(MiscConstants.RARE);
}
}
}else if(templateId == ToolCache.templateId){
byte[] materials = {
Materials.MATERIAL_SERYLL,
Materials.MATERIAL_GLIMMERSTEEL,
Materials.MATERIAL_ADAMANTINE,
Materials.MATERIAL_STEEL,
Materials.MATERIAL_TIN,
Materials.MATERIAL_BRONZE,
Materials.MATERIAL_BRASS,
Materials.MATERIAL_ZINC,
Materials.MATERIAL_IRON,
Materials.MATERIAL_COPPER,
Materials.MATERIAL_GOLD,
Materials.MATERIAL_LEAD,
Materials.MATERIAL_SILVER
};
item.setMaterial(materials[Server.rand.nextInt(materials.length)]);
if(Server.rand.nextInt(1200) < quality){
if(item.getRarity() == 0){
if(Server.rand.nextInt(2700) < quality){
item.setRarity(MiscConstants.SUPREME);
}else{
item.setRarity(MiscConstants.RARE);
}
}
}
if(Server.rand.nextInt(200) < quality){
byte rune = (byte) (Server.rand.nextInt(78)-128);
if(!ItemUtil.isSingleUseRune(rune)){
ItemUtil.applyEnchant(item, rune, 50);
}
}
if(quality > 30 && Server.rand.nextInt(250) < quality){
ItemUtil.applyEnchant(item, Enchants.BUFF_WIND_OF_AGES, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
}
if(quality > 30 && Server.rand.nextInt(250) < quality){
ItemUtil.applyEnchant(item, Enchants.BUFF_CIRCLE_CUNNING, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
}
if(quality > 50 && Server.rand.nextInt(250) < quality){ // Efficiency
ItemUtil.applyEnchant(item, (byte) 114, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
}
if(quality > 70 && Server.rand.nextInt(350) < quality){
ItemUtil.applyEnchant(item, Enchants.BUFF_BLESSINGDARK, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
}
if(quality > 90 && Server.rand.nextInt(5000) < quality){ // Titanforged
ItemUtil.applyEnchant(item, (byte) 120, quality*0.2f+(quality*0.2f*Server.rand.nextFloat()));
}
}
}
public static int getBasicNums(int templateId){
if(templateId == CrystalCache.templateId){
@@ -439,7 +527,7 @@ public class Caches {
TITAN_CACHE.createTemplate();
CACHE_IDS.add(TitanCache.templateId);
TOOL_CACHE.createTemplate();
//CACHE_IDS.add(ToolCache.templateId);
CACHE_IDS.add(ToolCache.templateId);
TREASUREMAP_CACHE.createTemplate();
CACHE_IDS.add(TreasureMapCache.templateId);
WEAPON_CACHE.createTemplate();

View File

@@ -9,21 +9,22 @@ import com.wurmonline.server.creatures.Creatures;
import com.wurmonline.server.items.Item;
import com.wurmonline.server.players.Player;
import com.wurmonline.shared.constants.Enchants;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.NotFoundException;
import javassist.*;
import javassist.bytecode.*;
import javassist.expr.ExprEditor;
import javassist.expr.FieldAccess;
import mod.sin.lib.Util;
import org.gotti.wurmunlimited.modloader.classhooks.HookException;
import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
import java.util.ArrayList;
import java.util.Objects;
import java.util.logging.Logger;
public class CombatChanges {
public static Logger logger = Logger.getLogger(CombatChanges.class.getName());
// Added to CombatHandled
public static int getWeaponType(Item weapon){
if(weapon.enchantment == Enchants.ACID_DAM){
return Wound.TYPE_ACID;
@@ -67,6 +68,7 @@ public class CombatChanges {
return mult;
}
// Added to CombatHandled
public static int getLifeTransferAmountModifier(Wound wound, int initial){
byte type = wound.getType();
if(type == Wound.TYPE_ACID || type == Wound.TYPE_BURN || type == Wound.TYPE_COLD){
@@ -77,6 +79,7 @@ public class CombatChanges {
return initial;
}
// Added to CombatHandled
public static float getLifeTransferModifier(Creature creature, Creature defender){
if(Servers.localServer.PVPSERVER && (defender.isDominated() || defender.isPlayer()) && creature.isPlayer()){
return 0.5f;
@@ -84,6 +87,7 @@ public class CombatChanges {
return 1.0f;
}
// Added to CombatHandled
public static void doLifeTransfer(Creature creature, Creature defender, Item attWeapon, double defdamage, float armourMod){
float lifeTransfer = attWeapon.getSpellLifeTransferModifier()*getLifeTransferModifier(creature, defender);
Wound[] w;
@@ -94,6 +98,7 @@ public class CombatChanges {
}
}
// Added (kind of) to CombatHandled
public static float getAdjustedOakshell(Creature defender, Item armour, float armourMod){
if(defender != null && armour == null){
float oakshellPower = defender.getBonusForSpellEffect(Enchants.CRET_OAKSHELL);
@@ -139,6 +144,8 @@ public class CombatChanges {
}
}
}
// Added to CombatHandled
public static boolean canDoDamage(double damage, Creature attacker, Creature defender) {
//logger.info(String.format("canDoDamage from %s to %s - %.1f", attacker.getName(), defender.getName(), damage));
return damage > 1D;
@@ -250,6 +257,18 @@ public class CombatChanges {
}
}
// Added to CombatHandled
public static void pollCreatureActionStacks(){
for(Creature c : Creatures.getInstance().getCreatures()){
if(c.isFighting()) {
c.getActions().poll(c);
}
}
}
public static void goodLog(String str){
logger.info(str);
}
public static void preInit(){
try{
@@ -383,6 +402,55 @@ public class CombatChanges {
"}";
Util.instrumentDeclared(thisClass, ctCombatHandler, "setDamage", "getSpellPainShare", replace);
/*Util.setReason("Debug attack method");
CtClass ctAction = classPool.get("com.wurmonline.server.behaviours.Action");
CtClass[] params4 = {
ctCreature,
CtClass.intType,
CtClass.booleanType,
CtClass.floatType,
ctAction
};
String desc4 = Descriptor.ofMethod(CtClass.booleanType, params4);
replace = "logger.info(\"opponent = \"+$1.getName()+\", combatCounter = \"+$2+\", opportunity = \"+$3+\", actionCounter = \"+$4);";
Util.insertBeforeDescribed(thisClass, ctCombatHandler, "attack", desc4, replace);*/
/*Util.setReason("Debug CreatureAI Poll");
CtClass ctCreatureAI = classPool.get("com.wurmonline.server.creatures.ai.CreatureAI");
replace = "if($1.getTemplate().getTemplateId() == 2147483619){" +
CombatChanges.class.getName()+".goodLog(\"CreatureAI.pollCreature(\"+$1.getName()+\", \"+$2+\")\");" +
"}";
Util.insertBeforeDeclared(thisClass, ctCreatureAI, "pollCreature", replace);*/
/*Util.setReason("Debug VolaTile Poll");
CtClass ctVolaTile = classPool.get("com.wurmonline.server.zones.VolaTile");
replace = "if($2.getTemplate().getTemplateId() == 2147483619){" +
CombatChanges.class.getName()+".goodLog(\"VolaTile.pollOneCreatureOnThisTile(\"+$2.getName()+\")\");" +
"}";
Util.insertBeforeDeclared(thisClass, ctVolaTile, "pollOneCreatureOnThisTile", replace);*/
/*Util.setReason("Debug Creature Poll");
replace = "if($0.getTemplate().getTemplateId() == 2147483619){" +
CombatChanges.class.getName()+".goodLog(\"Creature.poll(\"+$0.getName()+\")\");" +
"}";
Util.insertBeforeDeclared(thisClass, ctCreature, "poll", replace);*/
/*Util.setReason("Debug Creatures Poll");
CtClass ctCreatures = classPool.get("com.wurmonline.server.creatures.Creatures");
replace = CombatChanges.class.getName()+".goodLog(\"Creatures.pollAllCreatures()\");";
Util.insertBeforeDeclared(thisClass, ctCreatures, "pollAllCreatures", replace);*/
// TODO: Enable with new combat rework.
/*Util.setReason("Poll creature action stacks on every update.");
CtClass ctZones = classPool.get("com.wurmonline.server.zones.Zones");
replace = //CombatChanges.class.getName()+".goodLog(\"Zones.pollNextZones(\"+$1+\") [time \"+java.lang.System.currentTimeMillis()+\"]\");" +
CombatChanges.class.getName()+".pollCreatureActionStacks();";
Util.insertBeforeDeclared(thisClass, ctZones, "pollNextZones", replace);*/
/*replace = "$_ = $proceed($$);" +
CombatChanges.class.getName()+".goodLog(\"Zones.pollNextZones(\"+sleepTime+\") call to Creatures.getInstance().pollAllCreatures(\"+$1+\") [time \"+java.lang.System.currentTimeMillis()+\"]\");";
Util.instrumentDeclared(thisClass, ctZones, "pollNextZones", "pollAllCreatures", replace);*/
patchCombatDamageCheckCombatEngine(classPool);
patchCombatDamageCheckCombatHandler(classPool);

View File

@@ -28,7 +28,8 @@ public class Crystals {
Enchants.BUFF_VENOM,
Enchants.BUFF_WEBARMOUR,
Enchants.BUFF_WIND_OF_AGES,
110 // Harden
110, // Harden
114 // Efficiency
//110, 111 // Harden and Phasing
};
public static byte getNewRandomEnchant(Item target){

View File

@@ -0,0 +1,149 @@
package mod.sin.wyvern;
import com.wurmonline.server.players.Player;
import org.gotti.wurmunlimited.modsupport.ModSupportDb;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Logger;
public class DatabaseHelper {
private static Logger logger = Logger.getLogger(DatabaseHelper.class.getName());
public static void onPlayerLogin(Player p){
Connection dbcon;
PreparedStatement ps;
boolean foundLeaderboardOpt = false;
try {
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("SELECT * FROM LeaderboardOpt");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if (!rs.getString("name").equals(p.getName())) continue;
foundLeaderboardOpt = true;
}
rs.close();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
if (!foundLeaderboardOpt) {
logger.info("No leaderboard entry for "+p.getName()+". Creating one.");
try {
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("INSERT INTO LeaderboardOpt (name) VALUES(\"" + p.getName() + "\")");
ps.executeUpdate();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
boolean foundPlayerStats = false;
try {
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("SELECT * FROM PlayerStats");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if (!rs.getString("NAME").equals(p.getName())) continue;
foundPlayerStats = true;
}
rs.close();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
if (!foundPlayerStats) {
logger.info("No player stats entry for "+p.getName()+". Creating one.");
try {
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("INSERT INTO PlayerStats (NAME) VALUES(\"" + p.getName() + "\")");
ps.executeUpdate();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
public static void onServerStarted(){
try {
Connection con = ModSupportDb.getModSupportDb();
String sql;
String tableName = "LeaderboardOpt";
if (!ModSupportDb.hasTable(con, tableName)) {
logger.info(tableName+" table not found in ModSupport. Creating table now.");
sql = "CREATE TABLE "+tableName+" (name VARCHAR(30) NOT NULL DEFAULT 'Unknown', OPTIN INT NOT NULL DEFAULT 0)";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
}
tableName = "SteamIdMap";
if (!ModSupportDb.hasTable(con, tableName)) {
logger.info(tableName+" table not found in ModSupport. Creating table now.");
sql = "CREATE TABLE "+tableName+" (NAME VARCHAR(30) NOT NULL DEFAULT 'Unknown', STEAMID LONG NOT NULL DEFAULT 0)";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
}
tableName = "PlayerStats";
if (!ModSupportDb.hasTable(con, tableName)) {
logger.info(tableName+" table not found in ModSupport. Creating table now.");
sql = "CREATE TABLE "+tableName+" (NAME VARCHAR(30) NOT NULL DEFAULT 'Unknown', KILLS INT NOT NULL DEFAULT 0, DEATHS INT NOT NULL DEFAULT 0, DEPOTS INT NOT NULL DEFAULT 0, HOTAS INT NOT NULL DEFAULT 0, TITANS INT NOT NULL DEFAULT 0, UNIQUES INT NOT NULL DEFAULT 0)";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
}else{
logger.info("Found "+tableName+". Checking if it has a unique column.");
ResultSet rs = con.getMetaData().getColumns(null, null, tableName, "UNIQUES");
if(rs.next()){
logger.info(tableName+" already has a uniques column.");
}else{
logger.info("Detected no uniques column in "+tableName);
sql = "ALTER TABLE "+tableName+" ADD COLUMN UNIQUES INT NOT NULL DEFAULT 0";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
}
}
tableName = "ObjectiveTimers";
if (!ModSupportDb.hasTable(con, tableName)) {
logger.info(tableName+" table not found in ModSupport. Creating table now.");
sql = "CREATE TABLE "+tableName+" (ID VARCHAR(30) NOT NULL DEFAULT 'Unknown', TIMER LONG NOT NULL DEFAULT 0)";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
try {
Connection dbcon;
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("INSERT INTO ObjectiveTimers (ID, TIMER) VALUES(\"DEPOT\", 0)");
ps.executeUpdate();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
try {
Connection dbcon;
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("INSERT INTO ObjectiveTimers (ID, TIMER) VALUES(\"TITAN\", 0)");
ps.executeUpdate();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
SupplyDepots.initializeDepotTimer();
Titans.initializeTitanTimer();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,32 @@
package mod.sin.wyvern;
import java.util.logging.Logger;
public class DeityChanges {
public static Logger logger = Logger.getLogger(DeityChanges.class.getName());
public static void onServerStarted(){
/*if(Deities.getDeity(101) != null){ // Edit Breyk player god
Deity breyk = Deities.getDeity(101);
// Add some defining affinities
breyk.repairer = true;
breyk.learner = true;
breyk.deathProtector = true;
breyk.befriendCreature = true;
// Remove some affinities
breyk.warrior = false;
breyk.healer = false;
breyk.clayAffinity = false;
}*/
/*if(Deities.getDeity(102) != null){ // Edit Cyberhusky player god
Deity cyberhusky = Deities.getDeity(102);
// Add some defining affinities
cyberhusky.hateGod = true;
cyberhusky.allowsButchering = true;
cyberhusky.warrior = true;
// Remove some affinities
cyberhusky.woodAffinity = false;
cyberhusky.befriendCreature = false;
}*/
}
}

View File

@@ -1,6 +1,9 @@
package mod.sin.wyvern;
import com.wurmonline.server.economy.Economy;
import com.wurmonline.server.economy.Shop;
import com.wurmonline.server.items.Item;
import com.wurmonline.server.items.Trade;
import com.wurmonline.server.villages.GuardPlan;
import com.wurmonline.server.villages.Village;
import com.wurmonline.server.villages.Villages;
@@ -48,6 +51,36 @@ public class EconomicChanges {
return -10;
}
public static long getNewShopDiff(Trade trade, long money, long shopDiff){
Shop shop = null;
Village citizenVillage = null;
if (trade.creatureOne.isNpcTrader()) {
shop = Economy.getEconomy().getShop(trade.creatureOne);
}
if (trade.creatureTwo.isNpcTrader()) {
shop = Economy.getEconomy().getShop(trade.creatureTwo);
}
if(shop == null){
logger.info("Something went horribly wrong and the shop is null.");
return 0;
}
logger.info("Money = "+money+", shopDiff = "+shopDiff);
if(!shop.isPersonal() && money > 0){
logger.info("We're adding money. Testing to see how much difference there is.");
if(money + shopDiff > 0){
logger.info("Player actually purchased something. Reducing the income.");
long newDiff = money + shopDiff;
logger.info("Actual difference in currency: "+Economy.getEconomy().getChangeFor(newDiff).getChangeString());
newDiff *= 0.2;
logger.info("After 80% void: "+Economy.getEconomy().getChangeFor(newDiff).getChangeString());
logger.info("Returning the following amount of money to incur the change: "+(-shopDiff+newDiff));
return -shopDiff+newDiff;
}
//return (long) (money*0.2);
}
return money;
}
public static void preInit(){
try{
ClassPool classPool = HookManager.getInstance().getClassPool();
@@ -76,6 +109,11 @@ public class EconomicChanges {
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);
} catch ( NotFoundException | IllegalArgumentException | ClassCastException e) {
throw new HookException(e);
}

View File

@@ -10,6 +10,7 @@ import java.util.Map;
import java.util.logging.Logger;
import com.wurmonline.server.Servers;
import mod.sin.items.caches.*;
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
import org.gotti.wurmunlimited.modloader.classhooks.InvocationHandlerFactory;
@@ -35,7 +36,8 @@ import mod.sin.weapons.titan.*;
public class ItemMod {
public static Logger logger = Logger.getLogger(ItemMod.class.getName());
public static AffinityCatcher AFFINITY_CATCHER = new AffinityCatcher();
public static AffinityOrb AFFINITY_ORB = new AffinityOrb();
public static ArenaCache ARENA_CACHE = new ArenaCache();
public static ArenaSupplyDepot ARENA_SUPPLY_DEPOT = new ArenaSupplyDepot();
@@ -100,6 +102,7 @@ public class ItemMod {
public static void createItems(){
logger.info("createItems()");
try{
AFFINITY_CATCHER.createTemplate();
AFFINITY_ORB.createTemplate();
ARENA_CACHE.createTemplate();
ARENA_SUPPLY_DEPOT.createTemplate();
@@ -166,6 +169,8 @@ public class ItemMod {
}
public static void registerActions(){
ModActions.registerAction(new AffinityCatcherCaptureAction());
ModActions.registerAction(new AffinityCatcherConsumeAction());
ModActions.registerAction(new AffinityOrbAction());
ModActions.registerAction(new ArenaCacheOpenAction());
ModActions.registerAction(new ArrowPackUnpackAction());
@@ -270,6 +275,7 @@ public class ItemMod {
new Weapon(Club.templateId, 8.1f, 4.5f, 0.002f, 3, 3, 0.4f, 0.5d);
new Weapon(Knuckles.templateId, 3.6f, 2.2f, 0.002f, 1, 1, 0.2f, 0.5d);
new Weapon(Warhammer.templateId, 9.40f, 5.6f, 0.008f, 4, 3, 1f, 0d);
//new Weapon(ItemList.stoneChisel, 50f, 1f, 0.5f, 8, 1, 3f, -5f);
// Titan weaponry
new Weapon(MaartensMight.templateId, 11, 5, 0.02f, 4, 4, 1.0f, 0d);
new Weapon(RaffehsRage.templateId, 9.5f, 4.25f, 0.02f, 3, 3, 1.0f, 0d);
@@ -310,6 +316,15 @@ public class ItemMod {
}
return -10;
}
private static void setFragments(int templateId, int fragmentCount){
try {
ItemTemplate item = ItemTemplateFactory.getInstance().getTemplate(templateId);
ReflectionUtil.setPrivateField(item, ReflectionUtil.getField(item.getClass(), "fragmentAmount"), fragmentCount);
} catch (IllegalAccessException | NoSuchFieldException | NoSuchTemplateException e) {
e.printStackTrace();
}
}
public static void modifyItems() throws NoSuchTemplateException, IllegalArgumentException, IllegalAccessException, ClassCastException, NoSuchFieldException{
// Make leather able to be combined.
@@ -383,6 +398,29 @@ public class ItemMod {
ReflectionUtil.setPrivateField(marbleKeystone, ReflectionUtil.getField(marbleKeystone.getClass(), "decoration"), true);
ItemTemplate skull = ItemTemplateFactory.getInstance().getTemplate(ItemList.skull);
ReflectionUtil.setPrivateField(skull, ReflectionUtil.getField(skull.getClass(), "decoration"), true);
// Modify fragment counts
setFragments(ArmourCache.templateId, 18);
setFragments(ArtifactCache.templateId, 33);
setFragments(CrystalCache.templateId, 11);
setFragments(DragonCache.templateId, 19);
setFragments(GemCache.templateId, 7);
setFragments(MoonCache.templateId, 14);
setFragments(PotionCache.templateId, 18);
setFragments(RiftCache.templateId, 24);
setFragments(TitanCache.templateId, 100);
setFragments(ToolCache.templateId, 27);
setFragments(TreasureMapCache.templateId, 38);
setFragments(AffinityOrb.templateId, 20);
setFragments(ItemList.statueWorg, 40);
setFragments(ItemList.statueEagle, 40);
setFragments(ItemList.statueFo, 50);
setFragments(ItemList.statueMagranon, 50);
setFragments(ItemList.statueLibila, 50);
setFragments(ItemList.statueVynora, 50);
createCustomWeapons();
createCustomArmours();

View File

@@ -731,11 +731,77 @@ public class MiscChanges {
}
});
Util.setReason("Make armour title benefits always occur.");
replace = "$_ = improve.getNumber();";
Util.instrumentDeclared(thisClass, ctMethodsItems, "improveItem", "getSkillId", replace);
Util.instrumentDeclared(thisClass, ctMethodsItems, "polishItem", "getSkillId", replace);
Util.setReason("Make it so sorceries can be used anywhere with a flat 3x3 altar.");
CtClass ctAbilities = classPool.get("com.wurmonline.server.players.Abilities");
replace = "$_ = 1;";
Util.instrumentDeclared(thisClass, ctAbilities, "isInProperLocation", "getTemplateId", replace);
/*Util.setReason("Debug Login Handler when creating a new player via an exception.");
CtClass ctLoginHandler = classPool.get("com.wurmonline.server.LoginHandler");
replace = "$_ = $proceed($$);" +
"logger.info(ex.getMessage());";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "doNewPlayer", replace);
replace = "$_ = $proceed($$);" +
"logger.info(\"addPlayer(\"+$1+\")\");";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "addPlayer", replace);
replace = "$_ = $proceed($$);" +
"logger.info(\"initialisePlayer(\"+$1+\")\");";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "initialisePlayer", replace);
replace = "$_ = $proceed($$);" +
"logger.info(\"createBodyParts\");";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "createBodyParts", replace);
replace = "logger.info(\"loadSkills\");" +
"$_ = $proceed($$);";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "loadSkills", replace);
replace = "logger.info(\"loadAllItemsForCreature1(\"+$1+\")\");" +
"logger.info(\"loadAllItemsForCreature2(\"+$1.getStatus()+\")\");" +
"logger.info(\"loadAllItemsForCreature3(\"+$2+\")\");" +
"try{" +
" $_ = $proceed($$);" +
"}catch(com.wurmonline.server.NoSuchItemException ex){" +
" logger.info(ex.getMessage());" +
"}";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "loadAllItemsForCreature", replace);
// -- Items method debugging -- //
Util.setReason("Debug Items method loadAllitemsForCreature");
CtClass ctItems = classPool.get("com.wurmonline.server.Items");
replace = "logger.info(\"creature = \"+$1+\", inventoryId = \"+$2);";
Util.insertBeforeDeclared(thisClass, ctItems, "loadAllItemsForCreature", replace);
replace = "logger.info(\"loadPossessions(\"+$1+\")\");" +
"$_ = $proceed($$);";
Util.instrumentDeclared(thisClass, ctItems, "loadAllItemsForCreature", "loadPossessions", replace);
replace = "logger.info(\"sendMapInfo - Communicator: \"+$0);" +
"$_ = $proceed($$);";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "sendMapInfo", replace);
replace = "logger.info(\"loadAllPrivatePOIForPlayer(\"+$1+\")\");" +
"$_ = $proceed($$);";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "loadAllPrivatePOIForPlayer", replace);
replace = "$_ = $proceed($$);" +
"logger.info(\"resetLastSentToolbelt\");";
Util.instrumentDeclared(thisClass, ctLoginHandler, "handleLogin", "resetLastSentToolbelt", replace);*/
Util.setReason("Make drinks less filling.");
CtClass[] params13 = {
ctAction,
ctCreature,
ctItem,
CtClass.floatType
};
String desc13 = Descriptor.ofMethod(CtClass.booleanType, params13);
replace = "$_ = $proceed($1, $2, $3*5);";
Util.instrumentDescribed(thisClass, ctMethodsItems, "drink", desc13, "sendActionControl", replace);
replace = "$_ = $proceed($1/5, $2, $3, $4, $5);";
Util.instrumentDescribed(thisClass, ctMethodsItems, "drink", desc13, "modifyThirst", replace);
} catch (CannotCompileException | NotFoundException | IllegalArgumentException | ClassCastException e) {
throw new HookException(e);
}
}
public static void logMessage(String message){
logger.info(message);
}
}

View File

@@ -67,7 +67,7 @@ public class MountedChanges {
if(creature.isHorse() || creature.isUnicorn()) {
factor *= newCalcHorseShoeBonus(creature);
}
if(creature.isHorse()){
/*if(creature.isHorse()){
try {
Item barding = creature.getArmour(BodyPartConstants.TORSO);
if(barding != null){
@@ -81,7 +81,7 @@ public class MountedChanges {
}
} catch (NoArmourException | NoSpaceException ignored) {
}
}
}*/
if (creature.getBonusForSpellEffect(Enchants.CRET_OAKSHELL) > 0.0f) {
factor *= 1f - (0.3f * (creature.getBonusForSpellEffect(Enchants.CRET_OAKSHELL) / 100.0f));
}

View File

@@ -0,0 +1,144 @@
package mod.sin.wyvern;
import com.wurmonline.server.Server;
import com.wurmonline.server.TimeConstants;
import com.wurmonline.server.skills.*;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.NotFoundException;
import mod.sin.lib.Util;
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
import org.gotti.wurmunlimited.modloader.classhooks.HookException;
import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
import java.util.logging.Logger;
public class SkillChanges {
public static Logger logger = Logger.getLogger(SkillChanges.class.getName());
public static double newDoSkillGainNew(Skill skill, double check, double power, double learnMod, float times, double skillDivider) {
double bonus = 1.0;
double diff = Math.abs(check - skill.getKnowledge());
short sType = SkillSystem.getTypeFor(skill.getNumber());
boolean awardBonus = true;
if (sType == 1 || sType == 0) {
awardBonus = false;
}
if (diff <= 15.0 && awardBonus) {
bonus = 1.0 + (0.1 * (diff / 15.0));
}
/*if (power < 0.0) {
if (this.knowledge < 20.0) {
this.alterSkill((100.0 - this.knowledge) / (this.getDifficulty(this.parent.priest) * this.knowledge * this.knowledge) * learnMod * bonus, false, times, true, skillDivider);
}
} else {
this.alterSkill((100.0 - this.knowledge) / (this.getDifficulty(this.parent.priest) * this.knowledge * this.knowledge) * learnMod * bonus, false, times, true, skillDivider);
}*/
try {
Skills parent = ReflectionUtil.getPrivateField(skill, ReflectionUtil.getField(skill.getClass(), "parent"));
double advanceMultiplicator = (100.0 - skill.getKnowledge()) / (skill.getDifficulty(parent.priest) * skill.getKnowledge() * skill.getKnowledge()) * learnMod * bonus;
double p = 5;
double q = 3;
//advanceMultiplicator *= Math.pow(2, ((2-Math.pow((100/(100+power)), p))*(100-power)/100));
double mult = Math.pow(2, (2-Math.pow(100/(100+power), p))*Math.pow((100-power)*0.01, q));
if(mult < 0.5 && skill.getKnowledge() < 20){
advanceMultiplicator *= 0.5+(Server.rand.nextDouble()*0.5);
}else if(skill.getNumber() == SkillList.MEDITATING || skill.getNumber() == SkillList.LOCKPICKING){
advanceMultiplicator *= Math.max(mult, 0.8d);
}else if(mult > 0.0001) {
advanceMultiplicator *= mult*0.95d;
}else{
advanceMultiplicator = 0;
}
/*if(skill.getType() > 3) {
logger.info(String.format("Power of %.2f on skill %s gives multiplier of %.2f.", power, skill.getName(), mult));
}*/
return advanceMultiplicator;
//ReflectionUtil.callPrivateMethod(skill, ReflectionUtil.getMethod(skill.getClass(), "alterSkill"), advanceMultiplicator, false, times, true, skillDivider);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info(e.getMessage());
e.printStackTrace();
}
return 0;
}
public static void onServerStarted(){
/*SkillTemplate exorcism = SkillSystem.templates.get(SkillList.EXORCISM);
int[] deps = {SkillList.GROUP_ALCHEMY};
try {
String newName = "Crystal handling";
ReflectionUtil.setPrivateField(exorcism, ReflectionUtil.getField(exorcism.getClass(), "name"), newName);
SkillSystem.skillNames.put(exorcism.getNumber(), newName);
SkillSystem.namesToSkill.put(newName, exorcism.getNumber());
ReflectionUtil.setPrivateField(exorcism, ReflectionUtil.getField(exorcism.getClass(), "dependencies"), deps);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to rename exorcism!");
e.printStackTrace();
}
SkillTemplate ballistae = SkillSystem.templates.get(SkillList.BALLISTA);
int[] deps2 = {SkillList.GROUP_ALCHEMY};
try {
String newName = "Mystic components";
ReflectionUtil.setPrivateField(ballistae, ReflectionUtil.getField(ballistae.getClass(), "name"), newName);
SkillSystem.skillNames.put(ballistae.getNumber(), newName);
SkillSystem.namesToSkill.put(newName, ballistae.getNumber());
ReflectionUtil.setPrivateField(ballistae, ReflectionUtil.getField(ballistae.getClass(), "dependencies"), deps2);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to rename ballistae!");
e.printStackTrace();
}*/
SkillTemplate preaching = SkillSystem.templates.get(SkillList.PREACHING);
int[] deps3 = {SkillList.MASONRY};
try {
String newName = "Gem augmentation";
ReflectionUtil.setPrivateField(preaching, ReflectionUtil.getField(preaching.getClass(), "name"), newName);
SkillSystem.skillNames.put(preaching.getNumber(), newName);
SkillSystem.namesToSkill.put(newName, preaching.getNumber());
ReflectionUtil.setPrivateField(preaching, ReflectionUtil.getField(preaching.getClass(), "dependencies"), deps3);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to rename preaching!");
e.printStackTrace();
}
SkillTemplate stealing = SkillSystem.templates.get(SkillList.STEALING);
try {
ReflectionUtil.setPrivateField(stealing, ReflectionUtil.getField(stealing.getClass(), "tickTime"), 0);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to set tickTime for stealing!");
e.printStackTrace();
}
SkillTemplate meditating = SkillSystem.templates.get(SkillList.MEDITATING);
try {
ReflectionUtil.setPrivateField(meditating, ReflectionUtil.getField(meditating.getClass(), "tickTime"), TimeConstants.HOUR_MILLIS);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to set tickTime for meditating!");
e.printStackTrace();
}
meditating.setDifficulty(300f);
// Set mining difficulty down to be equivalent to digging.
SkillTemplate mining = SkillSystem.templates.get(SkillList.MINING);
mining.setDifficulty(3000f);
// Triple lockpicking skill
SkillTemplate lockpicking = SkillSystem.templates.get(SkillList.LOCKPICKING);
lockpicking.setDifficulty(700f);
}
public static void preInit(){
try{
ClassPool classPool = HookManager.getInstance().getClassPool();
final Class<SkillChanges> thisClass = SkillChanges.class;
String replace;
Util.setReason("Allow skill check failures to add skill gain.");
CtClass ctSkill = classPool.get("com.wurmonline.server.skills.Skill");
replace = "{" +
" double advanceMultiplicator = "+SkillChanges.class.getName()+".newDoSkillGainNew($0, $1, $2, $3, $4, $5);" +
" $0.alterSkill(advanceMultiplicator, false, $4, true, $5);" +
"}";
Util.setBodyDeclared(thisClass, ctSkill, "doSkillGainNew", replace);
} catch ( NotFoundException | IllegalArgumentException | ClassCastException e) {
throw new HookException(e);
}
}
}

View File

@@ -198,6 +198,7 @@ public class SupplyDepots {
MiscChanges.sendServerTabMessage("arena", "The next Arena depot will appear in 5 minutes!", 255, 128, 0);
}else if(minutesLeft == 19){
MiscChanges.sendServerTabMessage("arena", "The next Arena depot will appear in 20 minutes!", 255, 128, 0);
MiscChanges.sendGlobalFreedomChat(host, "The next Arena depot will appear in 20 minutes!", 255, 128, 0);
}else if(minutesLeft == 59){
MiscChanges.sendServerTabMessage("arena", "The next Arena depot will appear in 60 minutes!", 255, 128, 0);
MiscChanges.sendGlobalFreedomChat(host, "The next Arena depot will appear in 60 minutes!", 255, 128, 0);
@@ -251,14 +252,12 @@ public class SupplyDepots {
inv.insertItem(token, true);
i--;
}
// Seryll or sleep powder
if(Server.rand.nextBoolean()){
Item seryll = ItemFactory.createItem(ItemList.seryllBar, 70+(30*Server.rand.nextFloat()), null);
inv.insertItem(seryll, true);
}else{
Item sleepPowder = ItemFactory.createItem(ItemList.sleepPowder, 99f, null);
inv.insertItem(sleepPowder, true);
}
// High quality seryll
Item seryll = ItemFactory.createItem(ItemList.seryllBar, 80+(20*Server.rand.nextFloat()), null);
inv.insertItem(seryll, true);
// Sleep powder
Item sleepPowder = ItemFactory.createItem(ItemList.sleepPowder, 99f, null);
inv.insertItem(sleepPowder, true);
// Very low chance for a HotA statue.
if(Server.rand.nextFloat()*100f <= 1f){
Item hotaStatue = ItemFactory.createItem(ItemList.statueHota, 80f+(20f*Server.rand.nextFloat()), "");

View File

@@ -3,6 +3,7 @@ package mod.sin.wyvern;
import com.wurmonline.mesh.Tiles;
import com.wurmonline.server.*;
import com.wurmonline.server.bodys.Wound;
import com.wurmonline.server.bodys.Wounds;
import com.wurmonline.server.creatures.Creature;
import com.wurmonline.server.creatures.Creatures;
import com.wurmonline.server.creatures.MineDoorPermission;
@@ -675,6 +676,23 @@ public class Titans {
}
titanDamage.put(titan, currentDamage);
}
public static void pollTitanRegeneration(){
if(!titans.isEmpty()) {
for (Creature cret : titans) {
if (cret.getBody().isWounded()) {
Wounds tWounds = cret.getBody().getWounds();
int toHeal = 2;
Wound w = tWounds.getWounds()[Server.rand.nextInt(tWounds.getWounds().length)];
if (w.getSeverity() > toHeal) {
w.modifySeverity(-toHeal);
break;
} else {
w.heal();
}
}
}
}
}
public static void pollTitan(Creature titan){
if(titanDamage.containsKey(titan)){
int prevDamage = titanDamage.get(titan);
@@ -687,6 +705,14 @@ public class Titans {
titanDamage.put(titan, titan.getStatus().damage);
}
}
public static void pollTitans(){
for(Creature c : titans){
if(isTitan(c)){
pollTitan(c);
}
}
pollTitanRegeneration();
}
public static ArrayList<Creature> titans = new ArrayList<>();
public static long lastPolledTitanSpawn = 0;
@@ -764,7 +790,7 @@ public class Titans {
int tiley = (int) (minY+(minY*2*Server.rand.nextFloat()))*4;*/
int[] titanTemplates = {Lilith.templateId, Ifrit.templateId};
try {
Creature.doNew(titanTemplates[Server.rand.nextInt(titanTemplates.length)], spawnX, spawnY, 360f*Server.rand.nextFloat(), 1, "", (byte)0);
Creature.doNew(titanTemplates[Server.rand.nextInt(titanTemplates.length)], spawnX, spawnY, 360f*Server.rand.nextFloat(), 0, "", (byte)0);
lastSpawnedTitan = System.currentTimeMillis();
updateLastSpawnedTitan();
} catch (Exception e) {
@@ -779,13 +805,6 @@ public class Titans {
lastPolledTitanSpawn = System.currentTimeMillis();
}
}
public static void pollTitans(){
for(Creature c : titans){
if(isTitan(c)){
pollTitan(c);
}
}
}
public static void preInit(){
try {

View File

@@ -21,6 +21,7 @@ import com.wurmonline.server.creatures.Creature;
import com.wurmonline.server.creatures.CreatureTemplate;
import com.wurmonline.server.creatures.CreatureTemplateFactory;
import com.wurmonline.server.items.*;
import mod.sin.actions.items.SorcerySplitAction;
import mod.sin.lib.Util;
import org.gotti.wurmunlimited.modloader.ReflectionUtil;
import org.gotti.wurmunlimited.modloader.classhooks.HookException;
@@ -112,9 +113,9 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
}
}
/*public static void handleExamine(Creature performer, Item target) {
public static void handleExamine(Creature performer, Item target) {
// Im just not a smart man.
if(target.isContainerLiquid()){
/*if(target.isContainerLiquid()){
boolean found = false;
for(Item i : Items.getAllItems()){
if(i == target){
@@ -126,8 +127,8 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
}else{
logger.info("Item not found.");
}
}
}*/
}*/
}
public void preInit() {
logger.info("Pre-Initializing.");
@@ -144,6 +145,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
MethodsBestiary.preInit();
MissionCreator.preInit();
CombatChanges.preInit();
SkillChanges.preInit();
MeditationPerks.preInit();
MountedChanges.preInit();
EconomicChanges.preInit();
@@ -157,10 +159,10 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
Class<WyvernMods> thisClass = WyvernMods.class;
ClassPool classPool = HookManager.getInstance().getClassPool();
/*Util.setReason("Insert examine method.");
Util.setReason("Insert examine method.");
CtClass ctItemBehaviour = classPool.get("com.wurmonline.server.behaviours.ItemBehaviour");
String replace = WyvernMods.class.getName() + ".handleExamine($2, $3);";
Util.insertAfterDeclared(thisClass, ctItemBehaviour, "examine", replace);*/
Util.insertAfterDeclared(thisClass, ctItemBehaviour, "examine", replace);
// - Enable custom command handler - //
CtClass ctCommunicator = classPool.get("com.wurmonline.server.creatures.Communicator");
@@ -171,7 +173,6 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
+ "if(!mod.sin.wyvern.WyvernMods.customCommandHandler($1, this.player)){"
+ " $_ = $proceed(tempBuffer);"
+ "}");
return;
}
}
});
@@ -207,6 +208,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
// Flavor Mobs:
logger.info("Registering Flavor creatures.");
ModCreatures.addCreature(new Avenger());
ModCreatures.addCreature(new FireCrab());
ModCreatures.addCreature(new ForestSpider());
ModCreatures.addCreature(new Giant());
ModCreatures.addCreature(new Charger());
@@ -217,8 +219,8 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
// Event Mobs:
logger.info("Registering Event creatures.");
ModCreatures.addCreature(new IceCat());
ModCreatures.addCreature(new FireCrab());
ModCreatures.addCreature(new FireGiant());
ModCreatures.addCreature(new GuardianMagranon());
// Bosses:
logger.info("Registering Custom Boss creatures.");
@@ -265,62 +267,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
@Override
public void onPlayerLogin(Player p) {
Connection dbcon;
PreparedStatement ps;
boolean foundLeaderboardOpt = false;
try {
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("SELECT * FROM LeaderboardOpt");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if (!rs.getString("name").equals(p.getName())) continue;
foundLeaderboardOpt = true;
}
rs.close();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
if (!foundLeaderboardOpt) {
logger.info("No leaderboard entry for "+p.getName()+". Creating one.");
try {
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("INSERT INTO LeaderboardOpt (name) VALUES(\"" + p.getName() + "\")");
ps.executeUpdate();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
boolean foundPlayerStats = false;
try {
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("SELECT * FROM PlayerStats");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if (!rs.getString("NAME").equals(p.getName())) continue;
foundPlayerStats = true;
}
rs.close();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
if (!foundPlayerStats) {
logger.info("No player stats entry for "+p.getName()+". Creating one.");
try {
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("INSERT INTO PlayerStats (NAME) VALUES(\"" + p.getName() + "\")");
ps.executeUpdate();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
DatabaseHelper.onPlayerLogin(p);
PlayerTitles.awardCustomTitles(p);
}
@@ -340,6 +287,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
ModActions.registerAction(new ReceiveMailAction());
ModActions.registerAction(new LeaderboardAction());
ModActions.registerAction(new AddSubGroupAction());
ModActions.registerAction(new SorcerySplitAction());
logger.info("Registering Arena actions.");
ModActions.registerAction(new SorceryCombineAction());
//ModActions.registerAction(new VillageTeleportAction()); // [3/28/18] Disabled - Highway Portals added instead.
@@ -348,85 +296,19 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
logger.info("Registering Dev actions.");
ModActions.registerAction(new MissionAddAction());
ModActions.registerAction(new MissionRemoveAction());
ModActions.registerAction(new CreatureReportAction());
ModActions.registerAction(new SmoothTerrainAction());
logger.info("Setting custom creature corpse models.");
MethodsBestiary.setTemplateVariables();
/*if(Deities.getDeity(101) != null){ // Edit Breyk player god
Deity breyk = Deities.getDeity(101);
// Add some defining affinities
breyk.repairer = true;
breyk.learner = true;
breyk.deathProtector = true;
breyk.befriendCreature = true;
// Remove some affinities
breyk.warrior = false;
breyk.healer = false;
breyk.clayAffinity = false;
}*/
/*if(Deities.getDeity(102) != null){ // Edit Cyberhusky player god
Deity cyberhusky = Deities.getDeity(102);
// Add some defining affinities
cyberhusky.hateGod = true;
cyberhusky.allowsButchering = true;
cyberhusky.warrior = true;
// Remove some affinities
cyberhusky.woodAffinity = false;
cyberhusky.befriendCreature = false;
}*/
logger.info("Setting up Achievement templates.");
AchievementChanges.onServerStarted();
DeityChanges.onServerStarted();
//espCounter = Servers.localServer.PVPSERVER; // Enables on PvP server by default.
//espCounter = false;
SkillTemplate exorcism = SkillSystem.templates.get(SkillList.EXORCISM);
int[] deps = {SkillList.GROUP_ALCHEMY};
try {
String newName = "Crystal handling";
ReflectionUtil.setPrivateField(exorcism, ReflectionUtil.getField(exorcism.getClass(), "name"), newName);
SkillSystem.skillNames.put(exorcism.getNumber(), newName);
SkillSystem.namesToSkill.put(newName, exorcism.getNumber());
ReflectionUtil.setPrivateField(exorcism, ReflectionUtil.getField(exorcism.getClass(), "dependencies"), deps);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to rename exorcism!");
e.printStackTrace();
}
SkillTemplate ballistae = SkillSystem.templates.get(SkillList.BALLISTA);
int[] deps2 = {SkillList.GROUP_ALCHEMY};
try {
String newName = "Mystic components";
ReflectionUtil.setPrivateField(ballistae, ReflectionUtil.getField(ballistae.getClass(), "name"), newName);
SkillSystem.skillNames.put(ballistae.getNumber(), newName);
SkillSystem.namesToSkill.put(newName, ballistae.getNumber());
ReflectionUtil.setPrivateField(ballistae, ReflectionUtil.getField(ballistae.getClass(), "dependencies"), deps2);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to rename ballistae!");
e.printStackTrace();
}
SkillTemplate preaching = SkillSystem.templates.get(SkillList.PREACHING);
int[] deps3 = {SkillList.MASONRY};
try {
String newName = "Gem augmentation";
ReflectionUtil.setPrivateField(preaching, ReflectionUtil.getField(preaching.getClass(), "name"), newName);
SkillSystem.skillNames.put(preaching.getNumber(), newName);
SkillSystem.namesToSkill.put(newName, preaching.getNumber());
ReflectionUtil.setPrivateField(preaching, ReflectionUtil.getField(preaching.getClass(), "dependencies"), deps3);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to rename preaching!");
e.printStackTrace();
}
SkillTemplate stealing = SkillSystem.templates.get(SkillList.STEALING);
try {
ReflectionUtil.setPrivateField(stealing, ReflectionUtil.getField(stealing.getClass(), "tickTime"), 0);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to set tickTime for stealing!");
e.printStackTrace();
}
SkillTemplate meditating = SkillSystem.templates.get(SkillList.MEDITATING);
try {
ReflectionUtil.setPrivateField(meditating, ReflectionUtil.getField(meditating.getClass(), "tickTime"), TimeConstants.HOUR_MILLIS);
} catch (IllegalAccessException | NoSuchFieldException e) {
logger.info("Failed to set tickTime for meditating!");
e.printStackTrace();
}
meditating.setDifficulty(300f);
SkillChanges.onServerStarted();
CreationEntry lockpicks = CreationMatrix.getInstance().getCreationEntry(ItemList.lockpick);
try {
@@ -437,88 +319,10 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
e.printStackTrace();
}
// Set mining difficulty down to be equivalent to digging.
SkillTemplate mining = SkillSystem.templates.get(SkillList.MINING);
mining.setDifficulty(3000f);
// Triple lockpicking skill
SkillTemplate lockpicking = SkillSystem.templates.get(SkillList.LOCKPICKING);
lockpicking.setDifficulty(700f);
} catch (IllegalArgumentException | ClassCastException e) {
e.printStackTrace();
}
try {
Connection con = ModSupportDb.getModSupportDb();
String sql;
String tableName = "LeaderboardOpt";
if (!ModSupportDb.hasTable(con, tableName)) {
logger.info(tableName+" table not found in ModSupport. Creating table now.");
sql = "CREATE TABLE "+tableName+" (\t\tname\t\t\t\tVARCHAR(30)\t\t\tNOT NULL DEFAULT 'Unknown',\t\tOPTIN\t\t\t\t\tINT\t\tNOT NULL DEFAULT 0)";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
}
tableName = "SteamIdMap";
if (!ModSupportDb.hasTable(con, tableName)) {
logger.info(tableName+" table not found in ModSupport. Creating table now.");
sql = "CREATE TABLE "+tableName+" (\t\tNAME\t\t\t\tVARCHAR(30)\t\t\tNOT NULL DEFAULT 'Unknown',\t\tSTEAMID\t\t\t\t\tLONG\t\tNOT NULL DEFAULT 0)";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
}
tableName = "PlayerStats";
if (!ModSupportDb.hasTable(con, tableName)) {
logger.info(tableName+" table not found in ModSupport. Creating table now.");
sql = "CREATE TABLE "+tableName+" (NAME VARCHAR(30) NOT NULL DEFAULT 'Unknown', KILLS INT NOT NULL DEFAULT 0, DEATHS INT NOT NULL DEFAULT 0, DEPOTS INT NOT NULL DEFAULT 0, HOTAS INT NOT NULL DEFAULT 0, TITANS INT NOT NULL DEFAULT 0, UNIQUES INT NOT NULL DEFAULT 0)";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
}else{
logger.info("Found "+tableName+". Checking if it has a unique column.");
ResultSet rs = con.getMetaData().getColumns(null, null, tableName, "UNIQUES");
if(rs.next()){
logger.info(tableName+" already has a uniques column.");
}else{
logger.info("Detected no uniques column in "+tableName);
sql = "ALTER TABLE "+tableName+" ADD COLUMN UNIQUES INT NOT NULL DEFAULT 0";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
}
}
tableName = "ObjectiveTimers";
if (!ModSupportDb.hasTable(con, tableName)) {
logger.info(tableName+" table not found in ModSupport. Creating table now.");
sql = "CREATE TABLE "+tableName+" (ID VARCHAR(30) NOT NULL DEFAULT 'Unknown', TIMER LONG NOT NULL DEFAULT 0)";
PreparedStatement ps = con.prepareStatement(sql);
ps.execute();
ps.close();
try {
Connection dbcon;
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("INSERT INTO ObjectiveTimers (ID, TIMER) VALUES(\"DEPOT\", 0)");
ps.executeUpdate();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
try {
Connection dbcon;
dbcon = ModSupportDb.getModSupportDb();
ps = dbcon.prepareStatement("INSERT INTO ObjectiveTimers (ID, TIMER) VALUES(\"TITAN\", 0)");
ps.executeUpdate();
ps.close();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
}
SupplyDepots.initializeDepotTimer();
Titans.initializeTitanTimer();
}
catch (SQLException e) {
throw new RuntimeException(e);
}
DatabaseHelper.onServerStarted();
}
public static long lastSecondPolled = 0;
@@ -540,6 +344,8 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
public static final long pollUniqueRegenerationTime = TimeConstants.SECOND_MILLIS;
public static long lastPolledUniqueCollection = 0;
public static final long pollUniqueCollectionTime = TimeConstants.MINUTE_MILLIS*5;
public static long lastPolledTerrainSmooth = 0;
public static final long pollTerrainSmoothTime = TimeConstants.SECOND_MILLIS*5;
@Override
public void onServerPoll() {
if((lastSecondPolled + TimeConstants.SECOND_MILLIS) < System.currentTimeMillis()){
@@ -579,6 +385,10 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
CombatChanges.pollUniqueCollection();
lastPolledUniqueCollection += pollUniqueCollectionTime;
}
if(lastPolledTerrainSmooth + pollTerrainSmoothTime < System.currentTimeMillis()){
SmoothTerrainAction.onServerPoll();
lastPolledTerrainSmooth += pollTerrainSmoothTime;
}
// Update counter
if(lastSecondPolled + TimeConstants.SECOND_MILLIS*10 > System.currentTimeMillis()){
@@ -595,6 +405,7 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
lastPolledBloodlust = System.currentTimeMillis();
lastPolledUniqueRegeneration = System.currentTimeMillis();
lastPolledUniqueCollection = System.currentTimeMillis();
lastPolledTerrainSmooth = System.currentTimeMillis();
}
}
}

View File

@@ -4,6 +4,8 @@ import java.lang.reflect.InvocationTargetException;
import java.util.logging.Logger;
import com.wurmonline.mesh.Tiles;
import com.wurmonline.server.Servers;
import com.wurmonline.server.behaviours.AutoEquipMethods;
import com.wurmonline.server.combat.Weapon;
import com.wurmonline.server.creatures.*;
import com.wurmonline.server.items.*;
@@ -605,6 +607,11 @@ public class MethodsBestiary {
// Goblin leader natural armour increase:
setNaturalArmour(CreatureTemplate.GOBLIN_LEADER_CID, 0.055f);
// Worg armour reduction on Arena
if(Servers.localServer.PVPSERVER) {
setNaturalArmour(CreatureTemplate.WORG_CID, 0.3f);
}
// Make titan minions drop no corpse
setNoCorpse(IfritFiend.templateId);
setNoCorpse(IfritSpider.templateId);

View File

@@ -1,10 +1,7 @@
package mod.sin.wyvern.bounty;
import com.wurmonline.mesh.Tiles;
import com.wurmonline.server.FailedException;
import com.wurmonline.server.HistoryManager;
import com.wurmonline.server.Players;
import com.wurmonline.server.Server;
import com.wurmonline.server.*;
import com.wurmonline.server.creatures.Creature;
import com.wurmonline.server.creatures.CreatureTemplate;
import com.wurmonline.server.creatures.CreatureTemplateFactory;
@@ -311,6 +308,23 @@ public class LootBounty {
boolean sendLootHelp = false;
// Begin loot table drops
int templateId = mob.getTemplate().getTemplateId();
if(Servers.localServer.PVPSERVER && mob.isPlayer()){
if(mob.isDeathProtected()) {
logger.info("Death protection was active for " + mob.getName() + ". Inserting silver coin reward.");
try {
Item silver = ItemFactory.createItem(ItemList.coinSilver, 99f, null);
corpse.insertItem(silver, true);
} catch (FailedException | NoSuchTemplateException e) {
e.printStackTrace();
}
}
Item[] items = mob.getAllItems();
for(Item item : items){
if(item.isRepairable()){
item.setDamage(Math.min(99f, item.getDamage() + Math.max(10f+(Server.rand.nextFloat()*5f), 10f * item.getDamageModifier(false))));
}
}
}
if(templateId == Reaper.templateId || templateId == SpectralDrake.templateId){
Server.getInstance().broadCastAlert("The "+mob.getName()+" has been slain. A new creature shall enter the realm shortly.");
sendLootHelp = true;

View File

@@ -216,7 +216,7 @@ public class PlayerBounty {
try {
//Map<Long, Long> attackers = ReflectionUtil.getPrivateField(creature, ReflectionUtil.getField(creature.getClass(), "attackers"));
Map<Long, Long> attackers = Bounty.getAttackers(creature);
if(!Bounty.isCombatant(attackers, player.getWurmId()) || creature.isPlayer() || creature.isReborn()){
if((attackers != null && !Bounty.isCombatant(attackers, player.getWurmId())) || creature.isPlayer() || creature.isReborn()){
return;
}
logger.info(player.getName()+" killed "+creature.getName());

View File

@@ -92,6 +92,7 @@ public class Mastercraft {
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Home_Decorator", 600, "Home Decorator", "Home Decorator", -1, "NORMAL");
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Arena_Champion", 601, "Champion of the Arena", "Champion of the Arena", -1, "NORMAL");
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Pastamancer", 602, "Pastamancer", "Pastamancer", -1, "NORMAL");
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Pizzamancer", 603, "Pizzamancer", "Pizzamancer", -1, "NORMAL");
// Special Event Titles
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Titan_Slayer", 700, "Titanslayer", "Titanslayer", -1, "NORMAL");

View File

@@ -33,6 +33,14 @@ public class ItemUtil {
ItemList.tomeMagicBlue,
ItemList.tomeMagicWhite
};
public static boolean isSorcery(Item item){
for(int id : sorceryIds){
if(item.getTemplateId() == id){
return true;
}
}
return false;
}
public static int[] plateChainTemplates = {
ItemList.plateBoot,
ItemList.plateGauntlet,
@@ -266,4 +274,24 @@ public class ItemUtil {
}
return null;
}
public static boolean isSingleUseRune(byte rune){
if(rune == -80){
return true;
}else if(rune == -81){
return true;
}else if(rune == -91){
return true;
}else if(rune == -97){
return true;
}else if(rune == -104){
return true;
}else if(rune == -107){
return true;
}else if(rune == -119){
return true;
}else if(rune == -126){
return true;
}
return false;
}
}