axazol
New Member
- Joined
- Jun 27, 2010
- Messages
- 308
- Reaction score
- 8
PHP:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using Styx.Database;
using Styx.Helpers;
using Styx.Logic.BehaviorTree;
using Styx.Logic.Inventory.Frames.Gossip;
using Styx.Logic.Pathing;
using Styx.Logic.Questing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using TreeSharp;
using Action = TreeSharp.Action;
namespace Styx.Bot.Quest_Behaviors
{
///
/// RunMacro by AxaZol
/// Allows you to run custom macro at selected location.
/// ##Syntax##
/// Macro: Macro body.
/// NumOfTimes: Number of times to interact with object.
/// [Optional] WaitTime: Time in msec to wait after each macro usage.
///
public class RunMacro : CustomForcedBehavior
{
public RunMacro(Dictionary args)
: base(args)
{
bool error = false;
if (!Args.ContainsKey("Macro"))
{
Logging.Write("Could not find attribute 'Macro' in RunMacro behavior! please check your profile!");
error = true;
}
string macro = Args["Macro"];
int numOfTimes;
if (!int.TryParse(Args["NumOfTimes"], out numOfTimes))
{
Logging.Write("Parsing attribute 'NumOfTimes' in RunMacro behavior failed! please check your profile!");
error = true;
}
if(Args.ContainsKey("WaitTime"))
{
int waitTime;
int.TryParse(Args["WaitTime"], out waitTime);
WaitTime = waitTime != 0 ? waitTime : 1500;
}
if (error)
TreeRoot.Stop();
Macro = macro;
NumOfTimes = numOfTimes;
}
public string Macro { get; set; }
public int NumOfTimes { get; set; }
public int WaitTime { get; private set; }
#region Overrides of CustomForcedBehavior
private bool _isDone;
public override bool IsDone
{
get
{
return _isDone;
}
}
public override void OnStart()
{
TreeRoot.GoalText = string.Format("Run Macro {0} Times", NumOfTimes);
for (int counter = 1; counter <= NumOfTimes; counter++)
{
TreeRoot.StatusText = string.Format("Run Macro {0} Times", NumOfTimes);
Lua.DoString(string.Format("RunMacroText(\"{0}\")", Macro), 0);
Thread.Sleep(WaitTime);
};
_isDone = true;
}
#endregion
}
}
PHP:
<CustomBehavior File="RunMacro"
Macro="/wave\n/dance"
NumOfTimes="1"
WaitTime="2000" />
UPD: chinajade improvement
Attachments
Last edited: