Ejemplo n.º 1
0
        private void btnWaypointsInsert_Click(object sender, EventArgs e)
        {
            if (!Client.Player.Connected || Client.Player.Health == 0)
            {
                return;
            }
            if (comboboxWaypointsOffset.SelectedIndex < 0 || comboboxWaypointsType.SelectedIndex < 0 || listboxWaypoints.SelectedIndex < 0)
            {
                return;
            }
            Modules.Cavebot.Waypoint.Types type;
            switch (comboboxWaypointsType.Text)
            {
            case "Node":
                type = Modules.Cavebot.Waypoint.Types.Node;
                break;

            case "Walk":
                type = Modules.Cavebot.Waypoint.Types.Walk;
                break;

            case "Rope":
                type = Modules.Cavebot.Waypoint.Types.Rope;
                break;

            case "Shovel":
                type = Modules.Cavebot.Waypoint.Types.Shovel;
                break;

            case "Machete":
                type = Modules.Cavebot.Waypoint.Types.Machete;
                break;

            case "Pick":
                type = Modules.Cavebot.Waypoint.Types.Pick;
                break;

            case "Ladder":
                type = Modules.Cavebot.Waypoint.Types.Ladder;
                break;

            case "Script":
                type = Modules.Cavebot.Waypoint.Types.Script;
                break;

            default:
                type = Modules.Cavebot.Waypoint.Types.Node;
                break;
            }
            int diffX = 0, diffY = 0;

            switch (comboboxWaypointsOffset.SelectedIndex)
            {
            case 0:
                break;

            case 1:
                diffY = -1;
                break;

            case 2:
                diffX = 1;
                break;

            case 3:
                diffY = 1;
                break;

            case 4:
                diffX = -1;
                break;
            }
            int index = listboxWaypoints.SelectedIndex;

            if (type == Modules.Cavebot.Waypoint.Types.Script)
            {
                Objects.Location loc = new Objects.Location(this.Client.Player.X + diffX,
                                                            this.Client.Player.Y + diffY, this.Client.Player.Z);
                Modules.Cavebot.Waypoint wp = new Modules.Cavebot.Waypoint(this.Client.Modules.Cavebot, loc, Modules.Cavebot.Waypoint.Types.Script);
                this.Client.Modules.Cavebot.InsertWaypoint(wp, index);
            }
            else
            {
                Modules.Cavebot.Waypoint wp = new Modules.Cavebot.Waypoint(this.Client.Modules.Cavebot,
                                                                           new Objects.Location(this.Client.Player.X + diffX, this.Client.Player.Y + diffY, this.Client.Player.Z), type);
                if (type == Modules.Cavebot.Waypoint.Types.Node && numericSettingsNodeRadius.Value > 0)
                {
                    ushort             pX = this.Client.Player.X, pY = this.Client.Player.Y;
                    byte               pZ = this.Client.Player.Z, radius = (byte)numericSettingsNodeRadius.Value;
                    Map.TileCollection tiles      = this.Client.Map.GetTilesOnScreen();
                    Map.Tile           playerTile = tiles.GetTile(count: this.Client.Player.ID);
                    if (playerTile == null)
                    {
                        MessageBox.Show("Could not find player tile"); return;
                    }
                    List <Objects.Location> nodeLocations = new List <Objects.Location>();
                    for (ushort x = (ushort)(pX - radius); x < pX + radius; x++)
                    {
                        for (ushort y = (ushort)(pY - radius); y < pY + radius; y++)
                        {
                            if (x == pX && y == pY)
                            {
                                continue;
                            }
                            Map.Tile tile = tiles.GetTile(new Objects.Location(x, y, pZ));
                            if (tile == null)
                            {
                                continue;
                            }
                            if (tile.IsWalkable())
                            {
                                nodeLocations.Add(tile.WorldLocation);
                            }
                        }
                    }
                    wp.NodeLocations.AddRange(nodeLocations);
                }
                this.Client.Modules.Cavebot.InsertWaypoint(wp, index);
            }
        }