Bot commands only match against your levels, /bots output bot display name, update /env sidesheight to be /env sidesoffset instead

This commit is contained in:
UnknownShadow200 2017-04-16 15:28:03 +10:00
parent c01c2ab67a
commit 9aad601f2e
11 changed files with 36 additions and 44 deletions

View File

@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
string[] args = message.SplitSpaces();
PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, args[0]);
PlayerBot bot = Matcher.FindBotsInLevel(p, args[0]);
if (bot == null) return;
if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) {

View File

@ -27,28 +27,31 @@ namespace MCGalaxy.Commands {
public CmdBots() { }
public override void Use(Player p, string message) {
PlayerBot[] bots = PlayerBot.Bots.Items;
Level lvl = null;
Level lvl = p.level;
string[] args = message.SplitSpaces(2);
int ignored;
if (!(message == "" || args[0].CaselessEq("all"))) {
if (!(message == "" || args[0].CaselessEq("all") || int.TryParse(args[0], out ignored))) {
lvl = Matcher.FindLevels(p, args[0]);
if (lvl == null) return;
}
PlayerBot[] bots = PlayerBot.Bots.Items;
List<PlayerBot> inScope = new List<PlayerBot>();
foreach (PlayerBot bot in bots) {
if (lvl != null && bot.level != lvl) continue;
if (bot.level != lvl) continue;
inScope.Add(bot);
}
string cmd = lvl == null ? "bots all" : "bots " + lvl.name;
string cmd = lvl == p.level ? "bots" : "bots " + lvl.name;
string modifier = args.Length > 1 ? args[1] : "";
Player.Message(p, "Bots in {0}:", lvl.ColoredName);
MultiPageOutput.Output(p, inScope, FormatBot, cmd, "bots", modifier, false);
}
static string FormatBot(PlayerBot bot) {
string desc = bot.name + "(" + bot.level.name + ")";
string desc = bot.DisplayName;
if (bot.DisplayName != bot.name) desc += "%S(" + bot.name + ")";
if (bot.AIName != "") desc += "[" + bot.AIName + "]";
else if (bot.hunt) desc += "[Hunt]";
@ -57,8 +60,8 @@ namespace MCGalaxy.Commands {
}
public override void Help(Player p) {
Player.Message(p, "%T/bots %H- Shows a list of bots, their AIs and levels");
Player.Message(p, "%T/bots [level] %H- Only shows bots on the given level");
Player.Message(p, "%T/bots %H- Shows a list of bots on your level, and their AIs and levels");
Player.Message(p, "%T/bots [level] %H- Shows bots on the given level");
}
}
}

View File

@ -83,11 +83,11 @@ namespace MCGalaxy.Commands {
case "level":
LevelEnv.SetShort(p, value, EnvProp.EdgeLevel,
"water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel); break;
case "bedrocklevel":
case "sideslevel":
case "sidelevel":
LevelEnv.SetShort(p, value, EnvProp.SidesLevel,
"bedrock level", (short)(lvl.Height / 2 - 2), ref lvl.SidesLevel); break;
case "bedrockoffset":
case "sidesoffset":
case "sideoffset":
LevelEnv.SetShort(p, value, EnvProp.SidesOffset,
"bedrock offset", -2, ref lvl.SidesOffset); break;
case "maxfogdistance":
case "maxfog":
case "fogdistance":
@ -136,8 +136,8 @@ namespace MCGalaxy.Commands {
LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel,
"water level", (short)(lvl.Height / 2), ref lvl.EdgeLevel);
LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel,
"bedrock level", (short)(lvl.Height / 2 - 2), ref lvl.SidesLevel);
LevelEnv.SetShort(p, "normal", EnvProp.SidesOffset,
"bedrock offset", -2, ref lvl.SidesOffset);
LevelEnv.SetShort(p, "normal", EnvProp.CloudsLevel,
"clouds height", (short)(lvl.Height + 2), ref lvl.CloudsHeight);
}
@ -211,7 +211,7 @@ namespace MCGalaxy.Commands {
Player.Message(p, "%T/env [variable] [value]");
Player.Message(p, "%HVariables: fog, cloud, sky, sun, shadow, weather, level");
Player.Message(p, "%H horizon, border, preset, maxfog, cloudsheight");
Player.Message(p, "%H cloudspeed, weatherspeed, weatherfade, expfog, sideslevel");
Player.Message(p, "%H cloudspeed, weatherspeed, weatherfade, expfog, sidesoffset");
Player.Message(p, "%HUsing 'normal' as a value will reset the variable");
Player.Message(p, "%T/env normal %H- resets all variables");
}

View File

@ -28,7 +28,7 @@ namespace MCGalaxy.Commands {
Player who = null;
PlayerBot bot = null;
if (isBot) bot = PlayerBot.FindMatchesPreferLevel(p, args[1]);
if (isBot) bot = Matcher.FindBotsInLevel(p, args[1]);
else who = PlayerInfo.FindMatches(p, args[0]);
if (bot == null && who == null) return;

View File

@ -199,8 +199,8 @@ namespace MCGalaxy.Commands {
Player.Message(p, format, Color(data.Fog), Color(data.Sky), Color(data.Clouds),
Color(data.Light), Color(data.Shadow));
Player.Message(p, "Water level: &b{0}%S, Bedrock level: &b{1}%S, Clouds height: &b{2}%S, Max fog distance: &b{3}",
data.EdgeLevel, data.SidesLevel, data.CloudsHeight, data.MaxFog);
Player.Message(p, "Water level: &b{0}%S, Bedrock offset: &b{1}%S, Clouds height: &b{2}%S, Max fog distance: &b{3}",
data.EdgeLevel, data.SidesOffset, data.CloudsHeight, data.MaxFog);
Player.Message(p, "Edge Block: &b{0}%S, Horizon Block: &b{1}", data.EdgeBlock, data.HorizonBlock);
Player.Message(p, "Clouds speed: &b{0}%%S, Weather speed: &b{1}%",
(data.CloudsSpeed / 256f).ToString("F2"),
@ -220,7 +220,7 @@ namespace MCGalaxy.Commands {
// Env data
public string TerrainUrl, TextureUrl;
public string Fog, Sky, Clouds, Light, Shadow;
public int EdgeLevel, SidesLevel, CloudsHeight, MaxFog;
public int EdgeLevel, SidesOffset = -2, CloudsHeight, MaxFog;
public int CloudsSpeed = 256, WeatherSpeed = 256, WeatherFade = 128;
public byte EdgeBlock = Block.blackrock, HorizonBlock = Block.water;
public bool ExpFog;
@ -253,7 +253,7 @@ namespace MCGalaxy.Commands {
Fog = lvl.FogColor; Sky = lvl.SkyColor; Clouds = lvl.CloudColor;
Light = lvl.LightColor; Shadow = lvl.ShadowColor;
EdgeLevel = lvl.EdgeLevel; SidesLevel = lvl.SidesLevel; CloudsHeight = lvl.CloudsHeight;
EdgeLevel = lvl.EdgeLevel; SidesOffset = lvl.SidesOffset; CloudsHeight = lvl.CloudsHeight;
MaxFog = lvl.MaxFogDistance; ExpFog = lvl.ExpFog;
CloudsSpeed = lvl.CloudsSpeed; WeatherSpeed = lvl.WeatherSpeed;
EdgeBlock = (byte)lvl.EdgeBlock; HorizonBlock = (byte)lvl.HorizonBlock;
@ -275,16 +275,14 @@ namespace MCGalaxy.Commands {
Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path);
Width = dims.X; Height = dims.Y; Length = dims.Z;
EdgeLevel = Height / 2;
SidesLevel = int.MinValue;
CloudsHeight = Height + 2;
EdgeLevel = Height / 2; CloudsHeight = Height + 2;
BlockDBEntries = BlockDBFile.CountEntries(name);
path = LevelInfo.FindPropertiesFile(name);
if (path != null)
PropertiesFile.Read(path, ParseProperty, '=');
if (Authors == null) Authors = "";
if (SidesLevel == int.MinValue) SidesLevel = EdgeLevel - 2;
if (SidesOffset == int.MinValue) SidesOffset = EdgeLevel - 2;
}
void ParseProperty(string key, string value) {
@ -317,7 +315,7 @@ namespace MCGalaxy.Commands {
case "edgeblock": EdgeBlock = byte.Parse(value); break;
case "edgelevel": EdgeLevel = short.Parse(value); break;
case "sideslevel": SidesLevel = short.Parse(value); break;
case "sidesoffset": SidesOffset = short.Parse(value); break;
case "horizonblock": HorizonBlock = byte.Parse(value); break;
case "cloudsheight": CloudsHeight = short.Parse(value); break;
case "maxfog": MaxFog = short.Parse(value); break;

View File

@ -40,9 +40,7 @@ namespace MCGalaxy.Generator {
int grassHeight = lvl.Height / 2;
if (args.UseSeed && args.Seed >= 0 && args.Seed < lvl.Height)
grassHeight = args.Seed;
lvl.EdgeLevel = grassHeight + 1;
lvl.SidesLevel = lvl.EdgeLevel - 2;
fixed (byte* ptr = lvl.blocks) {
if (grassHeight > 0)

View File

@ -36,7 +36,6 @@ namespace MCGalaxy.Levels.IO {
Vec3U16 dims = ReadHeader(reader);
Level lvl = new Level(name, dims.X, dims.Y, dims.Z);
lvl.EdgeLevel = 0;
lvl.SidesLevel = lvl.EdgeLevel - 2;
byte[] blocks = lvl.blocks;
int size = dims.X * dims.Y * dims.Z, i = 0;

View File

@ -85,7 +85,6 @@ namespace MCGalaxy.Levels.IO {
if (lvl.EdgeLevel == -1)
lvl.EdgeLevel = (short)(lvl.Height / 2);
lvl.SidesLevel = lvl.EdgeLevel - 2;
if (!comp.Contains("TextureURL")) return;
string url = comp["TextureURL"].StringValue;

View File

@ -127,9 +127,9 @@ namespace MCGalaxy {
/// <summary> Elevation of the "ocean" that surrounds maps. Default is map height / 2. </summary>
[ConfigInt("EdgeLevel", "Env", null, -1, short.MinValue, short.MaxValue)]
public int EdgeLevel;
/// <summary> Elevation of the "bedrock" that surrounds map sides. Default is (map height / 2) - 2. </summary>
[ConfigInt("SidesLevel", "Env", null, -1, short.MinValue, short.MaxValue)]
public int SidesLevel;
/// <summary> Offset of the "bedrock" that surrounds map sides from edge level. Default is -2. </summary>
[ConfigInt("SidesOffset", "Env", null, -2, short.MinValue, short.MaxValue)]
public int SidesOffset = -2;
/// <summary> Elevation of the clouds. Default is map height + 2. </summary>
[ConfigInt("CloudsHeight", "Env", null, -1, short.MinValue, short.MaxValue)]
public int CloudsHeight;

View File

@ -77,7 +77,6 @@ namespace MCGalaxy {
name = n; MapName = n.ToLower();
BlockDB = new BlockDB(this);
EdgeLevel = (short)(y / 2);
SidesLevel = (short)(y / 2 - 2);
CloudsHeight = (short)(y + 2);
blocks = new byte[Width * Height * Length];
@ -382,7 +381,6 @@ namespace MCGalaxy {
}
public static void LoadMetadata(Level lvl) {
lvl.SidesLevel = int.MinValue;
try {
string propsPath = LevelInfo.FindPropertiesFile(lvl.MapName);
if (propsPath != null) {
@ -396,9 +394,6 @@ namespace MCGalaxy {
} catch (Exception e) {
Server.ErrorLog(e);
}
// backwards compatibility: old properties files don't have this field
if (lvl.SidesLevel == int.MinValue) lvl.SidesLevel = lvl.EdgeLevel - 2;
lvl.BlockDB.Cache.Enabled = lvl.UseBlockDB;
BlockDefinition[] defs = BlockDefinition.Load(false, lvl);

View File

@ -141,7 +141,7 @@ namespace MCGalaxy {
Send(Packet.EnvMapProperty(EnvProp.EdgeBlock, edge));
Send(Packet.EnvMapProperty(EnvProp.EdgeLevel, level.EdgeLevel));
Send(Packet.EnvMapProperty(EnvProp.SidesLevel, level.SidesLevel));
Send(Packet.EnvMapProperty(EnvProp.SidesOffset, level.SidesOffset));
Send(Packet.EnvMapProperty(EnvProp.CloudsLevel, level.CloudsHeight));
Send(Packet.EnvMapProperty(EnvProp.MaxFog, level.MaxFogDistance));
@ -264,7 +264,7 @@ namespace MCGalaxy {
SidesBlock = 0, EdgeBlock = 1, EdgeLevel = 2,
CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5,
WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8,
SidesLevel = 9,
SidesOffset = 9,
}
public enum EntityProp : byte {