public static ChatPacket ParseChatPacket(string[] lines, long index, BuildVersions buildVersion) { ChatPacket chatPacket = new ChatPacket("", 0, "", LineGetters.GetTimeSpanFromLine(lines[index])); if (IsCreatureText(lines[index + 1])) { do { if (LineGetters.GetGuidFromLine(lines[index], buildVersion, senderGuid: true) != "") { chatPacket.creatureGuid = LineGetters.GetGuidFromLine(lines[index], buildVersion, senderGuid: true); } if (GetTextFromLine(lines[index]) != "") { chatPacket.creatureText = GetTextFromLine(lines[index]); } index++; }while (lines[index] != ""); chatPacket.creatureEntry = CreatureScriptsCreator.GetCreatureEntryByGuid(chatPacket.creatureGuid); } return(chatPacket); }
public static SpellStartPacket ParseSpellStartPacket(string[] lines, long index, BuildVersions buildVersion) { SpellStartPacket spellPacket = new SpellStartPacket("", 0, new TimeSpan(), LineGetters.GetTimeSpanFromLine(lines[index]), new Position()); if (IsCreatureSpellCastLine(lines[index + 1])) { do { if (LineGetters.GetGuidFromLine(lines[index], buildVersion, casterGuid: true) != "") { spellPacket.casterGuid = LineGetters.GetGuidFromLine(lines[index], buildVersion, casterGuid: true); } if (GetSpellIdFromLine(lines[index]) != 0) { spellPacket.spellId = GetSpellIdFromLine(lines[index]); } if (GetCastTimeFromLine(lines[index]) != TimeSpan.Zero) { spellPacket.spellCastTime = GetCastTimeFromLine(lines[index]); } if (GetSpellDestinationFromLine(lines[index]).IsValid()) { spellPacket.spellDestination = GetSpellDestinationFromLine(lines[index]); } index++; }while (lines[index] != ""); } return(spellPacket); }
public static IEnumerable <AuraUpdatePacket> ParseAuraUpdatePacket(string[] lines, long index, BuildVersions buildVersion) { TimeSpan packetSendTime = LineGetters.GetTimeSpanFromLine(lines[index]); List <AuraUpdatePacket> aurasList = new List <AuraUpdatePacket>(); do { if (lines[index].Contains("Slot:")) { AuraUpdatePacket auraUpdatePacket = new AuraUpdatePacket("", null, 0, null, packetSendTime); do { if (GetAuraSlotFromLine(lines[index]) != null) { auraUpdatePacket.slot = GetAuraSlotFromLine(lines[index]); } if (GetHasAuraFromLine(lines[index]) != null) { auraUpdatePacket.HasAura = GetHasAuraFromLine(lines[index]); } if (SpellStartPacket.GetSpellIdFromLine(lines[index]) != 0) { auraUpdatePacket.spellId = SpellStartPacket.GetSpellIdFromLine(lines[index]); } if (LineGetters.GetGuidFromLine(lines[index], buildVersion, unitGuid: true) != "") { auraUpdatePacket.unitGuid = LineGetters.GetGuidFromLine(lines[index], buildVersion, unitGuid: true); } index++; }while (IsLineValidForAuraUpdateParsing(lines[index])); if (!auraUpdatePacket.IsValid()) { continue; } aurasList.Add(auraUpdatePacket); index--; } index++; }while (lines[index] != ""); return(aurasList); }
public static string GetUnitGuidFromAuraUpdatePacket(string[] lines, long index, BuildVersions build) { do { if (LineGetters.GetGuidFromLine(lines[index], build, unitGuid: true) != "") { return(LineGetters.GetGuidFromLine(lines[index], build, unitGuid: true)); } index++; }while (lines[index] != ""); return(""); }
public static AIReactionPacket ParseAIReactionPacket(string[] lines, long index, BuildVersions buildVersion) { AIReactionPacket reactionPacket = new AIReactionPacket("", 0, LineGetters.GetTimeSpanFromLine(lines[index])); do { if (LineGetters.GetGuidFromLine(lines[index], buildVersion, unitGuid: true) != "") { reactionPacket.creatureGuid = LineGetters.GetGuidFromLine(lines[index], buildVersion, unitGuid: true); } index++; }while (lines[index] != ""); reactionPacket.creatureEntry = CreatureScriptsCreator.GetCreatureEntryByGuid(reactionPacket.creatureGuid); return(reactionPacket); }
public static List <string> GetGuidsFromUpdatePacket(string[] lines, long index, BuildVersions build) { List <string> guidsList = new List <string>(); do { string guid = LineGetters.GetGuidFromLine(lines[index], build); if (guid != "") { if (!guidsList.Contains(guid)) { guidsList.Add(guid); } } index++; }while (lines[index] != ""); return(guidsList); }
public static EmotePacket ParseEmotePacket(string[] lines, long index, BuildVersions buildVersion) { EmotePacket emotePacket = new EmotePacket("", 0, LineGetters.GetTimeSpanFromLine(lines[index])); do { if (GetGuidFromLine(lines[index]) != "") { emotePacket.guid = GetGuidFromLine(lines[index]); } if (GetEmoteIdFromLine(lines[index]) != 0) { emotePacket.emoteId = GetEmoteIdFromLine(lines[index]); } index++; }while (lines[index] != ""); return(emotePacket); }
public static AttackStopPacket ParseAttackStopkPacket(string[] lines, long index, BuildVersions buildVersion) { AttackStopPacket attackPacket = new AttackStopPacket("", false, LineGetters.GetTimeSpanFromLine(lines[index])); if (LineGetters.IsCreatureLine(lines[index + 1])) { do { if (LineGetters.GetGuidFromLine(lines[index], buildVersion, attackerGuid: true) != "") { attackPacket.creatureGuid = LineGetters.GetGuidFromLine(lines[index], buildVersion, attackerGuid: true); } if (GetNowDeadFromLine(lines[index])) { attackPacket.nowDead = GetNowDeadFromLine(lines[index]); } index++; }while (lines[index] != ""); } return(attackPacket); }
public static MonsterMovePacket ParseMovementPacket(string[] lines, long index, BuildVersions buildVersion) { MonsterMovePacket movePacket = new MonsterMovePacket("", 0.0f, LineGetters.GetTimeSpanFromLine(lines[index]), new List <Waypoint>(), 0, new Position(), new JumpInfo()); if (LineGetters.IsCreatureLine(lines[index + 1])) { Position lastPosition = new Position(); do { if (lines[index].Contains("FacingGUID: Full:")) { movePacket.creatureGuid = ""; break; } if (LineGetters.GetGuidFromLine(lines[index], buildVersion, moverGuid: true) != "") { movePacket.creatureGuid = LineGetters.GetGuidFromLine(lines[index], buildVersion, moverGuid: true); } if (GetStartPositionFromLine(lines[index]).IsValid()) { movePacket.startPos = GetStartPositionFromLine(lines[index]); } if (GetMoveTimeFromLine(lines[index]) != 0) { movePacket.moveTime = GetMoveTimeFromLine(lines[index]); } if (GetFaceDirectionFromLine(lines[index]) != 0.0f) { movePacket.creatureOrientation = GetFaceDirectionFromLine(lines[index]); } if (GetPointPositionFromLine(lines[index]).IsValid()) { if (ConsistsOfPoints(lines[index], lines[index + 1])) { uint pointId = 1; do { if (GetPointPositionFromLine(lines[index]).IsValid()) { movePacket.waypoints.Add(new Waypoint(GetPointPositionFromLine(lines[index]), 0.0f, 0, movePacket.startPos, movePacket.moveTime, movePacket.packetSendTime, new TimeSpan(), new List <WaypointScript>(), pointId)); pointId++; } index++; }while (lines[index] != ""); } else { if (GetPointPositionFromLine(lines[index]).IsValid()) { lastPosition = GetPointPositionFromLine(lines[index]); } uint pointId = 1; do { if (GetWayPointPositionFromLine(lines[index]).IsValid()) { movePacket.waypoints.Add(new Waypoint(GetWayPointPositionFromLine(lines[index]), 0.0f, 0, movePacket.startPos, movePacket.moveTime, movePacket.packetSendTime, new TimeSpan(), new List <WaypointScript>(), pointId)); pointId++; } if (GetJumpGravityFromLine(lines[index]) != 0.0f) { movePacket.jumpInfo.jumpGravity = GetJumpGravityFromLine(lines[index]); } index++; }while (lines[index] != ""); } if (lastPosition.IsValid()) { if (movePacket.jumpInfo.jumpGravity != 0.0f) { movePacket.jumpInfo.moveTime = movePacket.moveTime; movePacket.jumpInfo.jumpPos = lastPosition; } else { movePacket.waypoints.Add(new Waypoint(lastPosition, 0.0f, 0, movePacket.startPos, movePacket.moveTime, movePacket.packetSendTime, new TimeSpan(), new List <WaypointScript>(), (uint)(movePacket.waypoints.Count + 1))); } } break; } index++; }while (lines[index] != ""); } return(movePacket); }
public static IEnumerable <UpdateObjectPacket> ParseObjectUpdatePacket(string[] lines, long index, BuildVersions buildVersion) { TimeSpan packetSendTime = LineGetters.GetTimeSpanFromLine(lines[index]); List <UpdateObjectPacket> updatePacketsList = new List <UpdateObjectPacket>(); do { if ((lines[index].Contains("UpdateType: CreateObject1") || lines[index].Contains("UpdateType: CreateObject2")) && LineGetters.IsCreatureLine(lines[index + 1])) { UpdateObjectPacket updatePacket = new UpdateObjectPacket(0, "", "Unknown", -1, 0, packetSendTime, new Position(), null, new List <Waypoint>(), null, null, null, false); do { if (MonsterMovePacket.GetPointPositionFromLine(lines[index]).IsValid()) { uint pointId = 1; do { updatePacket.waypoints.Add(new Waypoint(MonsterMovePacket.GetPointPositionFromLine(lines[index]), 0.0f, 0, new Position(), 0, packetSendTime, new TimeSpan(), new List <WaypointScript>(), pointId)); pointId++; index++; }while (lines[index].Contains("Points:")); } if (GetMapIdFromLine(lines[index]) != null) { updatePacket.mapId = GetMapIdFromLine(lines[index]); } if (GetSpawnPositionFromLine(lines[index], lines[index + 1]).IsValid()) { updatePacket.spawnPosition = GetSpawnPositionFromLine(lines[index], lines[index + 1]); } if (GetEntryFromLine(lines[index]) != 0) { updatePacket.creatureEntry = GetEntryFromLine(lines[index]); } if (LineGetters.GetGuidFromLine(lines[index], buildVersion, objectFieldGuid: true) != "") { updatePacket.creatureGuid = LineGetters.GetGuidFromLine(lines[index], buildVersion, objectFieldGuid: true); } if (GetMaxHealthFromLine(lines[index]) != 0) { updatePacket.creatureMaxHealth = GetMaxHealthFromLine(lines[index]); } if (GetDisableGravityFromLine(lines[index])) { updatePacket.hasDisableGravity = true; } index++; }while (IsLineValidForObjectParse(lines[index])); if (updatePacket.creatureEntry == 0 || updatePacket.creatureGuid == "") { continue; } updatePacket.creatureName = MainForm.GetCreatureNameByEntry(updatePacket.creatureEntry); updatePacketsList.Add(updatePacket); --index; } else if (lines[index].Contains("UpdateType: Values") && LineGetters.IsCreatureLine(lines[index + 1])) { UpdateObjectPacket updatePacket = new UpdateObjectPacket(0, "", "Unknown", -1, 0, packetSendTime, new Position(), null, new List <Waypoint>(), null, null, null, false); do { if (LineGetters.GetGuidFromLine(lines[index], buildVersion) != "") { updatePacket.creatureGuid = LineGetters.GetGuidFromLine(lines[index], buildVersion); } if (GetHealthFromLine(lines[index]) == 0) { updatePacket.creatureCurrentHealth = GetHealthFromLine(lines[index]); } if (GetEmoteStateFromLine(lines[index]) != null) { updatePacket.emoteStateId = GetEmoteStateFromLine(lines[index]); } if (GetSheatheStateFromLine(lines[index]) != null) { updatePacket.sheatheState = GetSheatheStateFromLine(lines[index]); } if (GetStandStateFromLine(lines[index]) != null) { updatePacket.standState = GetStandStateFromLine(lines[index]); } if (GetDisableGravityFromLine(lines[index])) { updatePacket.hasDisableGravity = true; } index++; }while (IsLineValidForObjectParse(lines[index])); updatePacket.creatureName = MainForm.GetCreatureNameByEntry(updatePacket.creatureEntry); if (updatePacket.creatureGuid == "") { continue; } updatePacketsList.Add(updatePacket); --index; } index++; } while (lines[index] != ""); return(updatePacketsList); }