mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 22:30:52 -04:00
Fix several bugs in zombie survival.
This commit is contained in:
parent
be4a50e0be
commit
5babc4332f
@ -32,17 +32,9 @@ namespace MCGalaxy.Commands {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
|
||||
foreach (Player pl in players) {
|
||||
if (pl.level != p.level || p == pl || !Player.CanSee(p, pl) || pl.referee) continue;
|
||||
|
||||
if (pl.level != p.level || p == pl || !Player.CanSee(p, pl) || pl.referee) continue;
|
||||
p.SendDespawn(pl.id);
|
||||
string name = null;
|
||||
if (pl.infected) {
|
||||
name = (Server.zombie.ZombieName != "" && showInfected) ?
|
||||
Colors.red + Server.zombie.ZombieName : Colors.red + pl.name;
|
||||
} else {
|
||||
name = pl.color + pl.name;
|
||||
}
|
||||
p.SendSpawn(pl.id, name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
|
||||
Player.SpawnEntity(pl, p, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,24 +75,9 @@ namespace MCGalaxy.Commands {
|
||||
PlayerBot[] bots = PlayerBot.Bots.Items;
|
||||
foreach (PlayerBot b in bots) if (who.level == b.level) who.SendDespawn(b.id);
|
||||
|
||||
ushort x = who.pos[0], y = who.pos[1], z = who.pos[2];
|
||||
Player.GlobalDespawn(who, true);
|
||||
who.SendUserMOTD(); who.SendMap(who.level);
|
||||
|
||||
if (!who.hidden)
|
||||
Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true);
|
||||
else
|
||||
who.SendPos(0xFF, x, y, z, who.level.rotx, who.level.roty);
|
||||
|
||||
players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players)
|
||||
if (pl.level == who.level && who != pl && !pl.hidden)
|
||||
who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
|
||||
bots = PlayerBot.Bots.Items;
|
||||
foreach (PlayerBot b in bots)
|
||||
if (b.level == who.level)
|
||||
who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
|
||||
|
||||
who.SendUserMOTD(); who.SendMap(who.level);
|
||||
CmdGoto.SpawnEntities(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
|
||||
who.Loading = false;
|
||||
|
||||
if (!showMessage) return;
|
||||
|
@ -49,7 +49,7 @@ namespace MCGalaxy.Commands {
|
||||
if (!didJoin) return;
|
||||
bool unloadOld = true;
|
||||
if (oldLevel.unload && !oldLevel.name.Contains("&cMuseum ")) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players)
|
||||
if (pl.level == oldLevel) { unloadOld = false; break; }
|
||||
if (unloadOld && Server.AutoLoad) oldLevel.Unload(true);
|
||||
@ -127,21 +127,7 @@ namespace MCGalaxy.Commands {
|
||||
ushort x = (ushort)((0.5 + lvl.spawnx) * 32);
|
||||
ushort y = (ushort)((1 + lvl.spawny) * 32);
|
||||
ushort z = (ushort)((0.5 + lvl.spawnz) * 32);
|
||||
|
||||
if (!p.hidden)
|
||||
Player.GlobalSpawn(p, x, y, z, lvl.rotx, lvl.roty, true, "");
|
||||
else
|
||||
p.SendPos(0xFF, x, y, z, lvl.rotx, lvl.roty);
|
||||
|
||||
players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players)
|
||||
if (pl.level == p.level && p != pl && !pl.hidden)
|
||||
p.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
|
||||
bots = PlayerBot.Bots.Items;
|
||||
foreach (PlayerBot b in bots)
|
||||
if (b.level == p.level)
|
||||
p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
|
||||
|
||||
SpawnEntities(p, x, y, z, lvl.rotx, lvl.roty);
|
||||
p.Loading = false;
|
||||
CheckGamesJoin(p, oldLevel);
|
||||
|
||||
@ -152,9 +138,25 @@ namespace MCGalaxy.Commands {
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void SpawnEntities(Player p, ushort x, ushort y, ushort z, byte rotX, byte rotY) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players) {
|
||||
if (pl.level != p.level || pl.hidden || p == pl) continue;
|
||||
Player.SpawnEntity(pl, p, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
|
||||
}
|
||||
|
||||
if (!p.hidden) Player.GlobalSpawn(p, x, y, z, rotX, rotY, true, "");
|
||||
else p.SendPos(0xFF, x, y, z, rotX, rotY);
|
||||
|
||||
PlayerBot[] bots = PlayerBot.Bots.Items;
|
||||
foreach (PlayerBot b in bots)
|
||||
if (b.level == p.level)
|
||||
p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
|
||||
}
|
||||
|
||||
internal static void CheckGamesJoin(Player p, Level oldLvl) {
|
||||
Server.lava.PlayerJoinedLevel(p, oldLvl);
|
||||
Server.zombie.PlayerJoinedLevel(p, oldLvl);
|
||||
Server.lava.PlayerJoinedLevel(p, oldLvl);
|
||||
Server.zombie.PlayerJoinedLevel(p, oldLvl);
|
||||
|
||||
if (p.inTNTwarsMap) p.canBuild = true;
|
||||
TntWarsGame game = TntWarsGame.Find(p.level);
|
||||
|
@ -69,7 +69,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
CurrentLevel.ChatLevel(first.color + first.name + " %Sstarted the infection!");
|
||||
first.infected = true;
|
||||
UpdatePlayerColor(first, Colors.red);
|
||||
UpdatePlayerColor(first, InfectCol);
|
||||
|
||||
RoundInProgress = true;
|
||||
int roundMins = random.Next(4, 7);
|
||||
@ -101,6 +101,7 @@ namespace MCGalaxy.Games {
|
||||
do {
|
||||
first = QueuedZombie != null ?
|
||||
PlayerInfo.Find(QueuedZombie) : players[random.Next(players.Count)];
|
||||
QueuedZombie = null;
|
||||
} while (first == null || !first.level.name.CaselessEq(CurrentLevelName));
|
||||
return first;
|
||||
}
|
||||
@ -153,7 +154,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
foreach (Player pKiller in infected) {
|
||||
pKiller.infected = true;
|
||||
UpdatePlayerColor(pKiller, Colors.red);
|
||||
UpdatePlayerColor(pKiller, InfectCol);
|
||||
bool aliveChanged = false;
|
||||
foreach (Player pAlive in alive) {
|
||||
UpdatePlayerColor(pAlive, pAlive.color);
|
||||
@ -190,7 +191,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
CheckHumanPledge(pAlive);
|
||||
CheckBounty(pAlive, pKiller);
|
||||
UpdatePlayerColor(pAlive, Colors.red);
|
||||
UpdatePlayerColor(pAlive, InfectCol);
|
||||
}
|
||||
}
|
||||
if (aliveChanged) alive = Alive.Items;
|
||||
|
@ -38,6 +38,8 @@ namespace MCGalaxy.Games {
|
||||
public enum ZombieGameStatus { NotStarted, InfiniteRounds, SingleRound, VariableRounds, LastRound }
|
||||
|
||||
public sealed partial class ZombieGame {
|
||||
|
||||
public const string InfectCol = "&infect";
|
||||
|
||||
/// <summary> The number of rounds that have been played in this game so far. </summary>
|
||||
public int RoundsDone = 0;
|
||||
|
@ -538,18 +538,7 @@ namespace MCGalaxy {
|
||||
ushort y = (ushort)((1 + level.spawny) * 32);
|
||||
ushort z = (ushort)((0.5 + level.spawnz) * 32);
|
||||
pos = new ushort[3] { x, y, z }; rot = new byte[2] { level.rotx, level.roty };
|
||||
|
||||
GlobalSpawn(this, x, y, z, rot[0], rot[1], true);
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player p in players) {
|
||||
if (p.level == level && p != this && !p.hidden)
|
||||
SendSpawn(p.id, p.color + p.name, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
|
||||
}
|
||||
PlayerBot[] bots = PlayerBot.Bots.Items;
|
||||
foreach (PlayerBot pB in bots) {
|
||||
if (pB.level == level)
|
||||
SendSpawn(pB.id, pB.color + pB.name, pB.pos[0], pB.pos[1], pB.pos[2], pB.rot[0], pB.rot[1]);
|
||||
}
|
||||
CmdGoto.SpawnEntities(this, x, y, z, rot[0], rot[1]);
|
||||
} catch (Exception e) {
|
||||
Server.ErrorLog(e);
|
||||
Server.s.Log("Error spawning player \"" + name + "\"");
|
||||
|
@ -487,34 +487,39 @@ namespace MCGalaxy {
|
||||
public static void GlobalSpawn(Player p, ushort x, ushort y, ushort z,
|
||||
byte rotx, byte roty, bool self, string possession = "") {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
p.lastSpawnColor = p.infected ? Colors.red : p.color;
|
||||
foreach (Player other in players) {
|
||||
p.lastSpawnColor = p.infected ? ZombieGame.InfectCol : p.color;
|
||||
foreach (Player other in players) {
|
||||
if (other.Loading && p != other) continue;
|
||||
if (p.level != other.level || (p.hidden && !self)) continue;
|
||||
|
||||
if (p != other) {
|
||||
if (Server.ZombieModeOn) {
|
||||
if (p.infected) {
|
||||
if (Server.zombie.ZombieName != "" && !other.aka)
|
||||
other.SendSpawn(p.id, Colors.red + Server.zombie.ZombieName + possession, x, y, z, rotx, roty);
|
||||
else
|
||||
other.SendSpawn(p.id, Colors.red + p.name + possession, x, y, z, rotx, roty);
|
||||
if (other.HasCpeExt(CpeExt.ChangeModel))
|
||||
other.SendChangeModel(p.id, "zombie");
|
||||
} else if (!p.referee) {
|
||||
other.SendSpawn(p.id, p.color + p.name + possession, x, y, z, rotx, roty);
|
||||
}
|
||||
} else {
|
||||
other.SendSpawn(p.id, p.color + p.name + possession, x, y, z, rotx, roty);
|
||||
}
|
||||
SpawnEntity(p, other, p.id, x, y, z, rotx, roty, possession);
|
||||
} else if (self) {
|
||||
other.pos = new ushort[3] { x, y, z }; other.rot = new byte[2] { rotx, roty };
|
||||
other.oldpos = other.pos; other.basepos = other.pos; other.oldrot = other.rot;
|
||||
other.SendSpawn(0xFF, p.color + p.name + possession, x, y, z, rotx, roty);
|
||||
SpawnEntity(p, other, 0xFF, x, y, z, rotx, roty, possession);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SpawnEntity(Player p, Player dst, byte id, ushort x, ushort y, ushort z,
|
||||
byte rotx, byte roty, string possession = "") {
|
||||
if (!Server.ZombieModeOn) {
|
||||
dst.SendSpawn(id, p.color + p.name + possession, x, y, z, rotx, roty); return;
|
||||
}
|
||||
|
||||
if (p.infected) {
|
||||
if (Server.zombie.ZombieName != "" && !dst.aka)
|
||||
dst.SendSpawn(id, Colors.red + Server.zombie.ZombieName + possession, x, y, z, rotx, roty);
|
||||
else
|
||||
dst.SendSpawn(id, Colors.red + p.name + possession, x, y, z, rotx, roty);
|
||||
if (dst.HasCpeExt(CpeExt.ChangeModel))
|
||||
dst.SendChangeModel(id, "zombie");
|
||||
} else if (!p.referee) {
|
||||
dst.SendSpawn(id, p.color + p.name + possession, x, y, z, rotx, roty);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GlobalDespawn(Player p, bool self) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player other in players) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user