mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
ZS: Allow people to go to different maps during a round.
This commit is contained in:
parent
baa337d225
commit
9ac7b17c8b
@ -127,7 +127,7 @@ namespace MCGalaxy.Commands.Fun {
|
||||
static void UpdateConfig(Player p, CTFConfig cfg) {
|
||||
if (!Directory.Exists("CTF")) Directory.CreateDirectory("CTF");
|
||||
cfg.Save(p.level.name);
|
||||
if (Server.ctf != null && p.level == Server.ctf.map) Server.ctf.UpdateConfig();
|
||||
if (Server.ctf != null && p.level == Server.ctf.Map) Server.ctf.UpdateConfig();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -42,7 +42,7 @@ namespace MCGalaxy.Games {
|
||||
public bool started = false;
|
||||
|
||||
public CtfTeam2 Red, Blue;
|
||||
public Level map;
|
||||
public Level Map;
|
||||
|
||||
List<string> maps = new List<string>();
|
||||
List<CtfData> cache = new List<CtfData>();
|
||||
@ -78,13 +78,13 @@ namespace MCGalaxy.Games {
|
||||
|
||||
File.Copy("CTF/maps/" + mapName + ".lvl", "levels/ctf.lvl");
|
||||
CmdLoad.LoadLevel(null, "ctf");
|
||||
map = LevelInfo.FindExact("ctf");
|
||||
Map = LevelInfo.FindExact("ctf");
|
||||
UpdateConfig();
|
||||
}
|
||||
|
||||
public void UpdateConfig() {
|
||||
Config.SetDefaults(map);
|
||||
Config.Retrieve(map.name);
|
||||
Config.SetDefaults(Map);
|
||||
Config.Retrieve(Map.name);
|
||||
CTFConfig cfg = Config;
|
||||
|
||||
Red.FlagBlock = ExtBlock.FromRaw(cfg.RedFlagBlock);
|
||||
@ -110,7 +110,7 @@ namespace MCGalaxy.Games {
|
||||
void CheckTagging(object sender, System.Timers.ElapsedEventArgs e) {
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player p in online) {
|
||||
if (p.level != map) continue;
|
||||
if (p.level != Map) continue;
|
||||
|
||||
CtfTeam2 team = TeamOf(p);
|
||||
if (team == null || Get(p).tagging) continue;
|
||||
@ -172,7 +172,7 @@ namespace MCGalaxy.Games {
|
||||
tagging.Stop();
|
||||
tagging.Dispose();
|
||||
|
||||
map = null;
|
||||
Map = null;
|
||||
started = false;
|
||||
if (LevelInfo.FindExact("ctf") != null)
|
||||
Command.all.Find("unload").Use(null, "ctf");
|
||||
@ -190,34 +190,34 @@ namespace MCGalaxy.Games {
|
||||
map2 = maps1[rand.Next(maps1.Count)];
|
||||
maps1.Remove(map2);
|
||||
map3 = maps1[rand.Next(maps1.Count)];
|
||||
Chat.MessageLevel(map, "%2VOTE:");
|
||||
Chat.MessageLevel(map, "1. " + map1 + " 2. " + map2 + " 3. " + map3);
|
||||
Chat.MessageLevel(Map, "%2VOTE:");
|
||||
Chat.MessageLevel(Map, "1. " + map1 + " 2. " + map2 + " 3. " + map3);
|
||||
voting = true;
|
||||
int seconds = rand.Next(15, 61);
|
||||
Chat.MessageLevel(map, "You have " + seconds + " seconds to vote!");
|
||||
Chat.MessageLevel(Map, "You have " + seconds + " seconds to vote!");
|
||||
Thread.Sleep(seconds * 1000);
|
||||
voting = false;
|
||||
Chat.MessageLevel(map, "VOTING ENDED!");
|
||||
Chat.MessageLevel(Map, "VOTING ENDED!");
|
||||
Thread.Sleep(rand.Next(1, 10) * 1000);
|
||||
if (vote1 > vote2 && vote1 > vote3)
|
||||
{
|
||||
Chat.MessageLevel(map, map1 + " WON!");
|
||||
Chat.MessageLevel(Map, map1 + " WON!");
|
||||
return map1;
|
||||
}
|
||||
if (vote2 > vote1 && vote2 > vote3)
|
||||
{
|
||||
Chat.MessageLevel(map, map2 + " WON!");
|
||||
Chat.MessageLevel(Map, map2 + " WON!");
|
||||
return map2;
|
||||
}
|
||||
if (vote3 > vote2 && vote3 > vote1)
|
||||
{
|
||||
Chat.MessageLevel(map, map3 + " WON!");
|
||||
Chat.MessageLevel(Map, map3 + " WON!");
|
||||
return map3;
|
||||
}
|
||||
else
|
||||
{
|
||||
Chat.MessageLevel(map, "There was a tie!");
|
||||
Chat.MessageLevel(map, "I'll choose!");
|
||||
Chat.MessageLevel(Map, "There was a tie!");
|
||||
Chat.MessageLevel(Map, "I'll choose!");
|
||||
return maps[rand.Next(maps.Count)];
|
||||
}
|
||||
}
|
||||
@ -227,11 +227,11 @@ namespace MCGalaxy.Games {
|
||||
started = false;
|
||||
string nextmap = "";
|
||||
if (Blue.Points >= Config.RoundPoints || Blue.Points > Red.Points) {
|
||||
Chat.MessageLevel(map, Blue.ColoredName + " %Swon this round of CTF!");
|
||||
Chat.MessageLevel(Map, Blue.ColoredName + " %Swon this round of CTF!");
|
||||
} else if (Red.Points >= Config.RoundPoints || Red.Points > Blue.Points) {
|
||||
Chat.MessageLevel(map, Red.ColoredName + " %Swon this round of CTF!");
|
||||
Chat.MessageLevel(Map, Red.ColoredName + " %Swon this round of CTF!");
|
||||
} else {
|
||||
Chat.MessageLevel(map, "The round ended in a tie!");
|
||||
Chat.MessageLevel(Map, "The round ended in a tie!");
|
||||
}
|
||||
|
||||
Thread.Sleep(4000);
|
||||
@ -242,7 +242,7 @@ namespace MCGalaxy.Games {
|
||||
"WHERE Name = @0", d.p.name, d.Points, d.Captures, d.Tags);
|
||||
});
|
||||
nextmap = Vote();
|
||||
Chat.MessageLevel(map, "Starting a new game!");
|
||||
Chat.MessageLevel(Map, "Starting a new game!");
|
||||
Blue.Members.Clear();
|
||||
Red.Members.Clear();
|
||||
Thread.Sleep(2000);
|
||||
@ -253,7 +253,7 @@ namespace MCGalaxy.Games {
|
||||
/// <summary> Called when the given player takes the opposing team's flag. </summary>
|
||||
public void TakeFlag(Player p, CtfTeam2 team) {
|
||||
CtfTeam2 opposing = Opposing(team);
|
||||
Chat.MessageLevel(map, team.Color + p.DisplayName + " took the " + Blue.ColoredName + " %Steam's FLAG");
|
||||
Chat.MessageLevel(Map, team.Color + p.DisplayName + " took the " + Blue.ColoredName + " %Steam's FLAG");
|
||||
Get(p).hasflag = true;
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
CtfData data = Get(p);
|
||||
if (data.hasflag) {
|
||||
Chat.MessageLevel(map, team.Color + p.DisplayName + " RETURNED THE FLAG!");
|
||||
Chat.MessageLevel(Map, team.Color + p.DisplayName + " RETURNED THE FLAG!");
|
||||
data.hasflag = false;
|
||||
data.Points += Config.Capture_PointsGained;
|
||||
data.Captures++;
|
||||
@ -273,7 +273,7 @@ namespace MCGalaxy.Games {
|
||||
CtfTeam2 opposing = Opposing(team);
|
||||
team.Points++;
|
||||
flagPos = opposing.FlagPos;
|
||||
map.Blockchange(flagPos.X, flagPos.Y, flagPos.Z, opposing.FlagBlock);
|
||||
Map.Blockchange(flagPos.X, flagPos.Y, flagPos.Z, opposing.FlagBlock);
|
||||
|
||||
if (team.Points >= Config.RoundPoints) EndRound();
|
||||
} else {
|
||||
@ -287,12 +287,12 @@ namespace MCGalaxy.Games {
|
||||
if (!data.hasflag) return;
|
||||
|
||||
data.hasflag = false;
|
||||
Chat.MessageLevel(map, team.Color + p.DisplayName + " DROPPED THE FLAG!");
|
||||
Chat.MessageLevel(Map, team.Color + p.DisplayName + " DROPPED THE FLAG!");
|
||||
data.Points -= Config.Capture_PointsLost;
|
||||
|
||||
CtfTeam2 opposing = Opposing(team);
|
||||
Vec3U16 pos = opposing.FlagPos;
|
||||
map.Blockchange(pos.X, pos.Y, pos.Z, opposing.FlagBlock);
|
||||
Map.Blockchange(pos.X, pos.Y, pos.Z, opposing.FlagBlock);
|
||||
}
|
||||
|
||||
|
||||
@ -304,7 +304,7 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
team.Members.Add(p);
|
||||
Chat.MessageLevel(map, p.ColoredName + " joined the " + team.ColoredName + " %Steam");
|
||||
Chat.MessageLevel(Map, p.ColoredName + " joined the " + team.ColoredName + " %Steam");
|
||||
Player.Message(p, team.Color + "You are now on the " + team.Name + " team!");
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
|
||||
void HandlePlayerDeath(Player p, ExtBlock deathblock) {
|
||||
if (!Game.started || p.level != Game.map) return;
|
||||
if (!Game.started || p.level != Game.Map) return;
|
||||
if (!Game.Get(p).hasflag) return;
|
||||
|
||||
CtfTeam2 team = Game.TeamOf(p);
|
||||
@ -82,7 +82,7 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
}
|
||||
|
||||
if (!Game.started || p.level != Game.map) return;
|
||||
if (!Game.started || p.level != Game.Map) return;
|
||||
if (!Game.Get(p).TeamChatting) return;
|
||||
|
||||
CtfTeam2 team = Game.TeamOf(p);
|
||||
@ -96,7 +96,7 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
void HandleBlockChange(Player p, ushort x, ushort y, ushort z, ExtBlock block) {
|
||||
if (!Game.started || p.level != Game.map) return;
|
||||
if (!Game.started || p.level != Game.Map) return;
|
||||
CtfTeam2 team = Game.TeamOf(p);
|
||||
if (team == null) {
|
||||
p.RevertBlock(x, y, z);
|
||||
@ -106,33 +106,33 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
Vec3U16 pos = new Vec3U16(x, y, z);
|
||||
if (pos == Game.Opposing(team).FlagPos && !Game.map.IsAirAt(x, y, z)) {
|
||||
if (pos == Game.Opposing(team).FlagPos && !Game.Map.IsAirAt(x, y, z)) {
|
||||
Game.TakeFlag(p, team);
|
||||
}
|
||||
if (pos == team.FlagPos && !Game.map.IsAirAt(x, y, z)) {
|
||||
if (pos == team.FlagPos && !Game.Map.IsAirAt(x, y, z)) {
|
||||
Game.ReturnFlag(p, team);
|
||||
}
|
||||
}
|
||||
|
||||
void HandleDisconnect(Player p, string reason) {
|
||||
if (p.level != Game.map) return;
|
||||
if (p.level != Game.Map) return;
|
||||
CtfTeam2 team = Game.TeamOf(p);
|
||||
if (team == null) return;
|
||||
|
||||
Game.DropFlag(p, team);
|
||||
team.Remove(p);
|
||||
Chat.MessageLevel(Game.map, team.Color + p.DisplayName + " %Sleft the ctf game");
|
||||
Chat.MessageLevel(Game.Map, team.Color + p.DisplayName + " %Sleft the ctf game");
|
||||
}
|
||||
|
||||
void HandleLevelUnload(Level lvl) {
|
||||
if (Game.started && lvl == Game.map) {
|
||||
if (Game.started && lvl == Game.Map) {
|
||||
Logger.Log(LogType.GameActivity, "Unload Failed!, A ctf game is currently going on!");
|
||||
lvl.cancelunload = true;
|
||||
}
|
||||
}
|
||||
|
||||
void HandlePlayerSpawning(Player p, ref Position pos, ref byte yaw, ref byte pitch, bool respawning) {
|
||||
if (!Game.started || p.level != Game.map) return;
|
||||
if (!Game.started || p.level != Game.Map) return;
|
||||
|
||||
CtfTeam2 team = Game.TeamOf(p);
|
||||
if (team != null) pos = team.SpawnPos;
|
||||
@ -141,7 +141,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
void HandleTabListEntryAdded(Entity entity, ref string tabName, ref string tabGroup, Player dst) {
|
||||
Player p = entity as Player;
|
||||
if (p == null || !Game.started || p.level != Game.map) return;
|
||||
if (p == null || !Game.started || p.level != Game.Map) return;
|
||||
CtfTeam2 team = Game.TeamOf(p);
|
||||
|
||||
if (p.Game.Referee) {
|
||||
@ -156,7 +156,7 @@ namespace MCGalaxy.Games {
|
||||
void HandlePlayerCommand(Player p, string cmd, string args) {
|
||||
if (!Game.started) return;
|
||||
|
||||
if (cmd == "teamchat" && p.level == Game.map) {
|
||||
if (cmd == "teamchat" && p.level == Game.Map) {
|
||||
CtfData data = Game.Get(p);
|
||||
if (data != null) {
|
||||
if (data.TeamChatting) {
|
||||
@ -170,7 +170,7 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
if (cmd != "goto") return;
|
||||
if (args == "ctf" && p.level != Game.map) {
|
||||
if (args == "ctf" && p.level != Game.Map) {
|
||||
if (Game.Blue.Members.Count > Game.Red.Members.Count) {
|
||||
Game.JoinTeam(p, Game.Red);
|
||||
} else if (Game.Red.Members.Count > Game.Blue.Members.Count) {
|
||||
@ -180,13 +180,13 @@ namespace MCGalaxy.Games {
|
||||
} else {
|
||||
Game.JoinTeam(p, Game.Blue);
|
||||
}
|
||||
} else if (args != "ctf" && p.level == Game.map) {
|
||||
} else if (args != "ctf" && p.level == Game.Map) {
|
||||
CtfTeam2 team = Game.TeamOf(p);
|
||||
if (team == null) return;
|
||||
|
||||
Game.DropFlag(p, team);
|
||||
team.Remove(p);
|
||||
Chat.MessageLevel(Game.map, team.Color + p.DisplayName + " %Sleft the ctf game");
|
||||
Chat.MessageLevel(Game.Map, team.Color + p.DisplayName + " %Sleft the ctf game");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,10 +47,6 @@ namespace MCGalaxy.Games {
|
||||
/// <summary> Raised when a player moves to a different map/level. </summary>
|
||||
public virtual void PlayerJoinedLevel(Player p, Level lvl, Level oldLvl) { }
|
||||
|
||||
public virtual bool PlayerCanJoinLevel(Player p, Level lvl, Level oldLvl) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary> Raised when the server is about to send a heartbeat. </summary>
|
||||
public virtual void OnHeartbeat(ref string name) { }
|
||||
|
||||
|
@ -78,13 +78,7 @@ namespace MCGalaxy.Games.ZS {
|
||||
}
|
||||
|
||||
void HandlePlayerDisconnect(Player p, string reason) {
|
||||
Game.Alive.Remove(p);
|
||||
Game.Infected.Remove(p);
|
||||
p.Game.Infected = false;
|
||||
Game.RemoveBounties(p);
|
||||
|
||||
Game.AssignFirstZombie();
|
||||
HUD.UpdateAllPrimary(Game);
|
||||
Game.PlayerLeftGame(p);
|
||||
}
|
||||
|
||||
void HandlePlayerMove(Player p, Position next, byte rotX, byte rotY) {
|
||||
|
@ -26,6 +26,16 @@ namespace MCGalaxy.Games {
|
||||
/// <summary> Whether players are allowed to teleport to others when not in referee mode. </summary>
|
||||
public override bool TeleportAllowed { get { return !RoundInProgress; } }
|
||||
|
||||
public override void PlayerLeftGame(Player p) {
|
||||
Alive.Remove(p);
|
||||
Infected.Remove(p);
|
||||
p.Game.Infected = false;
|
||||
RemoveBounties(p);
|
||||
|
||||
AssignFirstZombie();
|
||||
HUD.UpdateAllPrimary(this);
|
||||
}
|
||||
|
||||
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
||||
byte action, byte block, byte old) {
|
||||
if (!Running || (p.level == null || !p.level.name.CaselessEq(CurLevelName))) return false;
|
||||
@ -111,6 +121,9 @@ namespace MCGalaxy.Games {
|
||||
InfectPlayer(p, null);
|
||||
}
|
||||
}
|
||||
if (RoundInProgress && oldLvl == CurLevel) {
|
||||
PlayerLeftGame(p);
|
||||
}
|
||||
|
||||
if (lvl.name.CaselessEq(CurLevelName)) {
|
||||
double startLeft = (RoundStart - DateTime.UtcNow).TotalSeconds;
|
||||
@ -143,17 +156,6 @@ namespace MCGalaxy.Games {
|
||||
HUD.UpdateAllPrimary(this);
|
||||
}
|
||||
|
||||
public override bool PlayerCanJoinLevel(Player p, Level lvl, Level oldLvl) {
|
||||
if (!oldLvl.name.CaselessEq(CurLevelName)) return true;
|
||||
if (lvl.name.CaselessEq(CurLevelName)) return true;
|
||||
|
||||
if (RoundInProgress && !p.Game.Referee) {
|
||||
Player.Message(p, "Sorry, you cannot leave a zombie survival map until the current round has ended.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnHeartbeat(ref string name) {
|
||||
if (!Running || !ZSConfig.IncludeMapInHeartbeat || CurLevelName == null) return;
|
||||
name += " (map: " + CurLevelName + ")";
|
||||
|
@ -108,7 +108,6 @@ namespace MCGalaxy {
|
||||
static bool GotoLevel(Player p, Level lvl) {
|
||||
if (p.level == lvl) { Player.Message(p, "You are already in {0}%S.", lvl.ColoredName); return false; }
|
||||
if (!lvl.CanJoin(p)) return false;
|
||||
if (!Server.zombie.PlayerCanJoinLevel(p, lvl, p.level)) return false;
|
||||
|
||||
p.Loading = true;
|
||||
Entities.DespawnEntities(p);
|
||||
|
Loading…
x
Reference in New Issue
Block a user