mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
You can change LS settings while game is running
This commit is contained in:
parent
f7c762fc4c
commit
10465903fe
@ -51,11 +51,11 @@ namespace MCGalaxy.Commands.Fun {
|
||||
} else if (IsDeleteCommand(prop)) {
|
||||
HandleRemove(p);
|
||||
} if (prop.CaselessEq("bluespawn")) {
|
||||
cfg.BlueSpawnX = p.Pos.X; cfg.BlueSpawnY = p.Pos.Y; cfg.BlueSpawnZ = p.Pos.Z;
|
||||
cfg.BlueSpawn = (Vec3U16)p.Pos.FeetBlockCoords;
|
||||
Player.Message(p, "Set spawn of blue team to your position.");
|
||||
UpdateConfig(p, cfg);
|
||||
} else if (prop.CaselessEq("redspawn")) {
|
||||
cfg.RedSpawnX = p.Pos.X; cfg.RedSpawnY = p.Pos.Y; cfg.RedSpawnZ = p.Pos.Z;
|
||||
cfg.RedSpawn = (Vec3U16)p.Pos.FeetBlockCoords;
|
||||
Player.Message(p, "Set spawn of red team to your position.");
|
||||
UpdateConfig(p, cfg);
|
||||
} else if (prop.CaselessEq("blueflag")) {
|
||||
@ -100,11 +100,11 @@ namespace MCGalaxy.Commands.Fun {
|
||||
|
||||
static bool BlueFlagCallback(Player p, Vec3S32[] marks, object state, BlockID block) {
|
||||
CtfMapConfig cfg = RetrieveConfig(p);
|
||||
Vec3S32 P = marks[0];
|
||||
cfg.BlueFlagX = P.X; cfg.BlueFlagY = P.Y; cfg.BlueFlagZ = P.Z;
|
||||
Vec3U16 P = (Vec3U16)marks[0];
|
||||
cfg.BlueFlagPos = P;
|
||||
Player.Message(p, "Set flag position of blue team to ({0})", P);
|
||||
|
||||
block = p.level.GetBlock((ushort)P.X, (ushort)P.Y, (ushort)P.Z);
|
||||
block = p.level.GetBlock(P.X, P.Y, P.Z);
|
||||
if (block == Block.Air) block = Block.Blue;
|
||||
cfg.BlueFlagBlock = block;
|
||||
Player.Message(p, "Set flag block of blue team to {0}", Block.GetName(p, block));
|
||||
@ -115,11 +115,11 @@ namespace MCGalaxy.Commands.Fun {
|
||||
|
||||
static bool RedFlagCallback(Player p, Vec3S32[] marks, object state, BlockID block) {
|
||||
CtfMapConfig cfg = RetrieveConfig(p);
|
||||
Vec3S32 P = marks[0];
|
||||
cfg.RedFlagX = P.X; cfg.RedFlagY = P.Y; cfg.RedFlagZ = P.Z;
|
||||
Vec3U16 P = (Vec3U16)marks[0];
|
||||
cfg.RedFlagPos = P;
|
||||
Player.Message(p, "Set flag position of red team to ({0})", P);
|
||||
|
||||
block = p.level.GetBlock((ushort)P.X, (ushort)P.Y, (ushort)P.Z);
|
||||
block = p.level.GetBlock(P.X, P.Y, P.Z);
|
||||
if (block == Block.Air) block = Block.Red;
|
||||
cfg.RedFlagBlock = block;
|
||||
Player.Message(p, "Set flag block of red team to {0}", Block.GetName(p, block));
|
||||
|
@ -107,7 +107,7 @@ namespace MCGalaxy.Commands.Fun {
|
||||
}
|
||||
|
||||
game.FreezeMode = mode == "freeze" || mode == "frozen";
|
||||
game.SpeedType = speed;
|
||||
game.SpeedType = speed;
|
||||
game.Start(p, "countdown", int.MaxValue);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ namespace MCGalaxy.Commands.Fun {
|
||||
|
||||
if (p == null) { Player.Message(p, "/{0} setup can only be used in-game.", name); return; }
|
||||
if (args.Length < 2) { SetupHelp(p); return; }
|
||||
if (game.Running) { Player.Message(p, "You cannot configure Lava Survival while a game is active."); return; }
|
||||
string group = args[1];
|
||||
|
||||
LSGame ls = (LSGame)game;
|
||||
|
@ -20,43 +20,26 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using MCGalaxy.Config;
|
||||
using MCGalaxy.Maths;
|
||||
using BlockID = System.UInt16;
|
||||
|
||||
namespace MCGalaxy.Games {
|
||||
|
||||
public sealed class CtfMapConfig {
|
||||
|
||||
[ConfigInt("base.red.x", null, 0)]
|
||||
public int RedFlagX;
|
||||
[ConfigInt("base.red.y", null, 0)]
|
||||
public int RedFlagY;
|
||||
[ConfigInt("base.red.z", null, 0)]
|
||||
public int RedFlagZ;
|
||||
|
||||
[ConfigVec3("base.red.pos", null)]
|
||||
public Vec3U16 RedFlagPos;
|
||||
[ConfigBlock("base.red.block", null, Block.Air)]
|
||||
public BlockID RedFlagBlock;
|
||||
[ConfigVec3("base.red.spawn", null)]
|
||||
public Vec3U16 RedSpawn;
|
||||
|
||||
[ConfigInt("base.blue.x", null, 0)]
|
||||
public int BlueFlagX;
|
||||
[ConfigInt("base.blue.y", null, 0)]
|
||||
public int BlueFlagY;
|
||||
[ConfigInt("base.blue.z", null, 0)]
|
||||
public int BlueFlagZ;
|
||||
[ConfigVec3("base.blue.pos", null)]
|
||||
public Vec3U16 BlueFlagPos;
|
||||
[ConfigBlock("base.blue.block", null, Block.Air)]
|
||||
public BlockID BlueFlagBlock;
|
||||
|
||||
[ConfigInt("base.red.spawnx", null, 0)]
|
||||
public int RedSpawnX;
|
||||
[ConfigInt("base.red.spawny", null, 0)]
|
||||
public int RedSpawnY;
|
||||
[ConfigInt("base.red.spawnz", null, 0)]
|
||||
public int RedSpawnZ;
|
||||
|
||||
[ConfigInt("base.blue.spawnx", null, 0)]
|
||||
public int BlueSpawnX;
|
||||
[ConfigInt("base.blue.spawny", null, 0)]
|
||||
public int BlueSpawnY;
|
||||
[ConfigInt("base.blue.spawnz", null, 0)]
|
||||
public int BlueSpawnZ;
|
||||
[ConfigVec3("base.blue.spawn", null)]
|
||||
public Vec3U16 BlueSpawn;
|
||||
|
||||
[ConfigInt("map.line.z", null, 0)]
|
||||
public int ZDivider;
|
||||
@ -72,20 +55,16 @@ namespace MCGalaxy.Games {
|
||||
public int Capture_PointsLost;
|
||||
|
||||
|
||||
/// <summary> Sets the default CTF config values for the given map. </summary>
|
||||
public void SetDefaults(Level map) {
|
||||
ZDivider = map.Length / 2;
|
||||
RedFlagBlock = Block.Red;
|
||||
public void SetDefaults(Level lvl) {
|
||||
ZDivider = lvl.Length / 2;
|
||||
RedFlagBlock = Block.Red;
|
||||
BlueFlagBlock = Block.Blue;
|
||||
int midX = map.Width / 2, maxZ = map.Length - 1;
|
||||
ushort midX = (ushort)(lvl.Width / 2), maxZ = (ushort)(lvl.Length - 1);
|
||||
|
||||
RedFlagX = midX; RedSpawnX = midX * 32;
|
||||
RedFlagY = 6; RedSpawnY = 4 * 32 + Entities.CharacterHeight;
|
||||
RedFlagZ = 0; RedSpawnZ = 0 * 32;
|
||||
|
||||
BlueFlagX = midX; BlueSpawnX = midX * 32;
|
||||
BlueFlagY = 6; BlueSpawnY = 4 * 32 + Entities.CharacterHeight;
|
||||
BlueFlagZ = maxZ; BlueSpawnZ = maxZ * 32;
|
||||
RedFlagPos = new Vec3U16(midX, 6, 0);
|
||||
RedSpawn = new Vec3U16(midX, 4, 0);
|
||||
BlueFlagPos = new Vec3U16(midX, 6, maxZ);
|
||||
BlueSpawn = new Vec3U16(midX, 4, maxZ);
|
||||
|
||||
RoundPoints = 3;
|
||||
Tag_PointsGained = 5;
|
||||
|
@ -120,8 +120,11 @@ namespace MCGalaxy.Games {
|
||||
if (p.level != Map) return;
|
||||
CtfTeam team = TeamOf(p);
|
||||
|
||||
if (team != null) pos = team.SpawnPos;
|
||||
if (team != null && respawning) DropFlag(p, team);
|
||||
if (team == null) return;
|
||||
if (respawning) DropFlag(p, team);
|
||||
|
||||
Vec3U16 coords = team.SpawnPos;
|
||||
pos = Position.FromFeetBlockCoords(coords.X, coords.Y, coords.Z);
|
||||
}
|
||||
|
||||
void HandleTabListEntryAdded(Entity entity, ref string tabName, ref string tabGroup, Player dst) {
|
||||
|
@ -37,8 +37,7 @@ namespace MCGalaxy.Games {
|
||||
public string Name, Color;
|
||||
public string ColoredName { get { return Color + Name; } }
|
||||
public int Captures;
|
||||
public Vec3U16 FlagPos;
|
||||
public Position SpawnPos;
|
||||
public Vec3U16 FlagPos, SpawnPos;
|
||||
public BlockID FlagBlock;
|
||||
public VolatileArray<Player> Members = new VolatileArray<Player>();
|
||||
|
||||
@ -83,12 +82,12 @@ namespace MCGalaxy.Games {
|
||||
CtfMapConfig cfg = Config;
|
||||
|
||||
Red.FlagBlock = cfg.RedFlagBlock;
|
||||
Red.FlagPos = new Vec3U16((ushort)cfg.RedFlagX, (ushort)cfg.RedFlagY, (ushort)cfg.RedFlagZ);
|
||||
Red.SpawnPos = new Position(cfg.RedSpawnX, cfg.RedSpawnY, cfg.RedSpawnZ);
|
||||
Red.FlagPos = cfg.RedFlagPos;
|
||||
Red.SpawnPos = cfg.RedSpawn;
|
||||
|
||||
Blue.FlagBlock = cfg.BlueFlagBlock;
|
||||
Blue.FlagPos = new Vec3U16((ushort)cfg.BlueFlagX, (ushort)cfg.BlueFlagY, (ushort)cfg.BlueFlagZ);
|
||||
Blue.SpawnPos = new Position(cfg.BlueSpawnX, cfg.BlueSpawnY, cfg.BlueSpawnZ);
|
||||
Blue.FlagPos = cfg.BlueFlagPos;
|
||||
Blue.SpawnPos = cfg.BlueSpawn;
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,10 +104,6 @@ namespace MCGalaxy.Games {
|
||||
protected override bool SetMap(string map) {
|
||||
bool success = base.SetMap(map);
|
||||
if (!success) return false;
|
||||
|
||||
cfg = new LSMapConfig();
|
||||
cfg.SetDefaults(Map);
|
||||
cfg.Load(Map.name);
|
||||
UpdateMapConfig();
|
||||
|
||||
Map.SetPhysics(destroyMode ? 2 : 1);
|
||||
|
@ -55,6 +55,10 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
public void UpdateMapConfig() {
|
||||
cfg = new LSMapConfig();
|
||||
cfg.SetDefaults(Map);
|
||||
cfg.Load(Map.name);
|
||||
|
||||
killerMode = rand.Next(1, 101) <= cfg.KillerChance;
|
||||
destroyMode = rand.Next(1, 101) <= cfg.DestroyChance;
|
||||
waterMode = rand.Next(1, 101) <= cfg.WaterChance;
|
||||
|
@ -101,12 +101,12 @@ namespace MCGalaxy {
|
||||
string[] parts = line.Split(':');
|
||||
Warp warp = new Warp();
|
||||
try {
|
||||
warp.Name = parts[0];
|
||||
warp.Name = parts[0];
|
||||
warp.Level = parts[1];
|
||||
warp.Pos.X = int.Parse(parts[2]);
|
||||
warp.Pos.Y = int.Parse(parts[3]);
|
||||
warp.Pos.Z = int.Parse(parts[4]);
|
||||
warp.Yaw = byte.Parse(parts[5]);
|
||||
warp.Yaw = byte.Parse(parts[5]);
|
||||
warp.Pitch = byte.Parse(parts[6]);
|
||||
Items.Add(warp);
|
||||
} catch {
|
||||
|
Loading…
x
Reference in New Issue
Block a user