using FFXIVClassic_Lobby_Server; using FFXIVClassic_Lobby_Server.common; using FFXIVClassic_Lobby_Server.packets; using FFXIVClassic_Map_Server.actors.area; using FFXIVClassic_Map_Server.dataobjects; using FFXIVClassic_Map_Server.dataobjects.chara; using FFXIVClassic_Map_Server.lua; using FFXIVClassic_Map_Server.packets.send; using FFXIVClassic_Map_Server.packets.send.actor; using FFXIVClassic_Map_Server.packets.send.actor.inventory; using FFXIVClassic_Map_Server.packets.send.Actor.inventory; using FFXIVClassic_Map_Server.packets.send.events; using FFXIVClassic_Map_Server.packets.send.list; using FFXIVClassic_Map_Server.packets.send.login; using FFXIVClassic_Map_Server.packets.send.player; using FFXIVClassic_Map_Server.utils; using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FFXIVClassic_Map_Server.Actors { class Player : Character { public const int MAXSIZE_INVENTORY_NORMAL = 200; public const int MAXSIZE_INVENTORY_CURRANCY = 320; public const int MAXSIZE_INVENTORY_KEYITEMS = 500; public const int MAXSIZE_INVENTORY_LOOT = 10; public const int MAXSIZE_INVENTORY_MELDREQUEST = 4; public const int MAXSIZE_INVENTORY_BAZAAR = 10; public const int MAXSIZE_INVENTORY_EQUIPMENT = 10; public const int TIMER_TOTORAK = 0; public const int TIMER_DZEMAEL = 1; public const int TIMER_BOWL_OF_EMBERS_HARD = 2; public const int TIMER_BOWL_OF_EMBERS = 3; public const int TIMER_THORNMARCH = 4; public const int TIMER_AURUMVALE = 5; public const int TIMER_CUTTERSCRY = 6; public const int TIMER_BATTLE_ALEPORT = 7; public const int TIMER_BATTLE_HYRSTMILL = 8; public const int TIMER_BATTLE_GOLDENBAZAAR = 9; public const int TIMER_HOWLING_EYE_HARD = 10; public const int TIMER_HOWLING_EYE = 11; public const int TIMER_CASTRUM_TOWER = 12; public const int TIMER_BOWL_OF_EMBERS_EXTREME = 13; public const int TIMER_RIVENROAD = 14; public const int TIMER_RIVENROAD_HARD = 15; public const int TIMER_BEHEST = 16; public const int TIMER_COMPANYBEHEST = 17; public const int TIMER_RETURN = 18; public const int TIMER_SKIRMISH = 19; //Player Info public uint[] timers = new uint[20]; public ushort currentJob; public uint currentTitle; //Inventory public List invNormal = new List(); public List invCurrancy = new List(); public List invKeyItems = new List(); public List invLoot = new List(); public List invMeldRequest = new List(); public List invBazaar = new List(); public int[] invEquipment = new int[MAXSIZE_INVENTORY_EQUIPMENT]; //GC Related public byte gcCurrent; public byte gcRankLimsa; public byte gcRankGridania; public byte gcRankUldah; //Mount Related public bool hasChocobo; public bool hasGoobbue; public byte chocoboAppearance; public string chocoboName; public byte mountState = 0; //Event Related public uint eventCurrentOwner = 0; public string eventCurrentStarter = ""; public uint eventMenuId = 0; public uint achievementPoints; public PlayerWork playerWork = new PlayerWork(); public ConnectedPlayer playerSession; public Player(ConnectedPlayer cp, uint actorID) : base(actorID) { playerSession = cp; actorName = String.Format("_pc{0:00000000}", actorID); className = "Player"; currentSubState = SetActorStatePacket.SUB_STATE_PLAYER; charaWork.property[0] = 1; charaWork.property[1] = 1; charaWork.property[2] = 1; charaWork.property[4] = 1; charaWork.command[0] = 0xA0F00000 | 21001; charaWork.command[1] = 0xA0F00000 | 21001; charaWork.command[2] = 0xA0F00000 | 21002; charaWork.command[3] = 0xA0F00000 | 12004; charaWork.command[4] = 0xA0F00000 | 21005; charaWork.command[5] = 0xA0F00000 | 21006; charaWork.command[6] = 0xA0F00000 | 21007; charaWork.command[7] = 0xA0F00000 | 12009; charaWork.command[8] = 0xA0F00000 | 12010; charaWork.command[9] = 0xA0F00000 | 12005; charaWork.command[10] = 0xA0F00000 | 12007; charaWork.command[11] = 0xA0F00000 | 12011; charaWork.command[12] = 0xA0F00000 | 22012; charaWork.command[13] = 0xA0F00000 | 22013; charaWork.command[14] = 0xA0F00000 | 29497; charaWork.command[15] = 0xA0F00000 | 22015; charaWork.command[32] = 0xA0F00000 | 27191; charaWork.command[33] = 0xA0F00000 | 22302; charaWork.command[34] = 0xA0F00000 | 28466; charaWork.commandAcquired[27150 - 26000] = true; playerWork.questScenarioComplete[110001 - 110001] = true; playerWork.questGuildleveComplete[120050 - 120001] = true; for (int i = 0; i < charaWork.additionalCommandAcquired.Length; i++ ) charaWork.additionalCommandAcquired[i] = true; for (int i = 0; i < charaWork.commandCategory.Length; i++) charaWork.commandCategory[i] = 1; charaWork.battleTemp.generalParameter[3] = 1; charaWork.eventSave.bazaarTax = 5; charaWork.battleSave.potencial = 6.6f; charaWork.commandCategory[0] = 1; charaWork.commandCategory[1] = 1; charaWork.commandCategory[32] = 1; charaWork.commandCategory[33] = 1; charaWork.commandCategory[34] = 1; charaWork.parameterSave.commandSlot_compatibility[0] = true; charaWork.parameterSave.commandSlot_compatibility[1] = true; charaWork.parameterSave.commandSlot_compatibility[32] = true; charaWork.commandBorder = 0x20; charaWork.parameterTemp.tp = 3000; Database.loadPlayerCharacter(this); } public List create0x132Packets(uint playerActorId) { List packets = new List(); packets.Add(_0x132Packet.buildPacket(playerActorId, 0xB, "commandForced")); packets.Add(_0x132Packet.buildPacket(playerActorId, 0xA, "commandDefault")); packets.Add(_0x132Packet.buildPacket(playerActorId, 0x6, "commandWeak")); packets.Add(_0x132Packet.buildPacket(playerActorId, 0x4, "commandContent")); packets.Add(_0x132Packet.buildPacket(playerActorId, 0x6, "commandJudgeMode")); packets.Add(_0x132Packet.buildPacket(playerActorId, 0x100, "commandRequest")); packets.Add(_0x132Packet.buildPacket(playerActorId, 0x100, "widgetCreate")); packets.Add(_0x132Packet.buildPacket(playerActorId, 0x100, "macroRequest")); return packets; } public override SubPacket createScriptBindPacket(uint playerActorId) { List lParams; if (isMyPlayer(playerActorId)) { lParams = LuaUtils.createLuaParamList("/Chara/Player/Player_work", false, false, false, true, 0, false, timers, true); } else lParams = LuaUtils.createLuaParamList("/Chara/Player/Player_work", false, false, false, false, false, true); return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams); } public override BasePacket getSpawnPackets(uint playerActorId, uint spawnType) { List subpackets = new List(); subpackets.Add(createAddActorPacket(playerActorId, 8)); if (isMyPlayer(playerActorId)) subpackets.AddRange(create0x132Packets(playerActorId)); subpackets.Add(createSpeedPacket(playerActorId)); subpackets.Add(createSpawnPositonPacket(playerActorId, spawnType)); subpackets.Add(createAppearancePacket(playerActorId)); subpackets.Add(createNamePacket(playerActorId)); subpackets.Add(_0xFPacket.buildPacket(playerActorId, playerActorId)); subpackets.Add(createStatePacket(playerActorId)); subpackets.Add(createIdleAnimationPacket(playerActorId)); subpackets.Add(createInitStatusPacket(playerActorId)); subpackets.Add(createSetActorIconPacket(playerActorId)); subpackets.Add(createIsZoneingPacket(playerActorId)); subpackets.AddRange(createPlayerRelatedPackets(playerActorId)); subpackets.Add(createScriptBindPacket(playerActorId)); return BasePacket.createPacket(subpackets, true, false); } public List createPlayerRelatedPackets(uint playerActorId) { List subpackets = new List(); if (gcCurrent != 0) subpackets.Add(SetGrandCompanyPacket.buildPacket(actorId, playerActorId, gcCurrent, gcRankLimsa, gcRankGridania, gcRankUldah)); if (currentTitle != 0) subpackets.Add(SetPlayerTitlePacket.buildPacket(actorId, playerActorId, currentTitle)); if (currentJob != 0) subpackets.Add(SetCurrentJobPacket.buildPacket(actorId, playerActorId, currentJob)); if (isMyPlayer(playerActorId)) { subpackets.Add(_0x196Packet.buildPacket(playerActorId, playerActorId)); if (hasChocobo && chocoboName != null && !chocoboName.Equals("")) { subpackets.Add(SetChocoboNamePacket.buildPacket(actorId, playerActorId, chocoboName)); subpackets.Add(SetHasChocoboPacket.buildPacket(playerActorId, hasChocobo)); } if (hasGoobbue) subpackets.Add(SetHasGoobbuePacket.buildPacket(playerActorId, hasGoobbue)); subpackets.Add(SetAchievementPointsPacket.buildPacket(playerActorId, achievementPoints)); subpackets.Add(Database.getLatestAchievements(this)); subpackets.Add(Database.getAchievementsPacket(this)); /* if (isInn) { SetCutsceneBookPacket book = new SetCutsceneBookPacket(); for (int i = 0; i < book.cutsceneFlags.Length; i++) book.cutsceneFlags[i] = true; client.queuePacket(book.buildPacket(player.actorID), true, false); // //subpackets.Add(SetPlayerDreamPacket.buildPacket(playerActorId, ); } */ } return subpackets; } public override BasePacket getInitPackets(uint playerActorId) { ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("/_init", this, playerActorId); propPacketUtil.addProperty("charaWork.eventSave.bazaarTax"); propPacketUtil.addProperty("charaWork.battleSave.potencial"); //Properties for (int i = 0; i < charaWork.property.Length; i++) { if (charaWork.property[i] != 0) propPacketUtil.addProperty(String.Format("charaWork.property[{0}]", i)); } //Parameters propPacketUtil.addProperty("charaWork.parameterSave.hp[0]"); propPacketUtil.addProperty("charaWork.parameterSave.hpMax[0]"); propPacketUtil.addProperty("charaWork.parameterSave.mp"); propPacketUtil.addProperty("charaWork.parameterSave.mpMax"); propPacketUtil.addProperty("charaWork.parameterTemp.tp"); propPacketUtil.addProperty("charaWork.parameterSave.state_mainSkill[0]"); propPacketUtil.addProperty("charaWork.parameterSave.state_mainSkillLevel"); //Status Times for (int i = 0; i < charaWork.statusShownTime.Length; i++) { if (charaWork.statusShownTime[i] != 0xFFFFFFFF) propPacketUtil.addProperty(String.Format("charaWork.statusShownTime[{0}]", i)); } //General Parameters for (int i = 3; i < charaWork.battleTemp.generalParameter.Length; i++) { if (charaWork.battleTemp.generalParameter[i] != 0) propPacketUtil.addProperty(String.Format("charaWork.battleTemp.generalParameter[{0}]", i)); } propPacketUtil.addProperty("charaWork.battleTemp.castGauge_speed[0]"); propPacketUtil.addProperty("charaWork.battleTemp.castGauge_speed[1]"); //Battle Save Skillpoint //Commands propPacketUtil.addProperty("charaWork.commandBorder"); for (int i = 0; i < charaWork.command.Length; i++) { if (charaWork.command[i] != 0) propPacketUtil.addProperty(String.Format("charaWork.command[{0}]", i)); } for (int i = 0; i < charaWork.commandCategory.Length; i++) { charaWork.commandCategory[i] = 1; if (charaWork.commandCategory[i] != 0) propPacketUtil.addProperty(String.Format("charaWork.commandCategory[{0}]", i)); } for (int i = 0; i < charaWork.commandAcquired.Length; i++) { if (charaWork.commandAcquired[i] != false) propPacketUtil.addProperty(String.Format("charaWork.commandAcquired[{0}]", i)); } for (int i = 0; i < charaWork.additionalCommandAcquired.Length; i++) { if (charaWork.additionalCommandAcquired[i] != false) propPacketUtil.addProperty(String.Format("charaWork.additionalCommandAcquired[{0}]", i)); } for (int i = 0; i < charaWork.parameterSave.commandSlot_compatibility.Length; i++) { charaWork.parameterSave.commandSlot_compatibility[i] = true; if (charaWork.parameterSave.commandSlot_compatibility[i]) propPacketUtil.addProperty(String.Format("charaWork.parameterSave.commandSlot_compatibility[{0}]", i)); } /* for (int i = 0; i < charaWork.parameterSave.commandSlot_recastTime.Length; i++) { if (charaWork.parameterSave.commandSlot_recastTime[i] != 0) propPacketUtil.addProperty(String.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", i)); } */ //System propPacketUtil.addProperty("charaWork.parameterTemp.forceControl_float_forClientSelf[0]"); propPacketUtil.addProperty("charaWork.parameterTemp.forceControl_float_forClientSelf[1]"); propPacketUtil.addProperty("charaWork.parameterTemp.forceControl_int16_forClientSelf[0]"); propPacketUtil.addProperty("charaWork.parameterTemp.forceControl_int16_forClientSelf[1]"); charaWork.parameterTemp.otherClassAbilityCount[0] = 4; charaWork.parameterTemp.otherClassAbilityCount[1] = 5; charaWork.parameterTemp.giftCount[1] = 5; propPacketUtil.addProperty("charaWork.parameterTemp.otherClassAbilityCount[0]"); propPacketUtil.addProperty("charaWork.parameterTemp.otherClassAbilityCount[1]"); propPacketUtil.addProperty("charaWork.parameterTemp.giftCount[1]"); propPacketUtil.addProperty("charaWork.depictionJudge"); //Scenario for (int i = 0; i < playerWork.questScenario.Length; i++) { if (playerWork.questScenario[i] != 0) propPacketUtil.addProperty(String.Format("playerWork.questScenario[{0}]", i)); } //Guildleve - Local for (int i = 0; i < playerWork.questGuildleve.Length; i++) { if (playerWork.questGuildleve[i] != 0) propPacketUtil.addProperty(String.Format("playerWork.questGuildleve[{0}]", i)); } //Guildleve - Regional for (int i = 0; i < work.guildleveId.Length; i++) { if (work.guildleveId[i] != 0) propPacketUtil.addProperty(String.Format("work.guildleveId[{0}]", i)); if (work.guildleveDone[i] != false) propPacketUtil.addProperty(String.Format("work.guildleveDone[{0}]", i)); if (work.guildleveChecked[i] != false) propPacketUtil.addProperty(String.Format("work.guildleveChecked[{0}]", i)); } //NPC Linkshell for (int i = 0; i < playerWork.npcLinkshellChatCalling.Length; i++) { if (playerWork.npcLinkshellChatCalling[i] != false) propPacketUtil.addProperty(String.Format("playerWork.npcLinkshellChatCalling[{0}]", i)); if (playerWork.npcLinkshellChatExtra[i] != false) propPacketUtil.addProperty(String.Format("playerWork.npcLinkshellChatExtra[{0}]", i)); } propPacketUtil.addProperty("playerWork.restBonusExpRate"); //Profile propPacketUtil.addProperty("playerWork.tribe"); propPacketUtil.addProperty("playerWork.guardian"); propPacketUtil.addProperty("playerWork.birthdayMonth"); propPacketUtil.addProperty("playerWork.birthdayDay"); propPacketUtil.addProperty("playerWork.initialTown"); return propPacketUtil.done(); } public void sendZoneInPackets(WorldManager world, ushort spawnType) { queuePacket(SetMapPacket.buildPacket(actorId, zone.regionId, zone.actorId)); queuePacket(SetMusicPacket.buildPacket(actorId, zone.bgmDay, 0x01)); queuePacket(SetWeatherPacket.buildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR)); queuePacket(getSpawnPackets(actorId, spawnType)); #region grouptest //Retainers List retainerListEntries = new List(); retainerListEntries.Add(new ListEntry(actorId, 0xFFFFFFFF, 0x139E, false, true, customDisplayName)); retainerListEntries.Add(new ListEntry(0x23, 0x0, 0xFFFFFFFF, false, false, "TEST1")); retainerListEntries.Add(new ListEntry(0x24, 0x0, 0xFFFFFFFF, false, false, "TEST2")); retainerListEntries.Add(new ListEntry(0x25, 0x0, 0xFFFFFFFF, false, false, "TEST3")); BasePacket retainerListPacket = BasePacket.createPacket(ListUtils.createRetainerList(actorId, 0xF4, 1, 0x800000000004e639, retainerListEntries), true, false); playerSession.queuePacket(retainerListPacket); //Party List partyListEntries = new List(); partyListEntries.Add(new ListEntry(actorId, 0xFFFFFFFF, 0xFFFFFFFF, false, true, customDisplayName)); partyListEntries.Add(new ListEntry(0x029B27D3, 0xFFFFFFFF, 0x195, false, true, "Valentine Bluefeather")); BasePacket partyListPacket = BasePacket.createPacket(ListUtils.createPartyList(actorId, 0xF4, 1, 0x8000000000696df2, partyListEntries), true, false); playerSession.queuePacket(partyListPacket); #endregion #region itemsetup ////////ITEMS//////// queuePacket(InventoryBeginChangePacket.buildPacket(actorId)); queuePacket(InventorySetBeginPacket.buildPacket(actorId, 200, InventorySetBeginPacket.CODE_INVENTORY)); sendInventoryPackets(invNormal); queuePacket(InventorySetEndPacket.buildPacket(actorId)); /* //TEST List items = new List(); items.Add(new Item(1337, 8030920, 0)); //Leather Jacket items.Add(new Item(1338, 8013626, 1)); //Chocobo Mask items.Add(new Item(1339, 5030402, 2)); //Thyrus items.Add(new Item(1340, 8013635, 3)); //Dalamud Horn items.Add(new Item(1341, 10100132, 4)); //Savage Might 4 items.Add(new Item(1342, 8032407, 5)); //Green Summer Halter (Female) //items.Add(new Item(1343, 8051307, 6)); //Green Summer Tanga (Female) int count = 0; items[2].quality = 2; items[0].durability = 9999; items[0].spiritbind = 10000; items[0].materia1 = 6; items[0].materia2 = 7; items[0].materia3 = 8; items[0].materia4 = 9; items[0].materia5 = 10; items[1].durability = 9999; items[2].durability = 0xFFFFFFF; items[3].durability = 9999; items[4].quantity = 99; List packets = new List(); packets.Add(InventorySetBeginPacket.buildPacket(actorId, 200, InventorySetBeginPacket.CODE_INVENTORY)); packets.Add(InventoryListX08Packet.buildPacket(actorId, items,ref count)); packets.Add(InventorySetEndPacket.buildPacket(actorId)); Item i = new Item(1343, 8051307, 0); packets.Add(InventorySetBeginPacket.buildPacket(actorId, 0x500, InventorySetBeginPacket.CODE_KEYITEMS)); packets.Add(InventoryListX01Packet.buildPacket(actorId, i)); packets.Add(InventorySetEndPacket.buildPacket(actorId)); BasePacket testPacket = BasePacket.createPacket(packets, true, false); testPacket.debugPrintPacket(); playerSession.queuePacket(testPacket); */ #endregion #region equipsetup EquipmentListX08Packet initialEqupmentPacket = new EquipmentListX08Packet(); initialEqupmentPacket.setItem(EquipmentListX08Packet.SLOT_BODY, 5); initialEqupmentPacket.setItem(EquipmentListX08Packet.SLOT_HEAD, 3); initialEqupmentPacket.setItem(EquipmentListX08Packet.SLOT_UNDERSHIRT, 6); initialEqupmentPacket.setItem(EquipmentListX08Packet.SLOT_UNDERGARMENT, 7); initialEqupmentPacket.setItem(EquipmentListX08Packet.SLOT_MAINHAND, 2); initialEqupmentPacket.setItem(EquipmentListX08Packet.SLOT_LEGS, 8); //Equip Init // playerSession.queuePacket(InventorySetBeginPacket.buildPacket(actorId, 0x23, InventorySetBeginPacket.CODE_EQUIPMENT), true, false); // playerSession.queuePacket(BasePacket.createPacket(initialEqupmentPacket.buildPackets(actorId), true, false)); // playerSession.queuePacket(InventorySetEndPacket.buildPacket(actorId), true, false); playerSession.queuePacket(InventoryEndChangePacket.buildPacket(actorId), true, false); ////////ITEMS//////// #endregion playerSession.queuePacket(getInitPackets(actorId)); BasePacket areaMasterSpawn = zone.getSpawnPackets(actorId); BasePacket debugSpawn = world.GetDebugActor().getSpawnPackets(actorId); BasePacket worldMasterSpawn = world.GetActor().getSpawnPackets(actorId); playerSession.queuePacket(areaMasterSpawn); playerSession.queuePacket(debugSpawn); playerSession.queuePacket(worldMasterSpawn); #region hardcode BasePacket reply10 = new BasePacket("./packets/login/login10.bin"); //Item Storage, Inn Door created BasePacket reply11 = new BasePacket("./packets/login/login11.bin"); //NPC Create ??? Final init reply10.replaceActorID(actorId); reply11.replaceActorID(actorId); playerSession.queuePacket(reply10); playerSession.queuePacket(reply11); #endregion } private void sendInventoryPackets(Item item) { queuePacket(InventoryListX01Packet.buildPacket(actorId, item)); } private void sendInventoryPackets(List items) { int currentIndex = 0; while (true) { if (items.Count - currentIndex >= 64) queuePacket(InventoryListX64Packet.buildPacket(actorId, items, ref currentIndex)); else if (items.Count - currentIndex >= 32) queuePacket(InventoryListX32Packet.buildPacket(actorId, items, ref currentIndex)); else if (items.Count - currentIndex >= 16) queuePacket(InventoryListX16Packet.buildPacket(actorId, items, ref currentIndex)); else if (items.Count - currentIndex <= 8 && items.Count - currentIndex > 1) queuePacket(InventoryListX08Packet.buildPacket(actorId, items, ref currentIndex)); else if (items.Count - currentIndex == 1) { queuePacket(InventoryListX01Packet.buildPacket(actorId, items[currentIndex])); currentIndex++; } else break; } } private void sendRemoveInventoryPackets(List slots) { int currentIndex = 0; while (true) { if (slots.Count - currentIndex >= 64) queuePacket(InventoryRemoveX64Packet.buildPacket(actorId, slots, ref currentIndex)); else if (slots.Count - currentIndex >= 32) queuePacket(InventoryRemoveX32Packet.buildPacket(actorId, slots, ref currentIndex)); else if (slots.Count - currentIndex >= 16) queuePacket(InventoryRemoveX16Packet.buildPacket(actorId, slots, ref currentIndex)); else if (slots.Count - currentIndex >= 8) queuePacket(InventoryRemoveX08Packet.buildPacket(actorId, slots, ref currentIndex)); else if (slots.Count - currentIndex == 1) queuePacket(InventoryRemoveX01Packet.buildPacket(actorId, slots[currentIndex])); else break; } } /* private void sendEquipmentPackets(List indexes) { int currentIndex = 0; InventorySetBeginPacket.buildPacket(actorId, MAXSIZE_INVENTORY_EQUIPMENT, InventorySetBeginPacket.CODE_EQUIPMENT); while (true) { if (indexes.Count - currentIndex >= 64) queuePacket(EquipmentListX64Packet.buildPacket(actorId, indexes, ref currentIndex)); else if (indexes.Count - currentIndex >= 32) queuePacket(EquipmentListX32Packet.buildPacket(actorId, indexes, ref currentIndex)); else if (indexes.Count - currentIndex >= 16) queuePacket(EquipmentListX16Packet.buildPacket(actorId, indexes, ref currentIndex)); else if (indexes.Count - currentIndex >= 8) queuePacket(EquipmentListX08Packet.buildPacket(actorId, indexes, ref currentIndex)); else if (indexes.Count - currentIndex == 1) queuePacket(EquipmentListX01Packet.buildPacket(actorId, indexes[currentIndex])); else break; } InventorySetEndPacket.buildPacket(actorId); } */ public bool isMyPlayer(uint otherActorId) { return actorId == otherActorId; } public void queuePacket(BasePacket packet) { playerSession.queuePacket(packet); } public void queuePacket(SubPacket packet) { playerSession.queuePacket(packet, true, false); } public void broadcastPacket(SubPacket packet) { foreach (Actor a in playerSession.actorInstanceList) { if (a is Player) { Player p = (Player)a; SubPacket clonedPacket = new SubPacket(packet, a.actorId); p.queuePacket(clonedPacket); } } } public Zone getZone() { return zone; } public void sendMessage(uint logType, string sender, string message) { queuePacket(SendMessagePacket.buildPacket(actorId, actorId, logType, sender, message)); } public void logout() { queuePacket(LogoutPacket.buildPacket(actorId)); } public void quitGame() { queuePacket(QuitPacket.buildPacket(actorId)); } public void changeMusic(ushort musicId) { queuePacket(SetMusicPacket.buildPacket(actorId, musicId, 1)); } public void sendChocoboAppearance() { queuePacket(SetCurrentMountChocoboPacket.buildPacket(actorId, chocoboAppearance)); } public void sendGoobbueAppearance() { queuePacket(SetCurrentMountGoobbuePacket.buildPacket(actorId, 1)); } public void setMountState(byte mountState) { this.mountState = mountState; } public byte getMountState() { return mountState; } public void doEmote(uint emoteId) { broadcastPacket(ActorDoEmotePacket.buildPacket(actorId, actorId, emoteId)); } public void sendGameMessage(Actor sourceActor, Actor textIdOwner, ushort textId, byte log, params object[] msgParams) { if (msgParams.Length == 0) { queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); } else queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams) { if (msgParams.Length == 0) queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); else queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams) { if (msgParams.Length == 0) queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); else queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams) { if (msgParams.Length == 0) queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); else queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); } public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams) { //SubPacket worldMasterMessage = //zone.broadcastPacketAroundActor(this, worldMasterMessage); } public void addItem(uint itemId, ushort type, int quantity, byte quality) { List addItemPackets = new List(); Item storedItem = null; //Check if item id exists switch (type) { case InventorySetBeginPacket.CODE_INVENTORY: foreach (Item item in invNormal) { if (item.itemId == itemId) { storedItem = item; break; } } break; case InventorySetBeginPacket.CODE_KEYITEMS: break; case InventorySetBeginPacket.CODE_CURRANCY: break; case InventorySetBeginPacket.CODE_MELDREQUEST: break; case InventorySetBeginPacket.CODE_BAZAAR: break; case InventorySetBeginPacket.CODE_LOOT: break; } //Update lists and db queuePacket(InventoryBeginChangePacket.buildPacket(actorId)); switch (type) { case InventorySetBeginPacket.CODE_INVENTORY: queuePacket(InventorySetBeginPacket.buildPacket(actorId, 200, InventorySetBeginPacket.CODE_INVENTORY)); if (storedItem == null) { Item addedItem = Database.addItem(this, itemId, quantity, quality, false, 100, type); invNormal.Add(addedItem); sendInventoryPackets(addedItem); } else { Database.addQuantity(this, itemId, quantity); storedItem.quantity += quantity; sendInventoryPackets(storedItem); } queuePacket(InventorySetEndPacket.buildPacket(actorId)); break; case InventorySetBeginPacket.CODE_KEYITEMS: break; case InventorySetBeginPacket.CODE_CURRANCY: break; case InventorySetBeginPacket.CODE_MELDREQUEST: break; case InventorySetBeginPacket.CODE_BAZAAR: break; case InventorySetBeginPacket.CODE_LOOT: break; } //addItemPackets.Add(InventorySetBeginPacket.buildPacket(actorId, MAXSIZE_INVENTORY_NORMAL, type)); //sendInventoryPackets() queuePacket(InventorySetEndPacket.buildPacket(actorId)); } public void removeItem(uint itemId, uint quantity) { } public void changeDurability(uint slot, uint durabilityChange) { } public void changeSpiritBind(uint slot, uint spiritBindChange) { } public void changeMateria(uint slot, byte materiaSlot, byte materiaId) { } public void runEventFunction(string functionName, params object[] parameters) { List lParams = LuaUtils.createLuaParamList(parameters); SubPacket spacket = RunEventFunctionPacket.buildPacket(actorId, eventCurrentOwner, eventCurrentStarter, functionName, lParams); spacket.debugPrintSubPacket(); queuePacket(spacket); } public void endEvent() { SubPacket p = EndEventPacket.buildPacket(actorId, eventCurrentOwner, eventCurrentStarter); queuePacket(p); eventCurrentOwner = 0; eventCurrentStarter = ""; eventMenuId = 0; } public void setCurrentMenuId(uint id) { eventMenuId = id; } public uint getCurrentMenuId() { return eventMenuId; } public void sendInstanceUpdate() { //Update Instance List instanceUpdatePackets = playerSession.updateInstance(zone.getActorsAroundActor(this, 50)); foreach (BasePacket bp in instanceUpdatePackets) { // bp.debugPrintPacket(); queuePacket(bp); } } public int getLastInventorySlot(ushort type) { switch (type) { case InventorySetBeginPacket.CODE_INVENTORY: return invNormal.Count == 0 ? 0 : invNormal.Count() + 1; case InventorySetBeginPacket.CODE_KEYITEMS: return invKeyItems.Count == 0 ? 0 : invKeyItems.Count() + 1; case InventorySetBeginPacket.CODE_CURRANCY: return invCurrancy.Count == 0 ? 0 : invCurrancy.Count() + 1; case InventorySetBeginPacket.CODE_MELDREQUEST: return invMeldRequest.Count == 0 ? 0 : invMeldRequest.Count() + 1; case InventorySetBeginPacket.CODE_BAZAAR: return invBazaar.Count == 0 ? 0 : invBazaar.Count() + 1; case InventorySetBeginPacket.CODE_LOOT: return invLoot.Count == 0 ? 0 : invLoot.Count() + 1; } return 0; } } }