Project Download:
Download ascbq v1.2.zip from Sendspace.com - send big files the easy way
Source
Code:
/*
* Author: Bobbyjayblack
* Name: A Shattered Crown Begin Quest Bot (Mira Bot)
* Version: v1.2
* Filename: ascbq.cs
* Compiled location\name: .\ascbq\bin\Debug\ascbq.exe
* Required references: D3Advanced .NET.dll
* Description: A D3Advanced C# bot that does the quest Act 1 A Shattered Crown Begin Quest over and over.
* It changes quest to Act 1 A Shattered Crown Begin Quest. Starts Game. Quests until Act 1 A Shattered Crown Northwest Gate. Exits game, and repeats.
* You must not have Act 1 A Shattered Crown Begin Quest at a Resume point. If you do, simply change quests, Start Game, Exit Game, and then .load ascbq
* Usage: Compile ascbq, move ascbq.exe to D3Advanced\Assemblies\ascbq.exe . Once logged into the game, type: .load ascbq
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using D3;
namespace ascbq
{
public class Program
{
private static bool debug = false;
private static int _frameCount = 0;
private static int step = 0;
// Edit these to match your bar
private static SNOPowerId barSkill1 = SNOPowerId.Barbarian_GroundStomp;
private static SNOPowerId barSkill2 = SNOPowerId.Barbarian_ThreateningShout;
private static SNOPowerId barSkill3 = SNOPowerId.Barbarian_Revenge;
private static SNOPowerId barSkill4 = SNOPowerId.Barbarian_FuriousCharge;
private static SNOPowerId leftMouseSkill = SNOPowerId.Barbarian_Frenzy;
private static SNOPowerId rightMouseSkill = SNOPowerId.Barbarian_WarCry;
public static bool CheckItem(Unit unit)
{
// Edit to whatever you want to pickup.
return unit.Name.Contains("Topaz") // Gems
|| unit.Name.Contains("Amethyst")
|| unit.Name.Contains("Emerald")
|| unit.Name.Contains("Ruby")
|| unit.Name.Contains("Book") // Craft Mats (add "page"?)
|| unit.Name.Contains("Tome")
|| unit.Name.Contains("Mythic") // Health Potions
|| unit.ActorId == SNOActorId.GoldCoin
|| unit.ActorId == SNOActorId.GoldCoins
|| unit.ActorId == SNOActorId.GoldLarge
|| unit.ActorId == SNOActorId.GoldMedium
|| unit.ActorId == SNOActorId.GoldSmall
|| unit.Name.Contains("Chromatic") // Resist All Items
|| unit.Name.Contains("Spectral") // Resist All Items
|| unit.Name.Contains("Rugged") // +% Maximum Life
|| unit.Name.Contains("Stalwart") // +% Maximum Life
|| unit.Name.Contains("of the Leech") // X Life on Hit
|| unit.Name.Contains("of Carnage") // X Life on Hit
|| unit.Name.Contains("of Gore") // X Life on Hit
|| unit.Name.Contains("of Mangling") // X Life on Hit
|| unit.Name.Contains("Scouting") // % Magic Find
|| unit.Name.Contains("Ransacking") // % Magic Find
|| unit.Name.Contains("Seeking") // % Magic Find
//|| unit.ItemQuality >= UnitItemQuality.Magic1 // Pickup magic/rare/legendary items, I found this to fill my inventory in 30~ minutes. Currently, it keeps trying to pickup items over and over.
|| unit.ItemQuality >= UnitItemQuality.Rare4 // Pickup rare/legendary items
|| unit.ItemQuality == UnitItemQuality.Artifact;
}
// Stop editing
public static void Main(string[] args)
{
Game.Print("A Shattered Crown Begin Quest now active.");
if (Game.Ingame)
ExitGame();
Game.OnTickEvent += new TickEventHandler(Game_OnTickEvent);
}
private static void Game_OnTickEvent(EventArgs e)
{
if (++_frameCount % 20 != 0)
return;
/* TODO: Find UI Element to Revive at last checkpoint when dead.
if (Game.Ingame)
{
if (Me.WorldId != -1 && Me.WorldId != 0 && Me.Life == 0)
{
Game.Print("I died! Reviving...");
Click("Revive at last checkpoint UIElement");
step = 17;
}
}
*/
switch (step)
{
case 0:
if (Click("Root.NormalLayer.BattleNetCampaign_main.LayoutRoot.Menu.ChangeQuestButton"))
step++;
break;
case 1:
if (Click("Root.NormalLayer.BattleNetQuestSelection_main.LayoutRoot.OverlayContainer.QuestMenu.NavigationMenuList._content._stackpanel._item2"))
step++;
break;
case 2:
if (Click("Root.NormalLayer.BattleNetQuestSelection_main.LayoutRoot.OverlayContainer.SelectQuestButton"))
step++;
break;
case 3:
if (Click("Root.TopLayer.BattleNetModalNotifications_main.ModalNotification.Buttons.ButtonList.OkButton"))
step++;
break;
case 4:
if (Click("Root.NormalLayer.BattleNetCampaign_main.LayoutRoot.Menu.PlayGameButton"))
step++;
break;
case 5:
if (Game.Ingame && Me.InTown)
step++;
break;
case 6:
if (MoveTo("Deckard Cain"))
step++;
break;
case 7:
if(!Click("Root.NormalLayer.conversation_dialog_main.button_close"))
Interact("Deckard Cain");
else
step++;
break;
case 8:
if(!Click("Root.NormalLayer.conversation_dialog_main.button_close"))
step++;
break;
case 9:
if (MoveTo((float)3003.098, (float)2790.004))
step++;
break;
case 10:
if (MoveTo((float)2993.186, (float)2718.52))
step++;
break;
case 11:
if (MoveTo((float)2954.805, (float)2711.546))
step++;
break;
case 12:
if (MoveTo("Haedrig Eamon"))
step++;
break;
case 13:
if (!Click("Root.NormalLayer.conversation_dialog_main.button_close"))
Interact("Haedrig Eamon");
else
step++;
break;
case 14:
if(!Click("Root.NormalLayer.conversation_dialog_main.button_close"))
step++;
break;
case 15:
if (MoveTo((float)2792.586, (float)2619.849))
step++;
break;
case 16:
if (Me.LevelArea == SNOLevelArea.A1_trOUT_NewTristram)
Interact("Cellar of the Damned");
else
step++;
break;
case 17:
if (MoveTo((float)175.9097, (float)150.4982))
step++;
break;
case 18:
if (Attack("Door"))
step++;
break;
case 19:
if (MoveTo((float)132.1171, (float)127.0518))
step++;
break;
case 20:
if (MoveTo((float)132.5787, (float)168.4666))
step++;
break;
case 21:
if (!Attack("Mira Eamon") && Unit.Get().Where(x => x.Name.Contains("Mira")).FirstOrDefault() != default(Unit) )
Attack("Ravenous Dead");
else
step++;
break;
case 22:
if (!SnagItems())
step++;
break;
case 23:
if (MoveTo("Haedrig Eamon"))
step++;
break;
case 24:
if (!Click("Root.NormalLayer.conversation_dialog_main.button_close"))
Interact("Haedrig Eamon");
else
step++;
break;
case 25:
if (!Click("Root.NormalLayer.conversation_dialog_main.button_close"))
if (!SnagItems())
step++;
break;
case 26:
if ((!Me.InTown) && (Me.Mode != UnitMode.Casting || Me.Mode != UnitMode.Warping))
Me.UsePower(SNOPowerId.UseStoneOfRecall);
else if (Me.InTown)
step++;
break;
case 27:
ExitGame();
break;
case 28:
if (!Game.Ingame)
step = 0;
break;
}
}
public static void ExitGame()
{
UIElement ui = UIElement.Get(0x5DB09161C4D6B4C6);
if (ui != null)
{
ui.Click();
step = 0;
}
}
public static bool Click(string name)
{
var ui = UIElement.Get().Where(x => x.Name == name).FirstOrDefault();
if (ui.Name != null && ui.Visible && ui.Name == name)
{
if (debug)
Game.Print("Clicking " + ui.Name.ToString());
ui.Click();
return true;
}
return false;
}
public static bool Attack(string name)
{
var u = Unit.Get().Where(x => x.Name.Contains(name)).FirstOrDefault();
if (u == default(Unit))
return false;
if (u.Life <= 0 || u.Mode == UnitMode.Dead)
return true;
else
{
if (debug)
Game.Print("Attacking " +name +u.Life +"/" +u.MaxLife);
Me.UsePower(barSkill1, u);
Me.UsePower(barSkill2, u);
Me.UsePower(barSkill3, u);
Me.UsePower(barSkill4, u);
Me.UsePower(leftMouseSkill, u);
Me.UsePower(rightMouseSkill, u);
}
return false;
}
public static void Interact(string name)
{
var u = Unit.Get().Where(x => x.Name.Contains(name)).FirstOrDefault();
if (u.Name.Contains(name))
{
if (debug)
Game.Print("Interacting with " + name);
Me.UsePower(u.Type == UnitType.Gizmo || u.Type == UnitType.Item ? SNOPowerId.Axe_Operate_Gizmo : SNOPowerId.Axe_Operate_NPC, u);
}
}
public static void Interact(Unit u)
{
if (debug)
Game.Print("Interacting with " + u.Name);
Me.UsePower(u.Type == UnitType.Gizmo || u.Type == UnitType.Item ? SNOPowerId.Axe_Operate_Gizmo : SNOPowerId.Axe_Operate_NPC, u);
}
public static bool MoveTo(float x, float y)
{
if (debug)
Game.Print("Moving to " + x + ", " + y);
Me.UsePower(SNOPowerId.Walk, x, y, Me.Z);
if ((float)Math.Sqrt(Math.Pow(Me.X - x, 2) + Math.Pow(Me.Y - y, 2)) < 5)
return true;
return false;
}
public static bool MoveTo(string name)
{
var u = Unit.Get().Where(x => x.Name.Contains(name)).FirstOrDefault();
if (!u.Name.Contains(name))
return false;
if (debug)
Game.Print("Moving to " + name);
Me.UsePower(SNOPowerId.Walk, u);
if ((float)Math.Sqrt(Math.Pow(Me.X - u.X, 2) + Math.Pow(Me.Y - u.Y, 2)) < 5)
return true;
return false;
}
public static bool MoveTo(Unit u)
{
if (debug)
Game.Print("Moving to " + u.Name);
Me.UsePower(SNOPowerId.Walk, u);
if ((float)Math.Sqrt(Math.Pow(Me.X - u.X, 2) + Math.Pow(Me.Y - u.Y, 2)) < 5)
return true;
return false;
}
public static float GetDistance(string name)
{
var u = Unit.Get().Where(x => x.Name.Contains(name)).FirstOrDefault();
return (float)Math.Sqrt(Math.Pow(Me.X - u.X, 2) + Math.Pow(Me.Y - u.Y, 2));
}
public static bool SnagItems()
{
if (debug)
Game.Print("SnagItems");
List<Unit> items = new List<Unit>();
foreach (Unit u in Unit.Get())
if (CheckItem(u) && u.ItemContainer == Container.Unknown)
items.Add(u);
var iCount = items.Count();
if (debug)
Game.Print(iCount.ToString() + " items found");
if (items.Count() > 0)
{
if (debug)
Game.Print("Picking up: " + items[0].Name);
MoveTo(items[0]);
Interact(items[0]);
return true;
}
return false;
}
}
}
How to compile C# projects using Microsoft Visual Studios 2010:
1) Click File>Open>Project/Solution
2) Navigate to where you extracted the .zip
3) Click ascbq.sln
4) Click Build>Build Solution
SNOPowerID's:
SNOPowerId Enumeration
Bookmarks