Beispiel #1
0
 public static void SendStartMoveCommonToOneClienResponset(Character movingChr, IRealmClient recievingClient,
                                                           bool instant)
 {
     using (RealmPacketOut startComonMovePacket =
                Asda2MovmentHandler.CreateStartComonMovePacket(movingChr, instant))
         recievingClient.Send(startComonMovePacket, true);
 }
Beispiel #2
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);
        }
Beispiel #3
0
        public static void EndMoveRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position -= 3;
            float x  = packet.ReadFloat();
            float y  = packet.ReadFloat();
            float x1 = packet.ReadFloat();
            float y1 = packet.ReadFloat();

            packet.Position += 4;
            short target = packet.ReadInt16();

            client.ActiveCharacter.IsMoving = false;
            Asda2MovmentHandler.SendEndMoveCommonResponse(client, x, y, x1, y1, target);
        }
Beispiel #4
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);
        }
Beispiel #5
0
 public static void CalculateAndSetRealPos(Character chr, int dt)
 {
     if (!chr.IsMoving)
     {
         chr.CurrentMovingVector = Vector2.Zero;
     }
     else
     {
         Asda2MovmentHandler.SetPosition(chr);
         chr.TimeFromLastPositionUpdate += dt;
         if (chr.TimeFromLastPositionUpdate <= 3000)
         {
             return;
         }
         chr.TimeFromLastPositionUpdate = 0;
         Asda2MovmentHandler.NotifyMoving(chr);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="chr"></param>
        /// <param name="target"></param>
        /// <param name="status">0 - stop;1-start;2 90% weight;3 cannot see target</param>
        public static void StartAtackResponse(Character chr, Unit target, byte status)
        {
            if (chr.IsMoving)
            {
                Asda2MovmentHandler.SendEndMoveByFastInstantRegularMoveResponse(chr);
            }
            var npc = target as NPC;

            using (var p = new RealmPacketOut(RealmServerOpCode.StartAtackResponse)) //4027
            {
                p.WriteByte(status);                                                 //{status}default value : 1 Len : 1
                p.WriteInt16(chr.SessionId);                                         //{sessId}default value : 13 Len : 2
                p.WriteInt16(npc == null?-1:npc.UniqIdOnMap);                        //{monstrMapId}default value : 123 Len : 2
                p.WriteInt16(0);
                p.WriteInt16(0);
                p.WriteInt32(npc == null?-1:npc.UniqWorldEntityId);   //{UniqMonstrId}default value : 40 Len : 4
                chr.SendPacketToArea(p, true, false);
            }
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="chr"></param>
        /// <param name="target"></param>
        /// <param name="status">0 - stop;1-start;2 90% weight;3 cannot see target</param>
        public static void StartAtackResponse(Character chr, Unit target, byte status)
        {
            if (chr.IsMoving)
            {
                Asda2MovmentHandler.SendEndMoveByFastInstantRegularMoveResponse(chr);
            }
            NPC npc = target as NPC;

            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.StartAtackResponse))
            {
                packet.WriteByte(status);
                packet.WriteInt16(chr.SessionId);
                packet.WriteInt16(npc == null ? -1 : (int)npc.UniqIdOnMap);
                packet.WriteInt16(0);
                packet.WriteInt16(0);
                packet.WriteInt32(npc == null ? -1 : npc.UniqWorldEntityId);
                chr.SendPacketToArea(packet, true, false, Locale.Any, new float?());
            }
        }
Beispiel #8
0
        private static void SetPosition(Character chr)
        {
            float num1     = chr.CurrentMovingVector.Length();
            int   num2     = Environment.TickCount - chr.LastMoveTime;
            float distance = (float)((double)chr.RunSpeed * (double)num2 / 100.0);

            chr.OnMove();
            if ((double)distance >= (double)num1)
            {
                chr.SetPosition(new Vector3(chr.LastNewPosition.X + chr.Map.Offset,
                                            chr.LastNewPosition.Y + chr.Map.Offset));
                chr.CurrentMovingVector = new Vector2(0.0f, 0.0f);
                chr.IsMoving            = false;
            }
            else
            {
                Vector3 vector3 =
                    new Vector3(
                        Asda2MovmentHandler.FindRealPosition(chr.CurrentMovingVector, distance, chr.Asda2Position.XY),
                        0.0f);
                chr.SetPosition(new Vector3(vector3.X + chr.Map.Offset, vector3.Y + chr.Map.Offset));
                chr.CurrentMovingVector = chr.LastNewPosition.XY - chr.Asda2Position.XY;
            }
        }
 public static void SendAttackerStateUpdate(DamageAction action)
 {
     if (action.Attacker is Character && action.Victim is NPC)
     {
         var atacker = (Character)action.Attacker;
         var victim  = (NPC)action.Victim;
         using (var packet = new RealmPacketOut(RealmServerOpCode.MonstrTakeDmg)) //4029
         {
             packet.WriteInt16(atacker.SessionId);                                //{killerSessId}default value : 17 Len : 2
             packet.WriteInt16(victim.UniqIdOnMap);                               //{monstrMapId}default value : 125 Len : 2
             packet.WriteInt32(victim.UniqWorldEntityId);                         //value name : unk6 default value : 0Len : 4
             if (action.VictimState == VictimState.Evade)
             {
                 packet.WriteInt32(-1);
             }
             else if (action.VictimState == VictimState.Block)
             {
                 packet.WriteInt32(-2);
             }
             else if (action.VictimState == VictimState.Immune)
             {
                 packet.WriteInt32(-3);
             }
             else if (action.VictimState == VictimState.Deflect || action.VictimState == VictimState.Dodge || action.VictimState == VictimState.Interrupt || action.VictimState == VictimState.Parry)
             {
                 packet.WriteInt32(-1);
             }
             else
             {
                 packet.WriteUInt32(action.ActualDamage + (action.IsCritical?2147483648:0)); //{AmountOfDmg}default value : 482 Len : 4
             }
             packet.WriteSkip(unk8);                                                         //value name : unk8 default value : unk8Len : 21
             victim.SendPacketToArea(packet);
         }
         return;
     }
     else if (action.Attacker is NPC && action.Victim is Character)
     {
         var atacker = (NPC)action.Attacker;
         var victim  = (Character)action.Victim;
         var dmg     = 0;
         if (action.VictimState == VictimState.Evade)
         {
             dmg = -1;
         }
         else if (action.VictimState == VictimState.Block)
         {
             dmg = -2;
         }
         else if (action.VictimState == VictimState.Immune)
         {
             dmg = -3;
         }
         else if (action.VictimState == VictimState.Miss || action.VictimState == VictimState.Deflect || action.VictimState == VictimState.Dodge || action.VictimState == VictimState.Interrupt || action.VictimState == VictimState.Parry)
         {
             dmg = 0;
         }
         else
         {
             dmg = (int)(action.ActualDamage + (action.IsCritical?2147483648:0));     //{AmountOfDmg}default value : 482 Len : 4
         }
         Asda2MovmentHandler.SendMonstMoveOrAtackResponse(victim.SessionId, atacker, dmg, atacker.Asda2Position, true);
     }
     else if (action.Attacker is Character && action.Victim is Character)
     {
         var dmg = 0;
         if (action.VictimState == VictimState.Evade)
         {
             dmg = -1;
         }
         else if (action.VictimState == VictimState.Block)
         {
             dmg = -2;
         }
         else if (action.VictimState == VictimState.Immune)
         {
             dmg = -3;
         }
         else if (action.VictimState == VictimState.Miss || action.VictimState == VictimState.Deflect || action.VictimState == VictimState.Dodge || action.VictimState == VictimState.Interrupt || action.VictimState == VictimState.Parry)
         {
             dmg = 0;
         }
         else
         {
             dmg = (int)(action.ActualDamage + (action.IsCritical ? 2147483648 : 0)); //{AmountOfDmg}default value : 482 Len : 4
         }
         using (var packet = new RealmPacketOut(RealmServerOpCode.AtackCharacterRes)) //4204
         {
             packet.WriteInt16(action.Attacker.CharacterMaster.SessionId);            //{atackerSessId}default value : 11 Len : 2
             packet.WriteInt16(action.Victim.CharacterMaster.SessionId);              //{victimSessId}default value : 105 Len : 2
             packet.WriteInt32(0);                                                    //value name : unk6 default value : 0Len : 4
             packet.WriteInt32(dmg);                                                  //{dmg}default value : 1 Len : 4
             packet.WriteByte(0);                                                     //value name : unk8 default value : 0Len : 1
             packet.WriteInt16(-1);                                                   //value name : unk9 default value : -1Len : 2
             packet.WriteInt32(0);                                                    //value name : unk4 default value : 0Len : 4
             action.Victim.CharacterMaster.SendPacketToArea(packet, true, true);
         }
     }
 }
Beispiel #10
0
 public static void SendAttackerStateUpdate(DamageAction action)
 {
     if (action.Attacker is Character && action.Victim is NPC)
     {
         Character attacker = (Character)action.Attacker;
         NPC       victim   = (NPC)action.Victim;
         using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.MonstrTakeDmg))
         {
             packet.WriteInt16(attacker.SessionId);
             packet.WriteInt16(victim.UniqIdOnMap);
             packet.WriteInt32(victim.UniqWorldEntityId);
             if (action.VictimState == VictimState.Evade)
             {
                 packet.WriteInt32(-1);
             }
             else if (action.VictimState == VictimState.Block)
             {
                 packet.WriteInt32(-2);
             }
             else if (action.VictimState == VictimState.Immune)
             {
                 packet.WriteInt32(-3);
             }
             else if (action.VictimState == VictimState.Deflect || action.VictimState == VictimState.Dodge ||
                      (action.VictimState == VictimState.Interrupt || action.VictimState == VictimState.Parry))
             {
                 packet.WriteInt32(-1);
             }
             else
             {
                 packet.WriteUInt32((long)action.ActualDamage + (action.IsCritical ? 2147483648L : 0L));
             }
             packet.WriteSkip(Asda2CombatHandler.unk8);
             victim.SendPacketToArea(packet, true, true, Locale.Any, new float?());
         }
     }
     else if (action.Attacker is NPC && action.Victim is Character)
     {
         NPC       attacker = (NPC)action.Attacker;
         Character victim   = (Character)action.Victim;
         int       dmg      = action.VictimState != VictimState.Evade
             ? (action.VictimState != VictimState.Block
                 ? (action.VictimState != VictimState.Immune
                     ? (action.VictimState == VictimState.Miss || action.VictimState == VictimState.Deflect ||
                        (action.VictimState == VictimState.Dodge ||
                         action.VictimState == VictimState.Interrupt) || action.VictimState == VictimState.Parry
                         ? 0
                         : (int)((long)action.ActualDamage + (action.IsCritical ? 2147483648L : 0L)))
                     : -3)
                 : -2)
             : -1;
         Asda2MovmentHandler.SendMonstMoveOrAtackResponse(victim.SessionId, attacker, dmg,
                                                          attacker.Asda2Position, true);
     }
     else
     {
         if (!(action.Attacker is Character) || !(action.Victim is Character))
         {
             return;
         }
         int val = action.VictimState != VictimState.Evade
             ? (action.VictimState != VictimState.Block
                 ? (action.VictimState != VictimState.Immune
                     ? (action.VictimState == VictimState.Miss || action.VictimState == VictimState.Deflect ||
                        (action.VictimState == VictimState.Dodge ||
                         action.VictimState == VictimState.Interrupt) || action.VictimState == VictimState.Parry
                         ? 0
                         : (int)((long)action.ActualDamage + (action.IsCritical ? 2147483648L : 0L)))
                     : -3)
                 : -2)
             : -1;
         using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.AtackCharacterRes))
         {
             packet.WriteInt16(action.Attacker.CharacterMaster.SessionId);
             packet.WriteInt16(action.Victim.CharacterMaster.SessionId);
             packet.WriteInt32(0);
             packet.WriteInt32(val);
             packet.WriteByte(0);
             packet.WriteInt16(-1);
             packet.WriteInt32(0);
             action.Victim.CharacterMaster.SendPacketToArea(packet, true, true, Locale.Any, new float?());
         }
     }
 }
