Update to latest stable WyvernMods (1.6).
This commit is contained in:
@@ -4,6 +4,8 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.wurmonline.server.MiscConstants;
|
||||
import mod.sin.wyvern.util.ItemUtil;
|
||||
import org.gotti.wurmunlimited.modsupport.actions.ModActions;
|
||||
|
||||
import com.pveplands.treasurehunting.Treasuremap;
|
||||
@@ -29,7 +31,7 @@ import mod.sin.weapons.*;
|
||||
public class Caches {
|
||||
public static final Logger logger = Logger.getLogger(Caches.class.getName());
|
||||
|
||||
public static ArrayList<Integer> CACHE_IDS = new ArrayList<Integer>();
|
||||
public static ArrayList<Integer> CACHE_IDS = new ArrayList<>();
|
||||
|
||||
public static AnimalCache ANIMAL_CACHE = new AnimalCache();
|
||||
public static ArmourCache ARMOUR_CACHE = new ArmourCache();
|
||||
@@ -40,31 +42,31 @@ public class Caches {
|
||||
public static MoonCache MOON_CACHE = new MoonCache();
|
||||
public static PotionCache POTION_CACHE = new PotionCache();
|
||||
public static RiftCache RIFT_CACHE = new RiftCache();
|
||||
public static TitanCache TITAN_CACHE = new TitanCache();
|
||||
public static ToolCache TOOL_CACHE = new ToolCache();
|
||||
public static TreasureMapCache TREASUREMAP_CACHE = new TreasureMapCache();
|
||||
public static WeaponCache WEAPON_CACHE = new WeaponCache();
|
||||
|
||||
public static float minimumQuality = 10f;
|
||||
|
||||
public static boolean isTreasureCache(Item item){
|
||||
int templateId = item.getTemplateId();
|
||||
if(CACHE_IDS.contains(templateId)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return CACHE_IDS.contains(templateId);
|
||||
}
|
||||
|
||||
public static float getBaseQuality(float quality){
|
||||
return quality*0.5f;
|
||||
return quality*0.2f;
|
||||
}
|
||||
public static float getRandomQuality(float quality){
|
||||
return quality*0.55f;
|
||||
return quality*0.5f;
|
||||
}
|
||||
public static float getWeightMultiplier(int templateId, float quality){
|
||||
if(templateId == DragonCache.templateId){
|
||||
return (quality*0.005f)+(quality*0.001f*Server.rand.nextFloat());
|
||||
return 0.005f+(quality*0.0005f)+(quality*0.0001f*Server.rand.nextFloat());
|
||||
}else if(templateId == MoonCache.templateId){
|
||||
return 1f+(quality*0.05f)+(quality*0.05f*Server.rand.nextFloat());
|
||||
return 1f+(quality*0.005f)+(quality*0.005f*Server.rand.nextFloat());
|
||||
}
|
||||
return 1f+(quality*0.02f);
|
||||
return 1f+(quality*0.002f);
|
||||
}
|
||||
public static boolean adjustBasicWeight(int templateId){
|
||||
if(templateId == DragonCache.templateId){
|
||||
@@ -74,21 +76,11 @@ public class Caches {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static void applyEnchant(Item item, byte enchant, float power){
|
||||
ItemSpellEffects effs = item.getSpellEffects();
|
||||
if(effs == null){
|
||||
effs = new ItemSpellEffects(item.getWurmId());
|
||||
}
|
||||
SpellEffect eff = new SpellEffect(item.getWurmId(), enchant, power, 20000000);
|
||||
effs.addSpellEffect(eff);
|
||||
if(item.getDescription().length() > 0){
|
||||
item.setDescription(item.getDescription()+" ");
|
||||
}
|
||||
item.setDescription(item.getDescription()+eff.getName().substring(0,1)+Math.round(power));
|
||||
}
|
||||
|
||||
public static boolean createsCustomBasic(int templateId){
|
||||
if(templateId == TreasureMapCache.templateId){
|
||||
if(templateId == TitanCache.templateId){
|
||||
return true;
|
||||
}else if(templateId == TreasureMapCache.templateId){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -96,7 +88,16 @@ public class Caches {
|
||||
|
||||
public static void getCustomBasic(Creature performer, Item cache){
|
||||
int templateId = cache.getTemplateId();
|
||||
if(templateId == TreasureMapCache.templateId){
|
||||
if(templateId == TitanCache.templateId){
|
||||
Item efficiencyTool = ItemUtil.createRandomToolWeapon(20f, 40f, cache.getCreatorName());
|
||||
ItemUtil.applyEnchant(efficiencyTool, (byte) 114, 40f+(20f*Server.rand.nextFloat())); // Efficiency enchant is 114
|
||||
if(efficiencyTool.isMetal()){
|
||||
efficiencyTool.setMaterial(Server.rand.nextBoolean() ? Materials.MATERIAL_ADAMANTINE : Materials.MATERIAL_GLIMMERSTEEL);
|
||||
}else if(efficiencyTool.isWood()){
|
||||
efficiencyTool.setMaterial(Materials.MATERIAL_WOOD_WILLOW);
|
||||
}
|
||||
performer.getInventory().insertItem(efficiencyTool, true);
|
||||
}else if(templateId == TreasureMapCache.templateId){
|
||||
Item map = Treasuremap.CreateTreasuremap(performer, cache, null, null, true);
|
||||
map.setRarity(cache.getRarity());
|
||||
performer.getInventory().insertItem(map, true);
|
||||
@@ -117,7 +118,7 @@ public class Caches {
|
||||
ItemList.axeSmall, ItemList.axeMedium, ItemList.axeHuge,
|
||||
ItemList.maulSmall, ItemList.maulMedium, ItemList.maulLarge,
|
||||
ItemList.spearLong, ItemList.staffSteel, ItemList.halberd,
|
||||
Club.templateId, Knuckles.templateId, Warhammer.templateId
|
||||
Knuckles.templateId, Warhammer.templateId
|
||||
};
|
||||
}else if(templateId == CrystalCache.templateId){
|
||||
return new int[]{
|
||||
@@ -129,8 +130,8 @@ public class Caches {
|
||||
ItemList.drakeHide,
|
||||
ItemList.drakeHide,
|
||||
ItemList.dragonScale,
|
||||
ItemList.dragonScale,
|
||||
SpectralHide.templateId
|
||||
ItemList.dragonScale
|
||||
//SpectralHide.templateId
|
||||
};
|
||||
}else if(templateId == GemCache.templateId){
|
||||
return new int[]{
|
||||
@@ -142,8 +143,9 @@ public class Caches {
|
||||
};
|
||||
}else if(templateId == MoonCache.templateId){
|
||||
return new int[]{
|
||||
ItemList.glimmerSteelBar,
|
||||
ItemList.adamantineBar
|
||||
ItemList.glimmerSteelBar, ItemList.glimmerSteelBar, ItemList.glimmerSteelBar, ItemList.glimmerSteelBar, ItemList.glimmerSteelBar,
|
||||
ItemList.adamantineBar, ItemList.adamantineBar, ItemList.adamantineBar, ItemList.adamantineBar, ItemList.adamantineBar,
|
||||
ItemList.seryllBar
|
||||
};
|
||||
}else if(templateId == PotionCache.templateId){
|
||||
return new int[]{
|
||||
@@ -177,14 +179,14 @@ public class Caches {
|
||||
if(templateId == ArmourCache.templateId){
|
||||
if(quality > 50){
|
||||
if(quality > 95 && Server.rand.nextBoolean()){
|
||||
applyEnchant(item, Enchants.BUFF_SHARED_PAIN, quality*Server.rand.nextFloat()*1.2f);
|
||||
applyEnchant(item, Enchants.BUFF_WEBARMOUR, quality*Server.rand.nextFloat()*1.2f);
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_SHARED_PAIN, quality*Server.rand.nextFloat()*0.7f);
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_WEBARMOUR, quality*Server.rand.nextFloat()*0.7f);
|
||||
}else if(Server.rand.nextBoolean()){
|
||||
byte[] armourEnchants = {
|
||||
Enchants.BUFF_SHARED_PAIN,
|
||||
Enchants.BUFF_WEBARMOUR
|
||||
};
|
||||
applyEnchant(item, armourEnchants[Server.rand.nextInt(armourEnchants.length)], quality*Server.rand.nextFloat()*1.5f);
|
||||
ItemUtil.applyEnchant(item, armourEnchants[Server.rand.nextInt(armourEnchants.length)], quality*Server.rand.nextFloat()*1.5f);
|
||||
}
|
||||
}
|
||||
if(quality > 80 && Server.rand.nextInt(4) == 0){
|
||||
@@ -209,39 +211,41 @@ public class Caches {
|
||||
byte[] materials = {
|
||||
Materials.MATERIAL_ADAMANTINE,
|
||||
Materials.MATERIAL_GLIMMERSTEEL,
|
||||
Materials.MATERIAL_SERYLL,
|
||||
Materials.MATERIAL_STEEL,
|
||||
Materials.MATERIAL_STEEL
|
||||
};
|
||||
item.setMaterial(materials[Server.rand.nextInt(materials.length)]);
|
||||
float qualBoost = (100f-item.getQualityLevel())*Server.rand.nextFloat();
|
||||
item.setQualityLevel(item.getQualityLevel()+qualBoost);
|
||||
if(quality > 50 && Server.rand.nextInt(200) < quality){
|
||||
item.setQualityLevel(item.getQualityLevel());
|
||||
if(Server.rand.nextInt(400) < quality){
|
||||
if(item.getRarity() == 0){
|
||||
if(Server.rand.nextInt(600) < quality){
|
||||
item.setRarity((byte) 2);
|
||||
if(Server.rand.nextInt(900) < quality){
|
||||
item.setRarity(MiscConstants.SUPREME);
|
||||
}else{
|
||||
item.setRarity((byte) 1);
|
||||
item.setRarity(MiscConstants.RARE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(quality > 70 && Server.rand.nextBoolean()){
|
||||
if(Server.rand.nextBoolean()){
|
||||
byte[] enchants = {
|
||||
Enchants.BUFF_WIND_OF_AGES,
|
||||
Enchants.BUFF_BLESSINGDARK
|
||||
};
|
||||
applyEnchant(item, enchants[Server.rand.nextInt(enchants.length)], quality*Server.rand.nextFloat()*0.9f);
|
||||
applyEnchant(item, Enchants.BUFF_NIMBLENESS, quality*Server.rand.nextFloat()*1.2f);
|
||||
}else{
|
||||
applyEnchant(item, Enchants.BUFF_LIFETRANSFER, quality+(quality*Server.rand.nextFloat()));
|
||||
}
|
||||
if(quality > 50 && Server.rand.nextBoolean()){
|
||||
byte[] enchants = {
|
||||
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);
|
||||
}else if(quality > 30){
|
||||
ItemUtil.applyEnchant(item, Enchants.BUFF_LIFETRANSFER, quality*0.6f+(quality*0.6f*Server.rand.nextFloat()));
|
||||
}
|
||||
}else if(templateId == CrystalCache.templateId){
|
||||
item.setQualityLevel(Server.rand.nextFloat()*quality);
|
||||
if(Server.rand.nextInt(500) < quality){
|
||||
item.setRarity(MiscConstants.RARE);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static int getBasicNums(int templateId){
|
||||
if(templateId == CrystalCache.templateId){
|
||||
return 15;
|
||||
return Server.rand.nextInt(5)+5;
|
||||
}else if(templateId == GemCache.templateId){
|
||||
return 2;
|
||||
}
|
||||
@@ -251,7 +255,7 @@ public class Caches {
|
||||
if(templateId == ArmourCache.templateId){
|
||||
return Server.rand.nextInt(2);
|
||||
}else if(templateId == CrystalCache.templateId){
|
||||
return Server.rand.nextInt(Math.max((int) (quality*0.3f), 2));
|
||||
return Server.rand.nextInt(Math.max((int) (quality*0.08f), 2));
|
||||
}else if(templateId == DragonCache.templateId){
|
||||
if(Server.rand.nextInt(200) <= quality){
|
||||
return 1;
|
||||
@@ -272,17 +276,19 @@ public class Caches {
|
||||
return 0;
|
||||
}
|
||||
public static int getExtraItemChance(int templateId){
|
||||
if(templateId == ArmourCache.templateId){
|
||||
/*if(templateId == ArmourCache.templateId){
|
||||
return 1600;
|
||||
}else if(templateId == DragonCache.templateId){
|
||||
return 600;
|
||||
}else*/ if(templateId == DragonCache.templateId){
|
||||
return 500;
|
||||
}else if(templateId == GemCache.templateId){
|
||||
return 200;
|
||||
return 150;
|
||||
}else if(templateId == MoonCache.templateId){
|
||||
return 500;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static int[] getExtraTemplates(int templateId){
|
||||
if(templateId == ArmourCache.templateId){
|
||||
/*if(templateId == ArmourCache.templateId){
|
||||
return new int[]{
|
||||
GlimmerscaleBoot.templateId,
|
||||
GlimmerscaleGlove.templateId,
|
||||
@@ -297,7 +303,7 @@ public class Caches {
|
||||
SpectralJacket.templateId,
|
||||
SpectralSleeve.templateId
|
||||
};
|
||||
}else if(templateId == DragonCache.templateId){
|
||||
}else*/ if(templateId == DragonCache.templateId){
|
||||
return new int[]{
|
||||
ItemList.dragonLeatherBoot,
|
||||
ItemList.dragonLeatherCap,
|
||||
@@ -319,6 +325,23 @@ public class Caches {
|
||||
ItemList.rubyStar,
|
||||
ItemList.sapphireStar
|
||||
};
|
||||
}else if(templateId == MoonCache.templateId){
|
||||
return new int[]{
|
||||
ItemList.chainSleeve,
|
||||
ItemList.chainJacket,
|
||||
ItemList.chainHose,
|
||||
ItemList.chainGlove,
|
||||
ItemList.chainCoif,
|
||||
ItemList.chainBoot,
|
||||
ItemList.plateSleeve,
|
||||
ItemList.plateJacket,
|
||||
ItemList.plateHose,
|
||||
ItemList.plateBoot,
|
||||
ItemList.plateGauntlet,
|
||||
ItemList.helmetOpen,
|
||||
ItemList.helmetGreat,
|
||||
ItemList.helmetBasinet
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -328,6 +351,8 @@ public class Caches {
|
||||
item.setColor(WurmColor.createColor(100, 100, 100));
|
||||
}else if(templateId == DragonCache.templateId){
|
||||
item.setMaterial(Materials.MATERIAL_LEATHER);
|
||||
}else if(templateId == MoonCache.templateId){
|
||||
item.setMaterial(Server.rand.nextBoolean() ? Materials.MATERIAL_ADAMANTINE : Materials.MATERIAL_GLIMMERSTEEL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +376,7 @@ public class Caches {
|
||||
while(i < basicNums){
|
||||
try {
|
||||
float basicQuality = Math.max(baseQL+(randQL*Server.rand.nextFloat()), baseQL+(randQL*Server.rand.nextFloat()));
|
||||
basicQuality = Math.min(basicQuality, 100f);
|
||||
basicQuality = Math.min(minimumQuality+basicQuality, 100f);
|
||||
Item basicItem = ItemFactory.createItem(basicTemplates[Server.rand.nextInt(basicTemplates.length)], basicQuality, "");
|
||||
basicItem.setRarity(cache.getRarity());
|
||||
adjustBasicItem(templateId, quality, basicItem);
|
||||
@@ -373,7 +398,7 @@ public class Caches {
|
||||
int[] extraTemplates = getExtraTemplates(templateId);
|
||||
if(extraTemplates != null){
|
||||
float extraQuality = Math.max(baseQL+(randQL*Server.rand.nextFloat()), baseQL+(randQL*Server.rand.nextFloat()));
|
||||
extraQuality = Math.min(extraQuality, 100f);
|
||||
extraQuality = Math.min(minimumQuality+extraQuality, 100f);
|
||||
Item extraItem = ItemFactory.createItem(extraTemplates[Server.rand.nextInt(extraTemplates.length)], extraQuality, "");
|
||||
extraItem.setRarity(cache.getRarity());
|
||||
adjustExtraItem(templateId, extraItem);
|
||||
@@ -406,6 +431,8 @@ public class Caches {
|
||||
CACHE_IDS.add(PotionCache.templateId);
|
||||
RIFT_CACHE.createTemplate();
|
||||
CACHE_IDS.add(RiftCache.templateId);
|
||||
TITAN_CACHE.createTemplate();
|
||||
CACHE_IDS.add(TitanCache.templateId);
|
||||
TOOL_CACHE.createTemplate();
|
||||
//CACHE_IDS.add(ToolCache.templateId);
|
||||
TREASUREMAP_CACHE.createTemplate();
|
||||
|
||||
Reference in New Issue
Block a user