forked from MagicBane/Server
Start mobequip refactor
This commit is contained in:
@@ -1648,7 +1648,6 @@ public class Enum {
|
|||||||
Mine,
|
Mine,
|
||||||
Mob,
|
Mob,
|
||||||
MobBase,
|
MobBase,
|
||||||
MobEquipment,
|
|
||||||
MobLoot,
|
MobLoot,
|
||||||
MobType,
|
MobType,
|
||||||
NPC,
|
NPC,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import engine.Enum;
|
|||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.objects.Contract;
|
import engine.objects.Contract;
|
||||||
import engine.objects.ItemTemplate;
|
import engine.objects.ItemTemplate;
|
||||||
import engine.objects.MobEquipment;
|
import engine.objects.Item;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -65,7 +65,7 @@ public class dbContractHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
int templateID = rs.getInt("itembaseID");
|
int templateID = rs.getInt("itembaseID");
|
||||||
|
|
||||||
MobEquipment me = new MobEquipment(ItemTemplate.templates.get(templateID), Enum.EquipSlotType.NONE, 0);
|
Item me = new Item(ItemTemplate.templates.get(templateID), Enum.EquipSlotType.NONE, 0);
|
||||||
contract.getSellInventory().add(me);
|
contract.getSellInventory().add(me);
|
||||||
|
|
||||||
//handle magic effects
|
//handle magic effects
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ public class PrintEffectsCmd extends AbstractDevCmd {
|
|||||||
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
|
public static ItemBase getWeaponBase(int slot, HashMap<Integer, Item> equip) {
|
||||||
if (equip.containsKey(slot)) {
|
if (equip.containsKey(slot)) {
|
||||||
MobEquipment item = equip.get(slot);
|
Item item = equip.get(slot);
|
||||||
if (item != null && item.getItemBase() != null) {
|
if (item != null && item.getItemBase() != null) {
|
||||||
return item.getItemBase();
|
return item.getItemBase();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
|||||||
Mob tarMob = (Mob) tar;
|
Mob tarMob = (Mob) tar;
|
||||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||||
for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) {
|
for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) {
|
||||||
MobEquipment equip = tarMob.getEquip().get(slot);
|
Item equip = tarMob.getEquip().get(slot);
|
||||||
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
|
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -75,7 +75,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
|
|||||||
NPC tarMob = (NPC) tar;
|
NPC tarMob = (NPC) tar;
|
||||||
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
|
||||||
for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) {
|
for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) {
|
||||||
MobEquipment equip = tarMob.getEquip().get(slot);
|
Item equip = tarMob.getEquip().get(slot);
|
||||||
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
|
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ public class PrintRunesCmd extends AbstractDevCmd {
|
|||||||
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
|
public static ItemBase getWeaponBase(int slot, HashMap<Integer, Item> equip) {
|
||||||
if (equip.containsKey(slot)) {
|
if (equip.containsKey(slot)) {
|
||||||
MobEquipment item = equip.get(slot);
|
Item item = equip.get(slot);
|
||||||
if (item != null && item.getItemBase() != null) {
|
if (item != null && item.getItemBase() != null) {
|
||||||
return item.getItemBase();
|
return item.getItemBase();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
|||||||
out += "Defense: " + tar.getDefenseRating() + newline;
|
out += "Defense: " + tar.getDefenseRating() + newline;
|
||||||
|
|
||||||
//get weapons
|
//get weapons
|
||||||
HashMap<Enum.EquipSlotType, MobEquipment> equip = tar.getEquip();
|
HashMap<Enum.EquipSlotType, Item> equip = tar.getEquip();
|
||||||
|
|
||||||
if(equip != null){
|
if(equip != null){
|
||||||
if (equip.get(2) != null && !ItemTemplate.isShield(equip.get(2).template)) {
|
if (equip.get(2) != null && !ItemTemplate.isShield(equip.get(2).template)) {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
|||||||
failures++;
|
failures++;
|
||||||
}
|
}
|
||||||
if (mob.getEquip() != null) {
|
if (mob.getEquip() != null) {
|
||||||
for (MobEquipment me : mob.getEquip().values()) {
|
for (Item me : mob.getEquip().values()) {
|
||||||
|
|
||||||
if (me.getDropChance() == 0)
|
if (me.getDropChance() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ public enum LootManager {
|
|||||||
//do equipment here
|
//do equipment here
|
||||||
int dropCount = 0;
|
int dropCount = 0;
|
||||||
if (mob.getEquip() != null)
|
if (mob.getEquip() != null)
|
||||||
for (MobEquipment me : mob.getEquip().values()) {
|
for (Item me : mob.getEquip().values()) {
|
||||||
|
|
||||||
if (me.getDropChance() == 0)
|
if (me.getDropChance() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ public enum NPCManager {
|
|||||||
}else{
|
}else{
|
||||||
if (guard.equip.containsKey(Enum.EquipSlotType.RHELD)) {
|
if (guard.equip.containsKey(Enum.EquipSlotType.RHELD)) {
|
||||||
//has main hand weapon
|
//has main hand weapon
|
||||||
MobEquipment weapon = guard.equip.get(Enum.EquipSlotType.RHELD);
|
Item weapon = guard.equip.get(Enum.EquipSlotType.RHELD);
|
||||||
|
|
||||||
if (weapon.template.item_primary_attr.equals(Enum.AttributeType.Strength))
|
if (weapon.template.item_primary_attr.equals(Enum.AttributeType.Strength))
|
||||||
primaryStat = guard.getStatStrCurrent();
|
primaryStat = guard.getStatStrCurrent();
|
||||||
@@ -313,7 +313,7 @@ public enum NPCManager {
|
|||||||
guard.rangeHandOne = weapon.template.item_weapon_max_range;
|
guard.rangeHandOne = weapon.template.item_weapon_max_range;
|
||||||
} else if (guard.equip.containsKey(Enum.EquipSlotType.LHELD) && !ItemTemplate.isShield(guard.equip.get(Enum.EquipSlotType.LHELD).template)) {
|
} else if (guard.equip.containsKey(Enum.EquipSlotType.LHELD) && !ItemTemplate.isShield(guard.equip.get(Enum.EquipSlotType.LHELD).template)) {
|
||||||
//has off hand weapon
|
//has off hand weapon
|
||||||
MobEquipment weapon = guard.equip.get(Enum.EquipSlotType.LHELD);
|
Item weapon = guard.equip.get(Enum.EquipSlotType.LHELD);
|
||||||
if (weapon.template.item_primary_attr.equals(Enum.AttributeType.Strength))
|
if (weapon.template.item_primary_attr.equals(Enum.AttributeType.Strength))
|
||||||
primaryStat = guard.getStatStrCurrent();
|
primaryStat = guard.getStatStrCurrent();
|
||||||
else
|
else
|
||||||
@@ -338,7 +338,7 @@ public enum NPCManager {
|
|||||||
dexterity = 1;
|
dexterity = 1;
|
||||||
int baseDef = guard.mobBase.getDefenseRating();
|
int baseDef = guard.mobBase.getDefenseRating();
|
||||||
int armorDefense = 0;
|
int armorDefense = 0;
|
||||||
for(MobEquipment equipped : guard.equip.values())
|
for(Item equipped : guard.equip.values())
|
||||||
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR) || ItemTemplate.isShield(equipped.template))
|
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR) || ItemTemplate.isShield(equipped.template))
|
||||||
armorDefense += equipped.template.item_defense_rating;
|
armorDefense += equipped.template.item_defense_rating;
|
||||||
guard.defenseRating = dexterity + baseDef + armorDefense;
|
guard.defenseRating = dexterity + baseDef + armorDefense;
|
||||||
@@ -427,7 +427,7 @@ public enum NPCManager {
|
|||||||
if (mob.equip == null)
|
if (mob.equip == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (MobEquipment equipped : mob.equip.values()) {
|
for (Item equipped : mob.equip.values()) {
|
||||||
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR)) {
|
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR)) {
|
||||||
mob.resists.setResist(Enum.SourceType.SLASHING, mob.resists.getResist(Enum.SourceType.SLASHING, 0) + equipped.template.combat_attack_resist.get("SLASHING"));
|
mob.resists.setResist(Enum.SourceType.SLASHING, mob.resists.getResist(Enum.SourceType.SLASHING, 0) + equipped.template.combat_attack_resist.get("SLASHING"));
|
||||||
mob.resists.setResist(Enum.SourceType.CRUSHING, mob.resists.getResist(Enum.SourceType.CRUSHING, 0) + equipped.template.combat_attack_resist.get("CRUSHING"));
|
mob.resists.setResist(Enum.SourceType.CRUSHING, mob.resists.getResist(Enum.SourceType.CRUSHING, 0) + equipped.template.combat_attack_resist.get("CRUSHING"));
|
||||||
|
|||||||
@@ -699,7 +699,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
|
|
||||||
if (item != null && item.getObjectType() == GameObjectType.MobLoot) {
|
if (item != null && item.getObjectType() == GameObjectType.MobLoot) {
|
||||||
|
|
||||||
for (MobEquipment equip : mobTarget.getEquip().values()) {
|
for (Item equip : mobTarget.getEquip().values()) {
|
||||||
|
|
||||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.slot);
|
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.slot);
|
||||||
DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
|
|||||||
@@ -63,14 +63,14 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
Item buy = null;
|
Item buy = null;
|
||||||
|
|
||||||
if (buyFromNPCMsg.getItemType() == Enum.GameObjectType.MobEquipment.ordinal()) {
|
if (buyFromNPCMsg.getItemType() == Enum.GameObjectType.Item.ordinal()) {
|
||||||
|
|
||||||
ArrayList<MobEquipment> sellInventory = npc.getContract().getSellInventory();
|
ArrayList<Item> sellInventory = npc.getContract().getSellInventory();
|
||||||
|
|
||||||
if (sellInventory == null)
|
if (sellInventory == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (MobEquipment me : sellInventory) {
|
for (Item me : sellInventory) {
|
||||||
|
|
||||||
if (me.getObjectUUID() == buyFromNPCMsg.getItemID()) {
|
if (me.getObjectUUID() == buyFromNPCMsg.getItemID()) {
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
|
|||||||
NPC npc = NPC.getFromCache(npcID);
|
NPC npc = NPC.getFromCache(npcID);
|
||||||
CharacterItemManager man = null;
|
CharacterItemManager man = null;
|
||||||
ArrayList<Item> inventory = null;
|
ArrayList<Item> inventory = null;
|
||||||
ArrayList<MobEquipment> sellInventory = null;
|
ArrayList<Item> sellInventory = null;
|
||||||
|
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
man = npc.getCharItemManager();
|
man = npc.getCharItemManager();
|
||||||
@@ -147,9 +147,9 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
|
|||||||
//add generic sell inventory from contract
|
//add generic sell inventory from contract
|
||||||
if (sellInventory != null) {
|
if (sellInventory != null) {
|
||||||
|
|
||||||
for (MobEquipment mobEquipment : sellInventory) {
|
for (Item Item : sellInventory) {
|
||||||
try {
|
try {
|
||||||
MobEquipment.serializeForVendor(mobEquipment, writer, sellPercent);
|
Item.serializeForVendor(Item, writer, sellPercent);
|
||||||
} catch (SerializationException se) {
|
} catch (SerializationException se) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import engine.net.ByteBufferReader;
|
|||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
import engine.objects.Item;
|
import engine.objects.Item;
|
||||||
import engine.objects.MobEquipment;
|
import engine.objects.Item;
|
||||||
|
|
||||||
public class LootMsg extends ClientNetMsg {
|
public class LootMsg extends ClientNetMsg {
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public class LootMsg extends ClientNetMsg {
|
|||||||
private int unknown07;
|
private int unknown07;
|
||||||
private int unknown08;
|
private int unknown08;
|
||||||
|
|
||||||
private MobEquipment mobEquipment = null;
|
private Item Item = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
@@ -60,28 +60,6 @@ public class LootMsg extends ClientNetMsg {
|
|||||||
this.unknown08 = 0;
|
this.unknown08 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//for MobEquipment
|
|
||||||
|
|
||||||
public LootMsg(int sourceType, int sourceID, int targetType, int targetID, MobEquipment mobEquipment) {
|
|
||||||
super(Protocol.MOVEOBJECTTOCONTAINER);
|
|
||||||
this.sourceType1 = sourceType;
|
|
||||||
this.sourceID1 = sourceID;
|
|
||||||
this.targetType = targetType;
|
|
||||||
this.targetID = targetID;
|
|
||||||
this.sourceType2 = sourceType;
|
|
||||||
this.sourceID2 = sourceID;
|
|
||||||
this.item = null;
|
|
||||||
this.mobEquipment = mobEquipment;
|
|
||||||
|
|
||||||
this.unknown01 = 0;
|
|
||||||
this.unknown02 = 0;
|
|
||||||
this.unknown03 = 0;
|
|
||||||
this.unknown04 = 0;
|
|
||||||
this.unknown05 = 0;
|
|
||||||
this.unknown07 = 0;
|
|
||||||
this.unknown08 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||||
@@ -100,9 +78,9 @@ public class LootMsg extends ClientNetMsg {
|
|||||||
|
|
||||||
if (this.item != null)
|
if (this.item != null)
|
||||||
Item.serializeForClientMsgWithoutSlot(this.item, writer);
|
Item.serializeForClientMsgWithoutSlot(this.item, writer);
|
||||||
else if (this.mobEquipment != null)
|
else if (this.Item != null)
|
||||||
try {
|
try {
|
||||||
MobEquipment._serializeForClientMsg(this.mobEquipment, writer, false);
|
Item._serializeForClientMsg(this.Item, writer, false);
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -990,10 +990,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
return 300;
|
return 300;
|
||||||
}
|
}
|
||||||
float range = 8;
|
float range = 8;
|
||||||
if (((Mob) this).getEquip().get(1) != null) {
|
if (( this).charItemManager.equipped.get(EquipSlotType.RHELD) != null) {
|
||||||
range = ((Mob) this).getEquip().get(1).template.item_weapon_max_range;
|
range = ((Mob) this).charItemManager.equipped.get(EquipSlotType.RHELD).template.item_weapon_max_range;
|
||||||
} else if (((Mob) this).getEquip().get(2) != null) {
|
} else if (((Mob) this).charItemManager.equipped.get(EquipSlotType.LHELD) != null) {
|
||||||
range = ((Mob) this).getEquip().get(2).template.item_weapon_max_range;
|
range = ((Mob) this).charItemManager.equipped.get(EquipSlotType.LHELD).template.item_weapon_max_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Is this clamp from live?
|
// 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);
|
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
|
// Mapping of all items equipped in this Manager
|
||||||
// Key = Item Slot
|
// 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> inventory = new HashSet<>();
|
||||||
private final HashSet<Item> bank = new HashSet<>();
|
private final HashSet<Item> bank = new HashSet<>();
|
||||||
private final HashSet<Item> vault = new HashSet<>();
|
private final HashSet<Item> vault = new HashSet<>();
|
||||||
@@ -1203,7 +1203,7 @@ public class CharacterItemManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Used for buying MobEquipment from NPC
|
//Used for buying Item from NPC
|
||||||
//Handles the gold transfer aspect
|
//Handles the gold transfer aspect
|
||||||
|
|
||||||
// This removes ingame item from inventory for loot.
|
// 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> npcModTypeTable = new ArrayList<>();
|
||||||
private ArrayList<Integer> npcModSuffixTable = new ArrayList<>();
|
private ArrayList<Integer> npcModSuffixTable = new ArrayList<>();
|
||||||
private ArrayList<Byte> itemModTable = 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 EnumBitSet<Enum.BuildingGroup> allowedBuildings;
|
||||||
private ArrayList<Integer> buyItemType = new ArrayList<>();
|
private ArrayList<Integer> buyItemType = new ArrayList<>();
|
||||||
private ArrayList<Integer> buySkillToken = new ArrayList<>();
|
private ArrayList<Integer> buySkillToken = new ArrayList<>();
|
||||||
@@ -197,7 +197,7 @@ public class Contract extends AbstractGameObject {
|
|||||||
return itemModTable;
|
return itemModTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<MobEquipment> getSellInventory() {
|
public ArrayList<Item> getSellInventory() {
|
||||||
return this.sellInventory;
|
return this.sellInventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+35
-45
@@ -74,7 +74,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
private int currentID;
|
private int currentID;
|
||||||
private long lastAttackTime = 0;
|
private long lastAttackTime = 0;
|
||||||
private int lastMobPowerToken = 0;
|
private int lastMobPowerToken = 0;
|
||||||
public HashMap<Enum.EquipSlotType, MobEquipment> equip = null;
|
|
||||||
private DeferredPowerJob weaponPower;
|
private DeferredPowerJob weaponPower;
|
||||||
private DateTime upgradeDateTime = null;
|
private DateTime upgradeDateTime = null;
|
||||||
private boolean lootSync = false;
|
private boolean lootSync = false;
|
||||||
@@ -257,12 +256,12 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
|
|
||||||
// get a copy of the equipped items.
|
// 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())
|
for (Item me : mob.charItemManager.equipped.values())
|
||||||
MobEquipment.serializeForClientMsg(me, writer);
|
Item._serializeForClientMsg(me, writer);
|
||||||
} else
|
} else
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
|
|
||||||
@@ -934,7 +933,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
|
|
||||||
playerAgroMap.clear();
|
playerAgroMap.clear();
|
||||||
|
|
||||||
if (!this.isPlayerGuard() && this.equip != null)
|
if (!this.isPlayerGuard() && this.charItemManager.equipped != null)
|
||||||
LootManager.GenerateEquipmentDrop(this);
|
LootManager.GenerateEquipmentDrop(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1122,7 +1121,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
|
|
||||||
public void calculateAtrDefenseDamage() {
|
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");
|
Logger.error("Player " + currentID + " missing skills or equipment");
|
||||||
defaultAtrAndDamage(true);
|
defaultAtrAndDamage(true);
|
||||||
defaultAtrAndDamage(false);
|
defaultAtrAndDamage(false);
|
||||||
@@ -1141,16 +1140,16 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
this.rangeHandTwo = 6.5f;
|
this.rangeHandTwo = 6.5f;
|
||||||
this.speedHandTwo = 20;
|
this.speedHandTwo = 20;
|
||||||
|
|
||||||
if (this.equip.get(EquipSlotType.RHELD) != null)
|
if (this.charItemManager.equipped.get(EquipSlotType.RHELD) != null)
|
||||||
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), true); //has mainhand weapon to calculate
|
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))
|
if (this.charItemManager.equipped.get(EquipSlotType.LHELD) != null && !ItemTemplate.isShield(this.charItemManager.equipped.get(EquipSlotType.LHELD).template))
|
||||||
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), false); //has offhand weapon to calculate
|
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.LHELD), false); //has offhand weapon to calculate
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.RHELD), true);
|
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.RHELD), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
this.atrHandOne = (short) this.mobBase.getAttackRating();
|
this.atrHandOne = (short) this.mobBase.getAttackRating();
|
||||||
@@ -1162,7 +1161,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
calculateAtrDamageForWeapon(this.equip.get(EquipSlotType.LHELD), false);
|
calculateAtrDamageForWeapon(this.charItemManager.equipped.get(EquipSlotType.LHELD), false);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
@@ -1176,14 +1175,14 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
float defense = this.mobBase.getDefenseRating();
|
float defense = this.mobBase.getDefenseRating();
|
||||||
defense += getShieldDefense(equip.get(EquipSlotType.LHELD));
|
defense += getShieldDefense(charItemManager.equipped.get(EquipSlotType.LHELD));
|
||||||
defense += getArmorDefense(equip.get(EquipSlotType.HELM));
|
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.HELM));
|
||||||
defense += getArmorDefense(equip.get(EquipSlotType.CHEST));
|
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.CHEST));
|
||||||
defense += getArmorDefense(equip.get(EquipSlotType.UPARM));
|
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.UPARM));
|
||||||
defense += getArmorDefense(equip.get(EquipSlotType.HANDS));
|
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.HANDS));
|
||||||
defense += getArmorDefense(equip.get(EquipSlotType.LEGS));
|
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.LEGS));
|
||||||
defense += getArmorDefense(equip.get(EquipSlotType.FEET));
|
defense += getArmorDefense(charItemManager.equipped.get(EquipSlotType.FEET));
|
||||||
defense += getWeaponDefense(equip);
|
defense += getWeaponDefense(charItemManager.equipped);
|
||||||
|
|
||||||
// TODO add error log here
|
// TODO add error log here
|
||||||
if (this.bonuses != null) {
|
if (this.bonuses != null) {
|
||||||
@@ -1217,9 +1216,9 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
// calculate defense for equipment
|
// 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;
|
ItemBase wb = null;
|
||||||
CharacterSkill skill, mastery;
|
CharacterSkill skill, mastery;
|
||||||
float val = 0;
|
float val = 0;
|
||||||
@@ -1256,7 +1255,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getShieldDefense(MobEquipment shield) {
|
private float getShieldDefense(Item shield) {
|
||||||
|
|
||||||
if (shield == null)
|
if (shield == null)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1285,7 +1284,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
return (def * (1 + ((int) skillMod / 100f)));
|
return (def * (1 + ((int) skillMod / 100f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getArmorDefense(MobEquipment armor) {
|
private float getArmorDefense(Item armor) {
|
||||||
|
|
||||||
if (armor == null)
|
if (armor == null)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1313,7 +1312,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
return (def * (1 + ((int) armorSkill.getModifiedAmount() / 50f)));
|
return (def * (1 + ((int) armorSkill.getModifiedAmount() / 50f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateAtrDamageForWeapon(MobEquipment weapon, boolean mainHand) {
|
private void calculateAtrDamageForWeapon(Item weapon, boolean mainHand) {
|
||||||
|
|
||||||
int baseStrength = 0;
|
int baseStrength = 0;
|
||||||
|
|
||||||
@@ -1501,13 +1500,13 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
public ItemBase getWeaponItemBase(boolean mainHand) {
|
public ItemBase getWeaponItemBase(boolean mainHand) {
|
||||||
|
|
||||||
if (this.equipmentSetID != 0)
|
if (this.equipmentSetID != 0)
|
||||||
if (equip != null) {
|
if (charItemManager.equipped != null) {
|
||||||
MobEquipment me;
|
Item me;
|
||||||
|
|
||||||
if (mainHand)
|
if (mainHand)
|
||||||
me = equip.get(1); //mainHand
|
me = charItemManager.equipped.get(EquipSlotType.RHELD); //mainHand
|
||||||
else
|
else
|
||||||
me = equip.get(2); //offHand
|
me = charItemManager.equipped.get(EquipSlotType.LHELD); //offHand
|
||||||
|
|
||||||
if (me != null) {
|
if (me != null) {
|
||||||
|
|
||||||
@@ -1521,14 +1520,14 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
MobBase mb = this.mobBase;
|
MobBase mb = this.mobBase;
|
||||||
|
|
||||||
if (mb != null)
|
if (mb != null)
|
||||||
if (equip != null) {
|
if (this.charItemManager.equipped.isEmpty() == false) {
|
||||||
|
|
||||||
MobEquipment me;
|
Item me;
|
||||||
|
|
||||||
if (mainHand)
|
if (mainHand)
|
||||||
me = equip.get(1); //mainHand
|
me = this.charItemManager.equipped.get(EquipSlotType.RHELD); //mainHand
|
||||||
else
|
else
|
||||||
me = equip.get(2); //offHand
|
me = this.charItemManager.equipped.get(EquipSlotType.LHELD); //offHand
|
||||||
|
|
||||||
if (me != null)
|
if (me != null)
|
||||||
return me.getItemBase();
|
return me.getItemBase();
|
||||||
@@ -1670,14 +1669,9 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
this.loadInventory();
|
this.loadInventory();
|
||||||
|
|
||||||
if (this.equipmentSetID != 0)
|
if (this.equipmentSetID != 0)
|
||||||
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
|
this.charItemManager.equipped = MobBase.loadEquipmentSet(this.equipmentSetID);
|
||||||
else
|
else
|
||||||
this.equip = new HashMap<>();
|
this.charItemManager.equipped = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
if (this.equip == null) {
|
|
||||||
Logger.error("Null equipset returned for uuid " + currentID);
|
|
||||||
this.equip = new HashMap<>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combine mobbase and mob aggro arrays into one bitvector
|
// Combine mobbase and mob aggro arrays into one bitvector
|
||||||
//skip for pets
|
//skip for pets
|
||||||
@@ -1835,10 +1829,6 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
this.lootSync = lootSync;
|
this.lootSync = lootSync;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Enum.EquipSlotType, MobEquipment> getEquip() {
|
|
||||||
return equip;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNameOverride() {
|
public String getNameOverride() {
|
||||||
return firstName + " " + lastName;
|
return firstName + " " + lastName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class MobBase extends AbstractGameObject {
|
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;
|
ArrayList<BootySetEntry> equipList;
|
||||||
HashMap<Enum.EquipSlotType, MobEquipment> equip = new HashMap<>();
|
ConcurrentHashMap<Enum.EquipSlotType, Item> equip = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
if (equipmentSetID == 0)
|
if (equipmentSetID == 0)
|
||||||
return equip;
|
return equip;
|
||||||
@@ -125,14 +126,10 @@ public class MobBase extends AbstractGameObject {
|
|||||||
|
|
||||||
for (BootySetEntry equipmentSetEntry : equipList) {
|
for (BootySetEntry equipmentSetEntry : equipList) {
|
||||||
|
|
||||||
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.templateID, equipmentSetEntry.dropChance);
|
Item item = new Item(equipmentSetEntry.templateID);
|
||||||
ItemBase itemBase = mobEquipment.getItemBase();
|
item.drop_chance = equipmentSetEntry.dropChance;
|
||||||
|
|
||||||
// if (itemBase.getType().equals(Enum.ItemType.WEAPON))
|
equip.put(item.slot, Item);
|
||||||
// if (mobEquipment.getSlot() == 1 && itemBase.getEquipFlag() == 2)
|
|
||||||
// mobEquipment.setSlot(2);
|
|
||||||
|
|
||||||
equip.put(mobEquipment.slot, mobEquipment);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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<>();
|
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
||||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||||
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
|
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 runeSetID = 0;
|
||||||
public int extraRune2 = 0;
|
public int extraRune2 = 0;
|
||||||
protected int loadID;
|
protected int loadID;
|
||||||
@@ -344,8 +344,8 @@ public class NPC extends AbstractCharacter {
|
|||||||
if (npc.equip != null) {
|
if (npc.equip != null) {
|
||||||
writer.putInt(npc.equip.size());
|
writer.putInt(npc.equip.size());
|
||||||
|
|
||||||
for (MobEquipment me : npc.equip.values())
|
for (Item me : npc.equip.values())
|
||||||
MobEquipment.serializeForClientMsg(me, writer);
|
Item.serializeForClientMsg(me, writer);
|
||||||
} else
|
} else
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
|
|
||||||
@@ -1265,7 +1265,7 @@ public class NPC extends AbstractCharacter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Enum.EquipSlotType, MobEquipment> getEquip() {
|
public HashMap<Enum.EquipSlotType, Item> getEquip() {
|
||||||
return equip;
|
return equip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user