Example #1
0
        public static void OnMoveRequest(IRealmClient client, float y, float x)
        {
            Vector3   vector3         = new Vector3(x, y, 0.0f);
            Character activeCharacter = client.ActiveCharacter;

            if ((double)activeCharacter.Asda2X == (double)x && (double)activeCharacter.Asda2Y == (double)y)
            {
                return;
            }
            Unit mover = activeCharacter.MoveControl.Mover as Unit;

            if (mover == null || !mover.UnitFlags.HasFlag((Enum)UnitFlags.PlayerControlled) ||
                (mover.UnitFlags.HasFlag((Enum)UnitFlags.Influenced) || activeCharacter.IsDead))
            {
                return;
            }
            if (activeCharacter.CurrentMovingVector != Vector2.Zero)
            {
                Asda2MovmentHandler.CalculateAndSetRealPos(activeCharacter, 0);
            }
            mover.CancelEmote();
            activeCharacter.LastNewPosition     = vector3;
            activeCharacter.CurrentMovingVector = vector3.XY - activeCharacter.Asda2Position.XY;
            activeCharacter.IsMoving            = true;
            Asda2MovmentHandler.SendStartMoveCommonToAreaResponse(activeCharacter, false, true);
        }
Example #2
0
        public static void MoveToSelectedTargetAndAttack(Character chr)
        {
            if (chr.Target == null)
            {
                return;
            }
            Vector2 xy      = chr.Target.Asda2Position.XY;
            Vector3 vector3 = new Vector3(xy.X, xy.Y, 0.0f);

            chr.LastNewPosition     = vector3;
            chr.CurrentMovingVector = vector3.XY - chr.Asda2Position.XY;
            chr.IsMoving            = true;
            Asda2MovmentHandler.SendStartMoveCommonToAreaResponse(chr, false, true);
        }
Example #3
0
        public static void StartMoveRequest(IRealmClient client, RealmPacketIn packet)
        {
            if (!client.ActiveCharacter.CanMove)
            {
                Asda2MovmentHandler.SendStartComonMovePacketError(client.ActiveCharacter, false,
                                                                  Asda2StartMovementStatus.CantMoveInThisCondition);
            }
            else
            {
                if (client.ActiveCharacter.IsAggred)
                {
                    if (client.ActiveCharacter.ArggredDateTime < DateTime.Now)
                    {
                        client.ActiveCharacter.IsAggred = false;
                        client.ActiveCharacter.UpdateSpeedFactor();
                    }
                    else
                    {
                        client.ActiveCharacter.SendInfoMsg("You are aggred.");
                        Asda2MovmentHandler.SendStartComonMovePacketError(client.ActiveCharacter, false,
                                                                          Asda2StartMovementStatus.CantMoveInThisCondition);
                        return;
                    }
                }

                packet.Position -= 24;
                float x;
                float y;
                short num1;
                try
                {
                    packet.Position += 16;
                    packet.Position += 5;
                    double num2 = (double)packet.ReadSingle() / 100.0;
                    double num3 = (double)packet.ReadSingle() / 100.0;
                    x = packet.ReadSingle() / 100f;
                    y = packet.ReadSingle() / 100f;
                    packet.Position += 4;
                    num1             = packet.ReadInt16();
                }
                catch (EndOfStreamException ex)
                {
                    return;
                }

                Character activeCharacter = client.ActiveCharacter;
                if (activeCharacter.IsAsda2BattlegroundInProgress &&
                    (!activeCharacter.CurrentBattleGround.IsStarted &&
                     (double)new Vector3(activeCharacter.Map.Offset + x, activeCharacter.Map.Offset + y, 0.0f)
                     .GetDistance(activeCharacter.CurrentBattleGround.GetBasePosition(activeCharacter)) > 40.0 ||
                     (double)new Vector3(activeCharacter.Map.Offset + x, activeCharacter.Map.Offset + y, 0.0f)
                     .GetDistance(activeCharacter.CurrentBattleGround.GetForeigLocation(activeCharacter)) < 40.0))
                {
                    Asda2MovmentHandler.SendStartComonMovePacketError(client.ActiveCharacter, false,
                                                                      Asda2StartMovementStatus.YouCantMoveToOtherSideOfRevivalArea);
                }
                else
                {
                    if (activeCharacter.IsFirstMoveAfterAtack)
                    {
                        activeCharacter.IsFirstMoveAfterAtack = false;
                    }
                    if (activeCharacter.Target is NPC && activeCharacter.Target.IsDead)
                    {
                        activeCharacter.Target     = (Unit)null;
                        activeCharacter.IsFighting = false;
                    }

                    if (num1 == (short)-1)
                    {
                        activeCharacter.Target = (Unit)null;
                    }
                    else if (activeCharacter.Target == null || !(activeCharacter.Target is Character))
                    {
                        activeCharacter.Target = (Unit)activeCharacter.Map.GetNpcByUniqMapId((ushort)num1);
                    }
                    if (activeCharacter.Target == null || !(activeCharacter.Target is NPC))
                    {
                        activeCharacter.IsFighting = false;
                    }
                    activeCharacter.EndMoveCount = 0;
                    if (activeCharacter.IsFighting && activeCharacter.MainWeapon.IsRanged &&
                        activeCharacter.Target != null &&
                        (double)new Vector3(x, y, 0.0f).GetDistance(activeCharacter.Target.Asda2Position) < 3.0)
                    {
                        Asda2MovmentHandler.SendStartMoveCommonToAreaResponse(activeCharacter, false, true);
                    }
                    else
                    {
                        Asda2MovmentHandler.OnMoveRequest(client, y, x);
                    }
                }
            }
        }