/// <summary> /// Activates a log action. /// </summary> /// <param name="context">The context.</param> /// <param name="selectedPacket">The selected packet.</param> /// <returns><c>true</c> if log data tab should be updated.</returns> public override bool Activate(IExecutionContext context, PacketLocation selectedPacket) { PacketLog log = context.LogManager.GetPacketLog(selectedPacket.LogIndex); int selectedIndex = selectedPacket.PacketIndex; string serverName = "UNKNOWN"; int serverId = -1; int serverColorHandling = -1; int sessionId = -1; int objectId = -1; int petId = -1; int healthPercent = -1; int endurancePercent = -1; int manaPercent = -1; int concentrationPercent = -1; int speed = -1; int maxspeed = -1; int clientTargetOid = -1; int serverTargetOid = -1; int regionXOffset = 0; int regionYOffset = 0; int glocX = -1; int glocY = -1; int glocRegion = -1; string loc = "UNKNOWN"; string gloc = "UNKNOWN"; string state = ""; string charName = "UNKNOWN"; string lastName = ""; int playersInGroup = -1; int indexInGroup = -1; int mountId = -1; int mountSlot = -1; int level = -1; int mana = -1; int manaMax = -1; int health = -1; int healthMax = -1; int conc = -1; int concMax = -1; string className = "UNKNOWN"; string raceName = ""; int realm_level = -1; string realm_title = ""; int champ_level = -1; string champ_title = ""; int ml_level = -1; int houseLot = -1; string ml_title = ""; int guildID = -1; string guildName = "None"; string guildRank = ""; string enterRegionName = ""; string petInfo = ""; int insideHouseId = 0; Hashtable enterSubRegion = new Hashtable(); bool flagAwait0xA9 = false; for (int i = 0; i <= selectedIndex; i++) { Packet pak = log[i]; if (pak is CtoS_0xA9_PlayerPosition) { CtoS_0xA9_PlayerPosition pos = (CtoS_0xA9_PlayerPosition)pak; speed = pos.Status & 0x1FF; byte plrState = (byte)((pos.Status >> 10) & 7); state = plrState > 0 ? ((StoC_0xA9_PlayerPosition.PlrState)plrState).ToString() : ""; if ((pos.Status & 0x200) == 0x200) { state += ",Backward"; } if ((pos.Status & 0x8000) == 0x8000) { state += ",StrafeRight"; } if ((pos.Status & 0x4000) == 0x4000) { state += ",StrafeLeft"; } if ((pos.Status & 0x2000) == 0x2000) { state += "Move"; } if ((pos.Flag & 0x01) == 0x01) { state += ",CtoS_0xA9_Flagx01"; } if ((pos.Flag & 0x02) == 0x02) { state += ",Underwater"; } if ((pos.Flag & 0x04) == 0x04) { state += ",PetInView"; } if ((pos.Flag & 0x08) == 0x08) { state += ",GT"; } if ((pos.Flag & 0x10) == 0x10) { state += ",CheckTargetInView"; } if ((pos.Flag & 0x20) == 0x20) { state += ",TargetInView"; } if ((pos.Flag & 0x40) == 0x40) { state += ",MoveTo"; } if ((pos.Health & 0x80) == 0x80) { state += ",Combat"; } if ((pos.Speed & 0x8000) == 0x8000) { state += ",FallDown"; } loc = string.Format("({0,-3}): ({1,-6} {2,-6} {3,-5})", pos.CurrentZoneId, pos.CurrentZoneX, pos.CurrentZoneY, pos.CurrentZoneZ); if (flagAwait0xA9) { if (glocX != -1 && glocY != -1) { regionXOffset = glocX - pos.CurrentZoneX; regionYOffset = glocY - pos.CurrentZoneY; } flagAwait0xA9 = false; } gloc = string.Format("({0,-3}): ({1,-6} {2,-6} {3,-5})", glocRegion, regionXOffset + pos.CurrentZoneX, regionYOffset + pos.CurrentZoneY, pos.CurrentZoneZ); } else if (pak is StoC_0x16_VariousUpdate) { StoC_0x16_VariousUpdate stat = (StoC_0x16_VariousUpdate)pak; if (stat.SubCode == 3) { StoC_0x16_VariousUpdate.PlayerUpdate subData = (StoC_0x16_VariousUpdate.PlayerUpdate)stat.SubData; level = subData.playerLevel; className = subData.className; raceName = subData.raceName; healthMax = (ushort)(((subData.maxHealthHigh & 0xFF) << 8) | (subData.maxHealthLow & 0xFF)); realm_level = subData.realmLevel; realm_title = subData.realmTitle; ml_level = subData.mlLevel; ml_title = subData.mlTitle; houseLot = subData.personalHouse; guildName = subData.guildName; guildRank = subData.guildRank; lastName = subData.lastName; charName = subData.playerName; if (subData is StoC_0x16_VariousUpdate_179.PlayerUpdate_179) { champ_level = (subData as StoC_0x16_VariousUpdate_179.PlayerUpdate_179).championLevel; champ_title = (subData as StoC_0x16_VariousUpdate_179.PlayerUpdate_179).championTitle; } } else if (stat.SubCode == 6) { StoC_0x16_VariousUpdate.PlayerGroupUpdate subData = (StoC_0x16_VariousUpdate.PlayerGroupUpdate)stat.SubData; playersInGroup = stat.SubCount; for (int j = 0; j < stat.SubCount; j++) { StoC_0x16_VariousUpdate.GroupMember member = subData.groupMembers[j]; if (objectId >= 0 && objectId == member.oid) { indexInGroup = j; } } } } else if (pak is CtoS_0x10_CharacterSelectRequest) { CtoS_0x10_CharacterSelectRequest login = (CtoS_0x10_CharacterSelectRequest)pak; charName = login.CharName; } else if (pak is CtoS_0xB0_TargetChange) { CtoS_0xB0_TargetChange trg = (CtoS_0xB0_TargetChange)pak; clientTargetOid = trg.Oid; } else if (pak is StoC_0xAF_Message) { StoC_0xAF_Message msg = (StoC_0xAF_Message)pak; if (msg.Text.StartsWith("You have entered ")) { enterRegionName = regionNameFromMessage(msg.Text.Substring(17)); } else if (msg.Text.StartsWith("(Region) You have entered ")) { string enterSubRegionName = regionNameFromMessage(msg.Text.Substring(26)); if (!enterSubRegion.ContainsKey(enterSubRegionName)) { enterSubRegion.Add(enterSubRegionName, enterSubRegionName); } } else if (msg.Text.StartsWith("(Region) You have left ")) { string enterSubRegionName = regionNameFromMessage(msg.Text.Substring(23)); enterSubRegion.Remove(enterSubRegionName); } } else if (pak is StoC_0xF6_ChangeTarget) { StoC_0xF6_ChangeTarget trg = (StoC_0xF6_ChangeTarget)pak; serverTargetOid = trg.Oid; } else if (pak is StoC_0xB6_UpdateMaxSpeed) { StoC_0xB6_UpdateMaxSpeed spd = (StoC_0xB6_UpdateMaxSpeed)pak; maxspeed = spd.MaxSpeedPercent; } else if (pak is StoC_0xAD_StatusUpdate) { StoC_0xAD_StatusUpdate status = (StoC_0xAD_StatusUpdate)pak; healthPercent = status.HealthPercent; endurancePercent = status.EndurancePercent; manaPercent = status.ManaPercent; concentrationPercent = status.ConcentrationPercent; if (pak is StoC_0xAD_StatusUpdate_190) { health = (pak as StoC_0xAD_StatusUpdate_190).Health; healthMax = (pak as StoC_0xAD_StatusUpdate_190).MaxHealth; mana = (pak as StoC_0xAD_StatusUpdate_190).Power; manaMax = (pak as StoC_0xAD_StatusUpdate_190).MaxPower; conc = (pak as StoC_0xAD_StatusUpdate_190).Concentration; concMax = (pak as StoC_0xAD_StatusUpdate_190).MaxConcentration; } } else if (pak is StoC_0x28_SetSessionId) { StoC_0x28_SetSessionId session = (StoC_0x28_SetSessionId)pak; sessionId = session.SessionId; } else if (pak is StoC_0x20_PlayerPositionAndObjectID) { StoC_0x20_PlayerPositionAndObjectID posAndOid = (StoC_0x20_PlayerPositionAndObjectID)pak; objectId = posAndOid.PlayerOid; glocX = (int)posAndOid.X; glocY = (int)posAndOid.Y; if ((pak as StoC_0x20_PlayerPositionAndObjectID_171) != null) { glocRegion = (pak as StoC_0x20_PlayerPositionAndObjectID_171).Region; } loc = "UNKNOWN"; gloc = string.Format("({0,-3}): ({1,-6} {2,-6} {3,-5})", glocRegion, posAndOid.X, posAndOid.Y, posAndOid.Z); flagAwait0xA9 = true; enterSubRegion.Clear(); enterRegionName = ""; insideHouseId = 0; } else if (pak is StoC_0xDE_SetObjectGuildId) { StoC_0xDE_SetObjectGuildId guildId = (StoC_0xDE_SetObjectGuildId)pak; if (objectId == guildId.Oid) { guildID = guildId.GuildId; } if (guildId.ServerId == 0xFF) // set ObjectID for old logs (1.70-) { objectId = guildId.Oid; } } else if (pak is StoC_0x04_CharacterJump) { StoC_0x04_CharacterJump plrJump = (StoC_0x04_CharacterJump)pak; if (plrJump.X == 0 && plrJump.Y == 0 && plrJump.Z == 0) // skip /faceloc { continue; } objectId = plrJump.PlayerOid; glocX = (int)plrJump.X; glocY = (int)plrJump.Y; insideHouseId = plrJump.HouseId; loc = "UNKNOWN"; gloc = string.Format("({0,-3}): ({1,-6} {2,-6} {3,-5})", glocRegion, plrJump.X, plrJump.Y, plrJump.Z); flagAwait0xA9 = true; } else if (pak is StoC_0x88_PetWindowUpdate) { StoC_0x88_PetWindowUpdate pet = (StoC_0x88_PetWindowUpdate)pak; petId = pet.PetId; } else if (pak is StoC_0xDA_NpcCreate) { if (petId == -1) { continue; } StoC_0xDA_NpcCreate npc = (StoC_0xDA_NpcCreate)pak; if (npc.Oid != petId) { continue; } petInfo = string.Format(" \"{0}\" level:{1} model:0x{2:X4}", npc.Name, npc.Level, npc.Model); } else if (pak is StoC_0xC8_PlayerRide) { StoC_0xC8_PlayerRide ride = (StoC_0xC8_PlayerRide)pak; if (objectId >= 0 && objectId == ride.RiderOid) { if (ride.Flag == 0) { mountId = -1; mountSlot = -1; } else { mountId = ride.MountOid; mountSlot = ride.Slot; } } } else if (pak is StoC_0xFB_CharStatsUpdate_175) { if ((pak as StoC_0xFB_CharStatsUpdate_175).Flag != 0xFF) { healthMax = (pak as StoC_0xFB_CharStatsUpdate_175).MaxHealth; } } else if (pak is StoC_0xFB_CharStatsUpdate) { healthMax = (pak as StoC_0xFB_CharStatsUpdate).MaxHealth; } else if (pak is StoC_0x2A_LoginGranted) { StoC_0x2A_LoginGranted server = (StoC_0x2A_LoginGranted)pak; serverName = server.ServerName; serverId = server.ServerId; serverColorHandling = server.ColorHandling; } } int additionStrings = 0; StringBuilder str = new StringBuilder(); if (serverId > 0) { str.AppendFormat(" server: \"{0}\" id:0x{1:X2} color:{2}\n", serverName, serverId, serverColorHandling); additionStrings++; } str.AppendFormat("session id: 0x{0}\n", ValueToString(sessionId, "X4")); str.AppendFormat(" object id: 0x{0}\n", ValueToString(objectId, "X4")); str.AppendFormat(" pet id: 0x{0}{1}\n", ValueToString(petId, "X4"), petInfo); str.AppendFormat(" char name: {0}{1}\n", charName, lastName != "None" ? string.Format(" \"{0}\"", lastName) : ""); str.AppendFormat(" level: {0} {1}{2}\n", ValueToString(level), className, (raceName != "" ? " (" + raceName + ")" : "")); if (guildName != "None") { str.AppendFormat(" guild: {0}", guildName); str.AppendFormat(" rank:{0}", guildRank); if (guildID != -1) { str.AppendFormat(" guildId:0x{0:X4}", guildID); } str.AppendFormat("\n"); additionStrings++; } if (realm_level > 0) { str.AppendFormat("RealmLevel: {0} \"{1}\"\n", ValueToString(realm_level), realm_title); additionStrings++; } if (ml_level > 0) { str.AppendFormat(" ML level: {0} \"{1}\"\n", ValueToString(ml_level), ml_title); additionStrings++; } if (champ_level > 0) { str.AppendFormat("ChampLevel: {0} \"{1}\"\n", ValueToString(champ_level), champ_title); additionStrings++; } str.AppendFormat("\n"); if (houseLot > 0) { str.AppendFormat(" HouseLot: 0x{0}\n", ValueToString(houseLot, "X4")); additionStrings++; } if (mountId > 0) { str.AppendFormat(" mount id: 0x{0} (slot:{1})\n", ValueToString(mountId, "X4"), ValueToString(mountSlot)); additionStrings++; } if (playersInGroup > 0) { str.AppendFormat(" group: {0}[{1}]\n", ValueToString(indexInGroup), ValueToString(playersInGroup)); additionStrings++; } str.AppendFormat(" speed: {0,3}\n", ValueToString(speed)); str.AppendFormat(" maxSpeed: {0,3}%\n", ValueToString(maxspeed)); str.AppendFormat(" health: {0,3}%", ValueToString(healthPercent)); if (health != -1) { str.AppendFormat(" ({0}/{1})", health, healthMax); } else if (healthMax != -1) { str.AppendFormat(" (maxHealth:{0})", healthMax); } str.Append('\n'); str.AppendFormat(" mana: {0,3}%", ValueToString(manaPercent)); if (mana != -1) { str.AppendFormat(" ({0}/{1})", mana, manaMax); } str.Append('\n'); str.AppendFormat(" endurance: {0,3}%\n", ValueToString(endurancePercent)); str.AppendFormat("concentration: {0,3}%", ValueToString(concentrationPercent)); if (conc != -1) { str.AppendFormat(" ({0}/{1})", conc, concMax); } str.Append('\n'); str.AppendFormat(" clientTarget: 0x{0}\n", ValueToString(clientTargetOid, "X4")); str.AppendFormat(" checkTarget: 0x{0}\n", ValueToString(serverTargetOid, "X4")); str.AppendFormat(" current zone: {0}{1}\n", loc, enterRegionName == "" ? "" : " (" + enterRegionName + ")"); str.AppendFormat(" calced gloc: {0}\n", gloc); int subReg = 0; foreach (string subRegionName in enterSubRegion.Values) { str.AppendFormat(" subRegion[{0}]: {1}\n", subReg++, subRegionName); additionStrings++; } if (insideHouseId != 0) { str.AppendFormat(" inside House: {0}\n", insideHouseId); additionStrings++; } str.AppendFormat(" flags: {0}\n", state); InfoWindowForm infoWindow = new InfoWindowForm(); infoWindow.Text = "Player info (right click to close)"; infoWindow.Width = 500; infoWindow.Height = 310 + 15 * additionStrings; infoWindow.InfoRichTextBox.Text = str.ToString(); infoWindow.StartWindowThread(); return(false); }
private string MakeHidInfo(PacketLog log, int selectedIndex, ushort houseId) { StringBuilder str = new StringBuilder(); CtoS_0xA9_PlayerPosition lastSelfCoords = null; LocalCoords lastObjectCoords = null; LocalCoords regionGlobalCoords = null; LocalCoords firstSelfCoords = null; bool flagInteriorFound = false; bool flagInsideUpdateFound = false; bool flagExteriorFound = false; bool flagHouseFound = false; for (int i = selectedIndex; i >= 0; i--) { Packet pak = log[i]; if (pak is StoC_0x20_PlayerPositionAndObjectID) // stop scanning packets on enter region { regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z); break; } else if (pak is StoC_0xD1_HouseCreate) { if (!flagHouseFound && (pak as StoC_0xD1_HouseCreate).HouseId == houseId) { flagHouseFound = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xD1_HouseCreate).X, (pak as StoC_0xD1_HouseCreate).Y, (pak as StoC_0xD1_HouseCreate).Z); } } } else if (pak is StoC_0xD2_HouseUpdate) { if (!flagExteriorFound && (pak as StoC_0xD2_HouseUpdate).HouseId == houseId && (pak as StoC_0xD2_HouseUpdate).UpdateCode == 0x80) { flagExteriorFound = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x09_HouseDecorationUpdate) { if (!flagInteriorFound && (pak as StoC_0x09_HouseDecorationUpdate).HouseId == houseId && (pak as StoC_0x09_HouseDecorationUpdate).DecorationCode == 0x80) { flagInteriorFound = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x08_HouseInsideUpdate) { if (!flagInsideUpdateFound && (pak as StoC_0x08_HouseInsideUpdate).HouseId == houseId) { flagInsideUpdateFound = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is CtoS_0xA9_PlayerPosition) { if (firstSelfCoords == null) { firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF); } else { firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX; firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY; firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ; } if (lastSelfCoords == null) { lastSelfCoords = pak as CtoS_0xA9_PlayerPosition; } } } str.Insert(0, string.Format("\nhouseId:0x{0:X4}\n", houseId)); if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId) { long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (loc)\n", range)); } else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null) /* gloc Object */ { long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (gloc)\n", range)); // str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY)); } else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF) /* gloc Object */ { long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (gloc)\n", range)); } return(str.ToString()); }
public static SortedList MakeOidList(int selectedIndex, PacketLog log, out int currentRegion, out int currentZone) { SortedList oidInfo = new SortedList(); currentRegion = -1; currentZone = -1; ushort playerOid = 0; string CharName = "UNKNOWN"; for (int i = 0; i < selectedIndex; ++i) { Packet pak = log[i]; if (pak is StoC_0xD4_PlayerCreate) { StoC_0xD4_PlayerCreate player = (StoC_0xD4_PlayerCreate)pak; oidInfo[player.Oid] = new LivingInfo(pak.Time, "PLR", player.Name, player.Level, player.GuildName); } else if (pak is StoC_0x4B_PlayerCreate_172) { StoC_0x4B_PlayerCreate_172 player = (StoC_0x4B_PlayerCreate_172)pak; oidInfo[player.Oid] = new LivingInfo(pak.Time, "PLR", player.Name, player.Level, player.GuildName); if (currentZone == -1) { currentZone = player.ZoneId; } } else if (pak is StoC_0x12_CreateMovingObject) { StoC_0x12_CreateMovingObject obj = (StoC_0x12_CreateMovingObject)pak; oidInfo[obj.ObjectOid] = new ObjectInfo(pak.Time, "MOVE", obj.Name, 0); } else if (pak is StoC_0x6C_KeepComponentOverview) { StoC_0x6C_KeepComponentOverview keep = (StoC_0x6C_KeepComponentOverview)pak; oidInfo[keep.Uid] = new ObjectInfo(pak.Time, "Keep", string.Format("keepId:0x{0:X4} componentId:{1}", keep.KeepId, keep.ComponentId), 0); } else if (pak is StoC_0xD1_HouseCreate) { StoC_0xD1_HouseCreate house = (StoC_0xD1_HouseCreate)pak; oidInfo[house.HouseId] = new ObjectInfo(pak.Time, "HOUS", house.Name, 0); } else if (pak is StoC_0xDA_NpcCreate) { StoC_0xDA_NpcCreate npc = (StoC_0xDA_NpcCreate)pak; oidInfo[npc.Oid] = new LivingInfo(pak.Time, "NPC", npc.Name, npc.Level, npc.GuildName); } else if (pak is CtoS_0xA9_PlayerPosition) { CtoS_0xA9_PlayerPosition plr = (CtoS_0xA9_PlayerPosition)pak; if (currentZone == -1) { currentZone = plr.CurrentZoneId; } } else if (pak is StoC_0xD9_ItemDoorCreate) { StoC_0xD9_ItemDoorCreate item = (StoC_0xD9_ItemDoorCreate)pak; string type = "ITEM"; if (item.ExtraBytes > 0) { type = "DOOR"; } oidInfo[item.Oid] = new ObjectInfo(pak.Time, type, item.Name, 0); } else if (pak is StoC_0xB7_RegionChange) { StoC_0xB7_RegionChange region = (StoC_0xB7_RegionChange)pak; // if (region.RegionId != currentRegion) // { currentRegion = region.RegionId; currentZone = region.ZoneId; oidInfo.Clear(); // } } else if (pak is StoC_0x20_PlayerPositionAndObjectID_171) { StoC_0x20_PlayerPositionAndObjectID_171 region = (StoC_0x20_PlayerPositionAndObjectID_171)pak; // if (region.Region!= currentRegion) // { currentRegion = region.Region; oidInfo.Clear(); // } playerOid = region.PlayerOid; oidInfo[region.PlayerOid] = new LivingInfo(pak.Time, "YOU", CharName, 0, ""); } else if (pak is StoC_0x16_VariousUpdate) { if (playerOid != 0) { StoC_0x16_VariousUpdate stat = (StoC_0x16_VariousUpdate)pak; if (stat.SubCode == 3) { StoC_0x16_VariousUpdate.PlayerUpdate subData = (StoC_0x16_VariousUpdate.PlayerUpdate)stat.SubData; if (oidInfo[playerOid] != null) { LivingInfo plr = (LivingInfo)oidInfo[playerOid]; plr.level = subData.playerLevel; plr.guildName = subData.guildName; oidInfo[playerOid] = plr; } } } } else if (pak is CtoS_0x10_CharacterSelectRequest) { CtoS_0x10_CharacterSelectRequest login = (CtoS_0x10_CharacterSelectRequest)pak; CharName = login.CharName; } } return(oidInfo); }
private string MakeOidInfo(PacketLog log, int selectedIndex, ushort objectId, ushort sessionId, ushort keepId) { StringBuilder str = new StringBuilder(); int maxPacketsLookBackForGetCoords = 100000; // look back in log max 30 packets for find coords after found obejct creation packet bool fullInfoFound = false; bool flagPacketMove = false; bool flagPacketCreationRequest = false; bool flagPacketItem = false; bool flagPacketRide = false; bool flagPacketEquip = false; bool flagPacketGuild = false; bool flagPacketPet = false; bool flagPacketDialog = false; bool flagVisualEffect = false; bool flagPacketMobCreate = false; bool flagPacketCombatAnimation = false; bool flagAllowGetFirstSelfCoords = true; ushort selfId = 0; Hashtable ObjectsOnMount = null; BitArray m_packetsBitArrayStoC = new BitArray(255); m_packetsBitArrayStoC.SetAll(false); BitArray m_packetsBitArrayCtoS = new BitArray(255); m_packetsBitArrayCtoS.SetAll(false); CtoS_0xA9_PlayerPosition lastSelfCoords = null; LocalCoords lastObjectCoords = null; LocalCoords regionGlobalCoords = null; LocalCoords firstSelfCoords = null; // Packet lastObjectCoords = null; string objectType = ""; for (int i = selectedIndex; i >= 0; i--) { Packet pak = log[i]; if (fullInfoFound) { maxPacketsLookBackForGetCoords--; } if (pak is StoC_0x20_PlayerPositionAndObjectID) // stop scanning packets on enter region { if ((pak as StoC_0x20_PlayerPositionAndObjectID).PlayerOid == objectId) { objectType = " (Self)"; } // str.Insert(0, pak.ToHumanReadableString(TimeSpan(0), true) + '\n'); if (regionGlobalCoords == null) // skip if gloc Jump { regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z); } flagAllowGetFirstSelfCoords = false; break; } else if (pak is StoC_0x04_CharacterJump) { #warning TODO: Rewrite for find self Oid if ((pak as StoC_0x04_CharacterJump).PlayerOid == selfId) { regionGlobalCoords = new LocalCoords((pak as StoC_0x04_CharacterJump).X, (pak as StoC_0x04_CharacterJump).Y, (pak as StoC_0x04_CharacterJump).Z); flagAllowGetFirstSelfCoords = false; if (lastSelfCoords != null) { if (firstSelfCoords == null) { firstSelfCoords = new LocalCoords(lastSelfCoords.CurrentZoneX, lastSelfCoords.CurrentZoneY, lastSelfCoords.CurrentZoneZ, 0xFFFF); } else { firstSelfCoords.CurrentZoneX = lastSelfCoords.CurrentZoneX; firstSelfCoords.CurrentZoneY = lastSelfCoords.CurrentZoneY; firstSelfCoords.CurrentZoneZ = lastSelfCoords.CurrentZoneZ; } } // break; } } else if (pak is StoC_0xD4_PlayerCreate) { if (!fullInfoFound && (pak as StoC_0xD4_PlayerCreate).Oid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (player)"; fullInfoFound = true; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xD4_PlayerCreate).ZoneX, (pak as StoC_0xD4_PlayerCreate).ZoneY, (pak as StoC_0xD4_PlayerCreate).ZoneZ, (ushort)(pak as StoC_0xD4_PlayerCreate).ZoneId); } } } else if (pak is StoC_0x4B_PlayerCreate_172) { if (!fullInfoFound && (pak as StoC_0x4B_PlayerCreate_172).Oid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (player)"; fullInfoFound = true; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0x4B_PlayerCreate_172).ZoneX, (pak as StoC_0x4B_PlayerCreate_172).ZoneY, (pak as StoC_0x4B_PlayerCreate_172).ZoneZ, (pak as StoC_0x4B_PlayerCreate_172).ZoneId); } } } else if (pak is StoC_0xDA_NpcCreate) { if (!fullInfoFound && !flagPacketMobCreate && (pak as StoC_0xDA_NpcCreate).Oid == objectId) { flagPacketMobCreate = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (NPC)"; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xDA_NpcCreate).X, (pak as StoC_0xDA_NpcCreate).Y, (pak as StoC_0xDA_NpcCreate).Z); } // fullInfoFound = true; // need find 0x20 for get gloc region } } else if (pak is StoC_0xD9_ItemDoorCreate) { if (!fullInfoFound && !flagPacketItem && (pak as StoC_0xD9_ItemDoorCreate).Oid == objectId) { flagPacketItem = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); if ((pak as StoC_0xD9_ItemDoorCreate).ExtraBytes == 4) { objectType = " (Door)"; } else { objectType = " (Object)"; } if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xD9_ItemDoorCreate).X, (pak as StoC_0xD9_ItemDoorCreate).Y, (pak as StoC_0xD9_ItemDoorCreate).Z); } // fullInfoFound = true; // need find 0x20 for get gloc region } } else if (pak is StoC_0x12_CreateMovingObject) { if (!fullInfoFound && (pak as StoC_0x12_CreateMovingObject).ObjectOid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (MovingObject)"; fullInfoFound = true; } } else if (pak is StoC_0xC8_PlayerRide) // show object if rided { if (!fullInfoFound && !flagPacketRide && (pak as StoC_0xC8_PlayerRide).RiderOid == objectId) { flagPacketRide = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } else if ((pak as StoC_0xC8_PlayerRide).MountOid == objectId) { if (ObjectsOnMount == null) { ObjectsOnMount = new Hashtable(); } if (!ObjectsOnMount.ContainsKey((pak as StoC_0xC8_PlayerRide).Slot)) { ObjectsOnMount.Add((pak as StoC_0xC8_PlayerRide).Slot, (ushort)(pak as StoC_0xC8_PlayerRide).RiderOid); str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } } else if (pak is StoC_0x15_EquipmentUpdate) { if (!fullInfoFound && !flagPacketEquip && (pak as StoC_0x15_EquipmentUpdate).Oid == objectId) { flagPacketEquip = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0xEE_NpcChangeProperties) { if (!fullInfoFound && (pak as StoC_0xEE_NpcChangeProperties).Oid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0xDE_SetObjectGuildId) { if (!fullInfoFound && !flagPacketGuild && (pak as StoC_0xDE_SetObjectGuildId).Oid == objectId) { flagPacketGuild = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0xA1_NpcUpdate) { if (!fullInfoFound && !flagPacketMove && (pak as StoC_0xA1_NpcUpdate).NpcOid == objectId) { flagPacketMove = true; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xA1_NpcUpdate).CurrentZoneX, (pak as StoC_0xA1_NpcUpdate).CurrentZoneY, (pak as StoC_0xA1_NpcUpdate).CurrentZoneZ, (pak as StoC_0xA1_NpcUpdate).CurrentZoneId); } str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x81_ShowDialog) { if (!fullInfoFound && !flagPacketDialog && (pak as StoC_0x81_ShowDialog).ObjectIds != null && (pak as StoC_0x81_ShowDialog).ObjectIds.Length > 0 && (pak as StoC_0x81_ShowDialog).ObjectIds[0] == objectId) { flagPacketDialog = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0xA9_PlayerPosition) { if (!flagPacketMove && (pak as StoC_0xA9_PlayerPosition).SessionId == sessionId) { if (!fullInfoFound) { flagPacketMove = true; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xA9_PlayerPosition).CurrentZoneX, (pak as StoC_0xA9_PlayerPosition).CurrentZoneY, (pak as StoC_0xA9_PlayerPosition).CurrentZoneZ, (pak as StoC_0xA9_PlayerPosition).CurrentZoneId); } } str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x88_PetWindowUpdate) { if (!fullInfoFound && !flagPacketPet && (pak as StoC_0x88_PetWindowUpdate).PetId == objectId) { flagPacketPet = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x4C_VisualEffect) { if (!fullInfoFound && !flagVisualEffect && (pak as StoC_0x4C_VisualEffect).Oid == objectId) { flagVisualEffect = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is CtoS_0xA9_PlayerPosition) { if (flagAllowGetFirstSelfCoords) { if (firstSelfCoords == null) { firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF); } else { firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX; firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY; firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ; } } if (lastSelfCoords == null) { lastSelfCoords = pak as CtoS_0xA9_PlayerPosition; } } else if (pak is CtoS_0xBE_NpcCreationRequest) { if (!flagPacketCreationRequest && (pak as CtoS_0xBE_NpcCreationRequest).NpcOid == objectId) { flagPacketCreationRequest = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x69_KeepOverview) { if ((pak as StoC_0x69_KeepOverview).KeepId == keepId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0x69_KeepOverview).KeepX, (pak as StoC_0x69_KeepOverview).KeepY); } } } else if (pak is StoC_0x61_KeepRepair) { if (!fullInfoFound && (pak as StoC_0x61_KeepRepair).KeepId == keepId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x62_KeepClaim) { if (!fullInfoFound && (pak as StoC_0x62_KeepClaim).KeepId == keepId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x67_KeepUpdate) { if (!fullInfoFound && (pak as StoC_0x67_KeepUpdate).KeepId == keepId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is StoC_0x6C_KeepComponentOverview) { if (!fullInfoFound && (pak as StoC_0x6C_KeepComponentOverview).KeepId == keepId) // if (!fullInfoFound && (pak as StoC_0x6C_KeepComponentOverview).Uid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (KeepComponent)"; // fullInfoFound = true; } } else if (pak is StoC_0xBC_CombatAnimation) { if (!fullInfoFound && !flagPacketCombatAnimation && ((pak as StoC_0xBC_CombatAnimation).AttackerOid == objectId || (pak as StoC_0xBC_CombatAnimation).DefenderOid == objectId)) { flagPacketCombatAnimation = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else { if (pak is IObjectIdPacket) // all other packet's with OID { if (!(fullInfoFound || flagPacketMobCreate || flagPacketItem)) // not show packet's before creation object packet { if ((pak.Direction == ePacketDirection.ServerToClient && !m_packetsBitArrayStoC[pak.Code]) || (pak.Direction == ePacketDirection.ClientToServer && !m_packetsBitArrayCtoS[pak.Code])) { ushort[] objectIds = (pak as IObjectIdPacket).ObjectIds; if (objectIds != null && objectIds.Length > 0) { for (int j = 0; j < objectIds.Length; j++) { if (objectIds[j] > 0 && objectIds[j] == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); if (pak.Direction == ePacketDirection.ServerToClient) { m_packetsBitArrayStoC[pak.Code] = true; } else if (pak.Direction == ePacketDirection.ClientToServer) { m_packetsBitArrayCtoS[pak.Code] = true; } break; } } } } } } } // if we found object creation packets and both coords (self and object) then break; // if we found object creation packets but not find any coords break after maxPacketsLookBackForGetCoords look back if (fullInfoFound && ((lastObjectCoords != null && lastSelfCoords != null) || maxPacketsLookBackForGetCoords <= 0)) { break; } } // if (!fullInfoFound) // str.Insert(0, "No more info found\n"); // TODO add zone checks... (mb recalc in global coords if zones is different ?) { if (regionGlobalCoords != null) { str.Insert(0, string.Format("regionGlobalCoords (x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY)); } if (firstSelfCoords != null) { str.Insert(0, string.Format("firstSelfCoords (x:{0} y:{1})\n", firstSelfCoords.CurrentZoneX, firstSelfCoords.CurrentZoneY)); } if (lastSelfCoords != null) { str.Insert(0, string.Format("lastSelfCoords (x:{0} y:{1})\n", lastSelfCoords.CurrentZoneX, lastSelfCoords.CurrentZoneY)); } if (lastObjectCoords != null) { str.Insert(0, string.Format("lastObjectCoords (x:{0} y:{1})\n", lastObjectCoords.CurrentZoneX, lastObjectCoords.CurrentZoneY)); } } if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId) { long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (loc/loc)\n", range)); } else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null) /* gloc Object */ { long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = 0; if (lastObjectCoords.CurrentZoneZ != 0xFFFF) { zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; } int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (loc/gloc)\n", range)); str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY)); } else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF) /* gloc Object */ { long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = 0; if (lastObjectCoords.CurrentZoneZ != 0xFFFF) { zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; } int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (gloc/gloc)\n", range)); } if (objectId != 0xFFFF) { str.Insert(0, string.Format("\nobjectId:0x{0:X4}{1}\n", objectId, objectType)); } return(str.ToString()); }
private string MakeOidInfo(PacketLog log, int selectedIndex, ushort objectId, ushort sessionId) { StringBuilder str = new StringBuilder(); int maxPacketsLookBackForGetCoords = 50; // look back in log max 30 packets for find coords after found obejct creation packet bool fullInfoFound = false; bool flagPacketMove = false; bool flagPacketItem = false; bool flagPacketRide = false; bool flagPacketEquip = false; bool flagPacketGuild = false; bool flagPacketPet = false; bool flagPacketDialog = false; bool flagVisualEffect = false; bool flagPacketMobCreate = false; CtoS_0xA9_PlayerPosition lastSelfCoords = null; LocalCoords lastObjectCoords = null; LocalCoords regionGlobalCoords = null; LocalCoords firstSelfCoords = null; // Packet lastObjectCoords = null; string objectType = ""; for (int i = selectedIndex; i >= 0; i--) { Packet pak = log[i]; if (fullInfoFound) { maxPacketsLookBackForGetCoords--; } if (pak is StoC_0x20_PlayerPositionAndObjectID) // stop scanning packets on enter region { if ((pak as StoC_0x20_PlayerPositionAndObjectID).PlayerOid == objectId) { objectType = " (Self)"; } // str.Insert(0, pak.ToHumanReadableString(TimeSpan(0), true) + '\n'); regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z); break; } else if (!fullInfoFound && pak is StoC_0xD4_PlayerCreate) { if ((pak as StoC_0xD4_PlayerCreate).Oid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (player)"; fullInfoFound = true; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xD4_PlayerCreate).ZoneX, (pak as StoC_0xD4_PlayerCreate).ZoneY, (pak as StoC_0xD4_PlayerCreate).ZoneZ, (ushort)(pak as StoC_0xD4_PlayerCreate).ZoneId); } } } else if (!fullInfoFound && pak is StoC_0x4B_PlayerCreate_172) { if ((pak as StoC_0x4B_PlayerCreate_172).Oid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (player)"; fullInfoFound = true; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0x4B_PlayerCreate_172).ZoneX, (pak as StoC_0x4B_PlayerCreate_172).ZoneY, (pak as StoC_0x4B_PlayerCreate_172).ZoneZ, (pak as StoC_0x4B_PlayerCreate_172).ZoneId); } } } else if (!fullInfoFound && pak is StoC_0xDA_NpcCreate) { if (!flagPacketMobCreate && (pak as StoC_0xDA_NpcCreate).Oid == objectId) { flagPacketMobCreate = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (NPC)"; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xDA_NpcCreate).X, (pak as StoC_0xDA_NpcCreate).Y, (pak as StoC_0xDA_NpcCreate).Z); } // fullInfoFound = true; // need find 0x20 for get gloc region } } else if (!fullInfoFound && pak is StoC_0x6C_KeepComponentOverview) { if ((pak as StoC_0x6C_KeepComponentOverview).Uid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (KeepComponent)"; fullInfoFound = true; } } else if (!fullInfoFound && pak is StoC_0xD9_ItemDoorCreate) { if (!flagPacketItem && (pak as StoC_0xD9_ItemDoorCreate).Oid == objectId) { flagPacketItem = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); if ((pak as StoC_0xD9_ItemDoorCreate).ExtraBytes == 4) { objectType = " (Door)"; } else { objectType = " (Object)"; } if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xD9_ItemDoorCreate).X, (pak as StoC_0xD9_ItemDoorCreate).Y, (pak as StoC_0xD9_ItemDoorCreate).Z); } // fullInfoFound = true; // need find 0x20 for get gloc region } } else if (!fullInfoFound && pak is StoC_0x12_CreateMovingObject) { if ((pak as StoC_0x12_CreateMovingObject).ObjectOid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); objectType = " (MovingObject)"; fullInfoFound = true; } } else if (!fullInfoFound && pak is StoC_0xC8_PlayerRide) // show object if rided { if (!flagPacketRide && (pak as StoC_0xC8_PlayerRide).RiderOid == objectId) { flagPacketRide = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } else if ((pak as StoC_0xC8_PlayerRide).MountOid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (!fullInfoFound && pak is StoC_0x15_EquipmentUpdate) { if (!flagPacketEquip && (pak as StoC_0x15_EquipmentUpdate).Oid == objectId) { flagPacketEquip = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (!fullInfoFound && pak is StoC_0xEE_NpcChangeProperties) { if ((pak as StoC_0xEE_NpcChangeProperties).Oid == objectId) { str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (!fullInfoFound && pak is StoC_0xDE_SetObjectGuildId) { if (!flagPacketGuild && (pak as StoC_0xDE_SetObjectGuildId).Oid == objectId) { flagPacketGuild = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (!fullInfoFound && pak is StoC_0xA1_NpcUpdate) { if (!flagPacketMove && (pak as StoC_0xA1_NpcUpdate).NpcOid == objectId) { flagPacketMove = true; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xA1_NpcUpdate).CurrentZoneX, (pak as StoC_0xA1_NpcUpdate).CurrentZoneY, (pak as StoC_0xA1_NpcUpdate).CurrentZoneZ, (pak as StoC_0xA1_NpcUpdate).CurrentZoneId); } str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (!fullInfoFound && pak is StoC_0x81_ShowDialog) { if (!flagPacketDialog && (pak as StoC_0x81_ShowDialog).ObjectIds != null && (pak as StoC_0x81_ShowDialog).ObjectIds.Length > 0 && (pak as StoC_0x81_ShowDialog).ObjectIds[0] == objectId) { flagPacketDialog = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (!fullInfoFound && pak is StoC_0xA9_PlayerPosition) { if (!flagPacketMove && (pak as StoC_0xA9_PlayerPosition).SessionId == sessionId) { flagPacketMove = true; if (lastObjectCoords == null) { lastObjectCoords = new LocalCoords((pak as StoC_0xA9_PlayerPosition).CurrentZoneX, (pak as StoC_0xA9_PlayerPosition).CurrentZoneY, (pak as StoC_0xA9_PlayerPosition).CurrentZoneZ, (pak as StoC_0xA9_PlayerPosition).CurrentZoneId); } str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (!fullInfoFound && pak is StoC_0x88_PetWindowUpdate) { if (!flagPacketPet && (pak as StoC_0x88_PetWindowUpdate).PetId == objectId) { flagPacketPet = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (!fullInfoFound && pak is StoC_0x4C_VisualEffect) { if (!flagVisualEffect && (pak as StoC_0x4C_VisualEffect).Oid == objectId) { flagVisualEffect = true; str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n'); } } else if (pak is CtoS_0xA9_PlayerPosition) { if (firstSelfCoords == null) { firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF); } else { firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX; firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY; firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ; } if (lastSelfCoords == null) { lastSelfCoords = pak as CtoS_0xA9_PlayerPosition; } } // if we found object creation packets and both coords (self and object) then break; // if we found object creation packets but not find any coords break after maxPacketsLookBackForGetCoords look back if (fullInfoFound && ((lastObjectCoords != null && lastSelfCoords != null) || maxPacketsLookBackForGetCoords <= 0)) { break; } } if (!fullInfoFound) { str.Insert(0, "No more info found\n"); } // TODO add zone checks... (mb recalc in global coords if zones is different ?) if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId) { long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (loc)\n", range)); } else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null) /* gloc Object */ { long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (gloc)\n", range)); // str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY)); } else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF) /* gloc Object */ { long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX; long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY; long zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ; int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); str.Insert(0, string.Format("range from you:{0} (gloc)\n", range)); } str.Insert(0, string.Format("\nobjectId:0x{0:X4}{1}\n", objectId, objectType)); return(str.ToString()); }