mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
break everything
This commit is contained in:
parent
231f0dbc1a
commit
88b38a1c4b
@ -203,7 +203,7 @@ namespace MCGalaxy.Bots {
|
|||||||
CurInstruction = bot.cur;
|
CurInstruction = bot.cur;
|
||||||
|
|
||||||
X = bot.pos[0]; Y = bot.pos[1]; Z = bot.pos[2];
|
X = bot.pos[0]; Y = bot.pos[1]; Z = bot.pos[2];
|
||||||
RotX = bot.rot[0]; RotY = bot.rot[1];
|
RotX = bot.Rot.RotY; RotY = bot.Rot.HeadX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BotProperties Copy() {
|
public BotProperties Copy() {
|
||||||
|
@ -29,10 +29,9 @@ namespace MCGalaxy.Bots {
|
|||||||
if (bot.countdown == 0) { bot.countdown = meta.Seconds; return true; }
|
if (bot.countdown == 0) { bot.countdown = meta.Seconds; return true; }
|
||||||
bot.countdown--;
|
bot.countdown--;
|
||||||
|
|
||||||
byte speed = meta.Speed;
|
Orientation rot = bot.Rot;
|
||||||
if (bot.rot[0] + speed > 255) bot.rot[0] = 0;
|
rot.RotY += meta.Speed;
|
||||||
else if (bot.rot[0] + speed < 0) bot.rot[0] = 255;
|
bot.rot = Rot;
|
||||||
else bot.rot[0] += speed;
|
|
||||||
|
|
||||||
if (bot.countdown == 0) { bot.NextInstruction(); return false; }
|
if (bot.countdown == 0) { bot.NextInstruction(); return false; }
|
||||||
return true;
|
return true;
|
||||||
@ -74,21 +73,23 @@ namespace MCGalaxy.Bots {
|
|||||||
bot.countdown--;
|
bot.countdown--;
|
||||||
|
|
||||||
byte speed = meta.Speed;
|
byte speed = meta.Speed;
|
||||||
|
Orientation rot = bot.Rot;
|
||||||
if (bot.nodUp) {
|
if (bot.nodUp) {
|
||||||
if (bot.rot[1] > 32 && bot.rot[1] < 128) {
|
if (rot.HeadX > 32 && rot.HeadX < 128) {
|
||||||
bot.nodUp = !bot.nodUp;
|
bot.nodUp = !bot.nodUp;
|
||||||
} else {
|
} else {
|
||||||
if (bot.rot[1] + speed > 255) bot.rot[1] = 0;
|
if (rot.HeadX + speed > 255) rot.HeadX = 0;
|
||||||
else bot.rot[1] += speed;
|
else rot.HeadX += speed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (bot.rot[1] > 128 && bot.rot[1] < 224) {
|
if (rot.HeadX > 128 && rot.HeadX < 224) {
|
||||||
bot.nodUp = !bot.nodUp;
|
bot.nodUp = !bot.nodUp;
|
||||||
} else {
|
} else {
|
||||||
if (bot.rot[1] - speed < 0) bot.rot[1] = 255;
|
if (rot.HeadX - speed < 0) rot.HeadX = 255;
|
||||||
else bot.rot[1] -= speed;
|
else rot.HeadX -= speed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bot.Rot = rot;
|
||||||
|
|
||||||
if (bot.countdown == 0) { bot.NextInstruction(); return false; }
|
if (bot.countdown == 0) { bot.NextInstruction(); return false; }
|
||||||
return true;
|
return true;
|
||||||
|
@ -60,19 +60,15 @@ namespace MCGalaxy.Bots {
|
|||||||
|
|
||||||
Vec3F32 dir = new Vec3F32(dx, dy, dz);
|
Vec3F32 dir = new Vec3F32(dx, dy, dz);
|
||||||
dir = Vec3F32.Normalise(dir);
|
dir = Vec3F32.Normalise(dir);
|
||||||
byte yaw, pitch;
|
Orientation rot;
|
||||||
DirUtils.GetYawPitch(dir, out yaw, out pitch);
|
DirUtils.GetYawPitch(dir, out rot.RotY, out rot.HeadX);
|
||||||
|
|
||||||
// If we are very close to a player, switch from trying to look
|
// If we are very close to a player, switch from trying to look
|
||||||
// at them to just facing the opposite direction to them
|
// at them to just facing the opposite direction to them
|
||||||
if (Math.Abs(dx) >= 4 || Math.Abs(dz) >= 4) {
|
if (Math.Abs(dx) < 4 && Math.Abs(dz) < 4) {
|
||||||
bot.rot[0] = yaw;
|
rot.HeadX = (byte)(p.rot[0] + 128);
|
||||||
} else if (p.rot[0] < 128) {
|
|
||||||
bot.rot[0] = (byte)(p.rot[0] + 128);
|
|
||||||
} else {
|
|
||||||
bot.rot[0] = (byte)(p.rot[0] - 128);
|
|
||||||
}
|
}
|
||||||
bot.rot[1] = pitch;
|
bot.Rot = rot;
|
||||||
|
|
||||||
return dx <= 8 && dy <= 16 && dz <= 8;
|
return dx <= 8 && dy <= 16 && dz <= 8;
|
||||||
}
|
}
|
||||||
@ -157,7 +153,10 @@ namespace MCGalaxy.Bots {
|
|||||||
int dx = p.pos[0] - bot.pos[0], dy = p.pos[1] - bot.pos[1], dz = p.pos[2] - bot.pos[2];
|
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);
|
Vec3F32 dir = new Vec3F32(dx, dy, dz);
|
||||||
dir = Vec3F32.Normalise(dir);
|
dir = Vec3F32.Normalise(dir);
|
||||||
DirUtils.GetYawPitch(dir, out bot.rot[0], out bot.rot[1]);
|
|
||||||
|
Orientation rot = bot.Rot;
|
||||||
|
DirUtils.GetYawPitch(dir, out rot.RotY, out rot.HeadX);
|
||||||
|
bot.Rot = rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string[] Help { get { return help; } }
|
public override string[] Help { get { return help; } }
|
||||||
|
@ -27,7 +27,11 @@ namespace MCGalaxy.Bots {
|
|||||||
public override bool Execute(PlayerBot bot, InstructionData data) {
|
public override bool Execute(PlayerBot bot, InstructionData data) {
|
||||||
Coords coords = (Coords)data.Metadata;
|
Coords coords = (Coords)data.Metadata;
|
||||||
bot.pos[0] = coords.X; bot.pos[1] = coords.Y; bot.pos[2] = coords.Z;
|
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;
|
|
||||||
|
Orientation rot = bot.Rot;
|
||||||
|
rot.RotY = coords.RotX; rot.HeadX = coords.RotY;
|
||||||
|
bot.Rot = rot;
|
||||||
|
|
||||||
bot.NextInstruction();
|
bot.NextInstruction();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -73,7 +77,10 @@ namespace MCGalaxy.Bots {
|
|||||||
|
|
||||||
if ((ushort)(bot.pos[0] / 32) == (ushort)(target.X / 32)) {
|
if ((ushort)(bot.pos[0] / 32) == (ushort)(target.X / 32)) {
|
||||||
if ((ushort)(bot.pos[2] / 32) == (ushort)(target.Z / 32)) {
|
if ((ushort)(bot.pos[2] / 32) == (ushort)(target.Z / 32)) {
|
||||||
bot.rot[0] = target.RotX; bot.rot[1] = target.RotY;
|
Orientation rot = bot.Rot;
|
||||||
|
rot.RotY = target.RotX; rot.HeadX = target.RotY;
|
||||||
|
bot.Rot = rot;
|
||||||
|
|
||||||
bot.movement = false;
|
bot.movement = false;
|
||||||
bot.NextInstruction(); return false;
|
bot.NextInstruction(); return false;
|
||||||
}
|
}
|
||||||
|
@ -241,12 +241,14 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public void AdvanceRotation() {
|
public void AdvanceRotation() {
|
||||||
if (!movement && Instructions.Count > 0) {
|
if (!movement && Instructions.Count > 0) {
|
||||||
if (rot[0] < 245) rot[0] += 8;
|
Orientation rot = Rot;
|
||||||
else rot[0] = 0;
|
if (rot.RotY < 245) rot.RotY += 8;
|
||||||
|
else rot.RotY = 0;
|
||||||
|
|
||||||
if (rot[1] > 32 && rot[1] < 64) rot[1] = 224;
|
if (rot.HeadX > 32 && rot.HeadX < 64) rot.HeadX = 224;
|
||||||
else if (rot[1] > 250) rot[1] = 0;
|
else if (rot.HeadX > 250) rot.HeadX = 0;
|
||||||
else rot[1] += 4;
|
else rot.HeadX += 4;
|
||||||
|
Rot = rot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,8 +216,8 @@ namespace MCGalaxy {
|
|||||||
NetUtils.WriteU16(bot.pos[0], buffer, 2);
|
NetUtils.WriteU16(bot.pos[0], buffer, 2);
|
||||||
NetUtils.WriteU16(bot.pos[1], buffer, 4);
|
NetUtils.WriteU16(bot.pos[1], buffer, 4);
|
||||||
NetUtils.WriteU16(bot.pos[2], buffer, 6);
|
NetUtils.WriteU16(bot.pos[2], buffer, 6);
|
||||||
buffer[8] = bot.rot[0];
|
buffer[8] = bot.Rot.RotY;
|
||||||
buffer[9] = bot.rot[1];
|
buffer[9] = bot.Rot.HeadX;
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user