public static Stopwatch _Delay = new Stopwatch();
public void Delay()
{
Random random = new Random();
int Dely = random.Next(ini_MIN_DELAY, ini_MAX_DELAY);
_fightTimer.Reset();
_Delay.Start();
{
loop: if (_Delay.ElapsedMilliseconds > Dely)
goto end;
else
goto loop;
end: Logging.Write("Your delay time was: {0} ms. ", Dely);
}
_Delay.Reset();
return;
}
private ushort ini_MIN_DELAY = 0;
private ushort ini_MAX_DELAY = 0;
public override Composite CreateRestBehavior()
{
return new PrioritySelector(
new Action(ctx => smerf()),
new Action(ctx => Delay()),
new WaitContinue(Delay, ctx => false, ActionAlwaysSucceed()),
//Blah Blah Blah
);
}
void smerf()
{
RiftRogue settings = new RiftRogue();
settings.read_ini_settings();
settings.Delay();
}
private void read_ini_settings()
{
// get the configuration file
FileInfo config_file = new FileInfo(String.Format("C:\\RogueTest.ini"));
if (config_file.Exists)
{
using (StreamReader stream_reader = new StreamReader(config_file.FullName))
{
string section = "[]";
string line;
while ((line = stream_reader.ReadLine()) != null)
{
if (line.StartsWith("[") && line.EndsWith("]") && line != section)
{
section = line.ToUpper();
}
if (section == "[ROGUETEST.DLL SETTINGS]")
{
if (line.ToUpper().StartsWith("ROUTINE=") && line.Length > 8)
{
ini_ROUTINE = line.Substring(8);
}
else if (line.ToUpper().StartsWith("MIN_DELAY=") && line.Length > 10)
{
ini_MIN_DELAY = ushort.Parse(line.Substring(10));
}
else if (line.ToUpper().StartsWith("MAX_DELAY=") && line.Length > 10)
{
ini_MAX_DELAY = ushort.Parse(line.Substring(10));
}
}
}
}
}
else
{
throw new Exception("My INI file is missing.");
}
}
public int Delay()
{
Random random = new Random();
int Delay = random.Next(ini_MIN_DELAY, ini_MAX_DELAY);
return Delay;
}
void smerf() - works
private void read_ini_settings() - works
It's been about a week, any info on my question about this?
new WaitContinue(Delay, ctx => false, [COLOR="red"]new[/COLOR] ActionAlwaysSucceed()),
Altec said:Edited some code to what I have on-hand now. My question is, according to the Wiki, ActionAlwaysSucceed() is a universal command inside TreeSharp, but I am getting an error [The name 'ActionAlwaysSucceed' does not exist in the current context] Why is this? And will the command: new WaitContinue(Delay, ctx => false, ActionAlwaysSucceed()), work correctly? (meaning will it wait the int Delay's seconds?
using CommonBehaviors.Actions;
[ROGUETEST.DLL SETTINGS]
ROUTINE=RogueTest.DLL
MIN_DELAY=250
MAX_DELAY=2250
[color=blue]public override[/color] [color=teal]Composite[/color] CreateRestBehavior()
{
[color=blue]new[/color] [color=teal]Sequence[/color](
[color=blue]new[/color] [color=teal]Action[/color](ctx => smerf()),
[color=blue]new[/color] [color=teal]Action[/color](ctx => Delay()),
[color=blue]new[/color] [color=teal]WaitContinue[/color](Delay, ctx => [color=blue]false[/color], [color=blue]new[/color] [color=red][U]ActionAlwaysSucceed()[/U][/color]),
[color=blue]new[/color] [color=teal]PrioritySelector[/color](
[color=green]//PrioritySelector code[/color]
));
}
[color=blue]using[/color] [color=red][u]CommonBehaviors[/u][/color].Actions;
[color=blue]public override[/color] [color=teal]Composite[/color] CreateRestBehavior()
{
[color=blue]new[/color] [color=teal]Sequence[/color](
[color=blue]new[/color] [color=teal]Action[/color](ctx => smerf()),
[color=blue]new[/color] [color=teal]Action[/color](ctx => Delay()),
[color=blue]new[/color] [color=teal]WaitContinue[/color](Delay, ctx => [color=blue]false[/color], [color=blue]new[/color] [color=red][U]ActionAlwaysSucceed()[/U][/color]),
[color=blue]new[/color] [color=teal]Action[/color](ctx => PS()));
}
[color=blue]public override[/color] [color=teal]Composite[/color] PS()
{
[color=blue]return new[/color] [color=teal]PrioritySelector[/color](
[color=green]//PrioritySelector code[/color]
);
}
This is a very noble goal.Altec said:The main objective I had here was to offer the user a choice to "slow" their bot down
The Ryftomate API may have failed to provide the ActionAlwaysSucceed convenience class, or may have placed it elsewhere in the API. You'll just have to dig around to see if you can find it. If its not there, an effective replacement for ActionAlwaysSucceed is this...Altec said:The only error I get is ActionAlwaysSucceed(), which is marked red/underlined ablove. The error states: "The type or namespace name 'ActionAlwaysSucceed' could not be found (are you missing a using directive or an assembly reference?)."
The new structure you have is fine. If you'd like the whole thing in a single method, it would look like...Altec said:Another thing is the old way to the new way lost the ( return new PrioritySelector( ). I tried to put it in there but I always got an error: "Only assignment, call, increment, decrement, and new object expressions can be used as statement." and "Invalid expression term 'return'."
public override Composite CreateRestBehavior()
{
[COLOR="red"]return ([/COLOR]new Sequence(
new Action(ctx => smerf()),
new Action(ctx => Delay()),
new WaitContinue(Delay, ctx => false, new [COLOR="red"]Action(delegate { return (RunStatus.Success); })[/COLOR]),
[COLOR="red"]new PrioritySelector(
//PrioritySelector code
)[/COLOR])[COLOR="red"]);[/COLOR]
}
public override Composite CreateRestBehavior()
{
return (new Sequence(
new Action(ctx => smerf()),
new Action(ctx => Delay()),
new WaitContinue(Delay, ctx => false, new Action(delegate { return (RunStatus.Success); })),
new PrioritySelector(
//PrioritySelector code
)));
}
new Action(ctx => smerf()),
new Action(ctx => Delay()),
new WaitContinue(_Delay, ctx => false, new Action(delegate { })),
new WaitContinue(3, ctx => false, new Action(delegate {})),
^^^
This works for waiting 3 seconds, but...
-------------------------
private int _Delay = 3;
new WaitContinue(_Delay, ctx => false, new Action(delegate {})),
^^^
This does not work and it skips this line of code all together
[01:22:40.208 N] 8
[01:22:40.208 N] 0
[01:22:41.218 N] 3
[01:22:41.218 N] 0
[01:22:42.226 N] 6
[01:22:42.226 N] 0
[01:22:43.233 N] 9
[01:22:43.233 N] 0
Random random = new Random();
int Delay_ = random.Next(ini_MIN_DELAY, ini_MAX_DELAY);
Logging.Write("{0}", Delay_);
Random random = new Random();
int Delay_ = random.Next(2, 10);
Logging.Write("{0}", Delay_);
[01:28:47.201 N] 6
[01:28:47.201 N] 6
[01:28:48.211 N] 5
[01:28:48.211 N] 5
[01:28:49.219 N] 7
[01:28:49.219 N] 7
public override Composite CreateCombatBehavior()
{
return new Sequence(
new Action(ctx => smerf()),
new Action(ctx => RunStatus.Success));
}
void smerf()
{
RiftRogue settings = new RiftRogue();
settings.read_ini_settings();
settings.Delay();
Logging.Write("INI loading Complete!");
}
void Delay()
{
Random random = new Random();
Delay_ = random.Next(ini_MIN_DELAY, ini_MAX_DELAY);
Logging.Write("Delay: Min delay is: {0}", ini_MIN_DELAY);
Logging.Write("Delay: Max delay is: {0}", ini_MAX_DELAY);
Logging.Write("Delay: {0}", Delay_);
CreateCombatBehavior_();
public Composite CreateCombatBehavior_()
{
return new Sequence(
new WaitContinue(Delay_, ctx => false, new Action(delegate { })),
new PrioritySelector(
//PS code
));
}
public Composite CreateCombatBehavior_()
{
Logging.Write("Delay is: {0}", Delay_);
return new Sequence(
new WaitContinue(Delay_, ctx => false, new Action(delegate { })),
new PrioritySelector(
//PS code
));
}
public Composite CreateCombatBehavior_()
{
return new Sequence(
new Action(ctx => Logging.Write("Delay is: {0}", Delay_)),
new WaitContinue(Delay_, ctx => false, new Action(delegate { })),
new PrioritySelector(
//PS code
));
}
Altec said:Now, if I change the CreateCombatBehavior_() code to:
the chat command does the Logging.Write event, but, if I change CreateCombatBehavior_() to:Code:public Composite CreateCombatBehavior_() { Logging.Write("Delay is: {0}", Delay_); return new Sequence( new WaitContinue(Delay_, ctx => false, new Action(delegate { })), new PrioritySelector( //PS code )); }
then the Logging.Write fails to do anything.and it just loops smerf(). I am thinking the "return new Sequence(" inside CreateCombatBehavior_()is forcing the code to return to CreateCombatBehavior() instead.Code:public Composite CreateCombatBehavior_() { return new Sequence( new Action(ctx => Logging.Write("Delay is: {0}", Delay_)), new WaitContinue(Delay_, ctx => false, new Action(delegate { })), new PrioritySelector( //PS code )); }
I appreciate your willingness to do this. But, as I have stated, I have neither working copy of Ryft, nor Ryftomate. As such, I won't be able to examine your project in the context of the Ryftomate API.Altec said:PM'ing you my project in .ZIP.