mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Allow specifying search radius in stare botai instruction (Thanks JPlaysClassic)
This commit is contained in:
parent
b3cb31c135
commit
2f2b6093e9
@ -25,11 +25,9 @@ namespace MCGalaxy.Bots {
|
||||
public override string Name { get { return "hunt"; } }
|
||||
|
||||
public override bool Execute(PlayerBot bot, InstructionData data) {
|
||||
int searchRadius = 75;
|
||||
if (data.Metadata != null)
|
||||
searchRadius = (ushort)data.Metadata;
|
||||
|
||||
int dist = searchRadius * 32;
|
||||
int search = 75;
|
||||
if (data.Metadata != null) search = (ushort)data.Metadata;
|
||||
int dist = search * 32;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
Player closest = null;
|
||||
|
||||
@ -81,7 +79,7 @@ namespace MCGalaxy.Bots {
|
||||
return data;
|
||||
}
|
||||
|
||||
public override void Output(Player p, string[] args, StreamWriter w) {
|
||||
public override void Output(Player p, string[] args, StreamWriter w) {
|
||||
if (args.Length > 3) {
|
||||
w.WriteLine(Name + " " + ushort.Parse(args[3]));
|
||||
} else {
|
||||
@ -124,7 +122,9 @@ namespace MCGalaxy.Bots {
|
||||
public override string Name { get { return "stare"; } }
|
||||
|
||||
public override bool Execute(PlayerBot bot, InstructionData data) {
|
||||
int dist = 20000 * 32;
|
||||
int search = 20000;
|
||||
if (data.Metadata != null) search = (ushort)data.Metadata;
|
||||
int dist = search * 32;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
Player closest = null;
|
||||
|
||||
@ -144,6 +144,21 @@ namespace MCGalaxy.Bots {
|
||||
return true;
|
||||
}
|
||||
|
||||
public override InstructionData Parse(string[] args) {
|
||||
InstructionData data = default(InstructionData);
|
||||
if (args.Length > 1)
|
||||
data.Metadata = ushort.Parse(args[1]);
|
||||
return data;
|
||||
}
|
||||
|
||||
public override void Output(Player p, string[] args, StreamWriter w) {
|
||||
if (args.Length > 3) {
|
||||
w.WriteLine(Name + " " + ushort.Parse(args[3]));
|
||||
} else {
|
||||
w.WriteLine(Name);
|
||||
}
|
||||
}
|
||||
|
||||
static void FaceTowards(PlayerBot bot, Player p) {
|
||||
int dx = p.pos[0] - bot.pos[0], dy = p.pos[1] - bot.pos[1], dz = p.pos[2] - bot.pos[2];
|
||||
Vec3F32 dir = new Vec3F32(dx, dy, dz);
|
||||
@ -152,8 +167,9 @@ namespace MCGalaxy.Bots {
|
||||
}
|
||||
|
||||
public override string[] Help { get { return help; } }
|
||||
static string[] help = { "%T/botai add [name] stare",
|
||||
"%HCauses the bot to stare at the closest player.",
|
||||
static string[] help = { "%T/botai add [name] stare <radius>",
|
||||
"%HCauses the bot to stare at the closest player in the search radius.",
|
||||
"%H <radius> defaults to 20000 blocks.",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -141,9 +141,7 @@ namespace MCGalaxy {
|
||||
string name = Chat.Format(b.color + b.DisplayName, dst, true, true, false);
|
||||
if (b.DisplayName.CaselessEq("empty")) name = "";
|
||||
string skin = Chat.Format(b.SkinName, dst, true, true, false);
|
||||
|
||||
|
||||
|
||||
|
||||
if (dst.hasExtList) {
|
||||
dst.SendExtAddEntity2(b.id, skin, name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
|
||||
} else {
|
||||
@ -151,11 +149,6 @@ namespace MCGalaxy {
|
||||
}
|
||||
if (Server.TablistBots)
|
||||
TabList.Add(dst, b);
|
||||
|
||||
Server.s.Log("" + dst.HasCpeExt(CpeExt.EntityProperty));
|
||||
Server.s.Log("" + dst.HasCpeExt(CpeExt.EnvMapAspect));
|
||||
if (dst.HasCpeExt(CpeExt.EntityProperty))
|
||||
dst.Send(Packet.EntityProperty(b.id, EntityProp.RotZ, b.id * 80));
|
||||
}
|
||||
|
||||
internal static void Despawn(Player dst, byte id) {
|
||||
|
BIN
MCGalaxy/ProfilingSessions/Session20170208_080856.sdps
Normal file
BIN
MCGalaxy/ProfilingSessions/Session20170208_080856.sdps
Normal file
Binary file not shown.
@ -35,8 +35,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
/// <summary> Queues an action that is asynchronously executed one time, as soon as possible. </summary>
|
||||
public SchedulerTask QueueOnce(Action callback)
|
||||
{
|
||||
public SchedulerTask QueueOnce(Action callback) {
|
||||
return EnqueueTask(new SchedulerTask(obj => callback(), null, TimeSpan.Zero, false));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user