ohcrit95
New Member
- Joined
- May 22, 2010
- Messages
- 49
- Reaction score
- 0
Is there any way I can get a temporary Honorbuddy key? It's kinda hard to make a BG plugin if you can't test it. Lol. Here's some source, so you can kinda tell I'm not BS'ing. Don't complain about unnecessary code, and sloppiness, please.
<3
Thanks.

Code:
namespace Styx.Bot.CustomClasses
{
using Styx.Logic;
using System;
using Styx.Helpers;
using Styx.Logic.Pathing;
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Xml.Linq;
using System.Linq;
using System.Net;
using System.Windows.Forms;
using System.Drawing;
using Styx.Plugins.PluginClass;
using System.Reflection;
using Styx.Logic.Inventory.Frames.Gossip;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Combat.CombatRoutine;
using Styx.Logic.BehaviorTree;
using Styx.Logic.Combat;
using Styx;
using Styx.Logic.Profiles;
public class BGWorker : HBPlugin
{
public string _ihaveflag;
public string _tmhasflag;
public string _runtoenemybase;
public static readonly string PluginFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), Path.Combine("Plugins", "BotActions"));
private readonly string file = PluginFolderPath + "\\config.txt";
bool _spamstart = false;
Stopwatch sw = new Stopwatch();
private void slog(string format, params object[] args)
{
Logging.Write("[Battleground:]" + format, args);
}
public void LoadSettings()
{
TextReader r;
try
{
r = new StreamReader(file);
}
catch (FileNotFoundException)
{
Styx.Helpers.Logging.Write("No settings found. Creating new file.");
NewFile();
return;
}
try
{
_ihaveflag = r.ReadLine();
_tmhasflag = r.ReadLine();
_runtoenemybase = r.ReadLine();
}
catch
{
Styx.Helpers.Logging.Write("Failed to load settings! ):");
NewFile();
r.Close();
return;
}
r.Close();
slog("Settings loaded!");
}
public void NewFile()
{
_tmhasflag = "";
_ihaveflag = "";
_runtoenemybase = "";
//Save();
slog("Please make sure all profiles are loaded!");
var form = new Styx.Bot.CustomClasses.Settings1();
form.ShowDialog();
}
public void Save()
{
TextWriter f = new StreamWriter(file);
f.WriteLine(_ihaveflag);
f.WriteLine(_tmhasflag);
f.WriteLine(_runtoenemybase);
f.Close();
LoadSettings();
}
public BGWorker()
{
LoadSettings();
}
private WoWUnit FlagCarrier()
{
var playerList = ObjectManager.GetObjectsOfType<WoWUnit>();
foreach (WoWUnit players in ObjectManager.Me.RaidMembers)
{
//Horde
if (ObjectManager.Me.IsHorde)
{
//while (players.Buffs.ContainsKey("Silverwing Flag") && players.IsFriendly)
if (players.Buffs.ContainsKey("Silverwing Flag") && players.IsFriendly)
{
slog("Teammate has the Alliance flag. Let's run middle profile.");
Styx.Logic.Profiles.ProfileManager.LoadNew("c:\tmhasflag.xml");
return players;
}
if (ObjectManager.Me.Buffs.ContainsKey("Silverwing Flag"))
{
slog("I have the Alliance flag! Go go go!");
Styx.Logic.Profiles.ProfileManager.LoadNew(_ihaveflag);
return players;
}
}
//Alliance
else if (ObjectManager.Me.IsAlliance)
{
if (players.Buffs.ContainsKey("Warsong Flag") && players.IsFriendly)
{
slog("Teammate has the Horde flag. Let's run middle profile.");
ProfileManager.LoadNew(_tmhasflag);
//return players;
}
if (ObjectManager.Me.Buffs.ContainsKey("Warsong Flag"))
{
slog("I have the Horde flag! Go go go!");
Styx.Logic.Profiles.ProfileManager.LoadNew(_ihaveflag);
return players;
}
else
{
if (ObjectManager.Me.IsAlliance)
Styx.Logic.Profiles.ProfileManager.LoadNew(_runtoenemybase);
if (ObjectManager.Me.IsHorde)
Styx.Logic.Profiles.ProfileManager.LoadNew(_runtoenemybase);
}
}
}
return null;
}
void NearFlagCheck()
{
/*
if (sw.ElapsedMilliseconds <= 60000)
return;
*/
foreach (WoWObject flag in ObjectManager.ObjectList)
{
while ((flag.Name.Contains("Flag")) && flag.Distance >= 5)
{
Navigator.MoveTo(flag.Location);
}
if ((flag.Name.Contains("Flag")) && flag.Distance2D <= 4)
{
flag.Interact();
}
if ((flag.Name.Contains("Flag")) && flag.Distance2D <= 100)
{
Navigator.Clear();
Navigator.MoveTo(WoWMovement.CalculatePointFrom(flag.Location, 2f));
while (flag.Distance >= 5 && flag.IsValid)
{
slog("Approaching enemy flag!");
/*
if (ObjectManager.Me.WoWMovementInfo.CurrentSpeed == 0)
{
Navigator.CurrentPath.
slog("Stopped moving! That's no fun!");
}
*/
}
if ((flag.Name.Contains("Flag")) && flag.Distance2D <= 5)
{
flag.Interact();
sw.Reset();
}
}
}
return;
}
public override void Pulse()
{
if (ObjectManager.Me.RealZoneText == "Warsong Gulch")
return;
else
{
if (ObjectManager.Me.Buffs.ContainsKey("Preparation") && _spamstart == false)
{
slog("We are waiting for the battleground to start!");
return;
}
else
{
if (_spamstart == false)
_spamstart = true;
if (sw.IsRunning == false)
{
sw.Start();
}
ObjectManager.Update();
NearFlagCheck();
FlagCarrier();
}
}
}
public override string Name { get { return "Battleground Actions BETA"; } }
public override string Author { get { return "Ohcrit"; } }
public override Version Version { get { return new Version(0, 1, 0, 1); } }
public override string ButtonText { get { return "Settings"; } }
public override bool WantButton { get { return true; } }
public override void OnButtonPress()
{
var form = new Styx.Bot.CustomClasses.Settings1();
form.ShowDialog();
}
}
}
Thanks.