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