mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Implemented equipment and equip graphics. Add some zone callbacks and "first start" functionality. Added playtime.
This commit is contained in:
@@ -13,24 +13,24 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
{
|
||||
class Equipment
|
||||
{
|
||||
public const int SLOT_MAINHAND = 0x00;
|
||||
public const int SLOT_OFFHAND = 0x01;
|
||||
public const int SLOT_THROWINGWEAPON = 0x04;
|
||||
public const int SLOT_PACK = 0x05;
|
||||
public const int SLOT_POUCH = 0x06;
|
||||
public const int SLOT_HEAD = 0x08;
|
||||
public const int SLOT_UNDERSHIRT = 0x09;
|
||||
public const int SLOT_BODY = 0x0A;
|
||||
public const int SLOT_UNDERGARMENT = 0x0B;
|
||||
public const int SLOT_LEGS = 0x0C;
|
||||
public const int SLOT_HANDS = 0x0D;
|
||||
public const int SLOT_BOOTS = 0x0E;
|
||||
public const int SLOT_WAIST = 0x0F;
|
||||
public const int SLOT_NECK = 0x10;
|
||||
public const int SLOT_EARS = 0x11;
|
||||
public const int SLOT_WRISTS = 0x13;
|
||||
public const int SLOT_RIGHTFINGER = 0x15;
|
||||
public const int SLOT_LEFTFINGER = 0x16;
|
||||
public const int SLOT_MAINHAND = 0;
|
||||
public const int SLOT_OFFHAND = 1;
|
||||
public const int SLOT_THROWINGWEAPON = 4;
|
||||
public const int SLOT_PACK = 5;
|
||||
public const int SLOT_POUCH = 6;
|
||||
public const int SLOT_HEAD = 8;
|
||||
public const int SLOT_UNDERSHIRT = 9;
|
||||
public const int SLOT_BODY = 10;
|
||||
public const int SLOT_UNDERGARMENT = 11;
|
||||
public const int SLOT_LEGS = 12;
|
||||
public const int SLOT_HANDS = 13;
|
||||
public const int SLOT_BOOTS = 14;
|
||||
public const int SLOT_WAIST = 15;
|
||||
public const int SLOT_NECK = 16;
|
||||
public const int SLOT_EARS = 17;
|
||||
public const int SLOT_WRISTS = 19;
|
||||
public const int SLOT_RIGHTFINGER = 21;
|
||||
public const int SLOT_LEFTFINGER = 22;
|
||||
|
||||
private Player owner;
|
||||
private ushort inventoryCapacity;
|
||||
@@ -71,6 +71,27 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));
|
||||
}
|
||||
|
||||
public void SetEquipment(ushort[] slots, ushort[] itemSlots)
|
||||
{
|
||||
if (slots.Length != itemSlots.Length)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < slots.Length; i++)
|
||||
{
|
||||
InventoryItem item = normalInventory.getItem(itemSlots[i]);
|
||||
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
Database.equipItem(owner, slots[i], itemSlots[i]);
|
||||
list[slots[i]] = normalInventory.getItem(itemSlots[i]);
|
||||
}
|
||||
|
||||
owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
|
||||
SendFullEquipment(false);
|
||||
owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
|
||||
}
|
||||
|
||||
public void SetEquipment(List<Tuple<ushort, InventoryItem>> toEquip)
|
||||
{
|
||||
List<ushort> slotsToUpdate = new List<ushort>();
|
||||
@@ -81,6 +102,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
}
|
||||
}
|
||||
|
||||
public void Equip(ushort slot, ushort invSlot)
|
||||
{
|
||||
InventoryItem item = normalInventory.getItem(invSlot);
|
||||
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
Equip(slot, item);
|
||||
}
|
||||
|
||||
public void Equip(ushort slot, InventoryItem item)
|
||||
{
|
||||
if (slot >= list.Length)
|
||||
|
@@ -70,6 +70,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));
|
||||
}
|
||||
|
||||
public void addItem(uint itemId)
|
||||
{
|
||||
addItem(itemId, 1, 1);
|
||||
}
|
||||
|
||||
public void addItem(uint itemId, int quantity)
|
||||
{
|
||||
addItem(itemId, quantity, 1);
|
||||
}
|
||||
|
||||
public void addItem(uint itemId, int quantity, byte quality)
|
||||
{
|
||||
if (!isSpaceForAdd(itemId, quantity))
|
||||
@@ -119,7 +129,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
//New item that spilled over
|
||||
while (quantityCount > 0)
|
||||
{
|
||||
InventoryItem addedItem = Database.addItem(owner, itemId, Math.Min(quantityCount, 5), quality, gItem.isExclusive ? (byte)0x3 : (byte)0x0, gItem.durability, inventoryCode);
|
||||
InventoryItem addedItem = Database.addItem(owner, itemId, Math.Min(quantityCount, gItem.maxStack), quality, gItem.isExclusive ? (byte)0x3 : (byte)0x0, gItem.durability, inventoryCode);
|
||||
|
||||
|
||||
list.Add(addedItem);
|
||||
@@ -137,6 +147,31 @@ namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||
owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
|
||||
}
|
||||
|
||||
public void addItem(uint[] itemId)
|
||||
{
|
||||
if (!isSpaceForAdd(itemId[0], itemId.Length))
|
||||
return;
|
||||
|
||||
//Update lists and db
|
||||
owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
|
||||
owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));
|
||||
|
||||
int startPos = list.Count;
|
||||
|
||||
//New item that spilled over
|
||||
for (int i = 0; i < itemId.Length; i++)
|
||||
{
|
||||
Item gItem = Server.getItemGamedata(itemId[i]);
|
||||
InventoryItem addedItem = Database.addItem(owner, itemId[i], 1, (byte)1, gItem.isExclusive ? (byte)0x3 : (byte)0x0, gItem.durability, inventoryCode);
|
||||
list.Add(addedItem);
|
||||
}
|
||||
|
||||
sendInventoryPackets(startPos);
|
||||
|
||||
owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));
|
||||
owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
|
||||
}
|
||||
|
||||
public void removeItem(uint itemId, int quantity)
|
||||
{
|
||||
if (!hasItem(itemId, quantity))
|
||||
|
@@ -59,6 +59,9 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
public uint[] timers = new uint[20];
|
||||
public ushort currentJob;
|
||||
public uint currentTitle;
|
||||
public uint playTime;
|
||||
public uint lastPlayTimeUpdate;
|
||||
public bool isGM = false;
|
||||
|
||||
//Inventory
|
||||
private Dictionary<ushort, Inventory> inventories = new Dictionary<ushort, Inventory>();
|
||||
@@ -162,6 +165,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
charaWork.parameterTemp.tp = 3000;
|
||||
|
||||
Database.loadPlayerCharacter(this);
|
||||
lastPlayTimeUpdate = Utils.UnixTimeStampUTC();
|
||||
}
|
||||
|
||||
public List<SubPacket> create0x132Packets(uint playerActorId)
|
||||
@@ -545,6 +549,34 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
}
|
||||
}
|
||||
|
||||
public void setDCFlag(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
broadcastPacket(SetActorIconPacket.buildPacket(actorId, actorId, SetActorIconPacket.DISCONNECTING), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isGM)
|
||||
broadcastPacket(SetActorIconPacket.buildPacket(actorId, actorId, SetActorIconPacket.ISGM), true);
|
||||
else
|
||||
broadcastPacket(SetActorIconPacket.buildPacket(actorId, actorId, 0), true);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanupAndSave()
|
||||
{
|
||||
//Remove actor from zone and main server list
|
||||
zone.removeActorFromZone(this);
|
||||
Server.getServer().removePlayer(this);
|
||||
|
||||
//Save Player
|
||||
Database.savePlayerPlayTime(this);
|
||||
Database.savePlayerPosition(this);
|
||||
|
||||
Log.info(String.Format("{0} has been logged out and saved.", this.customDisplayName));
|
||||
}
|
||||
|
||||
public Zone getZone()
|
||||
{
|
||||
return zone;
|
||||
@@ -558,11 +590,25 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
public void logout()
|
||||
{
|
||||
queuePacket(LogoutPacket.buildPacket(actorId));
|
||||
cleanupAndSave();
|
||||
}
|
||||
|
||||
public void quitGame()
|
||||
{
|
||||
queuePacket(QuitPacket.buildPacket(actorId));
|
||||
cleanupAndSave();
|
||||
}
|
||||
|
||||
public uint getPlayTime(bool doUpdate)
|
||||
{
|
||||
if (doUpdate)
|
||||
{
|
||||
uint curTime = Utils.UnixTimeStampUTC();
|
||||
playTime += curTime - lastPlayTimeUpdate;
|
||||
lastPlayTimeUpdate = curTime;
|
||||
}
|
||||
|
||||
return playTime;
|
||||
}
|
||||
|
||||
public void changeMusic(ushort musicId)
|
||||
@@ -635,33 +681,62 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
//zone.broadcastPacketAroundActor(this, worldMasterMessage);
|
||||
}
|
||||
|
||||
public void graphicChange(uint slot, uint graphicId)
|
||||
{
|
||||
appearanceIds[slot] = graphicId;
|
||||
broadcastPacket(createAppearancePacket(actorId), true);
|
||||
}
|
||||
|
||||
public void graphicChange(uint slot, uint weapId, uint equipId, uint variantId, uint colorId)
|
||||
{
|
||||
|
||||
uint mixedVariantId;
|
||||
|
||||
if (weapId == 0)
|
||||
mixedVariantId = ((variantId & 0x1F) << 5) | colorId;
|
||||
else
|
||||
mixedVariantId = variantId;
|
||||
|
||||
uint graphicId =
|
||||
(weapId & 0x3FF) << 20 |
|
||||
(equipId & 0x3FF) << 10 |
|
||||
(mixedVariantId & 0x3FF);
|
||||
|
||||
appearanceIds[slot] = graphicId;
|
||||
broadcastPacket(createAppearancePacket(actorId), true);
|
||||
|
||||
}
|
||||
|
||||
public void graphicChange(int slot, InventoryItem invItem)
|
||||
{
|
||||
Item item = Server.getItemGamedata(invItem.itemId);
|
||||
|
||||
if (item == null)
|
||||
if (invItem == null)
|
||||
appearanceIds[slot] = 0;
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
else if (item is EquipmentItem)
|
||||
{
|
||||
EquipmentItem eqItem = (EquipmentItem)item;
|
||||
|
||||
uint graphicId;
|
||||
|
||||
if (eqItem.graphicsWeaponId == null || eqItem.graphicsEquipmentId == null || eqItem.graphicsVariantId == null)
|
||||
graphicId = 1025;
|
||||
else
|
||||
Item item = Server.getItemGamedata(invItem.itemId);
|
||||
if (item is EquipmentItem)
|
||||
{
|
||||
graphicId =
|
||||
eqItem.graphicsWeaponId << 20 |
|
||||
eqItem.graphicsEquipmentId << 10 |
|
||||
eqItem.graphicsVariantId << 5 |
|
||||
eqItem.graphicsColorId << 5;
|
||||
EquipmentItem eqItem = (EquipmentItem)item;
|
||||
|
||||
uint mixedVariantId;
|
||||
|
||||
if (eqItem.graphicsWeaponId == 0)
|
||||
mixedVariantId = ((eqItem.graphicsVariantId & 0x1F) << 5) | eqItem.graphicsColorId;
|
||||
else
|
||||
mixedVariantId = eqItem.graphicsVariantId;
|
||||
|
||||
uint graphicId =
|
||||
(eqItem.graphicsWeaponId & 0x3FF) << 20 |
|
||||
(eqItem.graphicsEquipmentId & 0x3FF) << 10 |
|
||||
(mixedVariantId & 0x3FF);
|
||||
|
||||
appearanceIds[slot] = graphicId;
|
||||
}
|
||||
appearanceIds[BODYGEAR] = graphicId;
|
||||
broadcastPacket(createAppearancePacket(actorId), true);
|
||||
}
|
||||
}
|
||||
|
||||
Database.savePlayerAppearance(this);
|
||||
|
||||
broadcastPacket(createAppearancePacket(actorId), true);
|
||||
}
|
||||
|
||||
public Inventory getInventory(ushort type)
|
||||
|
Reference in New Issue
Block a user