mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Finished check command as well as gearsets and switching between classes. Property changes still have to be written though.
This commit is contained in:
@@ -38,6 +38,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
private InventoryItem[] list;
|
||||
private Inventory normalInventory;
|
||||
|
||||
private bool writeToDB = true;
|
||||
|
||||
public Equipment(Player ownerPlayer, Inventory normalInventory, ushort capacity, ushort code)
|
||||
{
|
||||
owner = ownerPlayer;
|
||||
@@ -55,6 +57,38 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SendCheckEquipmentToPlayer(Player toPlayer)
|
||||
{
|
||||
List<InventoryItem> items = new List<InventoryItem>();
|
||||
for (ushort i = 0; i < list.Length; i++)
|
||||
{
|
||||
if (list[i] != null)
|
||||
{
|
||||
InventoryItem equipItem = new InventoryItem(list[i], i);
|
||||
items.Add(equipItem);
|
||||
}
|
||||
}
|
||||
|
||||
toPlayer.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, toPlayer.actorId, 0x23, Inventory.EQUIPMENT_OTHERPLAYER));
|
||||
int currentIndex = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (items.Count - currentIndex >= 16)
|
||||
toPlayer.queuePacket(InventoryListX16Packet.buildPacket(owner.actorId, toPlayer.actorId, items, ref currentIndex));
|
||||
else if (items.Count - currentIndex > 1)
|
||||
toPlayer.queuePacket(InventoryListX08Packet.buildPacket(owner.actorId, toPlayer.actorId, items, ref currentIndex));
|
||||
else if (items.Count - currentIndex == 1)
|
||||
{
|
||||
toPlayer.queuePacket(InventoryListX01Packet.buildPacket(owner.actorId, toPlayer.actorId, items[currentIndex]));
|
||||
currentIndex++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
toPlayer.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId, toPlayer.actorId));
|
||||
}
|
||||
|
||||
public void SendFullEquipment(bool doClear)
|
||||
{
|
||||
List<ushort> slotsToUpdate = new List<ushort>();
|
||||
@@ -78,13 +112,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
|
||||
for (int i = 0; i < slots.Length; i++)
|
||||
{
|
||||
InventoryItem item = normalInventory.getItem(itemSlots[i]);
|
||||
InventoryItem item = normalInventory.getItemBySlot(itemSlots[i]);
|
||||
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
Database.equipItem(owner, slots[i], itemSlots[i]);
|
||||
list[slots[i]] = normalInventory.getItem(itemSlots[i]);
|
||||
list[slots[i]] = normalInventory.getItemBySlot(itemSlots[i]);
|
||||
}
|
||||
|
||||
owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
|
||||
@@ -92,19 +126,20 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
|
||||
}
|
||||
|
||||
public void SetEquipment(List<Tuple<ushort, InventoryItem>> toEquip)
|
||||
public void SetEquipment(InventoryItem[] toEquip)
|
||||
{
|
||||
List<ushort> slotsToUpdate = new List<ushort>();
|
||||
for (int i = 0; i < toEquip.Count; i++)
|
||||
for (ushort i = 0; i < toEquip.Length; i++)
|
||||
{
|
||||
slotsToUpdate.Add(toEquip[i].Item1);
|
||||
list[toEquip[i].Item1] = toEquip[i].Item2;
|
||||
}
|
||||
if (toEquip[i] != null)
|
||||
slotsToUpdate.Add(i);
|
||||
}
|
||||
list = toEquip;
|
||||
}
|
||||
|
||||
public void Equip(ushort slot, ushort invSlot)
|
||||
{
|
||||
InventoryItem item = normalInventory.getItem(invSlot);
|
||||
InventoryItem item = normalInventory.getItemBySlot(invSlot);
|
||||
|
||||
if (item == null)
|
||||
return;
|
||||
@@ -117,7 +152,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
if (slot >= list.Length)
|
||||
return;
|
||||
|
||||
Database.equipItem(owner, slot, item.slot);
|
||||
if (writeToDB)
|
||||
Database.equipItem(owner, slot, item.uniqueId);
|
||||
|
||||
owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
|
||||
|
||||
@@ -135,12 +171,18 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
list[slot] = item;
|
||||
}
|
||||
|
||||
public void ToggleDBWrite(bool flag)
|
||||
{
|
||||
writeToDB = flag;
|
||||
}
|
||||
|
||||
public void Unequip(ushort slot)
|
||||
{
|
||||
if (slot >= list.Length)
|
||||
return;
|
||||
|
||||
Database.unequipItem(owner, slot);
|
||||
if (writeToDB)
|
||||
Database.unequipItem(owner, slot);
|
||||
|
||||
owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
|
||||
|
||||
@@ -189,5 +231,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
|
||||
}
|
||||
|
||||
public int GetCapacity()
|
||||
{
|
||||
return list.Length;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
list = itemsFromDB;
|
||||
}
|
||||
|
||||
public InventoryItem getItem(ushort slot)
|
||||
public InventoryItem getItemBySlot(ushort slot)
|
||||
{
|
||||
if (slot < list.Count)
|
||||
return list[slot];
|
||||
@@ -49,6 +49,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
return null;
|
||||
}
|
||||
|
||||
public InventoryItem getItemById(ulong itemId)
|
||||
{
|
||||
foreach (InventoryItem item in list)
|
||||
{
|
||||
if (item.uniqueId == itemId)
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void RefreshItem(InventoryItem item)
|
||||
{
|
||||
owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));
|
||||
|
@@ -409,7 +409,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
propPacketUtil.addProperty("playerWork.birthdayDay");
|
||||
propPacketUtil.addProperty("playerWork.initialTown");
|
||||
|
||||
return propPacketUtil.done();
|
||||
return BasePacket.createPacket(propPacketUtil.done(), true, false);
|
||||
}
|
||||
|
||||
public void sendZoneInPackets(WorldManager world, ushort spawnType)
|
||||
@@ -683,8 +683,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
|
||||
public void graphicChange(uint slot, uint graphicId)
|
||||
{
|
||||
appearanceIds[slot] = graphicId;
|
||||
broadcastPacket(createAppearancePacket(actorId), true);
|
||||
appearanceIds[slot] = graphicId;
|
||||
}
|
||||
|
||||
public void graphicChange(uint slot, uint weapId, uint equipId, uint variantId, uint colorId)
|
||||
@@ -702,11 +701,35 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
(equipId & 0x3FF) << 10 |
|
||||
(mixedVariantId & 0x3FF);
|
||||
|
||||
appearanceIds[slot] = graphicId;
|
||||
broadcastPacket(createAppearancePacket(actorId), true);
|
||||
appearanceIds[slot] = graphicId;
|
||||
|
||||
}
|
||||
|
||||
public void sendAppearance()
|
||||
{
|
||||
broadcastPacket(createAppearancePacket(actorId), true);
|
||||
}
|
||||
|
||||
public InventoryItem[] getGearset(ushort classId)
|
||||
{
|
||||
return Database.getEquipment(this, classId);
|
||||
}
|
||||
|
||||
public void doClassChange(byte classId)
|
||||
{
|
||||
charaWork.parameterSave.state_mainSkill[0] = classId;
|
||||
|
||||
ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("charaWork/stateForAll", this, actorId);
|
||||
propertyBuilder.addProperty("charaWork.parameterSave.state_mainSkill[0]");
|
||||
propertyBuilder.addProperty("charaWork.parameterSave.state_mainSkillLevel");
|
||||
List<SubPacket> packets = propertyBuilder.done();
|
||||
|
||||
foreach (SubPacket packet in packets)
|
||||
broadcastPacket(packet, true);
|
||||
|
||||
Log.info("Class change request to: " + classId);
|
||||
}
|
||||
|
||||
public void graphicChange(int slot, InventoryItem invItem)
|
||||
{
|
||||
if (invItem == null)
|
||||
@@ -747,11 +770,35 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
return null;
|
||||
}
|
||||
|
||||
public Actor getActorInInstance(uint actorId)
|
||||
{
|
||||
foreach (Actor a in playerSession.actorInstanceList)
|
||||
{
|
||||
if (a.actorId == actorId)
|
||||
return a;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Equipment getEquipment()
|
||||
{
|
||||
return equipment;
|
||||
}
|
||||
|
||||
public void examinePlayer(Actor examinee)
|
||||
{
|
||||
Player toBeExamined;
|
||||
if (examinee is Player)
|
||||
toBeExamined = (Player)examinee;
|
||||
else
|
||||
return;
|
||||
|
||||
queuePacket(InventoryBeginChangePacket.buildPacket(toBeExamined.actorId, actorId));
|
||||
toBeExamined.getEquipment().SendCheckEquipmentToPlayer(this);
|
||||
queuePacket(InventoryEndChangePacket.buildPacket(toBeExamined.actorId, actorId));
|
||||
}
|
||||
|
||||
public void runEventFunction(string functionName, params object[] parameters)
|
||||
{
|
||||
List<LuaParam> lParams = LuaUtils.createLuaParamList(parameters);
|
||||
|
Reference in New Issue
Block a user