Add proper help for bot AI instructions.

This commit is contained in:
UnknownShadow200 2016-09-10 13:40:29 +10:00
parent b97dc56257
commit 03100abf4d
6 changed files with 87 additions and 29 deletions

View File

@ -54,6 +54,14 @@ namespace MCGalaxy.Bots {
string speed = args.Length > 4 ? args[4] : "2";
w.WriteLine(Name + " " + short.Parse(time) + " " + byte.Parse(speed));
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] spin <interval> <speed>",
"%HCauses the bot to spin around for a period of time.",
"%H <interval> is in tenths of a second, so an interval of 20 means " +
"spin for two seconds. (defaults to 1 second)",
"%H <speed> sets how fast the bot spins. (defaults to 2)",
};
}
/// <summary> Causes the bot to nod down up and down for a certain interval. </summary>
@ -85,5 +93,13 @@ namespace MCGalaxy.Bots {
if (bot.countdown == 0) { bot.NextInstruction(); return false; }
return true;
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] nod <interval> <speed>",
"%HCauses the bot to nod up and down for a period of time.",
"%H <interval> is in tenths of a second, so an interval of 20 means " +
"nod for two seconds. (defaults to 1 second)",
"%H <speed> sets how fast the bot nods. (defaults to 2)",
};
}
}

View File

@ -88,6 +88,12 @@ namespace MCGalaxy.Bots {
w.WriteLine(Name);
}
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] hunt <radius>",
"%HCauses the bot to move towards the closest player in the search radius.",
"%H <radius> defaults to 75 blocks.",
};
}
/// <summary> Causes the bot to kill nearby humans. </summary>
@ -107,5 +113,10 @@ namespace MCGalaxy.Bots {
}
bot.NextInstruction(); return true;
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] kill",
"%HCauses the bot to kill any players it is touching.",
};
}
}

View File

@ -42,6 +42,9 @@ namespace MCGalaxy.Bots {
w.WriteLine(Name);
}
/// <summary> Returns the help for this instruction. n</summary>
public abstract string[] Help { get; }
/// <summary> All instructions that bots can execute. </summary>
public static List<BotInstruction> Instructions = new List<BotInstruction>() {
new NodInstruction(), new SpinInstruction(), new HuntInstruction(), new KillInstruction(),

View File

@ -53,6 +53,12 @@ namespace MCGalaxy.Bots {
public ushort X, Y, Z;
public byte RotX, RotY;
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] teleport",
"%HCauses the bot to instantly teleport to a position.",
"%H Note: The position saved to the AI is your current position.",
};
}
/// <summary> Causes the bot to gradually move to to a position. </summary>
@ -74,6 +80,12 @@ namespace MCGalaxy.Bots {
bot.AdvanceRotation();
return true;
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] walk",
"%HCauses the bot to walk towards to a position.",
"%H Note: The position saved to the AI is your current position.",
};
}
/// <summary> Causes the bot to begin jumping. </summary>
@ -84,6 +96,13 @@ namespace MCGalaxy.Bots {
bot.jumping = true;
bot.NextInstruction(); return false;
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] jump",
"%HCauses the bot to perform a jump.",
"%H Note bots can also do other instructions while jumping",
"%H (e.g. For a \"jump\" then a \"walk\" instruction, the bot will jump while also walking",
};
}
/// <summary> Causes the bot to change how fast it moves. </summary>
@ -106,5 +125,12 @@ namespace MCGalaxy.Bots {
string time = args.Length > 3 ? args[3] : "10";
w.WriteLine(Name + " " + short.Parse(time));
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] speed [percentage]",
"%HSets how fast the bot moves, relative to its normal speed.",
"%H 100 means it moves at normal speed",
"%H 50 means it moves at half speed",
};
}
}

View File

@ -27,6 +27,11 @@ namespace MCGalaxy.Bots {
public override bool Execute(PlayerBot bot, InstructionData data) {
bot.cur = 0; return false;
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] reset",
"%HCauses the bot to go back to the first instruction",
};
}
/// <summary> Causes the bot to be removed from the world. </summary>
@ -36,6 +41,11 @@ namespace MCGalaxy.Bots {
public override bool Execute(PlayerBot bot, InstructionData data) {
PlayerBot.Remove(bot); return true;
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] remove",
"%HCauses the bot to be removed from the world",
};
}
/// <summary> Causes the bot to switch to a different AI. </summary>
@ -65,6 +75,11 @@ namespace MCGalaxy.Bots {
w.WriteLine(Name + " " + script);
}
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] linkscript [ai name]",
"%HCauses the bot to switch to the given AI, and execute that AI's instructions instead.",
};
}
/// <summary> Causes the bot to wait/do nothing for a certain interval. </summary>
@ -92,5 +107,12 @@ namespace MCGalaxy.Bots {
string time = args.Length > 3 ? args[3] : "10";
w.WriteLine(Name + " " + short.Parse(time));
}
public override string[] Help { get { return help; } }
static string[] help = { "%T/botai add [name] wait <interval>",
"%HCauses the bot to stay still for a period of time.",
"%H <interval> is in tenths of a second, so an interval of 20 means " +
"stay still for two seconds. (defaults to 1 second)",
};
}
}

View File

@ -111,8 +111,8 @@ namespace MCGalaxy.Commands
}
try {
string action = args.Length > 2 ? args[2] : "";
if (action != "reverse") {
string action = args.Length > 2 ? args[2] : "";
if (action != "reverse") {
ScriptFile.Append(p, ai, action, args); return;
}
@ -146,36 +146,16 @@ namespace MCGalaxy.Commands
Player.Message(p, "%HInstructions: %S{0}, reverse",
BotInstruction.Instructions.Join(ins => ins.Name.ToLower()));
Player.Message(p, "%HTo see extended help, type %T/help botai [instruction]");
Player.Message(p, "%Hwait, nod, spin %S- optional arg specifies '0.1 seconds'");
Player.Message(p, "%Hnod, spin %S- optional second arg specifies 'speed'");
Player.Message(p, "%Hlinkscript %S- arg specifies another AI name");
Player.Message(p, "%HTo see detailed help, type %T/help botai [instruction]");
}
public override void Help(Player p, string message) {
switch (message.ToLower()) {
case "wait":
Player.Message(p, "%T/botai add [name] wait [interval]");
Player.Message(p, "%HCauses the bot to stay still for a period of time.");
Player.Message(p, "%HNote interval is in 10ths of a second, so an " +
"interval of 20 means stay still for two seconds.");
Player.Message(p, "%HIf interval is not given, stays still for one second.");
break;
case "speed":
Player.Message(p, "%T/botai add [name] speed [percentage]");
Player.Message(p, "%HSets how fast the bot moves, relative to its normal speed.");
Player.Message(p, "%H100 means it moves at normal speed, " +
"50 means it moves half as fast as normal");
break;
case "linkscript":
Player.Message(p, "%T/botai add [name] linkscript [AI name]");
Player.Message(p, "%HCauses the bot to execute all of " +
"the instructions defined in the given AI.");
break;
default:
Player.Message(p, "%HInstructions: %Swalk, teleport, wait, nod, speed, " +
"spin, reset, remove, reverse, linkscript, jump");
break;
BotInstruction ins = BotInstruction.Find(message);
if (ins == null) {
Player.Message(p, "%HInstructions: %S{0}, reverse",
BotInstruction.Instructions.Join(ins2 => ins2.Name.ToLower()));
} else {
Player.MessageLines(p, ins.Help);
}
}
}