forked from MagicBane/Server
Start mobequip refactor
This commit is contained in:
@@ -990,10 +990,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
return 300;
|
||||
}
|
||||
float range = 8;
|
||||
if (((Mob) this).getEquip().get(1) != null) {
|
||||
range = ((Mob) this).getEquip().get(1).template.item_weapon_max_range;
|
||||
} else if (((Mob) this).getEquip().get(2) != null) {
|
||||
range = ((Mob) this).getEquip().get(2).template.item_weapon_max_range;
|
||||
if (( this).charItemManager.equipped.get(EquipSlotType.RHELD) != null) {
|
||||
range = ((Mob) this).charItemManager.equipped.get(EquipSlotType.RHELD).template.item_weapon_max_range;
|
||||
} else if (((Mob) this).charItemManager.equipped.get(EquipSlotType.LHELD) != null) {
|
||||
range = ((Mob) this).charItemManager.equipped.get(EquipSlotType.LHELD).template.item_weapon_max_range;
|
||||
}
|
||||
|
||||
// TODO Is this clamp from live?
|
||||
|
||||
@@ -43,7 +43,7 @@ public class CharacterItemManager {
|
||||
private final ConcurrentHashMap<Integer, Integer> itemIDtoType = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
// Mapping of all items equipped in this Manager
|
||||
// Key = Item Slot
|
||||
public final ConcurrentHashMap<Enum.EquipSlotType, Item> equipped = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
public ConcurrentHashMap<Enum.EquipSlotType, Item> equipped = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
private final HashSet<Item> inventory = new HashSet<>();
|
||||
private final HashSet<Item> bank = new HashSet<>();
|
||||
private final HashSet<Item> vault = new HashSet<>();
|
||||
@@ -1203,7 +1203,7 @@ public class CharacterItemManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Used for buying MobEquipment from NPC
|
||||
//Used for buying Item from NPC
|
||||
//Handles the gold transfer aspect
|
||||
|
||||
// This removes ingame item from inventory for loot.
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Contract extends AbstractGameObject {
|
||||
private ArrayList<Integer> npcModTypeTable = new ArrayList<>();
|
||||
private ArrayList<Integer> npcModSuffixTable = new ArrayList<>();
|
||||
private ArrayList<Byte> itemModTable = new ArrayList<>();
|
||||
private ArrayList<MobEquipment> sellInventory = new ArrayList<>();
|
||||
private ArrayList<Item> sellInventory = new ArrayList<>();
|
||||
private EnumBitSet<Enum.BuildingGroup> allowedBuildings;
|
||||
private ArrayList<Integer> buyItemType = new ArrayList<>();
|
||||
private ArrayList<Integer> buySkillToken = new ArrayList<>();
|
||||
@@ -197,7 +197,7 @@ public class Contract extends AbstractGameObject {
|
||||
return itemModTable;
|
||||
}
|
||||
|
||||
public ArrayList<MobEquipment> getSellInventory() {
|
||||
public ArrayList<Item> getSellInventory() {
|
||||
return this.sellInventory;
|
||||
}
|
||||
|
||||
|
||||
+35
-45
@@ -74,7 +74,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
private int currentID;
|
||||
private long lastAttackTime = 0;
|
||||
private int lastMobPowerToken = 0;
|
||||
public HashMap<Enum.EquipSlotType, MobEquipment> equip = null;
|
||||
private DeferredPowerJob weaponPower;
|
||||
private DateTime upgradeDateTime = null;
|
||||
private boolean lootSync = false;
|
||||
@@ -257,12 +256,12 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
|
||||
// get a copy of the equipped items.
|
||||
|
||||
if (mob.equip != null) {
|
||||
if (!mob.charItemManager.equipped.isEmpty()) {
|
||||
|
||||
writer.putInt(mob.equip.size());
|
||||
writer.putInt(mob.charItemManager.equipped.size());
|
||||
|
||||
for (MobEquipment me : mob.equip.values())
|
||||
MobEquipment.serializeForClientMsg(me, writer);
|
||||
for (Item me : mob.charItemManager.equipped.values())
|
||||
Item._serializeForClientMsg(me, writer);
|
||||
} else
|
||||
writer.putInt(0);
|
||||
|
||||
@@ -934,7 +933,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
|
||||
playerAgroMap.clear();
|
||||
|
||||
if (!this.isPlayerGuard() && this.equip != null)
|
||||
if (!this.isPlayerGuard() && this.charItemManager.equipped != null)
|
||||
LootManager.GenerateEquipmentDrop(this);
|
||||
|
||||
}
|
||||
@@ -1122,7 +1121,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
|
||||
public void calculateAtrDefenseDamage() {
|
||||
|
||||
if (this.charItemManager == null || this.equip == null) {
|
||||
if (this.charItemManager == null || this.charItemManager.equipped == null) {
|
||||
Logger.error("Player " + currentID + " missing skills or equipment");
|
||||
defaultAtrAndDamage(true);
|
||||
defaultAtrAndDamage(false);
|
||||
@@ -1141,16 +1140,16 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
this.rangeHandTwo = 6.5f;
|
||||
this.speedHandTwo = 20;
|
||||
|
||||
if (this.equip.get(EquipSlotType.RHELD) != null)
|
||||
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), true); //has mainhand weapon to calculate
|
||||
if (this.charItemManager.equipped.get(EquipSlotType.RHELD) != null)
|
||||
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.LHELD), true); //has mainhand weapon to calculate
|
||||
|
||||
|
||||
if (this.equip.get(EquipSlotType.LHELD) != null && !ItemTemplate.isShield(this.equip.get(EquipSlotType.LHELD).template))
|
||||
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), false); //has offhand weapon to calculate
|
||||
if (this.charItemManager.equipped.get(EquipSlotType.LHELD) != null && !ItemTemplate.isShield(this.charItemManager.equipped.get(EquipSlotType.LHELD).template))
|
||||
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.LHELD), false); //has offhand weapon to calculate
|
||||
|
||||
|
||||
try {
|
||||
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.RHELD), true);
|
||||
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.RHELD), true);
|
||||
} catch (Exception e) {
|
||||
|
||||
this.atrHandOne = (short) this.mobBase.getAttackRating();
|
||||
@@ -1162,7 +1161,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
}
|
||||
|
||||
try {
|
||||
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), false);
|
||||
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.LHELD), false);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1176,14 +1175,14 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
|
||||
try {
|
||||
float defense = this.mobBase.getDefenseRating();
|
||||
defense += getShieldDefense(equip.get(EquipSlotType.LHELD));
|
||||
defense += getArmorDefense(equip.get(EquipSlotType.HELM));
|
||||
defense += getArmorDefense(equip.get(EquipSlotType.CHEST));
|
||||
defense += getArmorDefense(equip.get(EquipSlotType.UPARM));
|
||||
defense += getArmorDefense(equip.get(EquipSlotType.HANDS));
|
||||
defense += getArmorDefense(equip.get(EquipSlotType.LEGS));
|
||||
defense += getArmorDefense(equip.get(EquipSlotType.FEET));
|
||||
defense += getWeaponDefense(equip);
|
||||
defense += getShieldDefense(charItemManager.equipped.get(EquipSlotType.LHELD));
|
||||
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.HELM));
|
||||
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.CHEST));
|
||||
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.UPARM));
|
||||
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.HANDS));
|
||||
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.LEGS));
|
||||
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.FEET));
|
||||
defense += getWeaponDefense(charItemManager.equipped);
|
||||
|
||||
// TODO add error log here
|
||||
if (this.bonuses != null) {
|
||||
@@ -1217,9 +1216,9 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
// calculate defense for equipment
|
||||
}
|
||||
|
||||
private float getWeaponDefense(HashMap<Enum.EquipSlotType, MobEquipment> equipped) {
|
||||
private float getWeaponDefense(ConcurrentHashMap<Enum.EquipSlotType, Item> equipped) {
|
||||
|
||||
MobEquipment weapon = equipped.get(EquipSlotType.RHELD);
|
||||
Item weapon = equipped.get(EquipSlotType.RHELD);
|
||||
ItemBase wb = null;
|
||||
CharacterSkill skill, mastery;
|
||||
float val = 0;
|
||||
@@ -1256,7 +1255,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
return val;
|
||||
}
|
||||
|
||||
private float getShieldDefense(MobEquipment shield) {
|
||||
private float getShieldDefense(Item shield) {
|
||||
|
||||
if (shield == null)
|
||||
return 0;
|
||||
@@ -1285,7 +1284,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
return (def * (1 + ((int) skillMod / 100f)));
|
||||
}
|
||||
|
||||
private float getArmorDefense(MobEquipment armor) {
|
||||
private float getArmorDefense(Item armor) {
|
||||
|
||||
if (armor == null)
|
||||
return 0;
|
||||
@@ -1313,7 +1312,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
return (def * (1 + ((int) armorSkill.getModifiedAmount() / 50f)));
|
||||
}
|
||||
|
||||
private void calculateAtrDamageForWeapon(MobEquipment weapon, boolean mainHand) {
|
||||
private void calculateAtrDamageForWeapon(Item weapon, boolean mainHand) {
|
||||
|
||||
int baseStrength = 0;
|
||||
|
||||
@@ -1501,13 +1500,13 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
public ItemBase getWeaponItemBase(boolean mainHand) {
|
||||
|
||||
if (this.equipmentSetID != 0)
|
||||
if (equip != null) {
|
||||
MobEquipment me;
|
||||
if (charItemManager.equipped != null) {
|
||||
Item me;
|
||||
|
||||
if (mainHand)
|
||||
me = equip.get(1); //mainHand
|
||||
me = charItemManager.equipped.get(EquipSlotType.RHELD); //mainHand
|
||||
else
|
||||
me = equip.get(2); //offHand
|
||||
me = charItemManager.equipped.get(EquipSlotType.LHELD); //offHand
|
||||
|
||||
if (me != null) {
|
||||
|
||||
@@ -1521,14 +1520,14 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
MobBase mb = this.mobBase;
|
||||
|
||||
if (mb != null)
|
||||
if (equip != null) {
|
||||
if (this.charItemManager.equipped.isEmpty() == false) {
|
||||
|
||||
MobEquipment me;
|
||||
Item me;
|
||||
|
||||
if (mainHand)
|
||||
me = equip.get(1); //mainHand
|
||||
me = this.charItemManager.equipped.get(EquipSlotType.RHELD); //mainHand
|
||||
else
|
||||
me = equip.get(2); //offHand
|
||||
me = this.charItemManager.equipped.get(EquipSlotType.LHELD); //offHand
|
||||
|
||||
if (me != null)
|
||||
return me.getItemBase();
|
||||
@@ -1670,14 +1669,9 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
this.loadInventory();
|
||||
|
||||
if (this.equipmentSetID != 0)
|
||||
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
|
||||
this.charItemManager.equipped = MobBase.loadEquipmentSet(this.equipmentSetID);
|
||||
else
|
||||
this.equip = new HashMap<>();
|
||||
|
||||
if (this.equip == null) {
|
||||
Logger.error("Null equipset returned for uuid " + currentID);
|
||||
this.equip = new HashMap<>(0);
|
||||
}
|
||||
this.charItemManager.equipped = new ConcurrentHashMap<>();
|
||||
|
||||
// Combine mobbase and mob aggro arrays into one bitvector
|
||||
//skip for pets
|
||||
@@ -1835,10 +1829,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
||||
this.lootSync = lootSync;
|
||||
}
|
||||
|
||||
public HashMap<Enum.EquipSlotType, MobEquipment> getEquip() {
|
||||
return equip;
|
||||
}
|
||||
|
||||
public String getNameOverride() {
|
||||
return firstName + " " + lastName;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class MobBase extends AbstractGameObject {
|
||||
|
||||
@@ -110,10 +111,10 @@ public class MobBase extends AbstractGameObject {
|
||||
|
||||
}
|
||||
|
||||
public static HashMap<Enum.EquipSlotType, MobEquipment> loadEquipmentSet(int equipmentSetID) {
|
||||
public static ConcurrentHashMap<Enum.EquipSlotType, Item> loadEquipmentSet(int equipmentSetID) {
|
||||
|
||||
ArrayList<BootySetEntry> equipList;
|
||||
HashMap<Enum.EquipSlotType, MobEquipment> equip = new HashMap<>();
|
||||
ConcurrentHashMap<Enum.EquipSlotType, Item> equip = new ConcurrentHashMap<>();
|
||||
|
||||
if (equipmentSetID == 0)
|
||||
return equip;
|
||||
@@ -125,14 +126,10 @@ public class MobBase extends AbstractGameObject {
|
||||
|
||||
for (BootySetEntry equipmentSetEntry : equipList) {
|
||||
|
||||
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.templateID, equipmentSetEntry.dropChance);
|
||||
ItemBase itemBase = mobEquipment.getItemBase();
|
||||
Item item = new Item(equipmentSetEntry.templateID);
|
||||
item.drop_chance = equipmentSetEntry.dropChance;
|
||||
|
||||
// if (itemBase.getType().equals(Enum.ItemType.WEAPON))
|
||||
// if (mobEquipment.getSlot() == 1 && itemBase.getEquipFlag() == 2)
|
||||
// mobEquipment.setSlot(2);
|
||||
|
||||
equip.put(mobEquipment.slot, mobEquipment);
|
||||
equip.put(item.slot, Item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,320 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MobEquipment extends AbstractGameObject {
|
||||
|
||||
private static AtomicInteger equipCounter = new AtomicInteger(0);
|
||||
private final ItemBase itemBase;
|
||||
public Enum.EquipSlotType slot;
|
||||
private int parentID;
|
||||
|
||||
//effects
|
||||
private boolean enchanted;
|
||||
private boolean isID = false;
|
||||
private AbstractPowerAction prefix;
|
||||
private AbstractPowerAction suffix;
|
||||
private int pValue;
|
||||
private int sValue;
|
||||
private int magicValue;
|
||||
|
||||
private float dropChance = 0;
|
||||
public int templateID;
|
||||
public ItemTemplate template;
|
||||
|
||||
/**
|
||||
* No Id Constructor
|
||||
*/
|
||||
public MobEquipment(ItemTemplate template, Enum.EquipSlotType slot, int parentID) {
|
||||
super(MobEquipment.getNewID());
|
||||
this.templateID = template.template_id;
|
||||
this.template = ItemTemplate.templates.get(templateID);
|
||||
this.itemBase = ItemBase.getItemBase(templateID);
|
||||
this.slot = slot;
|
||||
this.parentID = parentID;
|
||||
this.enchanted = false;
|
||||
this.prefix = null;
|
||||
this.suffix = null;
|
||||
this.pValue = 0;
|
||||
this.sValue = 0;
|
||||
setMagicValue();
|
||||
}
|
||||
|
||||
public MobEquipment(int templateID, float dropChance) {
|
||||
super(MobEquipment.getNewID());
|
||||
this.itemBase = ItemBase.getItemBase(templateID);
|
||||
this.templateID = templateID;
|
||||
this.template = ItemTemplate.templates.get(this.templateID);
|
||||
|
||||
Enum.EquipSlotType equipSlot = template.item_eq_slots_or.iterator().next();
|
||||
|
||||
this.slot = equipSlot;
|
||||
this.dropChance = dropChance;
|
||||
|
||||
this.parentID = 0;
|
||||
setMagicValue();
|
||||
}
|
||||
|
||||
public static int getNewID() {
|
||||
return MobEquipment.equipCounter.incrementAndGet();
|
||||
}
|
||||
|
||||
public static void serializeForVendor(MobEquipment mobEquipment, ByteBufferWriter writer, float percent) throws SerializationException {
|
||||
_serializeForClientMsg(mobEquipment, writer, false);
|
||||
writer.putInt(mobEquipment.magicValue);
|
||||
writer.putInt(mobEquipment.magicValue);
|
||||
}
|
||||
|
||||
public static void serializeForClientMsg(MobEquipment mobEquipment, ByteBufferWriter writer) throws SerializationException {
|
||||
_serializeForClientMsg(mobEquipment, writer, true);
|
||||
}
|
||||
|
||||
public static void _serializeForClientMsg(MobEquipment mobEquipment, ByteBufferWriter writer, boolean useSlot) throws SerializationException {
|
||||
|
||||
if (useSlot)
|
||||
writer.putInt(mobEquipment.slot.ordinal());
|
||||
writer.putInt(0); // Pad
|
||||
writer.putInt(mobEquipment.templateID);
|
||||
writer.putInt(mobEquipment.getObjectType().ordinal());
|
||||
writer.putInt(mobEquipment.getObjectUUID());
|
||||
|
||||
// Unknown statics
|
||||
for (int i = 0; i < 3; i++) {
|
||||
writer.putInt(0); // Pad
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
writer.putInt(0x3F800000); // Static
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
writer.putInt(0); // Pad
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
writer.putInt(0xFFFFFFFF); // Static
|
||||
}
|
||||
|
||||
writer.putInt(0);
|
||||
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
writer.putInt(0); // Unknown. pad?
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
|
||||
writer.putFloat(mobEquipment.template.item_health_full);
|
||||
writer.putFloat(mobEquipment.template.item_health_full);
|
||||
|
||||
writer.put((byte) 1); // End Datablock byte
|
||||
|
||||
writer.putInt(0); // Pad
|
||||
writer.putInt(0); // Pad
|
||||
|
||||
writer.putInt(mobEquipment.template.item_value);
|
||||
writer.putInt(mobEquipment.magicValue);
|
||||
|
||||
serializeEffects(mobEquipment, writer);
|
||||
|
||||
writer.putInt(0x00000000);
|
||||
|
||||
//name color, think mobEquipment is where mobEquipment goes
|
||||
if (mobEquipment.enchanted)
|
||||
if (mobEquipment.isID)
|
||||
writer.putInt(36);
|
||||
else
|
||||
writer.putInt(40);
|
||||
else
|
||||
writer.putInt(4);
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(0); // Pad
|
||||
writer.putInt(1);
|
||||
writer.putShort((short) 0);
|
||||
writer.put((byte) 0);
|
||||
}
|
||||
|
||||
public static void serializeEffects(MobEquipment mobEquipment, ByteBufferWriter writer) {
|
||||
|
||||
//skip sending effects if not IDed
|
||||
if (!mobEquipment.isID) {
|
||||
writer.putInt(0);
|
||||
return;
|
||||
}
|
||||
|
||||
//handle effect count
|
||||
int cnt = 0;
|
||||
EffectsBase pre = null;
|
||||
EffectsBase suf = null;
|
||||
|
||||
if (mobEquipment.prefix != null) {
|
||||
pre = PowersManager.getEffectByIDString(mobEquipment.prefix.getIDString());
|
||||
if (pre != null)
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if (mobEquipment.suffix != null) {
|
||||
suf = PowersManager.getEffectByIDString(mobEquipment.suffix.getIDString());
|
||||
if (suf != null)
|
||||
cnt++;
|
||||
}
|
||||
|
||||
writer.putInt(cnt);
|
||||
|
||||
//serialize prefix
|
||||
if (pre != null)
|
||||
serializeEffect(mobEquipment, writer, pre, mobEquipment.pValue);
|
||||
|
||||
//serialize suffix
|
||||
if (suf != null)
|
||||
serializeEffect(mobEquipment, writer, suf, mobEquipment.sValue);
|
||||
}
|
||||
|
||||
public static void serializeEffect(MobEquipment mobEquipment, ByteBufferWriter writer, EffectsBase eb, int rank) {
|
||||
String name;
|
||||
if (eb.isPrefix()) {
|
||||
if (mobEquipment.itemBase == null)
|
||||
name = eb.getName();
|
||||
else
|
||||
name = eb.getName() + ' ' + ItemTemplate.templates.get(mobEquipment.itemBase.getUUID()).item_base_name;
|
||||
} else if (eb.isSuffix()) {
|
||||
if (mobEquipment.itemBase == null)
|
||||
name = eb.getName();
|
||||
else
|
||||
name = ItemTemplate.templates.get(mobEquipment.itemBase.getUUID()).item_base_name + ' ' + eb.getName();
|
||||
} else {
|
||||
if (mobEquipment.itemBase == null)
|
||||
name = "";
|
||||
else
|
||||
name = ItemTemplate.templates.get(mobEquipment.itemBase.getUUID()).item_base_name;
|
||||
}
|
||||
|
||||
writer.putInt(eb.getToken());
|
||||
writer.putInt(rank);
|
||||
writer.putInt(1);
|
||||
writer.put((byte) 1);
|
||||
writer.putInt(mobEquipment.getObjectType().ordinal());
|
||||
writer.putInt(mobEquipment.getObjectUUID());
|
||||
writer.putString(name);
|
||||
writer.putFloat(-1000f);
|
||||
}
|
||||
|
||||
public ItemBase getItemBase() {
|
||||
return itemBase;
|
||||
}
|
||||
public final void setMagicValue() {
|
||||
float value = 1;
|
||||
if (itemBase != null)
|
||||
value = template.item_value;
|
||||
if (this.prefix != null) {
|
||||
if (this.prefix.getEffectsBase() != null)
|
||||
value += this.prefix.getEffectsBase().getValue();
|
||||
if (this.prefix.getEffectsBase2() != null)
|
||||
value += this.prefix.getEffectsBase2().getValue();
|
||||
}
|
||||
if (this.suffix != null) {
|
||||
if (this.suffix.getEffectsBase() != null)
|
||||
value += this.suffix.getEffectsBase().getValue();
|
||||
if (this.suffix.getEffectsBase2() != null)
|
||||
value += this.suffix.getEffectsBase2().getValue();
|
||||
}
|
||||
|
||||
if (itemBase != null)
|
||||
|
||||
for (String effectID : this.template.item_user_power_action.keySet()) {
|
||||
|
||||
AbstractPowerAction apa = PowersManager.getPowerActionByIDString(effectID);
|
||||
|
||||
if (apa.getEffectsBase() != null)
|
||||
if (apa.getEffectsBase().getValue() > 0)
|
||||
value += apa.getEffectsBase().getValue();
|
||||
|
||||
if (apa.getEffectsBase2() != null)
|
||||
value += apa.getEffectsBase2().getValue();
|
||||
}
|
||||
|
||||
this.magicValue = (int) value;
|
||||
}
|
||||
|
||||
public int getMagicValue() {
|
||||
|
||||
if (!this.isID) {
|
||||
return template.item_value;
|
||||
}
|
||||
return this.magicValue;
|
||||
}
|
||||
|
||||
public void setPrefix(String pIDString, int pValue) {
|
||||
AbstractPowerAction apa = PowersManager.getPowerActionByIDString(pIDString);
|
||||
if (apa != null) {
|
||||
this.prefix = apa;
|
||||
this.pValue = pValue;
|
||||
} else
|
||||
this.prefix = null;
|
||||
|
||||
this.enchanted = this.prefix != null || this.suffix != null;
|
||||
|
||||
setMagicValue();
|
||||
}
|
||||
|
||||
public void setSuffix(String sIDString, int sValue) {
|
||||
AbstractPowerAction apa = PowersManager.getPowerActionByIDString(sIDString);
|
||||
if (apa != null) {
|
||||
this.suffix = apa;
|
||||
this.sValue = sValue;
|
||||
} else
|
||||
this.suffix = null;
|
||||
|
||||
this.enchanted = this.prefix != null || this.suffix != null;
|
||||
|
||||
setMagicValue();
|
||||
}
|
||||
|
||||
public void setIsID(boolean value) {
|
||||
this.isID = value;
|
||||
}
|
||||
|
||||
public boolean isID() {
|
||||
return this.isID;
|
||||
}
|
||||
|
||||
public void transferEnchants(Item item) {
|
||||
if (this.prefix != null) {
|
||||
String IDString = this.prefix.getIDString();
|
||||
item.addPermanentEnchantment(IDString, this.pValue);
|
||||
}
|
||||
if (this.suffix != null) {
|
||||
String IDString = this.suffix.getIDString();
|
||||
item.addPermanentEnchantment(IDString, this.sValue);
|
||||
}
|
||||
if (this.isID)
|
||||
item.setIsID(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Database
|
||||
*/
|
||||
@Override
|
||||
public void updateDatabase() {
|
||||
}
|
||||
|
||||
|
||||
public float getDropChance() {
|
||||
return dropChance;
|
||||
}
|
||||
|
||||
public void setDropChance(float dropChance) {
|
||||
this.dropChance = dropChance;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class NPC extends AbstractCharacter {
|
||||
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
|
||||
public HashMap<Enum.EquipSlotType, MobEquipment> equip = null;
|
||||
public HashMap<Enum.EquipSlotType, Item> equip = null;
|
||||
public int runeSetID = 0;
|
||||
public int extraRune2 = 0;
|
||||
protected int loadID;
|
||||
@@ -344,8 +344,8 @@ public class NPC extends AbstractCharacter {
|
||||
if (npc.equip != null) {
|
||||
writer.putInt(npc.equip.size());
|
||||
|
||||
for (MobEquipment me : npc.equip.values())
|
||||
MobEquipment.serializeForClientMsg(me, writer);
|
||||
for (Item me : npc.equip.values())
|
||||
Item.serializeForClientMsg(me, writer);
|
||||
} else
|
||||
writer.putInt(0);
|
||||
|
||||
@@ -1265,7 +1265,7 @@ public class NPC extends AbstractCharacter {
|
||||
return true;
|
||||
}
|
||||
|
||||
public HashMap<Enum.EquipSlotType, MobEquipment> getEquip() {
|
||||
public HashMap<Enum.EquipSlotType, Item> getEquip() {
|
||||
return equip;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user