Beispiel #1
0
        void Spellbook_OnCastSpell(Spellbook sender, SpellbookCastSpellEventArgs args)
        {
            if (!IsActive())
            {
                return;
            }


            if (_latestSpellSlot != SpellSlot.Unknown && sender.Owner.IsMe && IsWard(sender, args))
            {
                _drawSpots = false;
                foreach (WardSpot wardSpot in WardSpots)
                {
                    if (!wardSpot.SafeWard &&
                        Vector3.Distance(wardSpot.Pos,
                                         new Vector3(args.StartPosition.X, args.StartPosition.Y, args.StartPosition.Z)) <= 250 &&
                        !_wardAlreadyCorrected)
                    {
                        args.Process          = false;
                        _wardAlreadyCorrected = true;
                        //SendPacket
                        //var sCastPacket = new byte[28];
                        //var writer = new BinaryWriter(new MemoryStream(sCastPacket));
                        //writer.Write((byte)0x9A);
                        //writer.Write(mNetworkId);
                        //writer.Write(spellId);
                        //writer.Write(unknown);
                        //writer.Write(wardSpot.Pos.X);
                        //writer.Write(wardSpot.Pos.Y);
                        //writer.Write(wardSpot.Pos.X);
                        //writer.Write(wardSpot.Pos.Y);
                        //writer.Write(tNetworkId);
                        //Game.SendPacket(sCastPacket, PacketChannel.C2S, PacketProtocolFlags.Reliable);
                        sender.CastSpell(
                            args.Slot,
                            new Vector3(
                                wardSpot.Pos.X, wardSpot.Pos.Y,
                                NavMesh.GetHeightForPosition(wardSpot.Pos.X, wardSpot.Pos.Y)));
                        //Packet.C2S.Cast.Encoded(new Packet.C2S.Cast.Struct(decoded.TargetNetworkId, decoded.Slot, decoded.SourceNetworkId,
                        //    wardSpot.Pos.X, wardSpot.Pos.Y, wardSpot.Pos.X, wardSpot.Pos.Y, decoded.SpellFlag)).Send();
                        //TODO: Check if its correct
                        _wardAlreadyCorrected = false;
                        return;
                    }
                    if (wardSpot.SafeWard &&
                        Vector3.Distance(wardSpot.MagneticPos,
                                         new Vector3(args.StartPosition.X, args.StartPosition.Y, args.StartPosition.Z)) <=
                        250 &&
                        !_wardAlreadyCorrected)
                    {
                        args.Process = false;
                        ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo,
                                                        new Vector3(wardSpot.MovePos.X, wardSpot.MovePos.Y, wardSpot.MovePos.Z));
                        _latestWardSpot = wardSpot;
                        return;
                    }
                }
            }
        }
