public override bool Execute(PlayerBot bot, InstructionData data) { if (bot.curJump <= 0) { bot.curJump = 1; } bot.NextInstruction(); return(false); }
public override bool Execute(PlayerBot bot, InstructionData data) { bot.movementSpeed = (int)Math.Round(3m * (short)data.Metadata / 100m); if (bot.movementSpeed == 0) { bot.movementSpeed = 1; } bot.NextInstruction(); return(false); }
public override bool Execute(PlayerBot bot, InstructionData data) { Coords coords = (Coords)data.Metadata; bot.pos[0] = coords.X; bot.pos[1] = coords.Y; bot.pos[2] = coords.Z; bot.rot[0] = coords.RotX; bot.rot[1] = coords.RotY; bot.NextInstruction(); return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { Metadata meta = (Metadata)data.Metadata; if (bot.countdown == 0) { bot.countdown = meta.Seconds; return(true); } bot.countdown--; byte speed = (byte)meta.Speed; Orientation rot = bot.Rot; if (bot.nodUp) { if (rot.HeadX > 32 && rot.HeadX < 128) { bot.nodUp = !bot.nodUp; } else { if (rot.HeadX + speed > 255) { rot.HeadX = 0; } else { rot.HeadX += speed; } } } else { if (rot.HeadX > 128 && rot.HeadX < 224) { bot.nodUp = !bot.nodUp; } else { if (rot.HeadX - speed < 0) { rot.HeadX = 255; } else { rot.HeadX -= speed; } } } bot.Rot = rot; if (bot.countdown == 0) { bot.NextInstruction(); return(false); } 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 bool Execute(PlayerBot bot, InstructionData data) { Coords coords = (Coords)data.Metadata; bot.Pos = new Position(coords.X, coords.Y, coords.Z); bot.SetYawPitch(coords.RotX, coords.RotY); bot.NextInstruction(); return(true); }
public override InstructionData Parse(string[] args) { InstructionData data = default(InstructionData); Metadata meta = new Metadata(); meta.Seconds = short.Parse(args[1]); meta.Speed = short.Parse(args[2]); data.Metadata = meta; return(data); }
public override bool Execute(PlayerBot bot, InstructionData data) { Metadata meta = (Metadata)data.Metadata; if (bot.countdown == 0) { bot.countdown = meta.Seconds; return(true); } bot.countdown--; byte speed = meta.Speed; if (bot.nodUp) { if (bot.rot[1] > 32 && bot.rot[1] < 128) { bot.nodUp = !bot.nodUp; } else { if (bot.rot[1] + speed > 255) { bot.rot[1] = 0; } else { bot.rot[1] += speed; } } } else { if (bot.rot[1] > 128 && bot.rot[1] < 224) { bot.nodUp = !bot.nodUp; } else { if (bot.rot[1] - speed < 0) { bot.rot[1] = 255; } else { bot.rot[1] -= speed; } } } if (bot.countdown == 0) { bot.NextInstruction(); return(false); } return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { string script = (string)data.Metadata; if (File.Exists("bots/" + script)) { Command.all.Find("botset").Use(null, bot.name + " " + script); return(true); } bot.NextInstruction(); return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { string ai = (string)data.Metadata; if (File.Exists("bots/" + ai)) { ScriptFile.Parse(Player.Console, bot, ai); return(true); } bot.NextInstruction(); return(true); }
public override InstructionData Parse(string[] args) { Coords coords; coords.X = int.Parse(args[1]); coords.Y = int.Parse(args[2]); coords.Z = int.Parse(args[3]); coords.RotX = byte.Parse(args[4]); coords.RotY = byte.Parse(args[5]); InstructionData data = default(InstructionData); data.Metadata = coords; return(data); }
public override bool Execute(PlayerBot bot, InstructionData data) { if (bot.countdown == 0) { bot.countdown = (short)data.Metadata; return(true); } bot.countdown--; if (bot.countdown == 0) { bot.NextInstruction(); return(false); } return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { int dx = Math.Abs(bot.pos[0] - p.pos[0]); int dy = Math.Abs(bot.pos[1] - p.pos[1]); int dz = Math.Abs(bot.pos[2] - p.pos[2]); if (dx <= 8 && dy <= 16 && dz <= 8) { p.HandleDeath(Block.Invalid, 0); } } bot.NextInstruction(); return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { Coords target = (Coords)data.Metadata; bot.TargetPos = new Position(target.X, target.Y, target.Z); bot.movement = true; if (bot.Pos.BlockX == bot.TargetPos.BlockX && bot.Pos.BlockZ == bot.TargetPos.BlockZ) { bot.SetYawPitch(target.RotX, target.RotY); bot.movement = false; bot.NextInstruction(); return(false); } bot.AdvanceRotation(); return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { int search = 20000; if (data.Metadata != null) { search = (ushort)data.Metadata; } Player closest = HuntInstruction.ClosestPlayer(bot, search); if (closest == null) { return(true); } FaceTowards(bot, closest); return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { int searchRadius = 75; if (data.Metadata != null) { searchRadius = (ushort)data.Metadata; } int dist = searchRadius * 32; Player[] players = PlayerInfo.Online.Items; Player closest = null; foreach (Player p in players) { if (p.level != bot.level || p.invincible || p.hidden) { continue; } int dx = p.pos[0] - bot.pos[0], dy = p.pos[1] - bot.pos[1], dz = p.pos[2] - bot.pos[2]; int playerDist = Math.Abs(dx) + Math.Abs(dy) + Math.Abs(dz); if (playerDist >= dist) { continue; } closest = p; dist = playerDist; } if (closest == null) { bot.NextInstruction(); return(false); } bool overlapsPlayer = MoveTowards(bot, closest); if (overlapsPlayer) { bot.NextInstruction(); return(false); } return(true); }
public static bool Parse(Player p, PlayerBot bot, string ai) { string path = "bots/" + ai; if (!File.Exists(path)) { p.Message("Could not find specified AI."); return(false); } string[] instructions = File.ReadAllLines(path); if (instructions.Length == 0) { p.Message("No instructions in the AI."); return(false); } bot.AIName = ai; bot.Instructions.Clear(); bot.cur = 0; bot.countdown = 0; bot.movementSpeed = 3; foreach (string line in instructions) { if (line.IsCommentLine()) { continue; } string[] args = line.SplitSpaces(); try { BotInstruction ins = BotInstruction.Find(args[0]); if (ins == null) { continue; } InstructionData data = ins.Parse(args); data.Name = args[0]; bot.Instructions.Add(data); } catch { p.Message("AI file corrupt."); return(false); } } return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { Coords target = (Coords)data.Metadata; bot.foundPos[0] = target.X; bot.foundPos[1] = target.Y; bot.foundPos[2] = target.Z; bot.movement = true; if ((ushort)(bot.pos[0] / 32) == (ushort)(target.X / 32)) { if ((ushort)(bot.pos[2] / 32) == (ushort)(target.Z / 32)) { bot.rot[0] = target.RotX; bot.rot[1] = target.RotY; bot.movement = false; bot.NextInstruction(); return(false); } } bot.AdvanceRotation(); return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { Metadata meta = (Metadata)data.Metadata; if (bot.countdown == 0) { bot.countdown = meta.Seconds; return(true); } bot.countdown--; Orientation rot = bot.Rot; rot.RotY += (byte)meta.Speed; bot.Rot = rot; if (bot.countdown == 0) { bot.NextInstruction(); return(false); } return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { int dx = Math.Abs(bot.Pos.X - p.Pos.X); int dy = Math.Abs(bot.Pos.Y - p.Pos.Y); int dz = Math.Abs(bot.Pos.Z - p.Pos.Z); if (dx <= 8 && dy <= 16 && dz <= 8) { string msg = bot.DeathMessage; if (msg == null) { msg = "@p %Swas &cterminated."; } p.HandleDeath((ExtBlock)Block.Cobblestone, msg); } } bot.NextInstruction(); return(true); }
public static bool Parse(Player p, PlayerBot bot, string file) { if (!File.Exists(file)) { Player.Message(p, "Could not find specified AI."); return(false); } string[] instructions = File.ReadAllLines(file); if (instructions.Length == 0 || !instructions[0].CaselessEq("#Version 2")) { Player.Message(p, "Invalid file version. Remake"); return(false); } bot.Instructions.Clear(); bot.cur = 0; bot.countdown = 0; bot.movementSpeed = 3; foreach (string line in instructions) { if (line.Length == 0 || line[0] == '#') { continue; } string[] args = line.SplitSpaces(); try { BotInstruction ins = BotInstruction.Find(args[0]); if (ins == null) { continue; } InstructionData data = ins.Parse(args); data.Name = args[0]; bot.Instructions.Add(data); } catch { Player.Message(p, "AI file corrupt."); return(false); } } return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { int search = 75; if (data.Metadata != null) { search = (ushort)data.Metadata; } Player closest = ClosestPlayer(bot, search); if (closest == null) { bot.NextInstruction(); return(false); } bool overlapsPlayer = MoveTowards(bot, closest); if (overlapsPlayer) { bot.NextInstruction(); return(false); } return(true); }
public override bool Execute(PlayerBot bot, InstructionData data) { bot.jumping = true; bot.NextInstruction(); return(false); }
public override bool Execute(PlayerBot bot, InstructionData data) { bot.cur = 0; return(false); }
/// <summary> Performs a tick for this instruction. </summary> /// <returns> false if the bot should proceed to execute the /// next instruction in the same tick. </returns> public abstract bool Execute(PlayerBot bot, InstructionData data);
public override bool Execute(PlayerBot bot, InstructionData data) { PlayerBot.Remove(bot); return(true); }