Example #1
0
 private void comboboxWaypoint_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboboxWaypoint.SelectedIndex < 0)
     {
         return;
     }
     if (comboboxWaypoint.SelectedIndex == 0)
     {
         Modules.Cavebot.Waypoint wp = (Modules.Cavebot.Waypoint)comboboxWaypoint.SelectedItem;
         comboboxType.Enabled = true;
         foreach (object obj in comboboxType.Items)
         {
             if (obj.ToString() == wp.Type.ToString())
             {
                 comboboxWaypoint.SelectedItem = obj; break;
             }
         }
         numericLocX.Value = wp.Location.X;
         numericLocY.Value = wp.Location.Y;
         numericLocZ.Value = wp.Location.Z;
     }
     else
     {
         Objects.Location subnode = (Objects.Location)comboboxWaypoint.SelectedItem;
         comboboxType.Enabled = false;
         numericLocX.Value    = subnode.X;
         numericLocY.Value    = subnode.Y;
         numericLocZ.Value    = subnode.Z;
     }
 }
Example #2
0
        private void listboxWaypoints_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listboxWaypoints.SelectedIndex < 0)
            {
                return;
            }
            Modules.Cavebot.Waypoint wp = (Modules.Cavebot.Waypoint)listboxWaypoints.SelectedItem;
            bool enable = wp.Type == Modules.Cavebot.Waypoint.Types.Script;

            if (btnWaypointsLoadScript.Enabled != enable)
            {
                btnWaypointsLoadScript.Enabled = enable;
            }
            if (btnWaypointsClearScript.Enabled != enable)
            {
                btnWaypointsClearScript.Enabled = enable;
            }
            if (txtboxWaypointScript.Enabled != enable)
            {
                txtboxWaypointScript.Enabled = enable;
            }
            if (enable)
            {
                txtboxWaypointScript.Text = wp.Script.Code;
            }
            else
            {
                txtboxWaypointScript.Text = string.Empty;
            }
        }
Example #3
0
        private void picboxMap_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                this.mouseRightClickPosition = e.Location;
                // get world location of mouse click
                Objects.Location worldLoc = new Objects.Location(this.CurrentFloorBounds.X + this.CurrentLocation.X + (int)(e.Location.X / this.Scale),
                                                                 this.CurrentFloorBounds.Y + this.CurrentLocation.Y + (int)(e.Location.Y / this.Scale),
                                                                 this.CurrentLocation.Z);

                bool found = false;
                foreach (Modules.Cavebot.Waypoint wp in this.Client.Modules.Cavebot.GetWaypoints())
                {
                    if (wp.Location.DistanceTo(worldLoc) < 10 / this.Scale)
                    {
                        found = true;
                        this.selectedWaypoint = wp;
                        break;
                    }
                }
                if (!found)
                {
                    this.selectedWaypoint = null;
                }
                contextitemWaypointRemove.Enabled = found;

                contextmenuMap.Show(Cursor.Position);
            }
        }
Example #4
0
        private void btnWaypointsLoadScript_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Title            = "Choose a script to load";
            openFile.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
            openFile.Filter           = "C# code file (*.cs)|*.cs";
            openFile.Multiselect      = false;
            if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Modules.Cavebot.Waypoint wp = this.Client.Modules.Cavebot.GetWaypoints()
                                              .ToArray <Modules.Cavebot.Waypoint>()[this.listboxWaypoints.SelectedIndex];
                if (wp.Type != Modules.Cavebot.Waypoint.Types.Script)
                {
                    return;
                }
                using (System.IO.Stream fstream = openFile.OpenFile())
                {
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(fstream))
                    {
                        wp.Script = new Modules.Cavebot.Script(this.Client.Modules.Cavebot, reader.ReadToEnd(), wp);
                    }
                }
                txtboxWaypointScript.Text = wp.Script.Code;
            }
        }
Example #5
0
 private void toolstripRemoveWaypoint_Click(object sender, EventArgs e)
 {
     if (listboxWaypoints.SelectedIndex < 0)
     {
         return;
     }
     Modules.Cavebot.Waypoint wp = (Modules.Cavebot.Waypoint)listboxWaypoints.SelectedItem;
     this.Client.Modules.Cavebot.RemoveWaypoint(wp);
 }
Example #6
0
 private void contextitemWaypointRemove_Click(object sender, EventArgs e)
 {
     if (this.selectedWaypoint == null)
     {
         return;
     }
     this.Client.Modules.Cavebot.RemoveWaypoint(this.selectedWaypoint);
     this.selectedWaypoint = null;
     picboxMap.Invalidate();
 }
