mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Fix bots that have jump AI, having their position set to middle of jump Y on level unload, which causes them to reappear higher up on level load next time
This commit is contained in:
parent
d8954e5c38
commit
5c7af8b877
@ -98,6 +98,7 @@ namespace MCGalaxy.Bots {
|
|||||||
public bool Kill { get; set; }
|
public bool Kill { get; set; }
|
||||||
public bool Hunt { get; set; }
|
public bool Hunt { get; set; }
|
||||||
public int CurInstruction { get; set; }
|
public int CurInstruction { get; set; }
|
||||||
|
public sbyte CurJump { get; set; }
|
||||||
|
|
||||||
public int X { get; set; }
|
public int X { get; set; }
|
||||||
public int Y { get; set; }
|
public int Y { get; set; }
|
||||||
@ -113,7 +114,7 @@ namespace MCGalaxy.Bots {
|
|||||||
Model = bot.Model; Color = bot.color;
|
Model = bot.Model; Color = bot.color;
|
||||||
Kill = bot.kill; Hunt = bot.hunt;
|
Kill = bot.kill; Hunt = bot.hunt;
|
||||||
DisplayName = bot.DisplayName;
|
DisplayName = bot.DisplayName;
|
||||||
CurInstruction = bot.cur;
|
CurInstruction = bot.cur; CurJump = bot.curJump;
|
||||||
ClickedOnText = bot.ClickedOnText;
|
ClickedOnText = bot.ClickedOnText;
|
||||||
|
|
||||||
X = bot.Pos.X; Y = bot.Pos.Y; Z = bot.Pos.Z;
|
X = bot.Pos.X; Y = bot.Pos.Y; Z = bot.Pos.Z;
|
||||||
@ -132,7 +133,7 @@ namespace MCGalaxy.Bots {
|
|||||||
bot.AIName = AI; bot.hunt = Hunt; bot.kill = Kill;
|
bot.AIName = AI; bot.hunt = Hunt; bot.kill = Kill;
|
||||||
bot.DisplayName = DisplayName;
|
bot.DisplayName = DisplayName;
|
||||||
|
|
||||||
bot.cur = CurInstruction;
|
bot.cur = CurInstruction; bot.curJump = CurJump;
|
||||||
bot.ClickedOnText = ClickedOnText;
|
bot.ClickedOnText = ClickedOnText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ namespace MCGalaxy.Bots {
|
|||||||
copy.Model = Model; copy.Color = Color;
|
copy.Model = Model; copy.Color = Color;
|
||||||
|
|
||||||
copy.AI = AI; copy.Kill = Kill; copy.Hunt = Hunt;
|
copy.AI = AI; copy.Kill = Kill; copy.Hunt = Hunt;
|
||||||
copy.CurInstruction = CurInstruction;
|
copy.CurInstruction = CurInstruction; copy.CurJump = CurJump;
|
||||||
copy.ClickedOnText = ClickedOnText;
|
copy.ClickedOnText = ClickedOnText;
|
||||||
|
|
||||||
copy.X = X; copy.Y = Y; copy.Z = Z;
|
copy.X = X; copy.Y = Y; copy.Z = Z;
|
||||||
|
@ -66,7 +66,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bot.jumping) DoJump(bot);
|
if (bot.curJump > 0) DoJump(bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool DoInstruction(PlayerBot bot) {
|
static bool DoInstruction(PlayerBot bot) {
|
||||||
@ -75,16 +75,16 @@ namespace MCGalaxy {
|
|||||||
return ins.Execute(bot, bot.Instructions[bot.cur]);
|
return ins.Execute(bot, bot.Instructions[bot.cur]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoJump(PlayerBot bot) {
|
static void DoJump(PlayerBot bot) {
|
||||||
bot.currentjump++;
|
|
||||||
Position pos = bot.Pos;
|
Position pos = bot.Pos;
|
||||||
switch (bot.currentjump) {
|
switch (bot.curJump) {
|
||||||
case 1: pos.Y += 24; break;
|
case 1: pos.Y += 24; break;
|
||||||
case 2: pos.Y += 12; break;
|
case 2: pos.Y += 12; break;
|
||||||
case 3: break;
|
case 3: break;
|
||||||
case 4: pos.Y -= 12; break;
|
case 4: pos.Y -= 12; break;
|
||||||
case 5: pos.Y -= 24; bot.jumping = false; bot.currentjump = 0; break;
|
case 5: pos.Y -= 24; bot.curJump = -1; break;
|
||||||
}
|
}
|
||||||
|
bot.curJump++;
|
||||||
bot.Pos = pos;
|
bot.Pos = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ namespace MCGalaxy.Bots {
|
|||||||
public JumpInstruction() { Name = "jump"; }
|
public JumpInstruction() { Name = "jump"; }
|
||||||
|
|
||||||
public override bool Execute(PlayerBot bot, InstructionData data) {
|
public override bool Execute(PlayerBot bot, InstructionData data) {
|
||||||
bot.jumping = true;
|
if (bot.curJump <= 0) bot.curJump = 1;
|
||||||
bot.NextInstruction(); return false;
|
bot.NextInstruction(); return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +43,7 @@ namespace MCGalaxy {
|
|||||||
public Position TargetPos;
|
public Position TargetPos;
|
||||||
public bool movement = false;
|
public bool movement = false;
|
||||||
public int movementSpeed = 3;
|
public int movementSpeed = 3;
|
||||||
internal bool jumping = false;
|
internal sbyte curJump = 0;
|
||||||
internal int currentjump = 0;
|
|
||||||
|
|
||||||
public PlayerBot(string n, Level lvl) { Init(n, lvl); }
|
public PlayerBot(string n, Level lvl) { Init(n, lvl); }
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ namespace MCGalaxy {
|
|||||||
public static void Remove(PlayerBot bot, bool save = true) {
|
public static void Remove(PlayerBot bot, bool save = true) {
|
||||||
bot.level.Bots.Remove(bot);
|
bot.level.Bots.Remove(bot);
|
||||||
bot.GlobalDespawn();
|
bot.GlobalDespawn();
|
||||||
bot.jumping = false;
|
bot.curJump = 0;
|
||||||
if (save) BotsFile.Save(bot.level);
|
if (save) BotsFile.Save(bot.level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user