Skip to content

Commit

Permalink
Update to Wurm Unlimited 1.9 and latest code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sindusk committed Mar 22, 2019
1 parent 23fac18 commit 550ef20
Show file tree
Hide file tree
Showing 27 changed files with 397 additions and 119 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'java'

group "mod.sin"
version "1.2"
version "1.3"

repositories {
mavenCentral()
Expand All @@ -11,8 +11,8 @@ repositories {
}

dependencies {
compile 'org.gotti.wurmunlimited:server-modlauncher:0.39-beta1'
compile 'com.github.Sindusk:sindusklibrary:v1.7'
compile 'org.gotti.wurmunlimited:server-modlauncher:0.43-beta1'
compile 'com.github.Sindusk:sindusklibrary:v2.2'
compile 'com.github.Sindusk:DiscordRelay:v1.2'
compile 'com.github.Sindusk:DUSKombat:v1.0'
compile 'com.github.Sindusk:TreasureHunting:1.1.4'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public void answer(Properties answer) {
//logger.info("Converting "+player.getName()+" to " + Deities.getDeityName(deity));
String skillName = SkillSystem.getNameFor(skillNum);
logger.info("Adding affinity for skill "+skillName+" to "+player.getName());
Items.destroyItem(affinityOrb.getWurmId());

Affinity[] affs = Affinities.getAffinities(player.getWurmId());
boolean found = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void answer(Properties answer) {
Deity d = Deities.getDeity(deity);
p.setDeity(d);
p.setPriest(true);
if(d.hateGod){
if(d.isHateGod()){
p.setAlignment(-Math.abs(p.getAlignment()));
}else{
p.setAlignment(Math.abs(p.getAlignment()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mod/sin/actions/ArenaEscapeAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public ArenaEscapeAction() {
ModActions.registerAction(actionEntry);
}


@Override
public BehaviourProvider getBehaviourProvider()
{
Expand Down Expand Up @@ -93,6 +92,7 @@ public boolean action(Action act, Creature performer, Item target, short action,
}
if(counter == 1.0f){
performer.getCommunicator().sendNormalServerMessage("You prepare your body and mind to transfer to another realm.");
performer.playAnimation("meditate", false);
act.setTimeLeft(1800);
performer.sendActionControl("Preparing", true, act.getTimeLeft());
}else if(counter * 10f > performer.getCurrentAction().getTimeLeft()){
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/mod/sin/actions/ArenaTeleportAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,19 @@ public boolean action(Action act, Creature performer, Item target, short action,
}
if(counter == 1.0f){
performer.getCommunicator().sendNormalServerMessage("You sit and begin to transfer your mind.");
performer.playAnimation("meditate", false);
act.setTimeLeft(600);
performer.sendActionControl("Transferring", true, act.getTimeLeft());
}else if(act.currentSecond() == 10){
performer.getCommunicator().sendAlertServerMessage("You are about to enter a PvP environment.", (byte) 3);
performer.getCommunicator().sendAlertServerMessage("You are about to enter a full PvP environment.", (byte) 3);
}else if(act.currentSecond() == 20){
performer.getCommunicator().sendNormalServerMessage("Death will leave your corpse and return you here. Anyone may loot your corpse in the arena.", (byte) 3);
performer.getCommunicator().sendNormalServerMessage("Death will not drop your items. Instead they will be damaged heavily and returned to you upon respawn.", (byte) 3);
}else if(act.currentSecond() == 30){
performer.getCommunicator().sendNormalServerMessage("Upon transfer, you will be placed in a random location. This could be safely outside of danger, or directly on a group of enemies.", (byte) 3);
performer.getCommunicator().sendNormalServerMessage("If you are part of a deed, you will arrive at the token. Otherwise, you will be placed in a random location.", (byte) 3);
}else if(act.currentSecond() == 40){
performer.getCommunicator().sendNormalServerMessage("You can equip creatures such as horses by simply leading them. Taming is not required in the Arena.", (byte) 3);
}else if(act.currentSecond() == 55){
performer.getCommunicator().sendNormalServerMessage("It appears you have accepted these conditions. Transferring to the arena. Good luck.", (byte) 3);
performer.getCommunicator().sendNormalServerMessage("It appears you have accepted these conditions. Transferring to the Revenant Arena. Good luck.", (byte) 3);
}else if(counter * 10f > performer.getCurrentAction().getTimeLeft()){
ServerEntry targetserver = Servers.localServer.serverNorth;
if(targetserver == null){
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/mod/sin/actions/items/EternalOrbAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import com.wurmonline.server.behaviours.Action;
import com.wurmonline.server.behaviours.ActionEntry;
import com.wurmonline.server.creatures.Creature;
import com.wurmonline.server.items.Item;
import com.wurmonline.server.items.ItemFactory;
import com.wurmonline.server.items.ItemSpellEffects;
import com.wurmonline.server.items.NoSuchTemplateException;
import com.wurmonline.server.items.*;
import com.wurmonline.server.players.Player;
import com.wurmonline.server.skills.Skill;
import com.wurmonline.server.spells.Spell;
Expand Down Expand Up @@ -90,6 +87,10 @@ public boolean action(Action act, Creature performer, Item source, Item target,
player.getCommunicator().sendNormalServerMessage("You cannot absorb the orb with itself!");
return true;
}
if(target.getTemplateId() == ItemList.arrowHunting || target.getTemplateId() == ItemList.arrowWar){
player.getCommunicator().sendNormalServerMessage("You cannot use Eternal Orbs on arrows.");
return true;
}
ItemSpellEffects teffs = target.getSpellEffects();
if(teffs == null || teffs.getEffects().length == 0){
player.getCommunicator().sendNormalServerMessage("The "+target.getTemplate().getName()+" has no enchants.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mod/sin/creatures/Charger.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void setSettingsForVehicle(Creature creature, Vehicle v) {

vehicle.createPassengerSeats(0);
vehicle.setSeatFightMod(0, 0.8f, 1.1f);
vehicle.setSeatOffset(0, 0.0f, 0.0f, 0.5f);
vehicle.setSeatOffset(0, 0.0f, 0.0f, 0.0f);
vehicle.setCreature(true);
vehicle.setSkillNeeded(Servers.localServer.PVPSERVER ? 25.0f : 37.0f);
vehicle.setName(creature.getName());
Expand Down
1 change: 0 additions & 1 deletion src/main/java/mod/sin/items/AffinityOrb.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public void createTemplate() throws IOException{
itemBuilder.name(name, "affinity orbs", "A valuable orb that infuses the user with hidden knowledge.");
itemBuilder.descriptions("brilliantly glowing", "strongly glowing", "faintly glowing", "barely glowing");
itemBuilder.itemTypes(new short[]{
ItemTypes.ITEM_TYPE_NODROP,
ItemTypes.ITEM_TYPE_FULLPRICE,
ItemTypes.ITEM_TYPE_NOSELLBACK
});
Expand Down
25 changes: 13 additions & 12 deletions src/main/java/mod/sin/wyvern/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -427,20 +427,29 @@ public void edit(MethodCall m) throws CannotCompileException {
}
});*/

// Die method description
CtClass ctString = classPool.get("java.lang.String");
CtClass[] params8 = new CtClass[]{
CtClass.booleanType,
ctString,
CtClass.booleanType
};
String desc8 = Descriptor.ofMethod(CtClass.voidType, params8);

// - Ensure corpses are not loot protected on PvP - //
Util.setReason("Ensure corpses are not loot protected.");
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER){"
+ " $_ = $proceed(false);"
+ "}else{"
+ " $_ = $proceed($$);"
+ "}";
Util.instrumentDeclared(thisClass, ctCreature, "die", "setProtected", replace);
Util.instrumentDescribed(thisClass, ctCreature, "die", desc8, "setProtected", replace);
replace = "if(com.wurmonline.server.Servers.localServer.PVPSERVER){"
+ " $_ = true;"
+ "}else{"
+ " $_ = $proceed($$);"
+ "}";
Util.instrumentDeclared(thisClass, ctCreature, "die", "isInPvPZone", replace);
Util.instrumentDescribed(thisClass, ctCreature, "die", desc8, "isInPvPZone", replace);

// - Allow players to do actions in PvP houses - //
CtClass ctMethods = classPool.get("com.wurmonline.server.behaviours.Methods");
Expand Down Expand Up @@ -680,15 +689,7 @@ public void edit(MethodCall m) throws CannotCompileException {
"}else{" +
" $_ = $proceed($$);" +
"}";
Util.instrumentDeclared(thisClass, ctCreature, "die", "getFavor", replace);

/*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.instrumentDescribed(thisClass, ctCreature, "die", desc8, "getFavor", replace);

Util.setReason("Adjust spawn question mechanics.");
CtClass ctSpawnQuestion = classPool.get("com.wurmonline.server.questions.SpawnQuestion");
Expand Down Expand Up @@ -770,7 +771,7 @@ public void edit(MethodCall m) throws CannotCompileException {
" keepItems = true;" +
"}" +
"$_ = $proceed($$);";
Util.instrumentDeclaredCount(thisClass, ctCreature, "die", "isOnCurrentServer", 1, replace);
Util.instrumentDescribedCount(thisClass, ctCreature, "die", desc8, "isOnCurrentServer", 1, replace);

Util.setReason("Disable player skill loss on Arena.");
replace = "if(this.isPlayer() && this.isDeathProtected()){" +
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/mod/sin/wyvern/Bloodlust.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public static void preInit(){
final Class<Bloodlust> thisClass = Bloodlust.class;
String replace;

/* Disabled in Wurm Unlimited 1.9 - May need to be revisited in the future.
Util.setReason("Hook for bloodlust system.");
CtClass ctCreature = classPool.get("com.wurmonline.server.creatures.Creature");
CtClass ctString = classPool.get("java.lang.String");
Expand Down Expand Up @@ -97,8 +99,8 @@ public static void preInit(){
" float lustMult = "+Bloodlust.class.getName()+".getLustMult($1);" +
" $5 = $5 * lustMult;" +
"}";
Util.insertBeforeDescribed(thisClass, ctCombatEngine, "addWound", desc1, replace);
} catch ( NotFoundException | IllegalArgumentException | ClassCastException e) {
Util.insertBeforeDescribed(thisClass, ctCombatEngine, "addWound", desc1, replace);*/
} catch ( IllegalArgumentException | ClassCastException e) {
throw new HookException(e);
}
}
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/mod/sin/wyvern/Bounty.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,20 @@ public void edit(MethodCall m) throws CannotCompileException {
}
}
});*/

// Die method description
CtClass ctString = classPool.get("java.lang.String");
CtClass[] params1 = new CtClass[]{
CtClass.booleanType,
ctString,
CtClass.booleanType
};
String desc1 = Descriptor.ofMethod(CtClass.voidType, params1);

replace = "$_ = $proceed($$);"
//+ "mod.sin.wyvern.bounty.MethodsBounty.checkLootTable(this, corpse);";
+ LootBounty.class.getName()+".checkLootTable(this, corpse);";
Util.instrumentDeclared(thisClass, ctCreature, "die", "setRotation", replace);
Util.instrumentDescribed(thisClass, ctCreature, "die", desc1, "setRotation", replace);
/*ctCreature.getDeclaredMethod("die").instrument(new ExprEditor(){
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("setRotation")) {
Expand All @@ -135,7 +145,7 @@ public void edit(MethodCall m) throws CannotCompileException {
});*/

// doNew(int templateid, boolean createPossessions, float aPosX, float aPosY, float aRot, int layer, String name, byte gender, byte kingdom, byte ctype, boolean reborn, byte age)
CtClass[] params = {
CtClass[] params2 = {
CtClass.intType,
CtClass.booleanType,
CtClass.floatType,
Expand All @@ -150,16 +160,16 @@ public void edit(MethodCall m) throws CannotCompileException {
CtClass.byteType,
CtClass.intType
};
String desc = Descriptor.ofMethod(ctCreature, params);
Util.insertBeforeDescribed(thisClass, ctCreature, "doNew", desc, "logger.info(\"Creating new creature: \"+templateid+\" - \"+(aPosX/4)+\", \"+(aPosY/4)+\" [\"+com.wurmonline.server.creatures.CreatureTemplateFactory.getInstance().getTemplate(templateid).getName()+\"]\");");
String desc2 = Descriptor.ofMethod(ctCreature, params2);
Util.insertBeforeDescribed(thisClass, ctCreature, "doNew", desc2, "logger.info(\"Creating new creature: \"+templateid+\" - \"+(aPosX/4)+\", \"+(aPosY/4)+\" [\"+com.wurmonline.server.creatures.CreatureTemplateFactory.getInstance().getTemplate(templateid).getName()+\"]\");");
// Debugging to show all new creatures created.
//CtMethod ctDoNew = ctCreature.getMethod("doNew", "(IZFFFILjava/lang/String;BBBZB)Lcom/wurmonline/server/creatures/Creature;");
//ctDoNew.insertBefore("logger.info(\"Creating new creature: \"+templateid+\" - \"+(aPosX/4)+\", \"+(aPosY/4)+\" [\"+com.wurmonline.server.creatures.CreatureTemplateFactory.getInstance().getTemplate(templateid).getName()+\"]\");");
// Modify new creatures
replace = "$_ = $proceed($$);"
//+ "mod.sin.wyvern.bestiary.MethodsBestiary.modifyNewCreature($1);";
+ MethodsBestiary.class.getName()+".modifyNewCreature($1);";
Util.instrumentDescribed(thisClass, ctCreature, "doNew", desc, "sendToWorld", replace);
Util.instrumentDescribed(thisClass, ctCreature, "doNew", desc2, "sendToWorld", replace);
/*ctDoNew.instrument(new ExprEditor(){
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("sendToWorld")) {
Expand Down
Loading

0 comments on commit 550ef20

Please sign in to comment.