Example #1
0
            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);
            }
Example #2
0
            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);
            }
Example #3
0
            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);
            }