Beispiel #11
0
 public static void SendStartMoveCommonToAreaResponse(Character chr, bool instant, bool includeSelf = true)
 {
     using (RealmPacketOut startComonMovePacket = Asda2MovmentHandler.CreateStartComonMovePacket(chr, instant))
         chr.SendPacketToArea(startComonMovePacket, includeSelf, true, Locale.Any, new float?());
 }
Beispiel #12
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);
                    }
                }
            }
        }
Beispiel #13
0
        private static void ProcessUseSkill(IRealmClient client, byte targetType, short skillId, ushort targetId)
        {
            Unit target = null;

            switch (targetType)
            {
            case 0:
                target = client.ActiveCharacter.Map.GetNpcByUniqMapId(targetId);
                break;

            case 1:
                target = World.GetCharacterBySessionId(targetId);
                break;

            default:
                client.ActiveCharacter.SendSystemMessage(string.Format(
                                                             "Unknown skill target type {0}. SkillId {1}. Please report to developers.", targetType,
                                                             skillId));
                break;
            }

            if (target == null)
            {
                SendUseSkillResultResponse(client.ActiveCharacter, skillId,
                                           Asda2UseSkillResult.ChooseATarget);
            }
            else
            {
                if (targetType == 1)
                {
                    Character characterBySessionId = World.GetCharacterBySessionId(targetId);
                    if (characterBySessionId.Asda2FactionId == client.ActiveCharacter.Asda2FactionId &&
                        client.ActiveCharacter.IsAsda2BattlegroundInProgress &&
                        characterBySessionId.IsAsda2BattlegroundInProgress)
                    {
                        SendUseSkillResultResponse(client.ActiveCharacter, skillId,
                                                   Asda2UseSkillResult.YouCannotUseSkillToTargetYet);
                        return;
                    }

                    if (characterBySessionId == null)
                    {
                        SendUseSkillResultResponse(client.ActiveCharacter, skillId,
                                                   Asda2UseSkillResult.ChooseATarget);
                        return;
                    }
                }

                Spell spellByRealId = client.ActiveCharacter.Spells.GetSpellByRealId(skillId);
                if (spellByRealId == null)
                {
                    return;
                }
                switch (client.ActiveCharacter.SpellCast.Start(spellByRealId, target))
                {
                case SpellFailedReason.OutOfRange:
                    Asda2MovmentHandler.MoveToSelectedTargetAndAttack(client.ActiveCharacter);
                    break;

                case SpellFailedReason.Ok:
                    if (spellByRealId.LearnLevel >= 10)
                    {
                        if (spellByRealId.LearnLevel < 30)
                        {
                            if (client.ActiveCharacter.GreenCharges < 10)
                            {
                                ++client.ActiveCharacter.GreenCharges;
                            }
                        }
                        else if (spellByRealId.LearnLevel < 50)
                        {
                            if (client.ActiveCharacter.BlueCharges < 10)
                            {
                                ++client.ActiveCharacter.BlueCharges;
                            }
                            if (client.ActiveCharacter.GreenCharges < 10)
                            {
                                ++client.ActiveCharacter.GreenCharges;
                            }
                        }
                        else
                        {
                            if (client.ActiveCharacter.RedCharges < 10)
                            {
                                ++client.ActiveCharacter.RedCharges;
                            }
                            if (client.ActiveCharacter.BlueCharges < 10)
                            {
                                ++client.ActiveCharacter.BlueCharges;
                            }
                            if (client.ActiveCharacter.GreenCharges < 10)
                            {
                                ++client.ActiveCharacter.GreenCharges;
                            }
                        }
                    }

                    AchievementProgressRecord progressRecord =
                        client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(6U);
                    switch (++progressRecord.Counter)
                    {
                    case 50:
                        client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Skilled44);
                        break;

                    case 100:
                        client.ActiveCharacter.GetTitle(Asda2TitleId.Skilled44);
                        break;
                    }

                    progressRecord.SaveAndFlush();
                    SendSetSkiillPowersStatsResponse(client.ActiveCharacter, true, skillId);
                    break;
                }
            }
        }