Testing Bdew's title injector, might work better now that EnumExtend seems to be broken
This commit is contained in:
@@ -66,6 +66,10 @@ public class StableContractAction implements ModAction, BehaviourProvider, Actio
|
||||
performer.getCommunicator().sendNormalServerMessage("You cannot summon the stable master right now!");
|
||||
return true;
|
||||
}
|
||||
if(performer.getCurrentVillage() == null) {
|
||||
performer.getCommunicator().sendNormalServerMessage("You must be part of a settlement to summon a stablemaster.");
|
||||
return true;
|
||||
}
|
||||
if(counter == 1.0f) {
|
||||
performer.getCommunicator().sendNormalServerMessage("You begin reading the contract...");
|
||||
final int time = 5;
|
||||
|
||||
@@ -313,8 +313,9 @@ public class AchievementChanges {
|
||||
public static Titles.Title getAwardedTitle(Achievement a) {
|
||||
int count = a.getCounter();
|
||||
if(a.getTemplate() == gremlinSlayer) {
|
||||
logger.info("Achievement at " + count);
|
||||
if(count >= 100) {
|
||||
return Titles.Title.getTitle(Mastercraft.GremlinSlayer);
|
||||
return Titles.Title.getTitle(704);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -325,8 +326,10 @@ public class AchievementChanges {
|
||||
Achievements achievments = Achievements.getAchievementObject(player.getWurmId());
|
||||
Achievement achievment = achievments.getAchievement(tpl.getNumber());
|
||||
if (achievment != null) {
|
||||
logger.info("Achievemtn found");
|
||||
Titles.Title title = getAwardedTitle(achievment);
|
||||
if (title != null) {
|
||||
logger.info("Adding title");
|
||||
player.addTitle(title);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,6 +334,26 @@ public class CombatChanges {
|
||||
replace = "$_ = true;";
|
||||
Util.instrumentDescribed(thisClass, ctCombatHandler, "getDamage", desc2, "isThisAnEpicOrChallengeServer", replace);
|
||||
|
||||
CtClass ctAttackAction = classPool.get("com.wurmonline.server.creatures.AttackAction");
|
||||
CtClass[] paramsWoa1 = {
|
||||
ctAttackAction,
|
||||
ctItem
|
||||
};
|
||||
CtClass[] paramsWoa2 = {
|
||||
ctItem
|
||||
};
|
||||
String descWoa1 = Descriptor.ofMethod(CtClass.floatType, paramsWoa1);
|
||||
String descWoa2 = Descriptor.ofMethod(CtClass.floatType, paramsWoa2);
|
||||
Util.setReason("Adjust WoA effect on weapons to be more noticeable");
|
||||
replace = "$_ = $proceed($$) * 2;";
|
||||
Util.instrumentDescribedCount(thisClass, ctCombatHandler, "getSpeed", descWoa1,"getSpellSpeedBonus", 2, replace);
|
||||
Util.instrumentDescribedCount(thisClass, ctCombatHandler, "getSpeed", descWoa2,"getSpellSpeedBonus", 2, replace);
|
||||
|
||||
Util.setReason("Adjust bloodthirst cap up to 17k from 10k");
|
||||
replace = "$1 = 17000;" +
|
||||
"$_ = $proceed($$);";
|
||||
Util.instrumentDeclaredCount(thisClass, ctCombatHandler, "setDamage", "min", 5, replace);
|
||||
|
||||
Util.setReason("Fix magranon damage bonus stacking.");
|
||||
replace = "if(mildStack){" +
|
||||
" $_ = $proceed($$) * 8 / 5;" +
|
||||
@@ -343,7 +363,6 @@ public class CombatChanges {
|
||||
Util.instrumentDescribed(thisClass, ctCombatHandler, "getDamage", desc2, "getModifiedFloatEffect", replace);
|
||||
|
||||
Util.setReason("Adjust bloodthirst to epic settings.");
|
||||
CtClass ctAttackAction = classPool.get("com.wurmonline.server.creatures.AttackAction");
|
||||
CtClass[] params3 = {
|
||||
ctCreature,
|
||||
ctAttackAction,
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.wurmonline.server.Servers;
|
||||
import com.wurmonline.server.combat.ArmourTemplate;
|
||||
import mod.sin.actions.items.magicitems.MagicItemMenuProvider;
|
||||
import mod.sin.actions.items.magicitems.MagicItemRechargeAction;
|
||||
import mod.sin.items.schematicitems.SchematicItems;
|
||||
|
||||
@@ -284,9 +284,7 @@ public class MiscChanges {
|
||||
// Sleep powder added
|
||||
toRestock.add(new TraderItem(ItemList.sleepPowder, 99, false, 99, 99, 20));
|
||||
logger.info("Adding sleep powder to trader restock list");
|
||||
// Kingdom tokens added
|
||||
toRestock.add(new TraderItem(ItemCreator.KINGDOM_TOKEN.getTemplateId(), 99, false, 99, 99, 20));
|
||||
logger.info("Adding kingdom tokens to trader restock list");
|
||||
// Kingdom tokens Removed
|
||||
// Sealed maps added, use ranom qualities between 10 and 100 (inclusive)
|
||||
toRestock.add(new TraderItem(SealedMap.templateId, 99, true, 10, 101, 3));
|
||||
logger.info("Adding sealed maps to trader restock list");
|
||||
@@ -400,7 +398,7 @@ public class MiscChanges {
|
||||
}
|
||||
|
||||
public static void preInit(){
|
||||
try{
|
||||
try {
|
||||
ClassPool classPool = HookManager.getInstance().getClassPool();
|
||||
final Class<MiscChanges> thisClass = MiscChanges.class;
|
||||
String replace;
|
||||
@@ -463,7 +461,7 @@ public class MiscChanges {
|
||||
CtClass ctPlayer = classPool.get("com.wurmonline.server.players.Player");
|
||||
replace = "$_ = $proceed($$);"
|
||||
+ "if(!com.wurmonline.server.Servers.localServer.PVPSERVER && this.getPower() < 1){"
|
||||
+ " "+MiscChanges.class.getName()+".sendServerTabMessage(\"event\", this.getName()+\" just earned the title of \"+title.getName(this.isNotFemale())+\"!\", 200, 100, 0);"
|
||||
+ " " + MiscChanges.class.getName() + ".sendServerTabMessage(\"event\", this.getName()+\" just earned the title of \"+title.getName(this.isNotFemale())+\"!\", 200, 100, 0);"
|
||||
+ "}";
|
||||
Util.instrumentDeclared(thisClass, ctPlayer, "addTitle", "sendNormalServerMessage", replace);
|
||||
|
||||
@@ -477,7 +475,7 @@ public class MiscChanges {
|
||||
Util.instrumentDeclared(thisClass, ctMethodsItems, "improveItem", "isCombine", replace);
|
||||
|
||||
// - Check new improve materials - //
|
||||
replace = "int temp = "+ItemMod.class.getName()+".getModdedImproveTemplateId($1);"
|
||||
replace = "int temp = " + ItemMod.class.getName() + ".getModdedImproveTemplateId($1);"
|
||||
+ "if(temp != -10){"
|
||||
+ " return temp;"
|
||||
+ "}";
|
||||
@@ -486,7 +484,7 @@ public class MiscChanges {
|
||||
// - Remove fatiguing actions requiring you to be on the ground - //
|
||||
CtClass ctAction = classPool.get("com.wurmonline.server.behaviours.Action");
|
||||
CtConstructor[] ctActionConstructors = ctAction.getConstructors();
|
||||
for(CtConstructor constructor : ctActionConstructors) {
|
||||
for (CtConstructor constructor : ctActionConstructors) {
|
||||
constructor.instrument(new ExprEditor() {
|
||||
public void edit(MethodCall m) throws CannotCompileException {
|
||||
if (m.getMethodName().equals("isFatigue")) {
|
||||
@@ -536,11 +534,11 @@ public class MiscChanges {
|
||||
Util.instrumentDeclared(thisClass, ctArrows, "addToHitCreature", "addAttacker", replace);
|
||||
|
||||
Util.setReason("Broadcast death tabs to GL-Freedom.");
|
||||
replace = MiscChanges.class.getName()+".broadCastDeaths($1, $2);";
|
||||
replace = MiscChanges.class.getName() + ".broadCastDeaths($1, $2);";
|
||||
Util.insertBeforeDeclared(thisClass, ctPlayers, "broadCastDeathInfo", replace);
|
||||
|
||||
Util.setReason("Broadcast player death tabs always.");
|
||||
replace = MiscChanges.class.getName()+".broadCastDeathsPvE($0, $0.attackers);";
|
||||
replace = MiscChanges.class.getName() + ".broadCastDeathsPvE($0, $0.attackers);";
|
||||
Util.insertBeforeDeclared(thisClass, ctPlayer, "modifyRanking", replace);
|
||||
|
||||
Util.setReason("Disable PvP only death tabs.");
|
||||
@@ -552,7 +550,7 @@ public class MiscChanges {
|
||||
ctIntraServerConnection.getDeclaredMethod("savePlayerToDisk").instrument(new ExprEditor() {
|
||||
@Override
|
||||
public void edit(FieldAccess fieldAccess) throws CannotCompileException {
|
||||
if (Objects.equals("PVPSERVER", fieldAccess.getFieldName())){
|
||||
if (Objects.equals("PVPSERVER", fieldAccess.getFieldName())) {
|
||||
fieldAccess.replace("$_ = false;");
|
||||
logger.info("Instrumented PVPSERVER = false for Libila faith transfers.");
|
||||
}
|
||||
@@ -561,7 +559,7 @@ public class MiscChanges {
|
||||
ctIntraServerConnection.getDeclaredMethod("savePlayerToDisk").instrument(new ExprEditor() {
|
||||
@Override
|
||||
public void edit(FieldAccess fieldAccess) throws CannotCompileException {
|
||||
if (Objects.equals("HOMESERVER", fieldAccess.getFieldName())){
|
||||
if (Objects.equals("HOMESERVER", fieldAccess.getFieldName())) {
|
||||
fieldAccess.replace("$_ = false;");
|
||||
logger.info("Instrumented HOMESERVER = false for Libila faith transfers.");
|
||||
}
|
||||
@@ -597,9 +595,9 @@ public class MiscChanges {
|
||||
|
||||
Util.setReason("Allow traders to display more than 9 items of a single type.");
|
||||
CtClass ctTradeHandler = classPool.get("com.wurmonline.server.creatures.TradeHandler");
|
||||
ctTradeHandler.getDeclaredMethod("addItemsToTrade").instrument(new ExprEditor(){
|
||||
ctTradeHandler.getDeclaredMethod("addItemsToTrade").instrument(new ExprEditor() {
|
||||
public void edit(MethodCall m) throws CannotCompileException {
|
||||
if(m.getMethodName().equals("size") && m.getLineNumber() > 200){ // I don't think the line number check matters, but I'm leaving it here anyway.
|
||||
if (m.getMethodName().equals("size") && m.getLineNumber() > 200) { // I don't think the line number check matters, but I'm leaving it here anyway.
|
||||
m.replace("$_ = 1;");
|
||||
logger.info("Instrumented size for trades to allow traders to show more than 9 items at a time.");
|
||||
}
|
||||
@@ -642,7 +640,7 @@ public class MiscChanges {
|
||||
"double maxRate = " + String.valueOf(maxRate) + ";" +
|
||||
"double newPower = " + String.valueOf(newPower) + ";" +
|
||||
"$1 = $1*(minRate+(maxRate-minRate)*Math.pow((100-this.knowledge)*0.01, newPower));";
|
||||
Util.insertBeforeDescribed(thisClass, ctSkill,"alterSkill", desc, replace);
|
||||
Util.insertBeforeDescribed(thisClass, ctSkill, "alterSkill", desc, replace);
|
||||
|
||||
Util.setReason("Reduce chance of lockpicks breaking.");
|
||||
replace = "$_ = 40f + $proceed($$);";
|
||||
@@ -650,8 +648,8 @@ public class MiscChanges {
|
||||
|
||||
CtClass ctTileBehaviour = classPool.get("com.wurmonline.server.behaviours.TileBehaviour");
|
||||
CtMethod[] ctGetBehavioursFors = ctTileBehaviour.getDeclaredMethods("getBehavioursFor");
|
||||
for(CtMethod method : ctGetBehavioursFors){
|
||||
method.instrument(new ExprEditor(){
|
||||
for (CtMethod method : ctGetBehavioursFors) {
|
||||
method.instrument(new ExprEditor() {
|
||||
public void edit(MethodCall m) throws CannotCompileException {
|
||||
if (m.getMethodName().equals("getKingdomTemplateId")) {
|
||||
m.replace("$_ = 3;");
|
||||
@@ -664,7 +662,7 @@ public class MiscChanges {
|
||||
Util.setReason("Allow players to construct larger houses.");
|
||||
float carpentryMultiplier = 2f;
|
||||
replace = "if(!com.wurmonline.server.Servers.localServer.PVPSERVER){" +
|
||||
" $_ = $proceed($$)*"+String.valueOf(carpentryMultiplier)+";" +
|
||||
" $_ = $proceed($$)*" + String.valueOf(carpentryMultiplier) + ";" +
|
||||
"}else{" +
|
||||
" $_ = $proceed($$);" +
|
||||
"}";
|
||||
@@ -691,7 +689,7 @@ public class MiscChanges {
|
||||
|
||||
Util.setReason("Remove guard tower guards helping against certain types of enemies.");
|
||||
CtClass ctGuardTower = classPool.get("com.wurmonline.server.kingdom.GuardTower");
|
||||
replace = "if($0.isUnique() || "+Titans.class.getName()+".isTitan($0) || "+RareSpawns.class.getName()+".isRareCreature($0)){" +
|
||||
replace = "if($0.isUnique() || " + Titans.class.getName() + ".isTitan($0) || " + RareSpawns.class.getName() + ".isRareCreature($0)){" +
|
||||
" $_ = false;" +
|
||||
"}else{" +
|
||||
" $_ = $proceed($$);" +
|
||||
@@ -748,18 +746,18 @@ public class MiscChanges {
|
||||
Util.instrumentDescribed(thisClass, ctItem, "poll", desc11, "setDamage", replace);
|
||||
|
||||
Util.setReason("Allow mayors to command abandoned vehicles off their deed.");
|
||||
replace = "if("+MiscChanges.class.getName()+".checkMayorCommand($0, $1)){" +
|
||||
replace = "if(" + MiscChanges.class.getName() + ".checkMayorCommand($0, $1)){" +
|
||||
" return true;" +
|
||||
"}";
|
||||
Util.insertBeforeDeclared(thisClass, ctItem, "mayCommand", replace);
|
||||
|
||||
Util.setReason("Modify timed affinity timer.");
|
||||
CtClass ctAffinitiesTimed = classPool.get("com.wurmonline.server.skills.AffinitiesTimed");
|
||||
replace = "$_ = "+MiscChanges.class.getName()+".getFoodOpulenceBonus($0);";
|
||||
replace = "$_ = " + MiscChanges.class.getName() + ".getFoodOpulenceBonus($0);";
|
||||
Util.instrumentDeclared(thisClass, ctAffinitiesTimed, "addTimedAffinityFromBonus", "getFoodComplexity", replace);
|
||||
|
||||
Util.setReason("Food affinity timer normalization.");
|
||||
replace = "long time = "+WurmCalendar.class.getName()+".getCurrentTime();" +
|
||||
replace = "long time = " + WurmCalendar.class.getName() + ".getCurrentTime();" +
|
||||
"if($0.getExpires($1) == null){" +
|
||||
" $_ = Long.valueOf(time);" +
|
||||
"}else{" +
|
||||
@@ -775,7 +773,7 @@ public class MiscChanges {
|
||||
|
||||
Util.setReason("Make bed QL affect sleep bonus timer.");
|
||||
CtClass ctPlayerInfo = classPool.get("com.wurmonline.server.players.PlayerInfo");
|
||||
replace = "long secs2 = "+MiscChanges.class.getName()+".getBedBonus(secs, this.bed);" +
|
||||
replace = "long secs2 = " + MiscChanges.class.getName() + ".getBedBonus(secs, this.bed);" +
|
||||
"$_ = $proceed((int)(this.sleep + secs2));";
|
||||
Util.instrumentDeclared(thisClass, ctPlayerInfo, "calculateSleep", "setSleep", replace);
|
||||
|
||||
@@ -788,7 +786,7 @@ public class MiscChanges {
|
||||
Util.insertBeforeDeclared(thisClass, ctCreature, "intraTeleport", replace);
|
||||
|
||||
Util.setReason("Allow royal smith to improve smithing items faster.");
|
||||
replace = "if("+MiscChanges.class.getName()+".royalSmithImprove($1, improve)){" +
|
||||
replace = "if(" + MiscChanges.class.getName() + ".royalSmithImprove($1, improve)){" +
|
||||
" $_ = $proceed($$) * 0.9f;" +
|
||||
"}else{" +
|
||||
" $_ = $proceed($$);" +
|
||||
@@ -797,7 +795,7 @@ public class MiscChanges {
|
||||
Util.setReason("Allow royal smith to improve smithing items faster.");
|
||||
Util.instrumentDeclared(thisClass, ctMethodsItems, "polishItem", "getImproveActionTime", replace);
|
||||
Util.setReason("Allow royal smith to improve smithing items faster. Also make tempering use water enchants.");
|
||||
replace = "if("+MiscChanges.class.getName()+".royalSmithImprove($1, improve)){" +
|
||||
replace = "if(" + MiscChanges.class.getName() + ".royalSmithImprove($1, improve)){" +
|
||||
" $_ = $proceed($1, target) * 0.9f;" +
|
||||
"}else{" +
|
||||
" $_ = $proceed($1, target);" +
|
||||
@@ -828,7 +826,7 @@ public class MiscChanges {
|
||||
CtClass.floatType
|
||||
};
|
||||
String desc12 = Descriptor.ofMethod(CtClass.booleanType, params12);
|
||||
replace = "$_ = $proceed($1, $2, $3, $4, "+MiscChanges.class.getName()+".getNewFoodFill(qlevel));";
|
||||
replace = "$_ = $proceed($1, $2, $3, $4, " + MiscChanges.class.getName() + ".getNewFoodFill(qlevel));";
|
||||
Util.instrumentDescribed(thisClass, ctMethodsItems, "eat", desc12, "modifyHunger", replace);
|
||||
|
||||
// Fix for butchering not giving skill gain when butchering too many items
|
||||
@@ -840,7 +838,7 @@ public class MiscChanges {
|
||||
if (m.getMethodName().equals("skillCheck")) {
|
||||
if (first) {
|
||||
first = false;
|
||||
}else {
|
||||
} else {
|
||||
m.replace("$_ = $proceed($1, $2, $3, false, $5);");
|
||||
logger.info("Replaced filet skill check to ensure butchering skill is always gained.");
|
||||
}
|
||||
@@ -855,7 +853,7 @@ public class MiscChanges {
|
||||
\"Battle Yoyos\", 4000.0f, new int[]{1022}, 1209600000l, (short) 4, true, true));");*/
|
||||
|
||||
Util.setReason("Hook for rare material usage in improvement.");
|
||||
replace = "if("+MiscChanges.class.getName()+".rollRarityImprove($0, usedWeight)){" +
|
||||
replace = "if(" + MiscChanges.class.getName() + ".rollRarityImprove($0, usedWeight)){" +
|
||||
" rarity = source.getRarity();" +
|
||||
"}" +
|
||||
"$_ = $proceed($$);";
|
||||
@@ -863,7 +861,7 @@ public class MiscChanges {
|
||||
|
||||
Util.setReason("Bad luck protection on rarity windows.");
|
||||
replace = "if($1 == 3600){" +
|
||||
" $_ = "+MiscChanges.class.getName()+".getRarityWindowChance(this.getWurmId());" +
|
||||
" $_ = " + MiscChanges.class.getName() + ".getRarityWindowChance(this.getWurmId());" +
|
||||
"}else{" +
|
||||
" $_ = $proceed($$);" +
|
||||
"}";
|
||||
@@ -882,11 +880,10 @@ public class MiscChanges {
|
||||
|
||||
@Override
|
||||
public void edit(MethodCall m) throws CannotCompileException {
|
||||
if(m.getMethodName().equals("min")) {
|
||||
if(first) {
|
||||
if (m.getMethodName().equals("min")) {
|
||||
if (first) {
|
||||
first = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
m.replace("$_ = $proceed($1, $2 * " + MiscChanges.class.getName() + ".boatSpeedBonus(this));");
|
||||
logger.info("Allowing preists of vynora to gain 20% boat speed above 60 faith.");
|
||||
}
|
||||
@@ -902,7 +899,7 @@ public class MiscChanges {
|
||||
public void edit(MethodCall m) throws CannotCompileException {
|
||||
if (m.getMethodName().equals("getRarity")) {
|
||||
if (first) {
|
||||
m.replace("byte newRarity = "+MiscChanges.class.getName()+".getNewCreationRarity(this, source, target, template);" +
|
||||
m.replace("byte newRarity = " + MiscChanges.class.getName() + ".getNewCreationRarity(this, source, target, template);" +
|
||||
"if(newRarity > 0){" +
|
||||
" act.setRarity(newRarity);" +
|
||||
"}" +
|
||||
@@ -1000,6 +997,18 @@ public class MiscChanges {
|
||||
"}";
|
||||
Util.insertBeforeDescribed(thisClass, ctItemBehaviour, "action", desc15, replace);
|
||||
|
||||
Util.setReason("Change fantastic items to red.");
|
||||
CtClass ctManageObjectList = classPool.get("com.wurmonline.server.questions.ManageObjectList");
|
||||
/* This is for adding a new rarity!
|
||||
replace = "if (item.getRarity() == 4) {" +
|
||||
"return \"label{color=\\\"66,153,225\\\";text=\\\"rare \" + name + \"\\\"};\";" +
|
||||
"}";
|
||||
*/
|
||||
replace = "if (item.getRarity() == 3) {" +
|
||||
"return \"label{color=\\\"255,53,0\\\";text=\\\"fantastic \" + name + \"\\\"};\";" +
|
||||
"}";
|
||||
Util.insertBeforeDeclared(thisClass, ctManageObjectList, "addRariryColour", replace);
|
||||
|
||||
} catch (CannotCompileException | NotFoundException | IllegalArgumentException | ClassCastException e) {
|
||||
throw new HookException(e);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.wurmonline.server.Items;
|
||||
import com.wurmonline.server.Server;
|
||||
import com.wurmonline.server.creatures.Communicator;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.deities.Deities;
|
||||
import com.wurmonline.server.items.*;
|
||||
import com.wurmonline.server.kingdom.Kingdoms;
|
||||
import mod.sin.actions.items.SorcerySplitAction;
|
||||
@@ -325,9 +326,6 @@ implements WurmServerMod, Configurable, PreInitable, Initable, ItemTemplatesCrea
|
||||
// Stable master contract
|
||||
item = Creature.createItem(StableContract.templateId, 50);
|
||||
inventory.insertItem(item);
|
||||
// Kingdom token
|
||||
item = Creature.createItem(ItemCreator.KINGDOM_TOKEN.getTemplateId(), 50);
|
||||
inventory.insertItem(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ItemBonusOverhaul {
|
||||
*/
|
||||
public static void initializeBonuses() throws NoSuchTemplateException {
|
||||
itemBonuses.add(new ItemBonusWrapper(GlimmerscaleVest.templateId, SpellEffectsEnum.ITEM_RING_CR, false, 1.0f, false));
|
||||
itemBonuses.add(new ItemBonusWrapper(ArcaniteNecklaceFocus.templateId, SpellEffectsEnum.ITEM_NECKLACE_FOCUS, false, .2f, true));
|
||||
itemBonuses.add(new ItemBonusWrapper(ArcaniteNecklaceFocus.templateId, SpellEffectsEnum.ITEM_NECKLACE_FOCUS, false, 20.0f, true));
|
||||
|
||||
batteries = new Battery[] {
|
||||
new Battery(Soul.templateId, 30),
|
||||
|
||||
@@ -216,9 +216,11 @@ public class PlayerBounty {
|
||||
strBuilder += " for slaying the " + mob.getName() + ".";
|
||||
player.getCommunicator().sendSafeServerMessage(strBuilder);
|
||||
long playerSteamId = steamIdMap.get(player.getName());
|
||||
/* Maybe re-enable kingdom titles when they can be interesting again
|
||||
Item creatureToken = ItemFactory.createItem(ItemCreator.CREATURE_TOKEN.getTemplateId(), 50, (byte)0, "");
|
||||
inventory.insertItem(creatureToken);
|
||||
player.getCommunicator().sendSafeServerMessage("You also receive a " + creatureToken.getName() + "!");
|
||||
*/
|
||||
if(playersRewarded.containsKey(mobWurmId)){
|
||||
playersRewarded.get(mobWurmId).add(playerSteamId);
|
||||
}else{
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package mod.sin.wyvern.mastercraft;
|
||||
|
||||
import javassist.CannotCompileException;
|
||||
import javassist.ClassPool;
|
||||
import javassist.NotFoundException;
|
||||
import javassist.bytecode.BadBytecode;
|
||||
|
||||
public class AchievementTitles {
|
||||
public static int gremlinSlayerTitleID = 704;
|
||||
public static void register(ClassPool cp) throws NotFoundException, BadBytecode, CannotCompileException {
|
||||
TitleInjector injector = new TitleInjector(cp);
|
||||
injector.addTitle("GremlinSlayer", gremlinSlayerTitleID, "Gremlin Slayer", "Gremlin Slayer", -1, "NORMAL");
|
||||
}
|
||||
}
|
||||
@@ -491,4 +491,71 @@ public class BytecodeTools extends Bytecode {
|
||||
}
|
||||
logger.log(Level.INFO,name + " : " + Arrays.toString(a));
|
||||
}
|
||||
|
||||
// BDEW EXTRAS
|
||||
public static void putInteger(ConstPool cp, Bytecode code, int val) {
|
||||
switch (val) {
|
||||
case -1:
|
||||
code.add(Bytecode.ICONST_M1);
|
||||
break;
|
||||
case 0:
|
||||
code.add(Bytecode.ICONST_0);
|
||||
break;
|
||||
case 1:
|
||||
code.add(Bytecode.ICONST_1);
|
||||
break;
|
||||
case 2:
|
||||
code.add(Bytecode.ICONST_2);
|
||||
break;
|
||||
case 3:
|
||||
code.add(Bytecode.ICONST_3);
|
||||
break;
|
||||
case 4:
|
||||
code.add(Bytecode.ICONST_4);
|
||||
break;
|
||||
case 5:
|
||||
code.add(Bytecode.ICONST_5);
|
||||
break;
|
||||
default:
|
||||
if (val >= Byte.MIN_VALUE && val <= Byte.MAX_VALUE) {
|
||||
code.add(Bytecode.BIPUSH);
|
||||
code.add(val);
|
||||
} else if (val >= Short.MIN_VALUE && val <= Short.MAX_VALUE) {
|
||||
code.add(Bytecode.SIPUSH);
|
||||
code.add(val >> 8 & 0xFF, val & 0xFF);
|
||||
} else {
|
||||
code.addLdc(cp.addIntegerInfo(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getInteger(ConstPool cp, CodeIterator iterator, int pos) {
|
||||
int op = iterator.byteAt(pos);
|
||||
switch (op) {
|
||||
case Bytecode.ICONST_M1:
|
||||
return -1;
|
||||
case Bytecode.ICONST_0:
|
||||
return 0;
|
||||
case Bytecode.ICONST_1:
|
||||
return 1;
|
||||
case Bytecode.ICONST_2:
|
||||
return 2;
|
||||
case Bytecode.ICONST_3:
|
||||
return 3;
|
||||
case Bytecode.ICONST_4:
|
||||
return 4;
|
||||
case Bytecode.ICONST_5:
|
||||
return 5;
|
||||
case Bytecode.BIPUSH:
|
||||
return iterator.byteAt(pos + 1);
|
||||
case Bytecode.SIPUSH:
|
||||
return iterator.s16bitAt(pos + 1);
|
||||
case Bytecode.LDC:
|
||||
return cp.getIntegerInfo(iterator.byteAt(pos + 1));
|
||||
case Bytecode.LDC_W:
|
||||
return cp.getIntegerInfo(iterator.u16bitAt(pos + 1));
|
||||
default:
|
||||
throw new RuntimeException(String.format("Failed to decode integer. Pos = %d, Bytecode = %d", pos, op));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import java.util.logging.Logger;
|
||||
|
||||
public class Mastercraft {
|
||||
private static Logger logger = Logger.getLogger(Mastercraft.class.getName());
|
||||
public static int GremlinSlayer = 704;
|
||||
public static double getNewDifficulty(Skill skill, double diff, Item item){
|
||||
if(skill.affinity > 0){
|
||||
diff -= skill.affinity;
|
||||
@@ -100,7 +99,7 @@ public class Mastercraft {
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Spectral_Slayer", 701, "Spectral Warrior", "Spectral Warrior", -1, "NORMAL");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Holdstrong_Architect", 702, "Holdstrong Architect", "Holdstrong Architect", -1, "NORMAL");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Stronghold_Architect", 703, "Stronghold Architect", "Stronghold Architect", -1, "NORMAL");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Gremlin_Slayer", GremlinSlayer, "Gremlin Slayer", "Gremlin Slayer", -1, "NORMAL");
|
||||
//ExtendTitleEnum.getSingletonInstance().addExtendEntry("Gremlin_Slayer", 704, "Gremlin Slayer", "Gremlin Slayer", -1, "NORMAL");
|
||||
|
||||
// Donation titles
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Donator", 800, "Donator", "Donator", -1, "NORMAL");
|
||||
|
||||
96
src/main/java/mod/sin/wyvern/mastercraft/TitleInjector.java
Normal file
96
src/main/java/mod/sin/wyvern/mastercraft/TitleInjector.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package mod.sin.wyvern.mastercraft;
|
||||
|
||||
import javassist.ClassPool;
|
||||
import javassist.*;
|
||||
import javassist.bytecode.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TitleInjector {
|
||||
private final CtClass titleCls;
|
||||
private final ConstPool constPool;
|
||||
private final CodeIterator codeIterator;
|
||||
private int insertPos = -1;
|
||||
private int lastOrd = -1;
|
||||
private int arraySizePos = -1;
|
||||
|
||||
|
||||
public TitleInjector(ClassPool classPool) throws NotFoundException, BadBytecode {
|
||||
titleCls = classPool.getCtClass("com.wurmonline.server.players.Titles$Title");
|
||||
CtConstructor initializer = titleCls.getClassInitializer();
|
||||
CodeAttribute codeAttr = initializer.getMethodInfo().getCodeAttribute();
|
||||
constPool = codeAttr.getConstPool();
|
||||
codeIterator = codeAttr.iterator();
|
||||
|
||||
BytecodeTools b = new BytecodeTools(constPool);
|
||||
|
||||
// My code needs a bit more stack space than javac-generated one
|
||||
codeAttr.setMaxStack(codeAttr.getMaxStack() + 3);
|
||||
|
||||
while (codeIterator.hasNext()) {
|
||||
int pos = codeIterator.next();
|
||||
int op = codeIterator.byteAt(pos);
|
||||
if (op == Bytecode.AASTORE) {
|
||||
insertPos = codeIterator.next();
|
||||
} else if (op == Bytecode.ANEWARRAY) {
|
||||
arraySizePos = pos - 2;
|
||||
} else if (op == Bytecode.NEW) {
|
||||
pos = codeIterator.next(); // dup
|
||||
pos = codeIterator.next(); // ldc of ident
|
||||
pos = codeIterator.next(); // here's the ordinal
|
||||
lastOrd = BytecodeTools.getInteger(constPool, codeIterator, pos);
|
||||
}
|
||||
}
|
||||
|
||||
if (insertPos == -1) throw new RuntimeException("Failed to find AASTORE");
|
||||
if (lastOrd == -1) throw new RuntimeException("Failed to find ordinals");
|
||||
if (arraySizePos == -1) throw new RuntimeException("Failed to array size position");
|
||||
}
|
||||
|
||||
public void saveDebug() throws IOException, CannotCompileException, NotFoundException {
|
||||
titleCls.writeFile();
|
||||
}
|
||||
|
||||
|
||||
public void addTitle(String ident, int id, String name, String femaleName, int skillId, String type) throws BadBytecode, CannotCompileException {
|
||||
int ordinal = ++lastOrd;
|
||||
Bytecode code = new Bytecode(constPool);
|
||||
|
||||
// When starting the values array is on stack, dup it for later use
|
||||
code.add(Bytecode.DUP);
|
||||
|
||||
// Put out ordinal, will be used by AASTORE
|
||||
BytecodeTools.putInteger(constPool, code, ordinal);
|
||||
|
||||
// Make new instance, and dupe that too
|
||||
code.addNew("com.wurmonline.server.players.Titles$Title");
|
||||
code.add(Bytecode.DUP);
|
||||
|
||||
// Put constructor parameters into stack
|
||||
code.addLdc(ident);
|
||||
BytecodeTools.putInteger(constPool, code, ordinal);
|
||||
BytecodeTools.putInteger(constPool, code, id);
|
||||
code.addLdc(name);
|
||||
code.addLdc(femaleName);
|
||||
BytecodeTools.putInteger(constPool, code, skillId);
|
||||
code.addGetstatic("com.wurmonline.server.players.Titles$TitleType", type, "Lcom/wurmonline/server/players/Titles$TitleType;");
|
||||
|
||||
// Call constructor, this will use one copy of our instance duped above, we need 2 more so dup it again
|
||||
code.addInvokespecial("com.wurmonline.server.players.Titles$Title", "<init>", "(Ljava/lang/String;IILjava/lang/String;Ljava/lang/String;ILcom/wurmonline/server/players/Titles$TitleType;)V");
|
||||
code.add(Bytecode.DUP);
|
||||
|
||||
// Put instance into static field - this will use the second copy of our instance
|
||||
//code.addPutstatic("net.bdew.wurm.halloween.titles.TitlesExtended", ident, "Lcom/wurmonline/server/players/Titles$Title;");
|
||||
|
||||
// And finally stick it into values array, this will use the duped array, ordinal and the final copy of our instance
|
||||
code.add(Bytecode.AASTORE);
|
||||
|
||||
// End of bytecode gen, insert it into the initializer
|
||||
byte[] bytes = code.get();
|
||||
codeIterator.insertAt(insertPos, bytes);
|
||||
insertPos += bytes.length;
|
||||
|
||||
// And increase array size
|
||||
codeIterator.write16bit(codeIterator.u16bitAt(arraySizePos) + 1, arraySizePos);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user