Here's my roads to alcarnus quest script... This is UNTESTED.
For some reason I can't get SetQuest to work on the correct step of the quest. It just says Error ####### in diablo.
using System;
using System.Collections.Generic;
using System.Linq;
using D3;
using QB.Base;
namespace QB.Quests
{
internal class Road2Alcarnus
{
private static int _difficulty;
private static int _frameCount;
private static int _step;
private static readonly List<Action> _actionList = new List<Action>();
// Displays difficulty and quest, initializes creation of action list, starts on tick events
public static void Load(int i = 0)
{
_difficulty = i;
if (_difficulty == 3)
Game.Print("Inferno ROADS TO ALCARNUS loaded");
else if (_difficulty == 2)
Game.Print("Hell ROADS TO ALCARNUS loaded");
else if (_difficulty == 1)
Game.Print("Nightmare ROADS TO ALCARNUS loaded");
else
{
Game.Print("Normal ROADS TO ALCARNUS loaded");
_difficulty = 0;
}
CreateActionList();
Game.OnTickEvent += Game_OnTickEvent;
}
private static void CreateActionList()
{
// If in game, leave game
_actionList.Add(() =>
{
if (Game.Ingame)
MouseInterface.Click(UiElementHash.LeaveGame);
else
{
Combat.ResetBuffs();
_step++;
}
});
// If out of game, continue
_actionList.Add(() =>
{
if (!Game.Ingame)
_step++;
});
// Sets difficulty, SNOQuestId, and step http://d3advanced.com/wiki/index.php?title=Quests
//wont work!
_actionList.Add(() =>
{
Game.SetQuest(_difficulty, SNOQuestId.KhamsinGate,1);
_step++;
});
// Starts Game
_actionList.Add(() =>
{
MouseInterface.Click(UiElementHash.StartResumeGame);
_step++;
});
// If in game, continue
_actionList.Add(() =>
{
if (Game.Ingame)
_step++;
});
// Move to Waypoint
_actionList.Add(() =>
{
Navigation.MoveTo("Waypoint");
if (Navigation.GetDistance("Waypoint") > 2)
_step++;
});
// Take the correct waypoint.
_actionList.Add(() =>
{
try {
UIElement element = UIElement.Get ().Where (u => u.Name.Contains ("stackpanel.entry 2.wrapper.button")).FirstOrDefault ();
//Trying 2.
Game.Print ("'" + element.Name + "'");
if (element != default(UIElement))
element.Click ();
} catch (Exception e)
{
Game.Print (e.Message);
}
_step++;
});
// Move to waypoint.
_actionList.Add(() =>
{
if (Navigation.GetDistance(1354.539f, 278.476f) > 10f)
Navigation.MoveTo(1354.539f, 278.476f);
else
_step++;
});
// Move to waypoint.
_actionList.Add(() =>
{
if (Navigation.GetDistance(1311.929f, 282.5014f) > 10f)
Navigation.MoveTo(1311.929f, 282.5014f);
else
_step++;
});
// Move to waypoint.
_actionList.Add(() =>
{
if (Navigation.GetDistance(1301.325f, 339.3374f) > 10f)
Navigation.MoveTo(1301.325f, 339.3374f);
else
_step++;
});
// Move to waypoint.
_actionList.Add(() =>
{
if (Navigation.GetDistance(1327.392f, 407.039f ) > 10f)
Navigation.MoveTo(1327.392f, 407.039f);
else
_step++;
});
// Move to Lieutenant Vachem
_actionList.Add(() =>
{
if (Navigation.GetDistance("Lieutenant Vachem") > 5f)
Navigation.MoveTo("Lieutenant Vachem");
else
_step++;
});
// If there is no conversation dialog, interact with Lieutenant Vachem
_actionList.Add(() =>
{
if (!MouseInterface.Visible(UiElementHash.CloseConversation))
UnitCollection.Interact("Lieutenant Vachem");
else
_step++;
});
// Close conversation dialog
_actionList.Add(() =>
{
if (MouseInterface.Visible(UiElementHash.CloseConversation))
MouseInterface.Click(UiElementHash.CloseConversation);
else
_step++;
});
// Move to Command Post
_actionList.Add(() =>
{
if (Navigation.GetDistance(1293.944f, 421.0988f) > 5f)
Navigation.MoveTo(1293.944f, 421.0988f);
else
_step++;
});
// If Cellar of the Damned Exists, interact with it
_actionList.Add(() =>
{
if (UnitCollection.Exists("Command Post"))
{
UnitCollection.Interact("Command Post");
}
else
_step++;
});
//Move forward so magda talks.
_actionList.Add(() =>
{
if (Navigation.GetDistance(159.1746f, 159.7909f) > 5f)
Navigation.MoveTo(159.1746f, 159.7909f);
else
_step++;
});
// Kill the mobs!
_actionList.Add(() =>
{
if (UnitCollection.Exists("Copperfang Lurker"))
Combat.Attack("Copperfang Lurker");
else
_step++;
});
//Move to the cage...
_actionList.Add(() =>
{
if (Navigation.GetDistance(159.1746f, 173.6681f) > 5f)
Navigation.MoveTo(159.1746f, 173.6681f);
else
_step++;
});
//Open the cage
_actionList.Add(() =>
{
if (UnitCollection.Exists("Locked Cage"))
{
UnitCollection.Interact("Locked Cage");
}
else
_step++;
});
//Leave the command post back to the kasim outpost.
_actionList.Add(() =>
{
if (Navigation.GetDistance(158.4999f, 97.7180f) > 5f)
Navigation.MoveTo(158.4999f, 97.7180f);
else
_step++;
});
_actionList.Add(() =>
{
if (UnitCollection.Exists("Khasim Outpost"))
{
UnitCollection.Interact("Khasim Outpost");
}
else
_step++;
});
_actionList.Add(() =>
{
if (UnitCollection.Exists("Copperfang Lurker"))
Combat.Attack("Copperfang Lurker");
else
_step++;
});
_actionList.Add(() =>
{
if (Navigation.GetDistance(1342.75f, 423.9367f) > 5f)
Navigation.MoveTo(1342.75f, 423.9367f);
else
_step++;
});
_actionList.Add(() =>
{
if (UnitCollection.Exists("Copperfang Lurker"))
Combat.Attack("Copperfang Lurker");
else
_step++;
});
_actionList.Add(() =>
{
if (Navigation.GetDistance(1296.438f, 306.9593f) > 5f)
Navigation.MoveTo(1296.438f, 306.9593f);
else
_step++;
});
}
private static void Game_OnTickEvent(EventArgs e)
{
if (++_frameCount%20 != 0)
return;
#if DEBUG
Game.Print("_step = " + _step);
#endif
// Check if dead
if (Game.Ingame && Me.Life <= 0f && Me.Mode == UnitMode.Dead)
{
MouseInterface.Click(UiElementHash.Revive);
_step = 19;
}
// Invoke action
if (_actionList.Any())
_actionList[_step].Invoke();
}
}
}