rendered paste bodyusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Chief;
using D2Data;
namespace ChiefSpam
{
public partial class Form1 : Form
{
#region Fields
private Process[] Processes = Process.GetProcessesByName("Diablo II");
private Process SelectedProcess;
private List<Thread> Threads = new List<Thread>();
private List<int> Games = new List<int>();
#endregion
public Form1()
{
InitializeComponent();
this.comboBox1.DataSource = this.Processes;
this.comboBox1.ValueMember = "Id";
this.comboBox1.DisplayMember = "MainWindowTitle";
System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
myTimer.Interval = 200;
myTimer.Tick += new EventHandler(EH_myTimer_Tick);
myTimer.Start();
}
#region Stuff
delegate void SetAppendTextCallback(string text);
protected override void Dispose(bool disposing)
{
foreach (Thread thread in this.Threads)
thread.Abort();
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
#region Form Controls
private void EH_DDItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
ToolStripDropDownItem t = (ToolStripDropDownItem)sender;
if (t.Text == "Start")
if (this.Threads[0] != null)
{
foreach (Thread thread in this.Threads)
thread.Start();
this.Text = "ChiefBot - by Eric Carmichael (Started)";
}
else
MessageBox.Show("Nothing to start, attach the bot first!");
else
{
//foreach (Thread thread in this.Threads)
//thread.Abort();
Dispose(true);
this.Text = "ChiefBot - by Eric Carmichael (Stopped)";
}
}
private void EH_ButtonClicked(object sender, EventArgs e)
{
Button b = (Button)sender;
//Attach
//
if (b.Name == "btn_Attach")
{
if (this.SelectedProcess == null)
{
MessageBox.Show("You must select a Diablo II window to attach to.", "TristHelper", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (this.Games.Contains(this.SelectedProcess.Id))
{
MessageBox.Show("Already attached to this window!", "TristHelper", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else
this.Games.Add(this.SelectedProcess.Id);
Thread thread = new Thread(new ThreadStart(GameThread));
this.Threads.Add(thread);
}
//other buttons here:
}
#endregion
#region Private Methods
private void GameThread()
{
Chief.Game game = new Chief.Game();
game.Attach(this.SelectedProcess);
AppendText("Attached" + Environment.NewLine);
System.Threading.Thread.Sleep(250);
Chief.PacketConfirmation waitForGo = delegate(object packet)
{
string msg = (packet as GameClient.SendMessage).Message;
if (msg.ToLower() == "go")
return true;
else
return false;
};
game.WaitForPacket(D2Packets.GameClientPacket.SendMessage, waitForGo, 60 * 60 * 1000);
AppendText("Started" + Environment.NewLine);
//AppendText("Hero UID: " + game.Hero.UID + Environment.NewLine);
//AppendText(" X: " + game.Hero.X + Environment.NewLine);
//AppendText(" Y: " + game.Hero.Y + Environment.NewLine);
/* Switch weapons | CTA
*/
game.SwitchWeaponSlotWait();
if (game.Hero.GetItemAt(EquipmentLocation.LeftHand).Runeword != BaseRuneword.GetByName("Call to Arms") &&
game.Hero.GetItemAt(EquipmentLocation.RightHand).Runeword != BaseRuneword.GetByName("Call to Arms"))
game.SwitchWeaponSlotWait();
/* Move from: start of act 5, to: Red Portal
game.MoveWait(5103, 5043);
game.MoveWait(5110, 5064);
*/
#region Eldritch
if (ckBox_Elderitch.Checked == true)
{
game.WaypointInteract(game.Objects.Find("ExpansionWaypoint"), D2Data.WaypointDestination.FrigidHighlands);
game.TeleportWait(3760, 5097);
game.TeleportWait(3750, 5078);
List<NPC> eldritchAndMinions;
while ((eldritchAndMinions = game.Units.FindAll("MinionExp")) == null)
System.Threading.Thread.Sleep(10);
AppendText("Found: " + eldritchAndMinions.Count + " MinionExp" + Environment.NewLine);
for (int i = eldritchAndMinions.Count - 1; i > 0; i--)
{
AppendText("Targetting: " + eldritchAndMinions[i].UID + Environment.NewLine);
while (eldritchAndMinions[i].State != GameServer.NPCMode.Dead && eldritchAndMinions[i].State != GameServer.NPCMode.Dying)
{
AppendText("Attacking: " + eldritchAndMinions[i].UID + Environment.NewLine);
game.Attack(eldritchAndMinions[i], D2Data.SkillType.Lightning);
System.Threading.Thread.Sleep(250);
}
}
}
#endregion
#region Pindle
if (this.ckBox_Pindle.Checked == true)
{
game.MoveWait(5119, 5090);
game.MoveWait(5131, 5108);
game.MoveWait(5119, 5120);
game.PortalInteract(game.Objects.Find("PermanentTownPortal"));
game.TeleportWait(10064, 13293);
game.TeleportWait(10063, 13268);
game.TeleportWait(10058, 13238);
List<NPC> pindleAndMinions;
while ((pindleAndMinions = game.Units.FindAll("DefiledWarrior")) == null)
System.Threading.Thread.Sleep(10);
AppendText("Found: " + pindleAndMinions.Count + " DefiledWarriors" + Environment.NewLine);
// Go backwards down the list of units, because pindle is the last one we get
for (int i = pindleAndMinions.Count-1; i > 0; i--)
{
AppendText("Targetting: " + pindleAndMinions[i].UID + Environment.NewLine);
while (pindleAndMinions[i].State != GameServer.NPCMode.Dead && pindleAndMinions[i].State != GameServer.NPCMode.Dying)
{
AppendText("Attacking: " + pindleAndMinions[i].UID + Environment.NewLine);
game.Attack(pindleAndMinions[i], D2Data.SkillType.Lightning);
System.Threading.Thread.Sleep(250);
}
}
}
#endregion
// Clean up
game.Clear();
} //What to do once you start.
private void PreBuff(CharacterClass charClass)
{
if(charClass == CharacterClass.Paladin)
}
private void AppendText(string text)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.rTxtBox_Info.InvokeRequired)
{
SetAppendTextCallback d = new SetAppendTextCallback(AppendText);
this.Invoke(d, new object[] { text });
}
else
{
this.rTxtBox_Info.AppendText(text);
this.rTxtBox_Info.ScrollToCaret();
}
} //Write to the Info box
private void EH_myTimer_Tick(object sender, EventArgs e)
{
if (this.comboBox1.Items.Count != this.Processes.Length)
this.comboBox1.DataSource = this.Processes;
this.Processes = Process.GetProcessesByName("D2Loader-1.11b"); // <-Loader ftw
this.SelectedProcess = comboBox1.SelectedItem as Process;
}
#endregion
}
}