Beispiel #2
0
        private void OnSpellbookCastSpell(Spellbook sender, SpellbookCastSpellEventArgs args)
        {
            try
            {
                if (sender == null || args == null || !sender.Owner.IsMe || !IsWardSlot(args.Slot))
                {
                    return;
                }

                var spot = GetNearestWardSpot(Game.CursorPos);
                if (spot.Equals(default(WardSpot)) || args.EndPosition.Equals(spot.ClickPosition))
                {
                    return;
                }

                if (!Menu.Item(Name + "Hotkey").IsActive() && !Menu.Item(Name + "PermaShow").GetValue <bool>() &&
                    args.EndPosition.Distance(spot.MagneticPosition) <=
                    Menu.Item(Name + "DrawingRadius").GetValue <Slider>().Value)
                {
                    args.Process  = false;
                    _lastWardSpot = default(WardSpot);
                }

                if (!Menu.Item(Name + "Hotkey").IsActive() && !Menu.Item(Name + "PermaShow").GetValue <bool>())
                {
                    return;
                }

                if (spot.SafeSpot)
                {
                    if (Game.CursorPos.Distance(spot.MagneticPosition) <=
                        Menu.Item(Name + "DrawingRadius").GetValue <Slider>().Value)
                    {
                        args.Process = false;
                        if (_lastWardSpot.Equals(default(WardSpot)))
                        {
                            _lastWardSpot = spot;
                            _lastWardSlot = args.Slot;
                            ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo, spot.MovePosition);
                        }
                    }
                }
                else
                {
                    if (Game.CursorPos.Distance(spot.MagneticPosition) <=
                        Menu.Item(Name + "DrawingRadius").GetValue <Slider>().Value)
                    {
                        args.Process = false;
                        sender.CastSpell(args.Slot, spot.ClickPosition);
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
Beispiel #3
0
 private void Game_OnGameUpdate(EventArgs args)
 {
     if (!IsActive())
     {
         return;
     }
     if (_latestWardSpot != null && _latestSpellSlot != SpellSlot.Unknown)
     {
         if (Vector3.Distance(ObjectManager.Player.ServerPosition, _latestWardSpot.ClickPos) <= 650)
         {
             ObjectManager.Player.Spellbook.CastSpell(_latestSpellSlot, _latestWardSpot.ClickPos);
             _latestWardSpot = null;
         }
     }
 }
Beispiel #4
0
        private void Game_OnGameUpdate(object sender, EventArgs args)
        {
            if (!IsActive() || lastGameUpdateTime + new Random().Next(500, 1000) > Environment.TickCount)
            {
                return;
            }

            lastGameUpdateTime = Environment.TickCount;
            if (_latestWardSpot != null && _latestSpellSlot != SpellSlot.Unknown)
            {
                if (Vector3.Distance(ObjectManager.Player.ServerPosition, _latestWardSpot.ClickPos) <= 650)
                {
                    _wardAlreadyCorrected = true;
                    ObjectManager.Player.Spellbook.CastSpell(_latestSpellSlot, _latestWardSpot.ClickPos);
                    _wardAlreadyCorrected = false;
                    _latestWardSpot       = null;
                }
            }
        }
Beispiel #5
0
        private void OnGameUpdate(EventArgs args)
        {
            try
            {
                if (_lastCheck + CheckInterval > Environment.TickCount)
                {
                    return;
                }
                _lastCheck = Environment.TickCount;

                if (ObjectManager.Player.IsDead || _lastWardSpot.Equals(default(WardSpot)))
                {
                    return;
                }
                if (Menu.Item(Name + "Hotkey").IsActive() || Menu.Item(Name + "PermaShow").GetValue <bool>())
                {
                    if (
                        Math.Sqrt(
                            Math.Pow(_lastWardSpot.ClickPosition.X - ObjectManager.Player.Position.X, 2) +
                            Math.Pow(_lastWardSpot.ClickPosition.Y - ObjectManager.Player.Position.Y, 2)) <= 640.0)
                    {
                        ObjectManager.Player.Spellbook.CastSpell(_lastWardSlot, _lastWardSpot.ClickPosition);
                        _lastWardSpot = default(WardSpot);
                    }
                    else
                    {
                        ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo, _lastWardSpot.MovePosition);
                    }
                }
                else
                {
                    _lastWardSpot = default(WardSpot);
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
Beispiel #6
0
        private static void Game_OnUpdate(EventArgs args)
        {
            if(!Properties.GetData<bool>("Enable")) return;
            Wards.UpdateWardSpotObjects();
            if (_placingWardSpot != null)
            {
                //if (!Player.Instance.Path.Contains(_placingWardSpot.MovePosition)) { _placingWardSpot = null; return;}
                if (Player.Instance.Position.IsInRange(_placingWardSpot.MovePosition, 20) || Player.Instance.Position.IsInRange(_placingWardSpot.ClickPosition, 1100))
                {

                    var item = _placePinkWard ? Wards.GetPinkSlot() : Wards.GetWardSlot();

                    if (item != null)
                    {
                        Player.CastSpell(item.SpellSlot, _placingWardSpot.ClickPosition);
                    }
                    _placingWardSpot = null;
                    _placePinkWard = false;
                    Chat.Print(_placePinkWard ? "Placed pink ward!" : "Placed normal ward!");
                }
            }
        }
Beispiel #7
0
        private void Game_OnWndProc(WndEventArgs args)
        {
            //http://msdn.microsoft.com/en-us/library/windows/desktop/ms632585(v=vs.85).aspx
            const int WM_KEYDOWN     = 0x100;
            const int WM_LBUTTONUP   = 0x202;
            const int WM_LBUTTONDOWN = 0x201;
            const int WM_RBUTTONUP   = 0x205;
            const int WM_RBUTTONDOWN = 0x204;

            if (!IsActive())
            {
                return;
            }
            if (MenuGUI.IsChatOpen)
            {
                return;
            }
            uint trinketKey =
                WardCorrector_Wards.GetMenuItem("SAssembliesWardsWardCorrectorKey").GetValue <KeyBind>().Key;

            if (args.Msg == WM_KEYDOWN)
            {
                //Console.WriteLine("Hero: " + ObjectManager.Player.ServerPosition);
                //Console.WriteLine("Cursor: " + Drawing.ScreenToWorld(Utils.GetCursorPos()));
                InventorySlot inventoryItem   = null;
                int           inventoryItemId = -1;
                if (trinketKey == args.WParam)
                {
                    _latestSpellSlot = SpellSlot.Trinket;
                    inventoryItemId  = 6;
                }
                else
                {
                    _latestSpellSlot = SpellSlot.Unknown;
                }
                if (_latestSpellSlot == SpellSlot.Unknown)
                {
                    switch (args.WParam)
                    {
                    case '1':
                        _latestSpellSlot = SpellSlot.Item1;
                        inventoryItemId  = 0;
                        break;

                    case '2':
                        _latestSpellSlot = SpellSlot.Item2;
                        inventoryItemId  = 1;
                        break;

                    case '3':
                        _latestSpellSlot = SpellSlot.Item3;
                        inventoryItemId  = 2;
                        break;

                    //case trinketKey:
                    //    _latestSpellSlot = SpellSlot.Trinket;
                    //    inventoryItemId = 6;
                    //    break;

                    case '5':
                        _latestSpellSlot = SpellSlot.Item5;
                        inventoryItemId  = 3;
                        break;

                    case '6':
                        _latestSpellSlot = SpellSlot.Item6;
                        inventoryItemId  = 4;
                        break;

                    case '7':
                        _latestSpellSlot = SpellSlot.Item4;
                        inventoryItemId  = 5;
                        break;

                    default:
                        _drawSpots       = false;
                        _latestSpellSlot = SpellSlot.Unknown;
                        break;
                    }
                }

                foreach (InventorySlot inventorySlot in ObjectManager.Player.InventoryItems)
                {
                    if (inventorySlot.Slot == inventoryItemId)
                    {
                        inventoryItem = inventorySlot;
                        break;
                    }
                }

                if (_latestSpellSlot != SpellSlot.Unknown)
                {
                    if (inventoryItem != null)
                    {
                        foreach (SAssemblies.Ward.WardItem wardItem in SAssemblies.Ward.WardItems)
                        {
                            if ((int)inventoryItem.Id == wardItem.Id &&
                                wardItem.Type != SAssemblies.Ward.WardType.Temp &&
                                wardItem.Type != SAssemblies.Ward.WardType.TempVision &&
                                ObjectManager.Player.Spellbook.CanUseSpell(_latestSpellSlot) == SpellState.Ready ||
                                ObjectManager.Player.Spellbook.CanUseSpell(_latestSpellSlot) == (SpellState)1)
                            {
                                _drawSpots = true;
                            }
                        }
                        if (_drawSpots == false)
                        {
                            _latestSpellSlot = SpellSlot.Unknown;
                        }
                    }
                }
            }
            else if (args.Msg == WM_LBUTTONUP && _drawSpots)
            {
                _drawSpots = false;
            }
            else if (args.Msg == WM_RBUTTONDOWN && _drawSpots)
            {
                _drawSpots = false;
            }
            else if (args.Msg == WM_RBUTTONDOWN)
            {
                _latestWardSpot = null;
            }
        }
Beispiel #8
0
        private void Game_OnGameSendPacket(GamePacketEventArgs args) //TODO: Need to find a way to block item usage
        {
            if (!IsActive())
            {
                return;
            }

            var gPacket = new GamePacket(args.PacketData);
            var reader  = new BinaryReader(new MemoryStream(args.PacketData));

            byte packetId = reader.ReadByte(); //PacketId

            if (packetId == 0x9A)              //OLD 0x9A
            {
                //int mNetworkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                //byte spellId = reader.ReadByte();
                //byte unknown = reader.ReadByte();
                //float fromX = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                //float fromY = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                //float toX = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                //float toY = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                //int tNetworkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                Packet.C2S.Cast.Struct decoded = Packet.C2S.Cast.Decoded(args.PacketData);
                //PacketSpellId nSpellId = PacketSpellId.ConvertPacketCastToId(spellId);
                if (/*_latestSpellSlot == nSpellId.SSpellSlot && */ _latestSpellSlot != SpellSlot.Unknown)
                {
                    _drawSpots = false;
                    foreach (WardSpot wardSpot in WardSpots)
                    {
                        if (!wardSpot.SafeWard &&
                            Vector3.Distance(wardSpot.Pos,
                                             new Vector3(decoded.FromX, decoded.FromY, ObjectManager.Player.ServerPosition.Z)) <= 250 &&
                            !_wardAlreadyCorrected)
                        {
                            args.Process          = false;
                            _wardAlreadyCorrected = true;
                            //SendPacket
                            //var sCastPacket = new byte[28];
                            //var writer = new BinaryWriter(new MemoryStream(sCastPacket));
                            //writer.Write((byte)0x9A);
                            //writer.Write(mNetworkId);
                            //writer.Write(spellId);
                            //writer.Write(unknown);
                            //writer.Write(wardSpot.Pos.X);
                            //writer.Write(wardSpot.Pos.Y);
                            //writer.Write(wardSpot.Pos.X);
                            //writer.Write(wardSpot.Pos.Y);
                            //writer.Write(tNetworkId);
                            //Game.SendPacket(sCastPacket, PacketChannel.C2S, PacketProtocolFlags.Reliable);
                            Packet.C2S.Cast.Encoded(new Packet.C2S.Cast.Struct(decoded.TargetNetworkId, decoded.Slot, decoded.SourceNetworkId,
                                                                               wardSpot.Pos.X, wardSpot.Pos.Y, wardSpot.Pos.X, wardSpot.Pos.Y, decoded.SpellFlag)).Send();
                            //TODO: Check if its correct
                            _wardAlreadyCorrected = false;
                            return;
                        }
                        if (wardSpot.SafeWard &&
                            Vector3.Distance(wardSpot.MagneticPos,
                                             new Vector3(decoded.FromX, decoded.FromY, ObjectManager.Player.ServerPosition.Z)) <=
                            250 &&
                            !_wardAlreadyCorrected)
                        {
                            args.Process = false;
                            ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo,
                                                            new Vector3(wardSpot.MovePos.X, wardSpot.MovePos.Y, wardSpot.MovePos.Z));
                            _latestWardSpot = wardSpot;
                            return;
                        }
                    }
                }
            }
        }
Beispiel #9
0
        void Spellbook_OnCastSpell(Spellbook sender, SpellbookCastSpellEventArgs args)
        {
            if (!IsActive())
                return;

            if (_latestSpellSlot != SpellSlot.Unknown && sender.Owner.IsMe && IsWard(sender, args))
            {
                _drawSpots = false;
                foreach (WardSpot wardSpot in WardSpots)
                {
                    if (!wardSpot.SafeWard &&
                        Vector3.Distance(wardSpot.Pos,
                            new Vector3(args.StartPosition.X, args.StartPosition.Y, args.StartPosition.Z)) <= 250 &&
                        !_wardAlreadyCorrected)
                    {
                        args.Process = false;
                        _wardAlreadyCorrected = true;
                        //SendPacket
                        //var sCastPacket = new byte[28];
                        //var writer = new BinaryWriter(new MemoryStream(sCastPacket));
                        //writer.Write((byte)0x9A);
                        //writer.Write(mNetworkId);
                        //writer.Write(spellId);
                        //writer.Write(unknown);
                        //writer.Write(wardSpot.Pos.X);
                        //writer.Write(wardSpot.Pos.Y);
                        //writer.Write(wardSpot.Pos.X);
                        //writer.Write(wardSpot.Pos.Y);
                        //writer.Write(tNetworkId);
                        //Game.SendPacket(sCastPacket, PacketChannel.C2S, PacketProtocolFlags.Reliable);
                        sender.CastSpell(
                            args.Slot,
                            new Vector3(
                                wardSpot.Pos.X, wardSpot.Pos.Y,
                                NavMesh.GetHeightForPosition(wardSpot.Pos.X, wardSpot.Pos.Y)));
                        //Packet.C2S.Cast.Encoded(new Packet.C2S.Cast.Struct(decoded.TargetNetworkId, decoded.Slot, decoded.SourceNetworkId,
                        //    wardSpot.Pos.X, wardSpot.Pos.Y, wardSpot.Pos.X, wardSpot.Pos.Y, decoded.SpellFlag)).Send();
                        //TODO: Check if its correct
                        _wardAlreadyCorrected = false;
                        return;
                    }
                    if (wardSpot.SafeWard &&
                        Vector3.Distance(wardSpot.MagneticPos,
                            new Vector3(args.StartPosition.X, args.StartPosition.Y, args.StartPosition.Z)) <=
                        250 &&
                        !_wardAlreadyCorrected)
                    {
                        args.Process = false;
                        ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo,
                            new Vector3(wardSpot.MovePos.X, wardSpot.MovePos.Y, wardSpot.MovePos.Z));
                        _latestWardSpot = wardSpot;
                        return;
                    }
                }
            }
        }
Beispiel #10
0
        private void Game_OnWndProc(WndEventArgs args)
        {
            //http://msdn.microsoft.com/en-us/library/windows/desktop/ms632585(v=vs.85).aspx
            const int WM_KEYDOWN = 0x100;
            const int WM_LBUTTONUP = 0x202;
            const int WM_LBUTTONDOWN = 0x201;
            const int WM_RBUTTONUP = 0x205;
            const int WM_RBUTTONDOWN = 0x204;

            if (!IsActive())
                return;
            if (MenuGUI.IsChatOpen)
                return;
            uint trinketKey =
                WardCorrectorWard.GetMenuItem("SAssembliesWardsWardCorrectorKey").GetValue<KeyBind>().Key;
            if (args.Msg == WM_KEYDOWN)
            {
                //Console.WriteLine("Hero: " + ObjectManager.Player.ServerPosition);
                //Console.WriteLine("Cursor: " + Drawing.ScreenToWorld(Utils.GetCursorPos()));
                InventorySlot inventoryItem = null;
                int inventoryItemId = -1;
                if (trinketKey == args.WParam)
                {
                    _latestSpellSlot = SpellSlot.Trinket;
                    inventoryItemId = 6;
                }
                else
                {
                    _latestSpellSlot = SpellSlot.Unknown;
                }
                if (_latestSpellSlot == SpellSlot.Unknown)
                {
                    switch (args.WParam)
                    {
                        case '1':
                            _latestSpellSlot = SpellSlot.Item1;
                            inventoryItemId = 0;
                            break;

                        case '2':
                            _latestSpellSlot = SpellSlot.Item2;
                            inventoryItemId = 1;
                            break;

                        case '3':
                            _latestSpellSlot = SpellSlot.Item3;
                            inventoryItemId = 2;
                            break;

                        //case trinketKey:
                        //    _latestSpellSlot = SpellSlot.Trinket;
                        //    inventoryItemId = 6;
                        //    break;

                        case '5':
                            _latestSpellSlot = SpellSlot.Item5;
                            inventoryItemId = 3;
                            break;

                        case '6':
                            _latestSpellSlot = SpellSlot.Item6;
                            inventoryItemId = 4;
                            break;

                        case '7':
                            _latestSpellSlot = SpellSlot.Item4;
                            inventoryItemId = 5;
                            break;

                        default:
                            _drawSpots = false;
                            _latestSpellSlot = SpellSlot.Unknown;
                            break;
                    }
                }

                foreach (InventorySlot inventorySlot in ObjectManager.Player.InventoryItems)
                {
                    if (inventorySlot.Slot == inventoryItemId)
                    {
                        inventoryItem = inventorySlot;
                        break;
                    }
                }

                if (_latestSpellSlot != SpellSlot.Unknown)
                {
                    if (inventoryItem != null)
                    {
                        foreach (SAssemblies.Ward.WardItem wardItem in SAssemblies.Ward.WardItems)
                        {
                            if ((int)inventoryItem.Id == wardItem.Id &&
                                wardItem.Type != SAssemblies.Ward.WardType.Temp &&
                                wardItem.Type != SAssemblies.Ward.WardType.TempVision &&
                                ObjectManager.Player.Spellbook.CanUseSpell(_latestSpellSlot) == SpellState.Ready ||
                                ObjectManager.Player.Spellbook.CanUseSpell(_latestSpellSlot) == (SpellState)1)
                            {
                                _drawSpots = true;
                            }
                        }
                        if (_drawSpots == false)
                        {
                            _latestSpellSlot = SpellSlot.Unknown;
                        }
                    }
                }
            }
            else if (args.Msg == WM_LBUTTONUP && _drawSpots)
            {
                _drawSpots = false;
            }
            else if (args.Msg == WM_RBUTTONDOWN && _drawSpots)
            {
                _drawSpots = false;
            }
            else if (args.Msg == WM_RBUTTONDOWN)
            {
                _latestWardSpot = null;
            }
        }
Beispiel #11
0
        private void Game_OnGameUpdate(object sender, EventArgs args)
        {
            if (!IsActive() || lastGameUpdateTime + new Random().Next(500, 1000) > Environment.TickCount)
                return;

            lastGameUpdateTime = Environment.TickCount;
            if (_latestWardSpot != null && _latestSpellSlot != SpellSlot.Unknown)
            {
                if (Vector3.Distance(ObjectManager.Player.ServerPosition, _latestWardSpot.ClickPos) <= 650)
                {
                    _wardAlreadyCorrected = true;
                    ObjectManager.Player.Spellbook.CastSpell(_latestSpellSlot, _latestWardSpot.ClickPos);
                    _wardAlreadyCorrected = false;
                    _latestWardSpot = null;
                }
            }
        }
Beispiel #12
0
        //TODO: Need to find a way to block item usage
        private void Game_OnGameSendPacket(GamePacketEventArgs args)
        {
            if (!IsActive())
                return;

            var gPacket = new GamePacket(args.PacketData);
            var reader = new BinaryReader(new MemoryStream(args.PacketData));

            byte packetId = reader.ReadByte(); //PacketId
            if (packetId == 0x9A) //OLD 0x9A
            {
                //int mNetworkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                //byte spellId = reader.ReadByte();
                //byte unknown = reader.ReadByte();
                //float fromX = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                //float fromY = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                //float toX = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                //float toY = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                //int tNetworkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                Packet.C2S.Cast.Struct decoded = Packet.C2S.Cast.Decoded(args.PacketData);
                //PacketSpellId nSpellId = PacketSpellId.ConvertPacketCastToId(spellId);
                if (/*_latestSpellSlot == nSpellId.SSpellSlot && */_latestSpellSlot != SpellSlot.Unknown)
                {
                    _drawSpots = false;
                    foreach (WardSpot wardSpot in WardSpots)
                    {
                        if (!wardSpot.SafeWard &&
                            Vector3.Distance(wardSpot.Pos,
                                new Vector3(decoded.FromX, decoded.FromY, ObjectManager.Player.ServerPosition.Z)) <= 250 &&
                            !_wardAlreadyCorrected)
                        {
                            args.Process = false;
                            _wardAlreadyCorrected = true;
                            //SendPacket
                            //var sCastPacket = new byte[28];
                            //var writer = new BinaryWriter(new MemoryStream(sCastPacket));
                            //writer.Write((byte)0x9A);
                            //writer.Write(mNetworkId);
                            //writer.Write(spellId);
                            //writer.Write(unknown);
                            //writer.Write(wardSpot.Pos.X);
                            //writer.Write(wardSpot.Pos.Y);
                            //writer.Write(wardSpot.Pos.X);
                            //writer.Write(wardSpot.Pos.Y);
                            //writer.Write(tNetworkId);
                            //Game.SendPacket(sCastPacket, PacketChannel.C2S, PacketProtocolFlags.Reliable);
                            Packet.C2S.Cast.Encoded(new Packet.C2S.Cast.Struct(decoded.TargetNetworkId, decoded.Slot, decoded.SourceNetworkId,
                                wardSpot.Pos.X, wardSpot.Pos.Y, wardSpot.Pos.X, wardSpot.Pos.Y, decoded.SpellFlag)).Send();
                            //TODO: Check if its correct
                            _wardAlreadyCorrected = false;
                            return;
                        }
                        if (wardSpot.SafeWard &&
                            Vector3.Distance(wardSpot.MagneticPos,
                                new Vector3(decoded.FromX, decoded.FromY, ObjectManager.Player.ServerPosition.Z)) <=
                            250 &&
                            !_wardAlreadyCorrected)
                        {
                            args.Process = false;
                            ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo,
                                new Vector3(wardSpot.MovePos.X, wardSpot.MovePos.Y, wardSpot.MovePos.Z));
                            _latestWardSpot = wardSpot;
                            return;
                        }
                    }
                }
            }
        }
Beispiel #13
0
 private void Game_OnGameUpdate(EventArgs args)
 {
     if (!IsActive())
         return;
     if (_latestWardSpot != null && _latestSpellSlot != SpellSlot.Unknown)
     {
         if (Vector3.Distance(ObjectManager.Player.ServerPosition, _latestWardSpot.ClickPos) <= 650)
         {
             ObjectManager.Player.Spellbook.CastSpell(_latestSpellSlot, _latestWardSpot.ClickPos);
             _latestWardSpot = null;
         }
     }
 }
Beispiel #14
0
        private void Game_OnWndProc(WndEventArgs args)
        {
            //http://msdn.microsoft.com/en-us/library/windows/desktop/ms632585(v=vs.85).aspx
            const int WM_KEYDOWN = 0x100;
            const int WM_LBUTTONUP = 0x202;
            const int WM_LBUTTONDOWN = 0x201;
            const int WM_RBUTTONUP = 0x205;
            const int WM_RBUTTONDOWN = 0x204;

            if (!IsActive())
                return;
            if (MenuGUI.IsChatOpen)
                return;
            if (args.Msg == WM_KEYDOWN)
            {
                InventorySlot inventoryItem = null;
                int inventoryItemID = -1;
                switch (args.WParam)
                {
                    case '1':
                        latestSpellSlot = SpellSlot.Item1;
                        inventoryItemID = 0;
                        break;

                    case '2':
                        latestSpellSlot = SpellSlot.Item2;
                        inventoryItemID = 1;
                        break;

                    case '3':
                        latestSpellSlot = SpellSlot.Item3;
                        inventoryItemID = 2;
                        break;

                    case '4':
                        latestSpellSlot = SpellSlot.Trinket;
                        inventoryItemID = 6;
                        break;

                    case '5':
                        latestSpellSlot = SpellSlot.Item5;
                        inventoryItemID = 3;
                        break;

                    case '6':
                        latestSpellSlot = SpellSlot.Item6;
                        inventoryItemID = 4;
                        break;

                    case '7':
                        latestSpellSlot = SpellSlot.Item4;
                        inventoryItemID = 5;
                        break;

                    default:
                        drawSpots = false;
                        latestSpellSlot = SpellSlot.Unknown;
                        break;
                }

                foreach (InventorySlot inventorySlot in ObjectManager.Player.InventoryItems)
                {
                    if (inventorySlot.Slot == inventoryItemID)
                    {
                        inventoryItem = inventorySlot;
                        break;
                    }
                }

                if (latestSpellSlot != SpellSlot.Unknown)
                {
                    if (inventoryItem != null)
                    {
                        foreach (WardItem wardItem in WardItems)
                        {
                            if ((int) inventoryItem.Id == wardItem.Id &&
                                ObjectManager.Player.Spellbook.CanUseSpell(latestSpellSlot) == SpellState.Ready)
                            {
                                drawSpots = true;
                            }
                        }
                    }
                }
            }
            else if (args.Msg == WM_LBUTTONUP && drawSpots)
            {
                drawSpots = false;
            }
            else if (args.Msg == WM_RBUTTONDOWN && drawSpots)
            {
                drawSpots = false;
            }
            else if (args.Msg == WM_RBUTTONDOWN)
            {
                latestWardSpot = null;
            }
        }
Beispiel #15
0
        //TODO: Add Packetsupp for wards
        private void Game_OnGameSendPacket(GamePacketEventArgs args)
        {
            if (!IsActive())
                return;

            var gPacket = new GamePacket(args.PacketData);
            var reader = new BinaryReader(new MemoryStream(args.PacketData));

            byte PacketId = reader.ReadByte(); //PacketId
            if (PacketId == 0x9A) //OLD 0x9A
            {
                int mNetworkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                byte spellId = reader.ReadByte();
                float fromX = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                float fromY = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                float toX = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                float toY = BitConverter.ToSingle(reader.ReadBytes(4), 0);
                int tNetworkId = BitConverter.ToInt32(reader.ReadBytes(4), 0);
                PacketSpellId nSpellId = PacketSpellId.ConvertPacketCastToId(spellId);
                if (latestSpellSlot == nSpellId.SSpellSlot && latestSpellSlot != SpellSlot.Unknown)
                {
                    drawSpots = false;
                    foreach (WardSpot wardSpot in WardSpots)
                    {
                        if (!wardSpot.SafeWard &&
                            Vector3.Distance(wardSpot.Pos,
                                new Vector3(fromX, fromY, ObjectManager.Player.ServerPosition.Z)) <= 350 &&
                            !wardAlreadyCorrected)
                        {
                            args.Process = false;
                            wardAlreadyCorrected = true;
                            //SendPacket
                            var s_castPacket = new byte[28];
                            var writer = new BinaryWriter(new MemoryStream(s_castPacket));
                            writer.Write((byte) 0x9A);
                            writer.Write(mNetworkId);
                            writer.Write(spellId);
                            writer.Write(wardSpot.Pos.X);
                            writer.Write(wardSpot.Pos.Y);
                            writer.Write(wardSpot.Pos.X);
                            writer.Write(wardSpot.Pos.Y);
                            writer.Write(tNetworkId);
                            Game.SendPacket(s_castPacket, PacketChannel.C2S, PacketProtocolFlags.Reliable);
                                //TODO: Check if its correct
                            wardAlreadyCorrected = false;
                            return;
                        }
                        if (wardSpot.SafeWard &&
                            Vector3.Distance(wardSpot.MagneticPos,
                                new Vector3(fromX, fromY, ObjectManager.Player.ServerPosition.Z)) <=
                            100 &&
                            !wardAlreadyCorrected)
                        {
                            args.Process = false;
                            ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo,
                                new Vector3(wardSpot.MovePos.X, wardSpot.MovePos.Y, wardSpot.MovePos.Z));
                            latestWardSpot = wardSpot;
                            return;
                        }
                    }
                }
            }
        }
Beispiel #16
0
 private static void Program_PlaceWard_OnValueChange(ValueBase<bool> sender, ValueBase<bool>.ValueChangeArgs args)
 {
     if (!Properties.GetData<bool>("Enable")) return;
     if (!args.OldValue && args.NewValue)
     {
         WardSpot spot;
         if (Wards.TryFindNearestSafeWardSpot(Game.CursorPos, out spot))
         {
             if (spot.ClickPosition.IsInRange(Player.Instance, 1100))
             {
                 var item = Wards.GetWardSlot();
                 if (item != null)
                 {
                     if(Player.CastSpell(item.SpellSlot, spot.ClickPosition))
                         Chat.Print(_placePinkWard ? "Placed pink ward!" : "Placed normal ward!");
                     return;
                 }
             }
             Player.IssueOrder(GameObjectOrder.MoveTo, spot.MovePosition, false);
             _placingWardSpot = spot;
         }else if (Wards.TryFindNearestWardSpot(Game.CursorPos, out spot))
         {
             var item = Wards.GetWardSlot();
             if (item != null)
                 Player.CastSpell(item.SpellSlot, spot.MagneticPosition);
         }
     }
 }