Skip to content

Instantly share code, notes, and snippets.

@LordJZ
Created May 20, 2015 09:06
Show Gist options
  • Save LordJZ/a12456e957721119648a to your computer and use it in GitHub Desktop.
Save LordJZ/a12456e957721119648a to your computer and use it in GitHub Desktop.
Network-level World of Warcraft hacks from 2011
using System;
using System.IO;
using Kamilla.WorldOfWarcraft.Latest.Core;
using Kamilla.WorldOfWarcraft.Latest.OpcodeDatas;
using System.Threading;
namespace Kamilla.WorldOfWarcraft.Latest.Core.Hacks
{
[LoadPriority(LoadPriority.Medium)]
[ModuleReferences(typeof(Std))]
public sealed class AntiAFK : WowAddon
{
public static AntiAFK Activate(Module parent, object[] args)
{
if (parent is WowRelay)
return new AntiAFK(parent);
return null;
}
public AntiAFK(Module parent)
: base(parent)
{
RNG = new Random(Environment.TickCount / 3 * 2);
this.NodeName = "Anti-AFK";
}
private Std std;
private bool i_blockAFKChat;
/// <summary>
/// Indicated whether the addon will block AFK chat messages or not.
/// These messages are blocked always when the addon is running.
/// </summary>
public bool BlockAFKChat
{
get { return this.IsRunning || i_blockAFKChat; }
set { i_blockAFKChat = value; }
}
/// <summary>
/// Initializes the current instance of AntiAFKAddOn.
/// </summary>
protected override void Initialize(Module[] references)
{
this.std = (Std)references[0];
if (!std.RegisterChatCommandHandler("antiafk", new CommandHandler((x) =>
{
string orig = x;
switch (Std.ExtractBoolValue(ref x))
{
case BoolResult.False:
if (!IsRunning)
std.SendSystemMessage("[Anti-AFK] Automatic Anti-AFK actions are not enabled!");
else
{
std.SendSystemMessage("[Anti-AFK] Automatic Anti-AFK actions disabled.");
this.Stop();
}
break;
case BoolResult.True:
if (IsRunning)
std.SendSystemMessage("[Anti-AFK] Automatic Anti-AFK actions are already enabled!");
else
{
std.SendSystemMessage("[Anti-AFK] Automatic Anti-AFK actions enabled.");
this.Start();
}
break;
case BoolResult.Unknown:
if (orig == "fire")
{
std.SendSystemMessage("[Anti-AFK] Firing Anti-AFK action.");
this.FireAction();
break;
}
std.SendSystemMessage("[Anti-AFK] Automatic Anti-AFK actions are now " + (IsRunning ? "enabled" : "disabled") + ".");
break;
}
},
"Enables or disables automatic Anti-AFK actions. 'antiafk fire' to fire action instantly.")))
Console.WriteLine("[AntiAFKAddOn] Failed to register commands.");
std.Events.OnUnitMovementStatus += new TimelineHandler.OnUnitMovementStatusEventHandler(std_OnPlayerMovement);
std.Events.OnClientChatMessage += new TimelineHandler.OnClientChatMessageEventHandler(std_OnChatMessage);
}
private MovementStatus m_lastMovementStatus;
void std_OnPlayerMovement(object sender, TimelineDataEventArgs<RegularMovementPacket> args)
{
if (args.OpcodeData.Unit != std.CurrentPlayerGuid)
return;
m_lastMovementStatus = args.OpcodeData.Status;
}
void std_OnChatMessage(object sender, TimelineDataEventArgs<OpcodeDatas.ChatMessages.ClientChatMessage> args)
{
if (args.OpcodeData.MessageType == ChatMessageType.AFK && this.BlockAFKChat)
args.Cancel = true;
}
/// <summary>
/// Starts the automatic firing of Anti-AFK action.
/// </summary>
public override void Start()
{
base.Start();
}
private Random RNG;
/// <summary>
/// Stops the automatic firing of Anti-AFK action.
/// </summary>
public override void Stop()
{
base.Stop();
}
public override void HandlePacket(Packet pkt)
{
}
private bool CanPerformAntiAfkAction()
{
if (std.CurrentPlayerGuid.IsEmpty)
return false;
if (m_lastMovementStatus == null)
return false;
if ((m_lastMovementStatus.Flags & (MovementFlags.Falling | MovementFlags.FallingFar)) != 0)
return false;
return true;
}
public bool ShouldPerformAntiAfkAction()
{
if (!CanPerformAntiAfkAction())
return false;
int delta = Math.Abs(Environment.TickCount - (int)m_lastMovementStatus.TimeStamp);
return delta > 3 * Time.Minute * Time.InMilliseconds;
}
const int CheckInterval = (int)(3 * Time.Minute * Time.InMilliseconds);
int m_checkTimer = CheckInterval;
public override void Update(int msdiff)
{
if (std.CurrentPlayerGuid.IsEmpty)
return;
if (m_checkTimer <= 0)
{
m_checkTimer = CheckInterval;
if (m_lastMovementStatus != null)
{
int delta = Math.Abs(Environment.TickCount - (int)m_lastMovementStatus.TimeStamp);
if (delta > 3 * Time.Minute * Time.InMilliseconds)
{
FireAction();
m_checkTimer = (int)(5 * Time.InMilliseconds);
}
}
}
else
m_checkTimer -= msdiff;
}
/// <summary>
/// Instantly fires the Anti-AFK action.
/// </summary>
public void FireAction()
{
if (!CanPerformAntiAfkAction())
return;
var status = m_lastMovementStatus;
#if DEBUG
std.SendSystemMessage("Performing Anti-AFK action.");
#endif
float o = (float)(((double)status.Orientation + RNG.NextDouble() * Math.PI) % (Math.PI * 2));
float[] orientations = new float[2] { o, status.Orientation };
status.TimeStamp = (uint)Environment.TickCount;
foreach (var orientation in orientations)
{
status.Orientation = orientation;
status.TimeStamp += 1;
var setfacing = new MoveSetFacing();
setfacing.Unit = std.CurrentPlayerGuid;
setfacing.Status = status;
Send(setfacing);
}
// Sleep for 1 millisecond so Environment.TickCount increments.
Thread.Sleep(1);
}
}
}
using System;
using System.IO;
namespace Kamilla.WorldOfWarcraft.Latest.Core.Hacks
{
[LoadPriority(LoadPriority.Medium)]
[ModuleReferences(typeof(Std))]
public sealed partial class CustomPacketSender : WowAddon
{
private Std std;
protected override void Initialize(Module[] references)
{
this.std = (Std)references[0];
}
public override void Start()
{
base.Start();
}
public override void Stop()
{
base.Stop();
}
public static CustomPacketSender Activate(Module parent, object[] args)
{
if (parent is WowRelay)
return new CustomPacketSender(parent);
return null;
}
public CustomPacketSender(Module parent)
: base(parent)
{
this.NodeName = "Custom Packet Sender";
string nl = Environment.NewLine;
this.ui_tbHelp.Text = ""
+ "dX/uX [value] - signed/unsigned int of X bytes" + nl
+ "f [real value] - floating-point value" + nl
+ "s [string] - C-style string" + nl
+ "p [value] - packed 8-byte value" + nl
+ "b [hex set] - byte sequence" + nl
+ nl
+ "Value Tokens:" + nl
+ "guid - Current player Guid or 0" + nl
+ "target - Current target Guid or 0" + nl
+ "unix - Unix timestamp" + nl
+ "tick - Ms time ticks" + nl
+ "map - Current Map or -1" + nl
//+ "" + nl
;
}
void Error(string message)
{
System.Windows.Forms.MessageBox.Show(this.Box.FindForm(), message, "Custom Packet Sender",
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}
ulong ExtractValue(string str, bool signed)
{
switch (str)
{
case "guid":
return std.CurrentPlayerGuid.Raw;
case "target":
return std.CurrentTargetGuid.Raw;
case "unix":
return DateTime.UtcNow.ToUnixTime();
case "tick":
return (ulong)Environment.TickCount;
case "map":
return (ulong)(std.CurrentMap == Maps.NoMap ? -1 : (long)std.CurrentMap);
default:
return signed ? (ulong)str.ToNumeric<long>() : str.ToNumeric<ulong>();
}
}
void ui_btnSend_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(ui_tbOpcode.Text))
return;
WowOpcodes opcode = WowOpcodes.UNKNOWN_OPCODE;
ushort op_value = ui_tbOpcode.Text.ToNumeric<ushort>();
if (op_value != 0)
opcode = (WowOpcodes)op_value;
else if (!Enum.TryParse<WowOpcodes>(ui_tbOpcode.Text.ToUpper(), out opcode))
opcode = WowOpcodes.UNKNOWN_OPCODE;
if (opcode == WowOpcodes.UNKNOWN_OPCODE)
{
Error("Cannot convert line to opcode." + Environment.NewLine + Environment.NewLine + " " + ui_tbOpcode.Text);
if (!ui_tbOpcode.Focused)
ui_tbOpcode.Focus();
return;
}
using (var writer = new StreamHandler())
{
uint nLine = 0;
try
{
string[] lines = ui_tbCode.Text.Split(new string[] { Environment.NewLine },
StringSplitOptions.RemoveEmptyEntries);
for (; nLine < lines.Length; ++nLine)
{
string[] tokens = lines[nLine].Split(' ');
int i = 0;
string type = tokens[i++].ToLower();
switch (type[0])
{
case 'd':
case 'u':
{
string s_value = tokens[i++];
ulong value = ExtractValue(s_value, type[0] == 'd');
switch (type[1])
{
case '1':
writer.WriteByte((byte)value);
break;
case '2':
writer.WriteUInt16((ushort)value);
break;
case '4':
writer.WriteUInt32((uint)value);
break;
case '8':
writer.WriteUInt64((ulong)value);
break;
}
break;
}
case 'f':
{
string s_value = tokens[i++];
writer.WriteSingle((float)s_value.ToNumeric<double>());
break;
}
case 's':
{
string s_value = lines[nLine].Split(new char[] { ' ' }, 2)[1];
writer.WriteCString(s_value);
break;
}
case 'p':
{
string s_value = tokens[i++];
ulong value = ExtractValue(s_value, type[0] == 'd');
writer.WritePackedGuid(new WowGuid(value));
break;
}
case 'b':
{
string s_value = lines[nLine].Split(new char[] { ' ' }, 2)[1].Replace(" ", string.Empty);
writer.WriteBytes(s_value.AsByteArray());
break;
}
default:
throw new Exception();
}
}
}
catch
{
Error("Error parsing code at line " + nLine + ".");
return;
}
byte[] data = writer.ToByteArray();
var packet = new CustomPacket(opcode, ui_rbToClient.Checked ? Direction.ToClient : Direction.ToServer)
.WriteBytes(data);
Send(packet);
System.Windows.Forms.MessageBox.Show(this.Box.FindForm(), "Opcode sent.", "Custom Packet Sender",
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
}
}
}
}
using System;
using System.Windows.Forms;
namespace Kamilla.WorldOfWarcraft.Latest.Core.Hacks
{
partial class CustomPacketSender
{
private Kamilla.Forms.TextBoxCtrlA ui_tbCode;
private Kamilla.Forms.TextBoxCtrlA ui_tbHelp;
private Kamilla.Forms.TextBoxCtrlA ui_tbOpcode;
private System.Windows.Forms.Button ui_btnSend;
private System.Windows.Forms.RadioButton ui_rbToServer;
private System.Windows.Forms.RadioButton ui_rbToClient;
public override void CreateBox()
{
System.Windows.Forms.Label ui_lblOpcode;
this.ui_tbCode = new Kamilla.Forms.TextBoxCtrlA();
this.ui_tbHelp = new Kamilla.Forms.TextBoxCtrlA();
this.ui_rbToClient = new System.Windows.Forms.RadioButton();
this.ui_rbToServer = new System.Windows.Forms.RadioButton();
this.ui_btnSend = new System.Windows.Forms.Button();
ui_lblOpcode = new System.Windows.Forms.Label();
ui_tbOpcode = new Kamilla.Forms.TextBoxCtrlA();
this.Box.SuspendLayout();
this.Box.Controls.Add(this.ui_tbHelp);
this.Box.Controls.Add(this.ui_btnSend);
this.Box.Controls.Add(this.ui_rbToServer);
this.Box.Controls.Add(this.ui_rbToClient);
this.Box.Controls.Add(ui_tbOpcode);
this.Box.Controls.Add(ui_lblOpcode);
this.Box.Controls.Add(this.ui_tbCode);
//
// ui_tbCode
//
this.ui_tbCode.Location = new System.Drawing.Point(6, 39);
this.ui_tbCode.MaxLength = 500000;
this.ui_tbCode.Multiline = true;
this.ui_tbCode.Name = "ui_tbCode";
this.ui_tbCode.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.ui_tbCode.WordWrap = false;
this.ui_tbCode.Size = new System.Drawing.Size(309, 236);
//
// ui_lblOpcode
//
ui_lblOpcode.AutoSize = true;
ui_lblOpcode.Location = new System.Drawing.Point(6, 16);
ui_lblOpcode.Name = "ui_lblOpcode";
ui_lblOpcode.Size = new System.Drawing.Size(48, 13);
ui_lblOpcode.Text = "Opcode:";
//
// ui_tbOpcode
//
ui_tbOpcode.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
ui_tbOpcode.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
ui_tbOpcode.AutoCompleteCustomSource = new AutoCompleteStringCollection();
foreach (WowOpcodes opcode in Enum.GetValues(typeof(WowOpcodes)))
{
if (opcode != WowOpcodes.UNKNOWN_OPCODE)
ui_tbOpcode.AutoCompleteCustomSource.Add(opcode.ToString());
}
ui_tbOpcode.Location = new System.Drawing.Point(60, 13);
ui_tbOpcode.Name = "ui_tbOpcode";
ui_tbOpcode.Size = new System.Drawing.Size(255, 20);
//
// ui_rbToClient
//
this.ui_rbToClient.AutoSize = true;
this.ui_rbToClient.Checked = true;
this.ui_rbToClient.Location = new System.Drawing.Point(321, 14);
this.ui_rbToClient.Name = "ui_rbToClient";
this.ui_rbToClient.Size = new System.Drawing.Size(67, 17);
this.ui_rbToClient.TabIndex = 3;
this.ui_rbToClient.TabStop = true;
this.ui_rbToClient.Text = "To Client";
this.ui_rbToClient.UseVisualStyleBackColor = true;
//
// ui_rbToServer
//
this.ui_rbToServer.AutoSize = true;
this.ui_rbToServer.Location = new System.Drawing.Point(394, 14);
this.ui_rbToServer.Name = "ui_rbToServer";
this.ui_rbToServer.Size = new System.Drawing.Size(72, 17);
this.ui_rbToServer.TabIndex = 4;
this.ui_rbToServer.Text = "To Server";
this.ui_rbToServer.UseVisualStyleBackColor = true;
//
// ui_btnSend
//
this.ui_btnSend.Location = new System.Drawing.Point(472, 11);
this.ui_btnSend.Name = "ui_btnSend";
this.ui_btnSend.Size = new System.Drawing.Size(93, 23);
this.ui_btnSend.TabIndex = 5;
this.ui_btnSend.Text = "Send";
this.ui_btnSend.Click += new EventHandler(ui_btnSend_Click);
this.ui_btnSend.UseVisualStyleBackColor = true;
//
// ui_tbHelp
//
this.ui_tbHelp.Location = new System.Drawing.Point(321, 39);
this.ui_tbHelp.Multiline = true;
this.ui_tbHelp.Name = "ui_tbHelp";
this.ui_tbHelp.ReadOnly = true;
this.ui_tbHelp.Size = new System.Drawing.Size(244, 236);
this.ui_tbHelp.WordWrap = false;
//
// PacketSender
//
this.Box.ResumeLayout(false);
this.Box.PerformLayout();
}
}
}
using System;
using Kamilla.WorldOfWarcraft.Latest.OpcodeDatas;
namespace Kamilla.WorldOfWarcraft.Latest.Core.Hacks
{
[LoadPriority(LoadPriority.Medium)]
[ModuleReferences(typeof(Std), typeof(AntiAFK))]
public sealed class FishingBot : WowAddon
{
public static FishingBot Activate(Module parent, object[] args)
{
if (parent is WowRelay)
return new FishingBot(parent);
return null;
}
private Std std;
private AntiAFK antiAFK;
protected override void Initialize(Module[] references)
{
this.std = (Std)references[0];
this.antiAFK = (AntiAFK)references[1];
if (this.antiAFK == null)
{
((WowRelay)ParentModule).LoadAddon(typeof(AntiAFK));
this.antiAFK = GetSister<AntiAFK>();
if (this.antiAFK == null)
Console.WriteLine("[Fishing Bot] Cannot find Anti AFK addon.");
}
var CH_Command = new CommandHandler(HandleFishingBotCommand, "Turns the fishing bot on and off.");
var CH_FishingSpell = new CommandHandler(HandleFishingSpellCommand, "Internal command used to detect the fishing spell.");
var CH_FishingDebug = new CommandHandler(x =>
{
switch (Std.ExtractBoolValue(ref x))
{
case BoolResult.True:
m_debug = true;
break;
case BoolResult.False:
m_debug = false;
break;
case BoolResult.Unknown:
break;
}
std.SendSystemMessage("Fishing Bot Debugging is " + (m_debug ? "enabled" : "disabled"));
}, "Internal command used to detect the fishing spell.");
if (std != null)
{
if (!std.RegisterChatCommandHandler("fishingbot", CH_Command)
|| !std.RegisterChatCommandHandler("fishbot", CH_Command)
|| !std.RegisterChatCommandHandler("fishingspell", CH_FishingSpell)
|| !std.RegisterChatCommandHandler("fishingdebug", CH_FishingDebug))
Console.WriteLine("[Fishing Bot] Failed to register commands.");
}
BobberCreateHandler = new TimelineHandler.OnObjectCreateEventHandler(this.BobberCreated);
CastFailHandler = new TimelineHandler.OnCastFailEventHandler(this.CastFailed);
ChannelStartHandler = new TimelineHandler.OnChannelStartEventHandler(this.ChannelStarted);
SpellGoHandler = new TimelineHandler.OnSpellGoEventHandler(this.SpellGo);
SpellStartHandler = new TimelineHandler.OnSpellStartEventHandler(this.SpellStart);
AuraAddedHandler = new TimelineHandler.OnAuraEventHandler(this.AuraAdded);
GOCustomAnimHandler = new TimelineHandler.OnGameObjectCustomAnimEventHandler(this.GOCustomAnim);
LootRemovedHandler = new TimelineHandler.OnLootRemovedEventHandler(this.LootRemoved);
LootResponseHandler = new TimelineHandler.OnLootResponseEventHandler(this.LootResponse);
LootReleaseResponseHandler = new TimelineHandler.EntityEventHandler(this.LootReleaseResponse);
StandStateChangeRequestHandler = new TimelineHandler.OnStandStateChangeRequestEventHandler(this.StandStateChangeRequest);
std.Events.OnLootRemoved += LootRemovedHandler;
std.Events.OnGameObjectCustomAnim += GOCustomAnimHandler;
std.Events.OnStandStateChangeRequest += StandStateChangeRequestHandler;
RNG = new Random(Environment.TickCount / 2);
}
public FishingBot(Module parent)
: base(parent)
{
this.NodeName = "Fishing Bot";
}
private void HandleFishingBotCommand(string arg)
{
switch (Std.ExtractBoolValue(ref arg))
{
case BoolResult.True:
Start();
std.SendSystemMessage("Fishing Bot launched");
break;
case BoolResult.False:
Stop();
std.SendSystemMessage("Fishing Bot terminated");
break;
case BoolResult.Unknown:
std.SendSystemMessage("Fishing Bot is " + (IsRunning ? "running" : "disabled"));
break;
}
}
private const uint BobberEntry = 35591;
private bool m_debug;
private enum FishingBotState
{
WaitingFBHelper,
DoingFishingCast,
WaitingChannelStart,
WaitingAuraUpdate,
WaitingSpellStart,
WaitingSpellGo,
WaitingBobberCreate,
WaitingBobberAnim,
DoingBobberUse,
WaitingLootResponse,
WaitingLootReleaseResponse,
};
private Random RNG;
private FishingBotState i_backing_state;
private FishingBotState m_state
{
get { return i_backing_state; }
set
{
if (m_debug && std != null)
std.SendSystemMessage("[Fishing Bot] State changed {0} -> {1}", i_backing_state, value);
i_backing_state = value;
m_freezeCheckTimer = DefaultFreezeCheckInterval;
}
}
private WowGuid BobberGuid;
private uint FailedCasts;
private TimelineHandler.OnObjectCreateEventHandler BobberCreateHandler;
private TimelineHandler.OnCastFailEventHandler CastFailHandler;
private TimelineHandler.OnChannelStartEventHandler ChannelStartHandler;
private TimelineHandler.OnSpellGoEventHandler SpellGoHandler;
private TimelineHandler.OnSpellStartEventHandler SpellStartHandler;
private TimelineHandler.OnAuraEventHandler AuraAddedHandler;
private TimelineHandler.OnGameObjectCustomAnimEventHandler GOCustomAnimHandler;
private TimelineHandler.OnLootRemovedEventHandler LootRemovedHandler;
private TimelineHandler.OnLootResponseEventHandler LootResponseHandler;
private TimelineHandler.EntityEventHandler LootReleaseResponseHandler;
private TimelineHandler.OnStandStateChangeRequestEventHandler StandStateChangeRequestHandler;
private uint FishingSpell;
public void HandleFishingSpellCommand(string arg)
{
if (m_state == FishingBotState.WaitingFBHelper)
{
FishingSpell = uint.Parse(arg);
m_state = FishingBotState.DoingFishingCast;
m_actionTimer = 10;
m_pendingAction = true;
}
}
private void StandStateChangeRequest(StandState state, ref PacketFlags flags)
{
if (IsRunning)
{
flags |= PacketFlags.Freezed;
CustomPacket pkt = new CustomPacket(WowOpcodes.SMSG_STANDSTATE_UPDATE, Direction.ToClient);
pkt.WriteByte((byte)state);
Send(pkt);
}
}
private void CastFailed(byte cast_id, uint spell_id, SpellFailedReason reason, ref PacketFlags flags)
{
if (m_state != FishingBotState.WaitingChannelStart)
return;
if (spell_id != FishingSpell)
return;
++FailedCasts;
if (FailedCasts >= 10)
{
std.SendSystemMessage("[Fishing Bot] Cast failure.");
Console.WriteLine("[Fishing Bot] Failed to cast Fishing 10 times in a row, disabling.");
Stop();
return;
}
if (!m_debug)
flags |= PacketFlags.Freezed;
m_state = FishingBotState.DoingFishingCast;
m_actionTimer = 300 + RNG.Next(500);
m_pendingAction = true;
std.Events.OnCastFail -= this.CastFailHandler;
}
private void ChannelStarted(bool fromClient, WowGuid caster, uint spell, int duration, ref PacketFlags flags)
{
if (m_state != FishingBotState.WaitingChannelStart)
return;
if (fromClient)
return;
if (caster != std.CurrentPlayerGuid)
return;
if (spell != FishingSpell)
return;
FailedCasts = 0;
m_state = FishingBotState.WaitingAuraUpdate;
std.Events.OnChannelStart -= this.ChannelStartHandler;
std.Events.OnAuraAdded += this.AuraAddedHandler;
}
private void SpellStart(object sender, TimelineDataEventArgs<SpellStart> args)
{
if (m_state != FishingBotState.WaitingSpellStart)
return;
var data = args.OpcodeData;
if (data.Caster != std.CurrentPlayerGuid ||
data.CastInvoker != std.CurrentPlayerGuid)
return;
if (data.SpellId != FishingSpell)
return;
m_state = FishingBotState.WaitingSpellGo;
std.Events.OnSpellStart -= this.SpellStartHandler;
std.Events.OnSpellGo += this.SpellGoHandler;
}
private void SpellGo(object sender, TimelineDataEventArgs<SpellGo> args)
{
if (m_state != FishingBotState.WaitingSpellGo)
return;
var data = args.OpcodeData;
if (data.Caster != std.CurrentPlayerGuid ||
data.CastInvoker != std.CurrentPlayerGuid)
return;
if (data.SpellId != FishingSpell)
return;
m_state = FishingBotState.WaitingBobberCreate;
std.Events.OnSpellGo -= this.SpellGoHandler;
std.Events.OnObjectCreate += this.BobberCreateHandler;
}
private void BobberCreated(object sender, TimelineObjectEventArgs args)
{
if (this.m_state != FishingBotState.WaitingBobberCreate)
return;
var obj = args.Object;
if (obj.TypeId != ObjectTypeId.GameObject || obj.Entry != BobberEntry)
return;
if (std.CurrentPlayerGuid != ((WowGameObject)obj).CreatorGuid)
return;
BobberGuid = obj.Guid;
m_state = FishingBotState.WaitingBobberAnim;
// allow 1 second delay
m_freezeCheckTimer = (19 + 1) * (int)Time.InMilliseconds;
std.Events.OnObjectCreate -= this.BobberCreateHandler;
std.Events.OnGameObjectCustomAnim += this.GOCustomAnimHandler;
}
private void AuraAdded(object sender, TimelineAuraEventArgs args)
{
if (m_state != FishingBotState.WaitingAuraUpdate)
return;
var aura = args.Aura;
if (aura.Unit != std.CurrentPlayerGuid)
return;
if (aura.Spell != FishingSpell)
return;
m_state = FishingBotState.WaitingSpellStart;
std.Events.OnAuraAdded -= this.AuraAddedHandler;
std.Events.OnSpellStart += this.SpellStartHandler;
}
private void GOCustomAnim(object sender, TimelineObjectAnimEventArgs args)
{
if (!IsRunning)
return;
if (m_state != FishingBotState.WaitingBobberAnim)
return;
if (args.Entity != BobberGuid)
return;
m_state = FishingBotState.DoingBobberUse;
m_actionTimer = 300 + RNG.Next(800);
m_pendingAction = true;
std.Events.OnGameObjectCustomAnim -= this.GOCustomAnimHandler;
}
private void LootRemoved(object sender, TimelineEventArgs args)
{
if (IsRunning && !m_debug)
args.Cancel = true;
}
private void LootResponse(object sender, TimelineDataEventArgs<Loot> args)
{
if (m_state != FishingBotState.WaitingLootResponse)
return;
var loot = args.OpcodeData;
if (loot.Guid != BobberGuid)
return;
if (loot.Type != LootType.Fishing)
return;
if (loot.Gold.Raw > 0)
std.LootMoney();
foreach (Loot.Item item in loot.Items)
std.LootItem(item.Index);
foreach (Loot.Currency currency in loot.Currencies)
std.LootItem(currency.Index);
std.LootRelease(BobberGuid);
if (!m_debug)
args.Cancel = true;
m_state = FishingBotState.WaitingLootReleaseResponse;
std.Events.OnLootResponse -= this.LootResponseHandler;
std.Events.OnLootReleaseResponse += this.LootReleaseResponseHandler;
}
private void LootReleaseResponse(object sender, TimelineEntityEventArgs args)
{
if (m_state != FishingBotState.WaitingLootReleaseResponse)
return;
if (args.Entity != BobberGuid)
return;
this.BobberGuid = WowGuid.Empty;
if (!m_debug)
args.Cancel = true;
int start = 200;
if (antiAFK != null && antiAFK.ShouldPerformAntiAfkAction())
{
antiAFK.FireAction();
start += 1200;
}
m_state = FishingBotState.DoingFishingCast;
m_actionTimer = start + RNG.Next(300);
m_pendingAction = true;
std.Events.OnLootReleaseResponse -= this.LootReleaseResponseHandler;
}
public override void HandlePacket(WowPacket pkt)
{
if (IsRunning && (WowOpcodes)pkt.Opcode == WowOpcodes.CMSG_LOGOUT_REQUEST)
{
pkt.SetFlag(PacketFlags.Freezed);
std.SendSystemMessage("Cannot logout while Fishing Bot is running.");
}
}
bool m_antiAfkRunning = true;
public override void Start()
{
if (IsRunning)
return;
m_freezeCheckTimer = DefaultFreezeCheckInterval;
base.Start();
m_state = FishingBotState.WaitingFBHelper;
std.SendSystemMessage("Looking for fishing...");
if (antiAFK != null)
{
antiAFK.BlockAFKChat = true;
m_antiAfkRunning = antiAFK.IsRunning;
antiAFK.Stop();
}
}
public override void Stop()
{
if (!IsRunning)
return;
base.Stop();
if (antiAFK != null)
{
antiAFK.BlockAFKChat = false;
if (m_antiAfkRunning)
antiAFK.Start();
}
}
const int DefaultFreezeCheckInterval = 2000;
volatile bool m_pendingAction;
int m_freezeCheckTimer;
int m_actionTimer = 0;
DateTime m_lastFreezeTime = DateTime.Now;
int m_freezeCounter = 0;
public override void Update(int msdiff)
{
if (m_pendingAction)
{
if (m_actionTimer <= 0)
{
switch (m_state)
{
case FishingBotState.DoingFishingCast:
std.CastSpell(FishingSpell);
m_state = FishingBotState.WaitingChannelStart;
std.Events.OnChannelStart += this.ChannelStartHandler;
break;
case FishingBotState.DoingBobberUse:
std.UseGameObject(this.BobberGuid);
m_state = FishingBotState.WaitingLootResponse;
std.Events.OnLootResponse += this.LootResponseHandler;
break;
}
m_pendingAction = false;
}
else
m_actionTimer -= msdiff;
}
if (m_freezeCheckTimer <= 0)
{
string msg = "[Fishing Bot] Freezed at BotState=" + m_state.ToString() + ". Restarting.";
std.SendSystemMessage(msg);
Console.WriteLine("Error: " + msg);
base.Stop();
Start();
m_freezeCheckTimer = DefaultFreezeCheckInterval;
var now = DateTime.Now;
if ((now - m_lastFreezeTime).TotalSeconds > 60)
m_freezeCounter = 0;
else if (++m_freezeCounter > 15)
{
const string s = "[Fishing Bot] Freezed too many times in the last 60 seconds, shutting down.";
Console.WriteLine("Error: " + s);
std.SendSystemMessage(s);
m_freezeCounter = 0;
Stop();
}
m_lastFreezeTime = now;
}
else
m_freezeCheckTimer -= msdiff;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kamilla.WorldOfWarcraft.Latest.Core.Hacks
{
[LoadPriority(LoadPriority.Medium)]
[ModuleReferences(typeof(Std))]
public sealed class FocusObjectQuerier : WowAddon
{
public static FocusObjectQuerier Activate(Module parent, object[] args)
{
if (parent is WowRelay)
return new FocusObjectQuerier(parent);
return null;
}
private Std std;
protected override void Initialize(Module[] references)
{
std = (Std)references[0];
std.Events.OnSpellGo += new TimelineHandler.OnSpellGoEventHandler(Events_OnSpellGo);
}
List<uint> m_goEntries = new List<uint>();
void Events_OnSpellGo(object sender, TimelineDataEventArgs<OpcodeDatas.SpellGo> args)
{
if (!this.IsRunning)
return;
var go = args.OpcodeData;
foreach (var guid in go.Hits)
{
if (!guid.IsGameObject)
continue;
if (m_goEntries.Contains(guid.Entry))
continue;
m_goEntries.Add(guid.Entry);
var packet = new CustomPacket(WowOpcodes.CMSG_GAMEOBJECT_QUERY, Direction.ToServer);
packet.WriteUInt32(guid.Entry);
packet.WriteUInt64(guid.Raw);
Send(packet);
std.SendSystemMessage("Sent CMSG_GAMEOBJECT_QUERY for {0}", guid);
}
}
public FocusObjectQuerier(Module parent)
: base(parent)
{
this.NodeName = "Focus Object Querier";
this.Start();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using Kamilla.WorldOfWarcraft.Latest.OpcodeDatas;
using Kamilla.WorldOfWarcraft.Latest.OpcodeDatas.ChatMessages;
using Microsoft.Xna.Framework;
namespace Kamilla.WorldOfWarcraft.Latest.Core.Hacks
{
[LoadPriority(LoadPriority.Medium)]
[ModuleReferences(typeof(Std))]
public partial class BasicHacks : WowAddon
{
private Std std;
// BACKING FIELDS
private bool? i_global_showSpecialInfo;
private bool? i_global_highlightSparklingGOs;
private uint? i_global_highlightSparklingGOs_spell;
private bool? i_chat_translate;
private bool? i_chat_prependLang;
private bool? i_bgs_heralAsSystem;
private bool? i_auction_showExactTime;
// REAL FIELDS
private bool Global_HighlightSparklingGOs
{
get
{
if (i_global_highlightSparklingGOs == null)
i_global_highlightSparklingGOs = Configuration.GetValue("Global - Highlight Sparkling GOs", false);
return (bool)i_global_highlightSparklingGOs;
}
set
{
if (i_global_highlightSparklingGOs != value)
{
i_global_highlightSparklingGOs = value;
Configuration.SetValue("Global - Highlight Sparkling GOs", value);
}
}
}
private uint Global_HighlightSparklingGOs_Spell
{
get
{
if (i_global_highlightSparklingGOs_spell == null)
i_global_highlightSparklingGOs_spell = Configuration.GetValue("Global - Highlight Sparkling GOs Spell Id", 84996U);
return (uint)i_global_highlightSparklingGOs_spell;
}
set
{
if (i_global_highlightSparklingGOs_spell != value)
{
i_global_highlightSparklingGOs_spell = value;
Configuration.SetValue("Global - Highlight Sparkling GOs Spell Id", value);
}
}
}
private ushort HighlightSparklingGOs_SpellVisual
{
get
{
switch (Global_HighlightSparklingGOs_Spell)
{
case 84996: return 20021;
case 84997: return 20022;
case 84998: return 20023;
default:
case 84999: return 20024;
case 85000: return 20025;
}
}
}
private bool Global_ShowSpecialInfo
{
get
{
if (i_global_showSpecialInfo == null)
i_global_showSpecialInfo = Configuration.GetValue("Global - Show Special Info", false);
return (bool)i_global_showSpecialInfo;
}
set
{
if (i_global_showSpecialInfo != value)
{
i_global_showSpecialInfo = value;
Configuration.SetValue("Global - Show Special Info", value);
}
}
}
private bool Chat_Translate
{
get
{
if (i_chat_translate == null)
i_chat_translate = Configuration.GetValue("Chat - Translate Other Languages to Universal", true);
return (bool)i_chat_translate;
}
set
{
if (i_chat_translate != value)
{
i_chat_translate = value;
Configuration.SetValue("Chat - Translate Other Languages to Universal", value);
}
}
}
private bool Chat_PrependLang
{
get
{
if (i_chat_prependLang == null)
i_chat_prependLang = Configuration.GetValue("Chat - Prepend Language to Chat Messages", true);
return (bool)i_chat_prependLang;
}
set
{
if (i_chat_prependLang != value)
{
i_chat_prependLang = value;
Configuration.SetValue("Chat - Prepend Language to Chat Messages", value);
}
}
}
private bool Battlegrounds_HeraldAsSystem
{
get
{
if (i_bgs_heralAsSystem == null)
i_bgs_heralAsSystem = Configuration.GetValue("Battlegrounds - Display Herald Broadcasts as System Text", true);
return (bool)i_bgs_heralAsSystem;
}
set
{
if (i_bgs_heralAsSystem != value)
{
i_bgs_heralAsSystem = value;
Configuration.SetValue("Battlegrounds - Display Herald Broadcasts as System Text", value);
}
}
}
private bool Auction_ShowExactTime
{
get
{
if (i_auction_showExactTime == null)
i_auction_showExactTime = Configuration.GetValue("Auction - Show Exact Time", false);
return (bool)i_auction_showExactTime;
}
set
{
if (i_auction_showExactTime != value)
{
i_auction_showExactTime = value;
Configuration.SetValue("Auction - Show Exact Time", value);
}
}
}
private bool NoHorizontalKnockBack { get; set; }
protected override void Initialize(Module[] references)
{
m_miIdRetriever = new BackgroundWorker();
m_miIdRetriever.DoWork += new DoWorkEventHandler(m_miIdRetriever_DoWork);
m_miIdRetriever.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_miIdRetriever_RunWorkerCompleted);
m_miIdRetriever.WorkerSupportsCancellation = true;
this.std = (Std)references[0];
var CH_Translate = new CommandHandler(HandleTranslateMessage, "Turns the message translation on and off.");
var CH_PrependLang = new CommandHandler(HandlePrependLangMessage, "Turns the language prepending on and off.");
var CH_PushForward = new CommandHandler(HandlePushForwardMessage, "Sends your character forward for the specified value using your orientation and pitch. The changes are only visible client-side.");
var CH_PushAscend = new CommandHandler(HandlePushAscendMessage, "Sends your character up for the specified value. The changes are only visible client-side.");
var CH_HighlightQuestObjects = new CommandHandler(HandleHighlightQuestObjectsMessage, "Toggles quest objects highlighting.");
var CH_HighlightSpell = new CommandHandler(HandleHighlightSpellMessage, "Switches object highlighting spell.");
var CH_ResetModel = new CommandHandler(HandleResetModelMessage, "Restores your model to original.");
var CH_CopyModel = new CommandHandler(HandleCopyModelMessage, "Copies your target's model.");
var CH_ResetMount = new CommandHandler(HandleResetMountMessage, "Copies your target's mount.");
var CH_CopyMount = new CommandHandler(HandleCopyMountMessage, "Resets your mount.");
var CH_CastSpell = new CommandHandler(HandleCastSpellMessage, "Casts a spell by id.");
var CH_NoHorizontalKnockBack = new CommandHandler(HandleNoHorizontalKnockBackMessage, "Toggles zeroing horizontal knockback speed.");
var CH_SetPitch = new CommandHandler(HandleSetPitchMessage, "Sets pitch of the current player.");
var CH_SetFacing = new CommandHandler(HandleSetFacingMessage, "Sets facing of the current player.");
var CH_SetForceMove = new CommandHandler(HandleSetForceMoveMessage, "Sets the force move flag of the current player.");
var CH_SetCollisionHeight = new CommandHandler(HandleSetCollisionHeightMessage, "Sets the collision height for the current player.");
var CH_ForceCollision = new CommandHandler(HandleForceCollisionMessage, "Forces collision for the current player.");
var CH_TrackCreatures = new CommandHandler(HandleTrackCreaturesMessage, "Sets the creature tracking flags for the current player.");
var CH_TrackResources = new CommandHandler(HandleTrackResourcesMessage, "Sets the resource tracking flags for the current player.");
if (std != null)
{
if (!std.RegisterChatCommandHandler("translate", CH_Translate)
|| !std.RegisterChatCommandHandler("prependlanguage", CH_PrependLang)
|| !std.RegisterChatCommandHandler("pushforward", CH_PushForward)
|| !std.RegisterChatCommandHandler("pushascend", CH_PushAscend)
|| !std.RegisterChatCommandHandler("highlightquestobjects", CH_HighlightQuestObjects)
|| !std.RegisterChatCommandHandler("highlightspell", CH_HighlightSpell)
|| !std.RegisterChatCommandHandler("hls", CH_HighlightSpell)
|| !std.RegisterChatCommandHandler("resetimage", CH_ResetModel)
|| !std.RegisterChatCommandHandler("mirrorimage", CH_CopyModel)
|| !std.RegisterChatCommandHandler("demorph", CH_ResetModel)
|| !std.RegisterChatCommandHandler("resetmount", CH_ResetMount)
|| !std.RegisterChatCommandHandler("copymount", CH_CopyMount)
|| !std.RegisterChatCommandHandler("castspell", CH_CastSpell)
|| !std.RegisterChatCommandHandler("nohorizontalknockback", CH_NoHorizontalKnockBack)
|| !std.RegisterChatCommandHandler("setpitch", CH_SetPitch)
|| !std.RegisterChatCommandHandler("setfacing", CH_SetFacing)
|| !std.RegisterChatCommandHandler("setforcemove", CH_SetForceMove)
|| !std.RegisterChatCommandHandler("setcollisionheight", CH_SetCollisionHeight)
|| !std.RegisterChatCommandHandler("forcecollision", CH_ForceCollision)
|| !std.RegisterChatCommandHandler("trackcreatures", CH_TrackCreatures)
|| !std.RegisterChatCommandHandler("trackresources", CH_TrackResources)
)
Console.WriteLine("[Basic Hacks] Failed to register commands.");
std.Events.OnMirrorImageDataRequest += new TimelineHandler.EntityEventHandler(Events_OnMirrorImageDataRequest);
std.Events.OnServerChatMessage += new TimelineHandler.OnServerChatMessageEventHandler(Chat_OnServerChatMessage);
std.Events.OnAuctionListResult += new TimelineHandler.OnAuctionListResultHandler(Auction_OnAuctionListResult);
std.Events.OnUnitMovementStatus += new TimelineHandler.OnUnitMovementStatusEventHandler(std_OnPlayerMovement);
std.Events.OnObjectCreate += new TimelineHandler.OnObjectCreateEventHandler(Events_OnObjectCreate);
std.Events.OnObjectValuesUpdate += new TimelineHandler.OnObjectValuesUpdateEventHandler(Events_OnObjectValuesUpdate);
std.Events.OnObjectDestroy += new TimelineHandler.OnObjectDestroyEventHandler(Events_OnObjectDestroy);
std.Events.OnMapChange += new TimelineHandler.OnMapChangeEventHandler(Events_OnMapChange);
}
}
void HandleSetCollisionHeightMessage(string arg)
{
var player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Could not find player!");
return;
}
double value = Std.ExtractDouble(ref arg);
var move = new SetCollisionHeight();
move.NewValue = (float)value;
move.Status = player.MovementData;
move.Unit = player.Guid;
Send(move);
}
bool m_serverCollisionState = true;
BoolResult m_forceCollision = BoolResult.Unknown;
void HandleForceCollisionMessage(string arg)
{
if (std.CurrentPlayerGuid.IsEmpty)
{
std.SendSystemMessage("Could not find player!");
return;
}
m_forceCollision = Std.ExtractBoolValue(ref arg);
UpdateCollisionState();
}
void UpdateCollisionState()
{
var guid = std.CurrentPlayerGuid;
if (guid.IsEmpty)
return;
ForcePacket packet = null;
switch (m_forceCollision)
{
case BoolResult.False:
if (m_serverCollisionState)
packet = new ForceDisableCollision();
break;
case BoolResult.True:
if (!m_serverCollisionState)
packet = new ForceEnableCollision();
break;
case BoolResult.Unknown:
if (m_serverCollisionState)
packet = new ForceEnableCollision();
else
packet = new ForceDisableCollision();
break;
}
if (packet == null)
return;
packet.ChangeCounter = 99999999;
packet.Player = std.CurrentPlayerGuid;
Send(packet);
}
private void HandleSetForceMoveMessage(string arg)
{
if (std.CurrentPlayer == null)
{
std.SendSystemMessage("Could not find player!");
return;
}
var flags = std.CurrentPlayer.Flags2;
switch (Std.ExtractBoolValue(ref arg))
{
case BoolResult.True:
flags |= UnitFlags2.ForceAutoRunForward;
break;
case BoolResult.False:
flags &= ~UnitFlags2.ForceAutoRunForward;
break;
}
if (flags == std.CurrentPlayer.Flags2)
{
std.SendSystemMessage("Already this value!");
return;
}
var data = new UpdateData(std.CurrentMap);
var update = new UpdateFields();
update.Add((uint)UnitUpdateFields.UNIT_FIELD_FLAGS_2, (uint)flags);
data.ValuesUpdates.Add(std.CurrentPlayerGuid, update);
Send(data);
}
void HandleTrackCreaturesMessage(string arg)
{
var player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Could not find player!");
return;
}
CreatureTypeMask mask;
if (!Enum.TryParse(arg, true, out mask))
{
std.SendSystemMessage("Syntax: " + Std.CommandPrefix + "trackcreatures Type1[, Type2]");
std.SendSystemMessage("Possible types: " + Enum.GetNames(typeof(CreatureTypeMask)).ToStringJoin(", "));
return;
}
player.TrackedCreatures = mask;
var data = new UpdateData(std.CurrentMap);
data.ValuesUpdates.Add(player.Guid, player.CreateUpdate());
Send(data);
}
void HandleTrackResourcesMessage(string arg)
{
var player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Could not find player!");
return;
}
TrackedResourcesMask mask;
if (!Enum.TryParse(arg, true, out mask))
{
std.SendSystemMessage("Syntax: " + Std.CommandPrefix + "trackresources Type1[, Type2]");
std.SendSystemMessage("Possible types: " + Enum.GetNames(typeof(TrackedResourcesMask)).ToStringJoin(", "));
return;
}
player.TrackedResources = mask;
var data = new UpdateData(std.CurrentMap);
data.ValuesUpdates.Add(player.Guid, player.CreateUpdate());
Send(data);
}
private void HandleNoHorizontalKnockBackMessage(string arg)
{
switch (Std.ExtractBoolValue(ref arg))
{
case BoolResult.True:
NoHorizontalKnockBack = true;
std.SendSystemMessage("Zeroing horizontal knockback speed enabled");
break;
case BoolResult.False:
NoHorizontalKnockBack = false;
std.SendSystemMessage("Zeroing horizontal knockback speed disabled");
break;
case BoolResult.Unknown:
std.SendSystemMessage("Zeroing horizontal knockback speed is currently "
+ (NoHorizontalKnockBack ? "enabled" : "disabled"));
break;
}
}
private void HandleSetPitchMessage(string arg)
{
var player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Could not find player!");
return;
}
double value = Std.ExtractDouble(ref arg);
var move = new PlayerMove();
move.Unit = std.CurrentPlayerGuid;
var status = (MovementStatus)player.MovementData;
status.HavePitch = true;
status.Pitch = (float)value;
move.Status = status;
Send(move);
}
private void HandleSetFacingMessage(string arg)
{
var player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Could not find player!");
return;
}
double value = Std.ExtractDouble(ref arg);
var move = new PlayerMove();
move.Unit = std.CurrentPlayerGuid;
var status = (MovementStatus)player.MovementData;
status.HavePitch = true;
status.Pitch = (float)value;
move.Status = status;
Send(move);
}
void Events_OnMirrorImageDataRequest(object sender, TimelineEntityEventArgs args)
{
if (args.Entity == std.CurrentPlayerGuid && m_mirrorImageData != null)
{
args.Cancel = true;
Send(m_mirrorImageData);
}
}
/// <summary>
/// Key is the highlighted object, value is the highlighting object.
/// </summary>
private Dictionary<WowGuid, WowGuid> m_highlightedEntities = new Dictionary<WowGuid, WowGuid>();
private ulong m_dynamicObjectCounter = 1000000;
void Events_OnMapChange(Maps newMap, Vector3? newCoords)
{
m_highlightedEntities.Clear();
}
void Events_OnObjectDestroy(object sender, TimelineObjectAnimEventArgs args)
{
if (Global_HighlightSparklingGOs)
{
if (args.Entity.IsGameObject)
RemoveHighlight(args.Entity);
}
}
void Events_OnObjectValuesUpdate(object sender, TimelineObjectValuesUpdateEventArgs args)
{
if (Global_ShowSpecialInfo)
{
var obj = args.Object;
if (obj == null)
return;
if (obj.TypeId == ObjectTypeId.Unit || (obj.TypeId == ObjectTypeId.Player && obj.Guid != std.CurrentPlayerGuid))
{
uint index = (uint)UnitUpdateFields.UNIT_DYNAMIC_FLAGS;
if (!args.Values.ContainsKey(index))
return;
if ((args.Values[index] & (uint)UnitDynamicFlags.SpecialInfo) == 0)
{
args.Values[index] |= (uint)UnitDynamicFlags.SpecialInfo;
args.Modified = true;
}
}
}
if (Global_HighlightSparklingGOs)
{
uint index = (uint)GameObjectUpdateFields.GAMEOBJECT_DYNAMIC;
if (args.Entity.IsGameObject && args.Values.ContainsKey(index))
{
var flags = (GameObjectDynamicFlagsLo)(args.Values[index] & ushort.MaxValue);
if ((flags & GameObjectDynamicFlagsLo.Sparkle) == 0)
{
// sparkles removed
RemoveHighlight(args.Entity);
}
else if (args.Object != null && args.Object is WowGameObject)
{
// sparkles added
AddHighlight((WowGameObject)args.Object);
}
}
}
if (args.Entity == std.CurrentPlayerGuid && m_mirrorImageData != null && !args.Custom)
{
uint flags;
if (args.Values.TryGetValue((uint)UnitUpdateFields.UNIT_FIELD_FLAGS_2, out flags))
{
if ((((UnitFlags2)flags) & UnitFlags2.MirrorImage) == 0)
{
args.Values[(uint)UnitUpdateFields.UNIT_FIELD_FLAGS_2] |= (uint)UnitFlags2.MirrorImage;
args.Modified = true;
}
}
}
}
void Events_OnObjectCreate(object sender, TimelineObjectEventArgs args)
{
if (Global_ShowSpecialInfo)
{
var obj = args.Object;
if (obj.TypeId == ObjectTypeId.Unit
|| (obj.TypeId == ObjectTypeId.Player && obj.Guid != std.CurrentPlayerGuid))
{
var unit = (WowUnit)obj;
if ((unit.DynamicFlags & UnitDynamicFlags.SpecialInfo) == 0)
{
unit.DynamicFlags |= UnitDynamicFlags.SpecialInfo;
args.Modified = true;
}
}
}
if (Global_HighlightSparklingGOs)
{
if (args.Object is WowGameObject)
{
var go = (WowGameObject)args.Object;
if ((go.DynamicFlagsLo & GameObjectDynamicFlagsLo.Sparkle) != 0)
AddHighlight(go);
}
}
}
void Chat_OnServerChatMessage(object sender, TimelineDataEventArgs<ServerChatMessage> args)
{
if (!IsRunning || args.Custom || args.Cancel)
return;
var message = args.OpcodeData;
// Chat
if (message.Language != Language.Universal && message.Language != Language.Addon)
{
if (Chat_PrependLang)
{
message.Text = string.Format("[{0}] ", message.Language) + message.Text;
args.Modified = true;
}
if (Chat_Translate)
{
message.Language = Language.Universal;
args.Modified = true;
}
}
// Battlegrounds
if (message.Type == ChatMessageType.RaidBossEmote
&& Battlegrounds_HeraldAsSystem)
{
switch (std.CurrentMap)
{
case Maps.PVPZone01:
case Maps.PVPZone02:
case Maps.PVPZone03:
case Maps.PVPZone04:
case Maps.NorthrendBG:
case Maps.NetherstormBG:
case Maps.IsleofConquest:
case Maps.CataclysmCTF:
case Maps.TheBattleforGilneas:
case Maps.Gilneas_BG_2:
message.Type = ChatMessageType.BGSystemNeutral;
args.Modified = true;
break;
}
}
}
void Auction_OnAuctionListResult(object sender, TimelineDataEventArgs<AuctionListResult> args)
{
if (IsRunning && Auction_ShowExactTime && !args.Custom && !args.Cancel)
{
var result = args.OpcodeData;
for (int i = 0; i < result.Items.Length; ++i)
{
var item = result.Items[i];
// Currently max(stack) == 1000, which is 10 bits or 0x3FF
// 1 bit out of 32 is for value sign
// we have 32-1-10 = 21 bit for time, which is 0x1FFFFF
if (item.Count > 0x3FF)
continue;
if (item.TimeLeftMs / Time.InMilliseconds > 0x1FFFFF)
continue;
result.Items[i].Count = ((uint)(item.TimeLeftMs / Time.InMilliseconds) << 10) | item.Count;
args.Modified = true;
}
}
}
private MovementStatus m_lastMovementStatus;
void std_OnPlayerMovement(object sender, TimelineDataEventArgs<RegularMovementPacket> args)
{
if (args.OpcodeData.Unit != std.CurrentPlayerGuid)
return;
var status = args.OpcodeData.Status;
if (m_forceCollision != BoolResult.Unknown)
{
if (args.PacketDirection == Direction.ToServer)
{
// We should the value server expects.
var flags = status.Flags;
if (m_serverCollisionState)
flags = flags & ~MovementFlags.CollisionDisabled;
else
flags |= MovementFlags.CollisionDisabled;
if (flags != status.Flags)
{
status.Flags = flags;
args.Modified = true;
}
}
else
{
// We should the value we want the client to get.
var flags = status.Flags;
if (m_forceCollision == BoolResult.True)
flags = flags & ~MovementFlags.CollisionDisabled;
else
flags |= MovementFlags.CollisionDisabled;
if (flags != status.Flags)
{
status.Flags = flags;
args.Modified = true;
}
}
}
m_lastMovementStatus = status;
}
void AddHighlight(WowGameObject go)
{
if (!m_highlightedEntities.ContainsKey(go.Guid))
{
var highlighterGuid = new WowGuid(WowGuidType.Creature, 46645, ++m_dynamicObjectCounter);
var unit = new WowUnit();
var movement = new MovementInfo(highlighterGuid);
movement.Living = true;
movement.Position = go.MovementData.Position;
movement.Orientation = 3.141593f;
movement.TimeStamp = 2751961664;
unit.MovementData = movement;
unit.Guid = highlighterGuid;
unit.Scale = Math.Max(go.Scale, 1.0f);
unit.Entry = 46645;
unit.Class = Classes.Warrior;
unit.Gender = Genders.None;
unit.PowerType = PowerType.Rage;
unit.Health = 4979;
unit.MaxHealth = 4979;
unit.Level = 60;
unit.Model = unit.NativeModel = 37259;
unit.Faction = 190;
unit.Flags2 = UnitFlags2.Flag_0x800;
unit.BoundingRadius = 1.595f;
unit.CombatReach = 1.65f;
std.CreateObject(unit);
var aura = new Aura();
aura.AppliedTime = (uint)Environment.TickCount;
aura.Caster = highlighterGuid;
aura.Slot = 0;
aura.Level = 60;
aura.Flags = AuraFlags.EffectIndex_0 | AuraFlags.Positive | AuraFlags.NotCaster;
aura.Spell = Global_HighlightSparklingGOs_Spell;
aura.Unit = highlighterGuid;
var auraUpdate = new AuraUpdate(highlighterGuid);
auraUpdate.Full = true;
auraUpdate.Auras.Add(aura);
Send(auraUpdate);
m_highlightedEntities.Add(go.Guid, highlighterGuid);
}
}
void RemoveHighlight(WowGuid guid)
{
WowGuid highlighter;
if (m_highlightedEntities.TryGetValue(guid, out highlighter))
{
m_highlightedEntities.Remove(guid);
std.DestroyObject(highlighter);
}
}
public static BasicHacks Activate(Module parent, object[] args)
{
if (parent is WowRelay)
return new BasicHacks(parent);
return null;
}
private void HandleTranslateMessage(string arg)
{
switch (Std.ExtractBoolValue(ref arg))
{
case BoolResult.True:
Chat_Translate = true;
std.SendSystemMessage("Chat message translation enabled");
break;
case BoolResult.False:
Chat_Translate = false;
std.SendSystemMessage("Chat message translation disabled");
break;
case BoolResult.Unknown:
std.SendSystemMessage("Chat message translation is now "
+ (Chat_Translate ? "enabled" : "disabled"));
break;
}
}
private void HandleHighlightQuestObjectsMessage(string arg)
{
switch (Std.ExtractBoolValue(ref arg))
{
case BoolResult.True:
Global_HighlightSparklingGOs = true;
std.SendSystemMessage("Object highlighting has been enabled.");
break;
case BoolResult.False:
Global_HighlightSparklingGOs = false;
std.SendSystemMessage("Object highlighting has been disabled.");
break;
case BoolResult.Unknown:
std.SendSystemMessage("Object highlighting is now "
+ (Global_HighlightSparklingGOs ? "enabled" : "disabled"));
break;
}
}
private void HandleHighlightSpellMessage(string arg)
{
if (!string.IsNullOrWhiteSpace(arg))
{
RaidMarkerSpells spell;
if (Enum.TryParse(arg, true, out spell) && spell != default(RaidMarkerSpells))
Global_HighlightSparklingGOs_Spell = (uint)spell;
else
Global_HighlightSparklingGOs_Spell = arg.ToNumeric<uint>();
std.SendSystemMessage("Object highlighting spell has been changed to " + Global_HighlightSparklingGOs_Spell);
var newEntities = new Dictionary<WowGuid, WowGuid>();
var data = new UpdateData(std.CurrentMap);
foreach (var pair in m_highlightedEntities)
{
var dynObj = (WowDynamicObject)std.GetObject(pair.Value);
dynObj.Guid = new WowGuid(WowGuidType.DynamicObject, ++m_dynamicObjectCounter);
dynObj.Spell = Global_HighlightSparklingGOs_Spell;
dynObj.SpellVisual = HighlightSparklingGOs_SpellVisual;
data.CreatedObjects.Add(dynObj.Guid, dynObj);
data.DestroyedObjects.Add(pair.Value);
newEntities.Add(pair.Key, dynObj.Guid);
}
Send(data);
m_highlightedEntities = newEntities;
}
else
std.SendSystemMessage("Object highlighting spell is now " + Global_HighlightSparklingGOs_Spell);
}
private void HandleResetModelMessage(string arg)
{
WowPlayer player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Cannot find player.");
return;
}
player.Flags2 &= ~UnitFlags2.MirrorImage;
player.Model = player.NativeModel;
if (m_miIdRetriever.IsBusy)
m_miIdRetriever.CancelAsync();
m_mirrorImageData = null;
var data = new UpdateData(std.CurrentMap);
data.ValuesUpdates.Add(std.CurrentPlayerGuid, player.CreateUpdate());
Send(data);
}
BackgroundWorker m_miIdRetriever;
MirrorImageData m_mirrorImageData;
private void HandleCopyModelMessage(string arg)
{
var player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Cannot find player.");
return;
}
var target = std.CurrentTarget;
if (target == null)
{
std.SendSystemMessage("Cannot find target.");
return;
}
if (m_miIdRetriever.IsBusy)
m_miIdRetriever.CancelAsync();
m_mirrorImageData = new MirrorImageData(target, player.Guid);
if (target is WowPlayer)
m_miIdRetriever.RunWorkerAsync((WowPlayer)target);
else
CompleteMirrorImage();
}
void m_miIdRetriever_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Cancelled)
{
Console.WriteLine("Cancelled");
return;
}
if (e.Error != null)
{
Console.WriteLine("Error: retriever failed: " + e.Error.ToString());
std.SendSystemMessage(e.Error.ToString());
return;
}
this.CompleteMirrorImage();
}
void m_miIdRetriever_DoWork(object sender, DoWorkEventArgs e)
{
var target = (WowPlayer)e.Argument;
var arr = new[]
{
InventorySlot.Head, InventorySlot.Shoulders, InventorySlot.Body,
InventorySlot.Chest, InventorySlot.Waist, InventorySlot.Legs,
InventorySlot.Feet, InventorySlot.Wrists, InventorySlot.Hands,
InventorySlot.Back, InventorySlot.Tabard
};
var regex = new Regex(@"displayId: (\d+),");
Func<uint, uint> getDisplayId = (entry) =>
{
var req = HttpWebRequest.Create("http://www.wowhead.com/item=" + entry);
var resp = req.GetResponse();
string s;
using (var stream = resp.GetResponseStream())
using (var sr = new StreamReader(stream))
s = sr.ReadToEnd();
Console.WriteLine(s);
var match = regex.Match(s);
if (match != null && match.Success)
return uint.Parse(match.Groups[1].Captures[0].Value);
return 0;
};
int i = 0;
foreach (var el in arr)
{
var entry = target.GetVisibleItemEntry(el);
if (entry != 0)
{
var id = getDisplayId(entry);
std.SendSystemMessage("{0}: {1} -> {2}", el, entry, id);
m_mirrorImageData.DisplayIds[i++] = id;
}
}
}
void CompleteMirrorImage()
{
var player = std.CurrentPlayer;
if (player == null)
return;
if ((player.Flags2 & UnitFlags2.MirrorImage) != 0)
{
player.Flags2 &= ~UnitFlags2.MirrorImage;
var update2 = new UpdateData(std.CurrentMap);
update2.ValuesUpdates.Add(player.Guid, player.CreateUpdate());
this.Send(update2);
}
player.Model = m_mirrorImageData.Model;
player.Flags2 |= UnitFlags2.MirrorImage;
var data = new UpdateData(std.CurrentMap);
data.ValuesUpdates.Add(player.Guid, player.CreateUpdate());
Send(data);
}
private void HandleResetMountMessage(string arg)
{
var player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Cannot find player.");
return;
}
var data = new UpdateData(std.CurrentMap);
var fields = new UpdateFields();
fields.Add((uint)UnitUpdateFields.UNIT_FIELD_MOUNTDISPLAYID, 0);
data.ValuesUpdates.Add(std.CurrentPlayerGuid, fields);
Send(data);
}
private void HandleCopyMountMessage(string arg)
{
WowPlayer player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Cannot find player.");
return;
}
WowUnit target = std.CurrentTarget;
if (target == null)
{
std.SendSystemMessage("Cannot find target.");
return;
}
var data = new UpdateData(std.CurrentMap);
var fields = new UpdateFields();
fields.Add((uint)UnitUpdateFields.UNIT_FIELD_MOUNTDISPLAYID,
target.GetUInt(UnitUpdateFields.UNIT_FIELD_MOUNTDISPLAYID));
data.ValuesUpdates.Add(std.CurrentPlayerGuid, fields);
Send(data);
}
private void HandleCastSpellMessage(string arg)
{
string[] args = arg.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (args.Length < 2)
{
std.SendSystemMessage("Syntax: \\castspell <id> <target type>");
return;
}
uint spell = args[0].ToNumeric<uint>();
if (spell == 0)
{
std.SendSystemMessage("Wrong spell: " + args[0]);
return;
}
var targets = new SpellTargetData();
switch (args[1])
{
case "self":
targets.Flags = SpellCastTargetFlags.Self;
break;
case "selfloc":
{
targets.Flags = SpellCastTargetFlags.DestLocation;
var player = std.CurrentPlayer;
if (player == null)
{
std.SendSystemMessage("Cannot find player.");
return;
}
targets.DestLocation = player.MovementData.Position;
targets.DestTransportGuid = player.MovementData.TransportGuid;
break;
}
case "target":
if (std.CurrentTargetGuid.IsEmpty)
{
std.SendSystemMessage("Cannot find target.");
return;
}
targets.Flags = SpellCastTargetFlags.Unit;
targets.TargetUnit = std.CurrentTargetGuid;
break;
case "targetloc":
{
targets.Flags = SpellCastTargetFlags.DestLocation;
var target = std.CurrentTarget;
if (target == null)
{
std.SendSystemMessage("Cannot find target.");
return;
}
targets.DestLocation = target.MovementData.Position;
targets.DestTransportGuid = target.MovementData.TransportGuid;
break;
}
case "guid":
{
if (args.Length < 3)
{
std.SendSystemMessage("Supply entity to cast spell on.");
return;
}
ulong guid = args[2].ToNumeric<ulong>();
if (guid == 0)
{
std.SendSystemMessage("Cannot find guid " + args[2]);
return;
}
targets.Flags = SpellCastTargetFlags.Unit;
targets.TargetUnit = new WowGuid(guid);
break;
}
case "guidloc":
{
if (args.Length < 3)
{
std.SendSystemMessage("Supply entity to cast spell on.");
return;
}
ulong guid = args[2].ToNumeric<ulong>();
if (guid == 0)
{
std.SendSystemMessage("Cannot find guid " + args[2]);
return;
}
var objguid = new WowGuid(guid);
var obj = std.GetObject(objguid);
if (obj == null)
{
std.SendSystemMessage("Cannot find object " + objguid);
return;
}
targets.Flags = SpellCastTargetFlags.DestLocation;
targets.DestLocation = obj.MovementData.Position;
targets.DestTransportGuid = obj.MovementData.TransportGuid;
break;
}
default:
std.SendSystemMessage("Unknown target type: " + args[1]);
std.SendSystemMessage("Allowed target types: self, selfloc, target, targetloc, guid, guidloc");
return;
}
std.CastSpell(spell, targets);
}
private void HandlePrependLangMessage(string arg)
{
switch (Std.ExtractBoolValue(ref arg))
{
case BoolResult.True:
Chat_PrependLang = true;
std.SendSystemMessage("Chat message language prepending enabled");
break;
case BoolResult.False:
Chat_PrependLang = false;
std.SendSystemMessage("Chat message language prepending disabled");
break;
case BoolResult.Unknown:
std.SendSystemMessage("Chat message language prepending is now "
+ (Chat_PrependLang ? "enabled" : "disabled"));
break;
}
}
private void HandlePushForwardMessage(string arg)
{
if (m_lastMovementStatus == null)
{
std.SendSystemMessage("Movement Status is not loaded for your character.");
return;
}
double delta = arg.ToNumeric<double>();
/* Orientation:
* 0 X
* PI/2 3PI/2 ^
* PI |
* Y<------------*
*/
var status = m_lastMovementStatus;
double ori = status.Orientation;
status.Position.X += (float)(delta * Math.Cos(ori));
status.Position.Y += (float)(delta * Math.Sin(ori));
status.TimeStamp = (uint)Environment.TickCount;
var move = new PlayerMove();
move.Unit = std.CurrentPlayerGuid;
move.Status = status;
Send(move);
}
private void HandlePushAscendMessage(string arg)
{
if (m_lastMovementStatus == null)
{
std.SendSystemMessage("Movement Status is not loaded for your character.");
return;
}
double delta = arg.ToNumeric<double>();
var status = m_lastMovementStatus;
status.Position.Z += (float)delta;
status.TimeStamp = (uint)Environment.TickCount;
var move = new PlayerMove();
move.Unit = std.CurrentPlayerGuid;
move.Status = status;
Send(move);
}
public override void HandlePacket(Packet packet)
{
var wowPacket = packet as WowPacket;
if (wowPacket == null)
return;
switch ((WowOpcodes)wowPacket.Opcode)
{
case WowOpcodes.SMSG_MOVE_ENABLE_COLLISION:
if (!packet.HasFlag(PacketFlags.Custom))
{
m_serverCollisionState = true;
if (m_forceCollision != BoolResult.Unknown)
packet.SetFlag(PacketFlags.Freezed);
}
break;
case WowOpcodes.SMSG_MOVE_DISABLE_COLLISION:
if (!packet.HasFlag(PacketFlags.Custom))
{
m_serverCollisionState = false;
if (m_forceCollision != BoolResult.Unknown)
packet.SetFlag(PacketFlags.Freezed);
}
break;
}
}
public BasicHacks(Module parent)
: base(parent)
{
this.NodeName = "Basic Hacks";
Start();
}
}
}
using Kamilla.Forms;
namespace Kamilla.WorldOfWarcraft.Latest.Core.Hacks
{
partial class BasicHacks
{
private System.Windows.Forms.CheckBox cbTranslatorPrependLang;
private System.Windows.Forms.CheckBox cbTranslatorTranslate;
private System.Windows.Forms.CheckBox cbBattlegrounds_Herald;
private System.Windows.Forms.CheckBox cbAuctionShowExactTime;
public override void CreateBox()
{
Box.ThreadSafe(x =>
{
System.Windows.Forms.TabControl tabControl;
System.Windows.Forms.TabPage tabPageBasic;
System.Windows.Forms.TabPage tabPageZones;
System.Windows.Forms.GroupBox gbChat;
System.Windows.Forms.GroupBox gbBattlegrounds;
System.Windows.Forms.GroupBox gbAuction;
this.cbTranslatorTranslate = new System.Windows.Forms.CheckBox();
this.cbTranslatorPrependLang = new System.Windows.Forms.CheckBox();
this.cbBattlegrounds_Herald = new System.Windows.Forms.CheckBox();
this.cbAuctionShowExactTime = new System.Windows.Forms.CheckBox();
tabControl = new System.Windows.Forms.TabControl();
tabPageBasic = new System.Windows.Forms.TabPage();
tabPageZones = new System.Windows.Forms.TabPage();
gbChat = new System.Windows.Forms.GroupBox();
gbBattlegrounds = new System.Windows.Forms.GroupBox();
gbAuction = new System.Windows.Forms.GroupBox();
this.Box.SuspendLayout();
tabControl.SuspendLayout();
tabPageBasic.SuspendLayout();
gbChat.SuspendLayout();
gbBattlegrounds.SuspendLayout();
gbAuction.SuspendLayout();
//
// Box
//
this.Box.Controls.Add(tabControl);
//
// tabControl
//
tabControl.Controls.Add(tabPageBasic);
tabControl.Controls.Add(tabPageZones);
tabControl.Location = new System.Drawing.Point(6, 19);
tabControl.Name = "tabControl";
tabControl.SelectedIndex = 0;
tabControl.Size = new System.Drawing.Size(559, 244);
tabControl.TabIndex = 0;
//
// tabPageBasic
//
tabPageBasic.Controls.Add(gbChat);
tabPageBasic.Controls.Add(gbAuction);
tabPageBasic.Location = new System.Drawing.Point(4, 22);
tabPageBasic.Name = "tabPageBasic";
tabPageBasic.Padding = new System.Windows.Forms.Padding(3);
tabPageBasic.Size = new System.Drawing.Size(551, 218);
tabPageBasic.TabIndex = 0;
tabPageBasic.Text = "Basic";
tabPageBasic.UseVisualStyleBackColor = true;
//
// tabPageZones
//
tabPageZones.Controls.Add(gbBattlegrounds);
tabPageZones.Location = new System.Drawing.Point(4, 22);
tabPageZones.Name = "tabPageZones";
tabPageZones.Padding = new System.Windows.Forms.Padding(3);
tabPageZones.Size = new System.Drawing.Size(551, 218);
tabPageZones.TabIndex = 1;
tabPageZones.Text = "Zones";
tabPageZones.UseVisualStyleBackColor = true;
//
// gbChat
//
gbChat.Controls.Add(this.cbTranslatorPrependLang);
gbChat.Controls.Add(this.cbTranslatorTranslate);
gbChat.Location = new System.Drawing.Point(6, 6);
gbChat.Name = "gb";
gbChat.Size = new System.Drawing.Size(159, 68);
gbChat.TabIndex = 0;
gbChat.TabStop = false;
gbChat.Text = "Chat";
//
// cbTranslatorTranslate
//
this.cbTranslatorTranslate.AutoSize = true;
this.cbTranslatorTranslate.Location = new System.Drawing.Point(6, 19);
this.cbTranslatorTranslate.Name = "cbTranslatorTranslate";
this.cbTranslatorTranslate.Size = new System.Drawing.Size(129, 17);
this.cbTranslatorTranslate.TabIndex = 0;
this.cbTranslatorTranslate.Text = "Translate to Universal";
this.cbTranslatorTranslate.UseVisualStyleBackColor = true;
this.cbTranslatorTranslate.CheckedChanged +=
new System.EventHandler((a, b) => Chat_Translate = this.cbTranslatorTranslate.Checked);
//
// cbTranslatorPrependLang
//
this.cbTranslatorPrependLang.AutoSize = true;
this.cbTranslatorPrependLang.Location = new System.Drawing.Point(6, 42);
this.cbTranslatorPrependLang.Name = "cbTranslatorPrependLang";
this.cbTranslatorPrependLang.Size = new System.Drawing.Size(139, 17);
this.cbTranslatorPrependLang.TabIndex = 1;
this.cbTranslatorPrependLang.Text = "Prepend Used Language";
this.cbTranslatorPrependLang.UseVisualStyleBackColor = true;
this.cbTranslatorPrependLang.CheckedChanged +=
new System.EventHandler((a, b) => Chat_PrependLang = this.cbTranslatorPrependLang.Checked);
//
// gbBattlegrounds
//
gbBattlegrounds.Controls.Add(this.cbBattlegrounds_Herald);
gbBattlegrounds.Location = new System.Drawing.Point(6, 6);
gbBattlegrounds.Name = "gbBattlegrounds";
gbBattlegrounds.Size = new System.Drawing.Size(200, 100);
gbBattlegrounds.Text = "Battlegrounds";
//
// cbBattlegrounds_Herald
//
this.cbBattlegrounds_Herald.AutoSize = true;
this.cbBattlegrounds_Herald.Location = new System.Drawing.Point(6, 19);
this.cbBattlegrounds_Herald.Name = "cbBattlegrounds_Herald";
this.cbBattlegrounds_Herald.Size = new System.Drawing.Size(158, 17);
this.cbBattlegrounds_Herald.TabIndex = 0;
this.cbBattlegrounds_Herald.Text = "Herald Messages as System";
this.cbBattlegrounds_Herald.UseVisualStyleBackColor = true;
this.cbBattlegrounds_Herald.CheckedChanged +=
new System.EventHandler((a, b) => Battlegrounds_HeraldAsSystem = this.cbBattlegrounds_Herald.Checked);
//
// gbAuction
//
gbAuction.Controls.Add(this.cbAuctionShowExactTime);
gbAuction.Location = new System.Drawing.Point(171, 6);
gbAuction.Name = "gbAuction";
gbAuction.Size = new System.Drawing.Size(159, 68);
gbAuction.TabIndex = 1;
gbAuction.TabStop = false;
gbAuction.Text = "Auction";
//
// cbAuctionShowExactTime
//
this.cbAuctionShowExactTime.AutoSize = true;
this.cbAuctionShowExactTime.Location = new System.Drawing.Point(6, 19);
this.cbAuctionShowExactTime.Name = "cbAuctionShowExactTime";
this.cbAuctionShowExactTime.Size = new System.Drawing.Size(109, 17);
this.cbAuctionShowExactTime.TabIndex = 0;
this.cbAuctionShowExactTime.Text = "Show Exact Time";
this.cbAuctionShowExactTime.UseVisualStyleBackColor = true;
this.cbAuctionShowExactTime.CheckedChanged +=
new System.EventHandler((a, b) => Auction_ShowExactTime = this.cbAuctionShowExactTime.Checked);
//
// Views
//
this.Box.ResumeLayout(false);
tabControl.ResumeLayout(false);
tabPageBasic.ResumeLayout(false);
gbChat.ResumeLayout(false);
gbChat.PerformLayout();
gbAuction.ResumeLayout(false);
gbAuction.PerformLayout();
});
}
public override void UpdateBox()
{
Box.ThreadSafe(x =>
{
this.cbTranslatorPrependLang.Checked = Chat_PrependLang;
this.cbTranslatorTranslate.Checked = Chat_Translate;
this.cbBattlegrounds_Herald.Checked = Battlegrounds_HeraldAsSystem;
this.cbAuctionShowExactTime.Checked = Auction_ShowExactTime;
});
}
}
}
using System.Linq;
using Kamilla.WorldOfWarcraft.Latest.OpcodeDatas;
using Microsoft.Xna.Framework;
namespace Kamilla.WorldOfWarcraft.Latest.Core.Hacks
{
[LoadPriority(LoadPriority.Medium)]
[ModuleReferences(typeof(Std))]
public sealed class MapAssist : WowAddon
{
public static MapAssist Activate(Module parent, object[] args)
{
if (parent is WowRelay)
return new MapAssist(parent);
return null;
}
private Std std;
protected override void Initialize(Module[] references)
{
std = (Std)references[0];
std.Events.OnMapChange += new TimelineHandler.OnMapChangeEventHandler(Events_OnMapChange);
m_monsterMoveHandler = new TimelineHandler.OnMonsterMoveHandler(Events_OnMonsterMove);
m_objectCreateHandler = new TimelineHandler.OnObjectCreateEventHandler(Events_OnObjectCreate);
}
public MapAssist(Module parent)
: base(parent)
{
this.NodeName = "Map Assist";
}
private TimelineHandler.OnMonsterMoveHandler m_monsterMoveHandler;
private TimelineHandler.OnObjectCreateEventHandler m_objectCreateHandler;
void NotifyGroupOfPoint(ref Vector3 point)
{
std.SetRaidMarker(ref point, RaidMarkerSpells.Cross);
//std.SendMinimapPing(point.X, point.Y);
}
void Events_OnMonsterMove(object sender, TimelineDataEventArgs<MonsterMove> args)
{
var move = args.OpcodeData;
if (move.Unit.Entry == 46492) // Vortex Pinnacle last boss
{
if (move.Points.Length == 0)
return;
var center = new Vector3(
move.Points.Average(v3 => v3.X),
move.Points.Average(v3 => v3.Y),
move.Points.Average(v3 => v3.Z)
);
NotifyGroupOfPoint(ref center);
}
}
void Events_OnMapChange(Maps newMap, Vector3? newCoords)
{
switch (newMap)
{
case Maps.SkywallDungeon: // Vortex Pinnacle
case Maps.GrimBatolDungeon: // Grim Batol
Start();
break;
default:
Stop();
return;
}
}
void Events_OnObjectCreate(object sender, TimelineObjectEventArgs args)
{
if (args.Entity.Entry == 40567) // Grim Batol last boss Shadow Gale Stalker
NotifyGroupOfPoint(ref args.Object.MovementData.Position);
}
public override void Start()
{
if (IsRunning)
return;
base.Start();
std.Events.OnMonsterMove += m_monsterMoveHandler;
std.Events.OnObjectCreate += m_objectCreateHandler;
}
public override void Stop()
{
if (!IsRunning)
return;
base.Stop();
std.Events.OnMonsterMove -= m_monsterMoveHandler;
std.Events.OnObjectCreate -= m_objectCreateHandler;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment