Changed trader restocking to use a new object, added 20% boat speed to vynora, started on wood essence
This commit is contained in:
@@ -102,6 +102,7 @@ public class ItemMod {
|
||||
//Ocnoc
|
||||
public static PipingKit PIPING_KIT = new PipingKit();
|
||||
public static StableContract STABLE_CONTRACT = new StableContract();
|
||||
public static MoreAnchors MORE_ANCHORS = new MoreAnchors();
|
||||
|
||||
public static void createItems(){
|
||||
logger.info("createItems()");
|
||||
@@ -213,6 +214,7 @@ public class ItemMod {
|
||||
WARHAMMER.initCreationEntry();
|
||||
WARHAMMER_HEAD.initCreationEntry();
|
||||
//HUGE_CRATE.initCreationEntry();
|
||||
MORE_ANCHORS.initCreationEntry();
|
||||
|
||||
// Spectral set
|
||||
/*SPECTRAL_BOOT.initCreationEntry();
|
||||
@@ -280,7 +282,7 @@ public class ItemMod {
|
||||
logger.info("Beginning custom weapon creation.");
|
||||
new Weapon(BattleYoyo.templateId, 6.85f, 3.85f, 0.008f, 2, 2, 0.0f, 0d);
|
||||
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(Knuckles.templateId, 3.6f, 2.1f, 0.002f, 1, 1, 0.2f, 0.5d);
|
||||
new Weapon(Warhammer.templateId, 9.40f, 5.6f, 0.008f, 4, 3, 1f, 0d);
|
||||
// Titan weaponry
|
||||
new Weapon(MaartensMight.templateId, 11, 5, 0.02f, 4, 4, 1.0f, 0d);
|
||||
|
||||
@@ -3,9 +3,11 @@ package mod.sin.wyvern;
|
||||
import com.wurmonline.server.*;
|
||||
import com.wurmonline.server.bodys.Wound;
|
||||
import com.wurmonline.server.creatures.Creature;
|
||||
import com.wurmonline.server.items.Item;
|
||||
import com.wurmonline.server.items.ItemTemplate;
|
||||
import com.wurmonline.server.items.SimpleCreationEntry;
|
||||
import com.wurmonline.server.creatures.CreatureTemplateIds;
|
||||
import com.wurmonline.server.creatures.Creatures;
|
||||
import com.wurmonline.server.deities.Deities;
|
||||
import com.wurmonline.server.economy.Economy;
|
||||
import com.wurmonline.server.items.*;
|
||||
import com.wurmonline.server.players.Player;
|
||||
import com.wurmonline.server.players.PlayerInfo;
|
||||
import com.wurmonline.server.players.PlayerInfoFactory;
|
||||
@@ -21,18 +23,21 @@ import javassist.bytecode.Descriptor;
|
||||
import javassist.expr.ExprEditor;
|
||||
import javassist.expr.FieldAccess;
|
||||
import javassist.expr.MethodCall;
|
||||
import mod.sin.items.ChaosCrystal;
|
||||
import mod.sin.items.EnchantersCrystal;
|
||||
import mod.sin.items.SealedMap;
|
||||
import mod.sin.kingdomoffices.ItemCreator;
|
||||
import mod.sin.lib.Util;
|
||||
import mod.sin.wyvern.util.TraderItem;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.HookException;
|
||||
import org.gotti.wurmunlimited.modloader.classhooks.HookManager;
|
||||
import org.gotti.wurmunlimited.modsupport.ModSupportDb;
|
||||
import org.nyxcode.wurm.discordrelay.DiscordRelay;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MiscChanges {
|
||||
@@ -153,6 +158,18 @@ public class MiscChanges {
|
||||
return food.getFoodComplexity()*mult;
|
||||
}
|
||||
|
||||
public static float boatSpeedBonus(Creature captain) {
|
||||
if(captain.getDeity().getNumber() != Deities.DEITY_VYNORA) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
if(captain.getFaith() >= 60.0) {
|
||||
return (float)1.2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getBedBonus(long secs, long bed){
|
||||
Optional<Item> beds = Items.getItemOptional(bed);
|
||||
if(beds.isPresent()) {
|
||||
@@ -182,6 +199,51 @@ public class MiscChanges {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void restockTrader(Creature trader) {
|
||||
try {
|
||||
if(trader.getTemplate().getTemplateId() != CreatureTemplateIds.SALESMAN_CID || Economy.getEconomy().getShop(trader).isPersonal()) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
Item item;
|
||||
// Hashset of trader items
|
||||
Set<TraderItem> toRestock = new HashSet<>();
|
||||
|
||||
// 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");
|
||||
// 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");
|
||||
toRestock.add(new TraderItem(EnchantersCrystal.templateId, 99, true, 10, 101, 10));
|
||||
logger.info("Adding enchant crystals to trader restock list");
|
||||
toRestock.add(new TraderItem(ChaosCrystal.templateId, 99, true, 10, 101, 10));
|
||||
logger.info("Adding chaos crystals to trader restock list");
|
||||
|
||||
|
||||
for (TraderItem tItem : toRestock) {
|
||||
logger.info("Counting number of " + ItemTemplateFactory.getInstance().getTemplate(tItem.getTemplateid()).getName() + " instances in trader inventory.");
|
||||
count = 0;
|
||||
for (Item i : trader.getInventory().getItemsAsArray()) {
|
||||
if (i.getTemplateId() == tItem.getTemplateid()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
logger.info("Trader had " + count + " " + ItemTemplateFactory.getInstance().getTemplate(tItem.getTemplateid()).getName() + ".");
|
||||
while (count < tItem.getQuantity()) {
|
||||
item = Creature.createItem(tItem.getTemplateid(), tItem.getQuality());
|
||||
trader.getInventory().insertItem(item);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNewFoodFill(float qlevel){
|
||||
float startPercent = 0.004f;
|
||||
float endPercent = 0.015f;
|
||||
@@ -715,6 +777,31 @@ public class MiscChanges {
|
||||
"}";
|
||||
Util.instrumentDeclared(thisClass, ctPlayer, "poll", "nextInt", replace);
|
||||
|
||||
CtClass ctShop = classPool.get("com.wurmonline.server.items.Trade");
|
||||
Util.setReason("Restock certain items after every trade with a trader");
|
||||
replace = "$_ = $proceed($$);" + MiscChanges.class.getName() + ".restockTrader($1);";
|
||||
Util.instrumentDeclared(thisClass, ctShop, "makeTrade", "getShop", replace);
|
||||
|
||||
CtClass ctVehicles = classPool.get("com.wurmonline.server.behaviours.VehicleBehaviour");
|
||||
Util.setReason("Allow preists of vynora to gain 20% boat speed above 60 faith.");
|
||||
replace = "$_ = $proceed($1, $2 * " + MiscChanges.class.getName() + ".boatSpeedBonus(Players.getInstance().getPlayer(this.pilotId)));";
|
||||
ctVehicles.getDeclaredMethod("calculateNewBoatSpeed").instrument(new ExprEditor() {
|
||||
private boolean first = true;
|
||||
|
||||
@Override
|
||||
public void edit(MethodCall m) throws CannotCompileException {
|
||||
if(m.getMethodName().equals("min")) {
|
||||
if(first) {
|
||||
first = false;
|
||||
}
|
||||
else {
|
||||
m.replace("$_ = $proceed($1, $2 * " + MiscChanges.class.getName() + ".boatSpeedBonus(Players.getInstance().getPlayer(this.pilotId)));");
|
||||
logger.info("Allowing preists of vynora to gain 20% boat speed above 60 faith.");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CtClass ctSimpleCreationEntry = classPool.get("com.wurmonline.server.items.SimpleCreationEntry");
|
||||
ctSimpleCreationEntry.getDeclaredMethod("run").instrument(new ExprEditor() {
|
||||
private boolean first = true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mod.sin.wyvern.bestiary;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.wurmonline.mesh.Tiles;
|
||||
@@ -249,6 +250,9 @@ public class MethodsBestiary {
|
||||
}else if(creature.getTemplate().getTemplateId() == Charger.templateId){
|
||||
return true;
|
||||
}
|
||||
else if(creature.getTemplate().getTemplateId() == CreatureTemplateFactory.UNICORN_CID) {
|
||||
return true;
|
||||
}
|
||||
return creature.isHorse();
|
||||
}
|
||||
|
||||
@@ -649,6 +653,10 @@ public class MethodsBestiary {
|
||||
protected static void sendAddEffect(Communicator comm, long creatureId, byte effectNum){
|
||||
comm.sendAttachEffect(creatureId, effectNum, (byte) 1, (byte) -1, (byte) -1, (byte) 1);
|
||||
}
|
||||
|
||||
protected static void sendRepaintEffect(Communicator comm, long wurmId, byte r, byte g, byte b, byte a) {
|
||||
comm.sendRepaint(wurmId, r, g, b, a, (byte)0);
|
||||
}
|
||||
// - Good Effects -
|
||||
// rift01 [large], rift02 [small]
|
||||
// treasureP [light bubbles]
|
||||
@@ -677,6 +685,13 @@ public class MethodsBestiary {
|
||||
}else if(templateId == FireGiant.templateId){
|
||||
sendAddEffect(comm, creatureId, (byte) 1);
|
||||
}
|
||||
else if(templateId == CreatureTemplateFactory.UNICORN_CID) {
|
||||
Random random = new Random();
|
||||
byte r = (byte)random.nextInt(257);
|
||||
byte g = (byte)random.nextInt(257);
|
||||
byte b = (byte)random.nextInt(257);
|
||||
sendRepaintEffect(comm, creatureId, r, g, b, (byte)255);
|
||||
}
|
||||
}
|
||||
|
||||
public static void preInit(){
|
||||
|
||||
@@ -128,6 +128,11 @@ public class LootBounty {
|
||||
corpse.insertItem(cache);
|
||||
i--;
|
||||
}
|
||||
Item item = ItemFactory.createItem(ItemUtil.getMysteryEggID(), 50, (byte)1, "");
|
||||
if(random.nextInt(100) < 25) {
|
||||
item.setRarity((byte)3);
|
||||
}
|
||||
corpse.insertItem(item);
|
||||
if(mob.isDragon()) {
|
||||
int mTemplate = mob.getTemplate().getTemplateId();
|
||||
int lootTemplate = ItemList.drakeHide;
|
||||
@@ -279,7 +284,7 @@ public class LootBounty {
|
||||
int[] caches = {
|
||||
TreasureMapCache.templateId,
|
||||
GemCache.templateId,
|
||||
RiftCache.templateId
|
||||
CrystalCache.templateId
|
||||
};
|
||||
int cacheSelected = random.nextInt(3);
|
||||
Item item = ItemFactory.createItem(caches[cacheSelected], 20 + random.nextInt(40), "");
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Mastercraft {
|
||||
diff -= skill.affinity;
|
||||
}
|
||||
if(skill.getKnowledge() > 99.0d){
|
||||
diff -= 4d-((100d-skill.getKnowledge())*4d);
|
||||
diff -= 8d-((100d-skill.getKnowledge())*8d);
|
||||
}
|
||||
if(skill.getKnowledge() > 90.0d){
|
||||
diff -= 2d-((100d-skill.getKnowledge())*0.2d);
|
||||
@@ -175,6 +175,10 @@ public class Mastercraft {
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("HeadSmithing_Minor", 1129, "Renowned Headsmither", "Renowned Headsmither", SkillList.SMITHING_WEAPON_HEADS, "MINOR");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("HeadSmithing_Master", 1130, "Master Headsmither", "Master Headsmither", SkillList.SMITHING_WEAPON_HEADS, "MASTER");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("HeadSmithing_Legendary", 1131, "Legendary Headsmither", "Legendary Headsmither", SkillList.SMITHING_WEAPON_HEADS, "LEGENDARY");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Hatchet_Normal", 1132, "Hatcheter", "Hatcheter", SkillList.HATCHET, "NORMAL");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Hatchet_Minor", 1133, "Renowned Hatcheter", "Renowned Hatcheter", SkillList.HATCHET, "MINOR");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Hatchet_Master", 1134, "Master Hatcheter", "Master Hatcheter", SkillList.HATCHET, "MASTER");
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Hatchet_Legendary", 1135, "Hatchslinging Slasher", "Hatchslinging Slasher", SkillList.HATCHET, "LEGENDARY");
|
||||
|
||||
// Skill Titles (100)
|
||||
ExtendTitleEnum.getSingletonInstance().addExtendEntry("Archery_Legendary", 1500, "Legendary Marksman", "Legendary Marksman", 1030, "LEGENDARY");
|
||||
|
||||
39
src/main/java/mod/sin/wyvern/util/TraderItem.java
Normal file
39
src/main/java/mod/sin/wyvern/util/TraderItem.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package mod.sin.wyvern.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class TraderItem {
|
||||
int templateid;
|
||||
int quality;
|
||||
boolean randomQuality;
|
||||
int lowerQuality, upperQuality;
|
||||
int quantity;
|
||||
|
||||
public TraderItem(int templateid, int quality, boolean randomQuality, int lowerQuality, int upperQuality, int quantity) {
|
||||
this.templateid = templateid;
|
||||
this.quality = quality;
|
||||
this.randomQuality = randomQuality;
|
||||
this.lowerQuality = lowerQuality;
|
||||
this.upperQuality = upperQuality;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public int getQuality() {
|
||||
if(!randomQuality) {
|
||||
return quality;
|
||||
}
|
||||
else {
|
||||
Random rand = new Random();
|
||||
int q = lowerQuality + rand.nextInt(upperQuality-lowerQuality);
|
||||
return q;
|
||||
}
|
||||
}
|
||||
|
||||
public int getTemplateid() {
|
||||
return templateid;
|
||||
}
|
||||
|
||||
public int getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user