Example #7
0
 private void txtboxWaypointScript_TextChanged(object sender, EventArgs e)
 {
     if (listboxWaypoints.SelectedIndex < 0)
     {
         return;
     }
     Modules.Cavebot.Waypoint wp = (Modules.Cavebot.Waypoint)listboxWaypoints.SelectedItem;
     if (wp.Type != Modules.Cavebot.Waypoint.Types.Script)
     {
         return;
     }
     wp.Script.Code = txtboxWaypointScript.Text;
 }
Example #8
0
 private void btnWaypointsClearScript_Click(object sender, EventArgs e)
 {
     Modules.Cavebot.Waypoint wp = this.Client.Modules.Cavebot.GetWaypoints()
                                   .ToArray <Modules.Cavebot.Waypoint>()[this.listboxWaypoints.SelectedIndex];
     if (wp.Type != Modules.Cavebot.Waypoint.Types.Script)
     {
         return;
     }
     if (MessageBox.Show("Are you sure you want to clear this script?", "Warning", MessageBoxButtons.YesNo) ==
         DialogResult.Yes)
     {
         wp.Script.Code = string.Empty;
     }
 }
Example #9
0
 internal WaypointEditor(Objects.Client c, Modules.Cavebot.Waypoint waypoint)
 {
     this.Client   = c;
     this.Waypoint = waypoint;
     InitializeComponent();
     this.Icon = Properties.Resources.icon;
     timerUpdate.Start();
     comboboxWaypoint.Items.Add(waypoint);
     if (waypoint.Type == Modules.Cavebot.Waypoint.Types.Node)
     {
         foreach (Objects.Location loc in waypoint.NodeLocations)
         {
             comboboxWaypoint.Items.Add(loc);
         }
     }
 }
Example #10
0
 private void numericLocZ_ValueChanged(object sender, EventArgs e)
 {
     if (comboboxWaypoint.SelectedIndex < 0)
     {
         return;
     }
     if (comboboxWaypoint.SelectedIndex == 0)
     {
         Modules.Cavebot.Waypoint wp = (Modules.Cavebot.Waypoint)comboboxWaypoint.SelectedItem;
         wp.Location.Z = (byte)numericLocZ.Value;
     }
     else
     {
         Objects.Location subnode = (Objects.Location)comboboxWaypoint.SelectedItem;
         subnode.Z = (byte)numericLocZ.Value;
     }
 }
Example #11
0
        private void comboboxType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboboxWaypoint.SelectedIndex < 0 || comboboxWaypoint.SelectedIndex > 0)
            {
                return;
            }
            Modules.Cavebot.Waypoint wp = (Modules.Cavebot.Waypoint)comboboxWaypoint.SelectedItem;
            switch (comboboxType.SelectedItem.ToString())
            {
            case "Node":
                wp.Type = Modules.Cavebot.Waypoint.Types.Node;
                break;

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

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

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

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

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

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

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

            default:
                wp.Type = Modules.Cavebot.Waypoint.Types.Node;
                break;
            }
        }
Example #12
0
        private void picboxMap_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                this.mouseRightClickPosition = e.Location;
                // get world location of mouse click
                Objects.Location worldLoc = new Objects.Location(this.CurrentFloorBounds.X + this.CurrentLocation.X + (int)(e.Location.X / this.Scale),
                    this.CurrentFloorBounds.Y + this.CurrentLocation.Y + (int)(e.Location.Y / this.Scale),
                    this.CurrentLocation.Z);

                bool found = false;
                foreach (Modules.Cavebot.Waypoint wp in this.Client.Modules.Cavebot.GetWaypoints())
                {
                    if (wp.Location.DistanceTo(worldLoc) < 10 / this.Scale)
                    {
                        found = true;
                        this.selectedWaypoint = wp;
                        break;
                    }
                }
                if (!found) this.selectedWaypoint = null;
                contextitemWaypointRemove.Enabled = found;

                contextmenuMap.Show(Cursor.Position);
            }
        }
Example #13
0
 void Cavebot_WaypointInserted(Modules.Cavebot.Waypoint waypoint, int index)
 {
     listboxWaypoints.Items.Insert(index, waypoint);
 }
Example #14
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);
            }
        }
Example #15
0
 void Cavebot_WaypointRemoved(Modules.Cavebot.Waypoint waypoint)
 {
     listboxWaypoints.Items.Remove(waypoint);
 }
Example #16
0
 void Cavebot_WaypointAdded(Modules.Cavebot.Waypoint waypoint)
 {
     listboxWaypoints.Items.Add(waypoint);
 }
Example #17
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);
     }
 }
Example #18
0
 private void contextitemWaypointRemove_Click(object sender, EventArgs e)
 {
     if (this.selectedWaypoint == null) return;
     this.Client.Modules.Cavebot.RemoveWaypoint(this.selectedWaypoint);
     this.selectedWaypoint = null;
     picboxMap.Invalidate();
 }