Skip to content

Commit

Permalink
Allow /where bot to see bot positions, improve /where output format
Browse files Browse the repository at this point in the history
  • Loading branch information
Goodlyay committed Apr 29, 2024
1 parent 8d892df commit 197f37d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
36 changes: 20 additions & 16 deletions MCGalaxy/Commands/Information/CmdWhere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,31 @@ public sealed class CmdWhere : Command2
public override string type { get { return CommandTypes.Information; } }

public override void Use(Player p, string message, CommandData data) {
if (message.Length == 0) message = p.name;
Player target = PlayerInfo.FindMatches(p, message);
if (target == null) return;

if (IGame.GameOn(target.level) != null && !(p.IsSuper || p.Game.Referee)) {
p.Message("You can only use /where on people in games when you are in referee mode."); return;
Entity target;
string targetName;
if (message.CaselessStarts("bot ")) {
string botName = message.SplitSpaces(2)[1];
target = Matcher.FindBots(p, botName);
if (target == null) return;
targetName = "Bot " + ((PlayerBot)target).DisplayName;
} else {
if (message.Length == 0) message = p.name;
target = PlayerInfo.FindMatches(p, message);
if (target == null) return;
if (IGame.GameOn(target.Level) != null && !(p.IsSuper || p.Game.Referee)) {
p.Message("You can only use /where on people in games when you are in referee mode."); return;
}
targetName = p.FormatNick((Player)target);
}

int x = target.Pos.X, y = target.Pos.Y - Entities.CharacterHeight, z = target.Pos.Z;
p.Message("{0} &Sis on {1}", p.FormatNick(target), target.level.ColoredName);
p.Message(" X: &b{0:F5} &SY: &b{1:F5} &SZ: &b{2:F5}",
x / 32.0, y / 32.0, z / 32.0);

p.Message(" Yaw: &b{0} &Sdegrees, Pitch: &b{1} &Sdegrees",
Orientation.PackedToDegrees(target.Rot.RotY),
Orientation.PackedToDegrees(target.Rot.HeadX));
}

target.DisplayPosition(p, p.FormatNick(targetName));
}

public override void Help(Player p) {
p.Message("&T/Where [name]");
p.Message("&HDisplays level, position, and orientation of that player.");
p.Message("&T/Where bot [name]");
p.Message("&HDisplays level, position, and orientation of that bot.");
}
}
}
13 changes: 13 additions & 0 deletions MCGalaxy/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,18 @@ public void UpdateModel(string model) {
SetModel(model);
Entities.BroadcastModel(this, model);
}
public void DisplayPosition(Player p, string displayName) {
Vec3S32 feet = Pos.FeetBlockCoords;
int x = Pos.X, y = Pos.Y - Entities.CharacterHeight, z = Pos.Z;
p.Message("{0} &Sis on {1}", displayName, Level.ColoredName);
p.Message(" Block coords: &b{0} {1} {2}",
feet.X, feet.Y, feet.Z);
p.Message(" Precise coords: &b{0} {1} {2}",
x, y, z);

p.Message("Yaw pitch degrees: &b{0} {1}",
Orientation.PackedToDegrees(Rot.RotY),
Orientation.PackedToDegrees(Rot.HeadX));
}
}
}

0 comments on commit 197f37d

Please sign in to comment.