mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 23:02:04 -04:00
Add initial basis for a /human (similiar to /ironman in MCDzienny) command for zombie survival.
This commit is contained in:
parent
2ad392819c
commit
440b1d4982
48
Commands/Fun/ZombieSurvival/CmdHuman.cs
Normal file
48
Commands/Fun/ZombieSurvival/CmdHuman.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using MCGalaxy.Games;
|
||||||
|
|
||||||
|
namespace MCGalaxy.Commands {
|
||||||
|
|
||||||
|
public sealed class CmdHuman : Command {
|
||||||
|
public override string name { get { return "human"; } }
|
||||||
|
public override string shortcut { get { return ""; } }
|
||||||
|
public override string type { get { return CommandTypes.Moderation; } }
|
||||||
|
public override bool museumUsable { get { return true; } }
|
||||||
|
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||||
|
public override bool Enabled { get { return Server.ZombieModeOn; } }
|
||||||
|
public CmdHuman() { }
|
||||||
|
|
||||||
|
public override void Use(Player p, string message) {
|
||||||
|
if (p == null) { MessageInGameOnly(p); return; }
|
||||||
|
if (p.assertingSurvive) {
|
||||||
|
Player.SendMessage(p, "You cannot un-assert that you will be infected."); return;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.assertingSurvive = true;
|
||||||
|
Server.zombie.CurrentLevel
|
||||||
|
.ChatLevel(p.FullName + " %Sasserts that they will not succumb to the infection!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Help(Player p) {
|
||||||
|
Player.SendMessage(p, "%T/human %H- asserts that you will not be infected.");
|
||||||
|
Player.SendMessage(p, "%HIf you survive, you receive an &aextra 5 %3" + Server.moneys);
|
||||||
|
Player.SendMessage(p, "%HHowever, if you are infected, you will &close 2 %3" + Server.moneys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -303,6 +303,7 @@ namespace MCGalaxy.Games
|
|||||||
Player[] online = PlayerInfo.Online.Items;
|
Player[] online = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in online) {
|
foreach (Player pl in online) {
|
||||||
pl.ratedMap = false;
|
pl.ratedMap = false;
|
||||||
|
pl.assertingSurvive = false;
|
||||||
if (pl.level == oldMap)
|
if (pl.level == oldMap)
|
||||||
{
|
{
|
||||||
if (sendAfkMain && Server.afkset.Contains(pl.name)) Command.all.Find("main").Use(pl, "");
|
if (sendAfkMain && Server.afkset.Contains(pl.name)) Command.all.Find("main").Use(pl, "");
|
||||||
|
@ -66,7 +66,7 @@ namespace MCGalaxy.Games {
|
|||||||
RoundInProgress = true;
|
RoundInProgress = true;
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
pickFirst:
|
pickFirst:
|
||||||
int firstinfect = random.Next(players.Count());
|
int firstinfect = random.Next(players.Count());
|
||||||
Player first = null;
|
Player first = null;
|
||||||
if (queZombie) first = PlayerInfo.Find(nextZombie);
|
if (queZombie) first = PlayerInfo.Find(nextZombie);
|
||||||
@ -80,7 +80,7 @@ namespace MCGalaxy.Games {
|
|||||||
UpdatePlayerColor(first, Colors.red);
|
UpdatePlayerColor(first, Colors.red);
|
||||||
|
|
||||||
RoundInProgress = true;
|
RoundInProgress = true;
|
||||||
int roundMins = random.Next(5, 8);
|
int roundMins = random.Next(4, 7);
|
||||||
CurrentLevel.ChatLevel("The round will last for " + roundMins + " minutes!");
|
CurrentLevel.ChatLevel("The round will last for " + roundMins + " minutes!");
|
||||||
RoundEnd = DateTime.UtcNow.AddMinutes(roundMins);
|
RoundEnd = DateTime.UtcNow.AddMinutes(roundMins);
|
||||||
timer = new System.Timers.Timer(roundMins * 60 * 1000);
|
timer = new System.Timers.Timer(roundMins * 60 * 1000);
|
||||||
@ -145,7 +145,7 @@ namespace MCGalaxy.Games {
|
|||||||
while ((alive = Alive.Items).Length > 0) {
|
while ((alive = Alive.Items).Length > 0) {
|
||||||
Player[] infected = Infected.Items;
|
Player[] infected = Infected.Items;
|
||||||
foreach (Player pKiller in infected) {
|
foreach (Player pKiller in infected) {
|
||||||
pKiller.infected = true;
|
pKiller.infected = true;
|
||||||
UpdatePlayerColor(pKiller, Colors.red);
|
UpdatePlayerColor(pKiller, Colors.red);
|
||||||
bool aliveChanged = false;
|
bool aliveChanged = false;
|
||||||
foreach (Player pAlive in alive) {
|
foreach (Player pAlive in alive) {
|
||||||
@ -155,7 +155,7 @@ namespace MCGalaxy.Games {
|
|||||||
|| Math.Abs(pAlive.pos[2] - pKiller.pos[2]) > HitboxPrecision)
|
|| Math.Abs(pAlive.pos[2] - pKiller.pos[2]) > HitboxPrecision)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!pAlive.infected && pKiller.infected && !pAlive.referee && !pKiller.referee && pKiller != pAlive
|
if (!pAlive.infected && pKiller.infected && !pAlive.referee && !pKiller.referee && pKiller != pAlive
|
||||||
&& pKiller.level.name.CaselessEq(CurrentLevelName) && pAlive.level.name.CaselessEq(CurrentLevelName))
|
&& pKiller.level.name.CaselessEq(CurrentLevelName) && pAlive.level.name.CaselessEq(CurrentLevelName))
|
||||||
{
|
{
|
||||||
InfectPlayer(pAlive);
|
InfectPlayer(pAlive);
|
||||||
@ -181,17 +181,8 @@ namespace MCGalaxy.Games {
|
|||||||
Colors.red + pKiller.DisplayName + Colors.yellow,
|
Colors.red + pKiller.DisplayName + Colors.yellow,
|
||||||
Colors.red + pAlive.DisplayName + Colors.yellow));
|
Colors.red + pAlive.DisplayName + Colors.yellow));
|
||||||
|
|
||||||
BountyData bounty;
|
CheckAssertHuman(pAlive);
|
||||||
if (Bounties.TryGetValue(pAlive.name, out bounty))
|
CheckBounty(pAlive, pKiller);
|
||||||
Bounties.Remove(pAlive.name);
|
|
||||||
if (bounty != null) {
|
|
||||||
CurrentLevel.ChatLevel(pKiller.FullName + " %Scollected the bounty of &a" +
|
|
||||||
bounty.Amount + " %S" + Server.moneys + " on " + pAlive.FullName + "%S.");
|
|
||||||
bounty.Origin.money = Math.Max(0, bounty.Origin.money - bounty.Amount);
|
|
||||||
bounty.Origin.OnMoneyChanged();
|
|
||||||
pKiller.money += bounty.Amount;
|
|
||||||
pKiller.OnMoneyChanged();
|
|
||||||
}
|
|
||||||
UpdatePlayerColor(pAlive, Colors.red);
|
UpdatePlayerColor(pAlive, Colors.red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,6 +191,28 @@ namespace MCGalaxy.Games {
|
|||||||
Thread.Sleep(50);
|
Thread.Sleep(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckAssertHuman(Player pAlive) {
|
||||||
|
if (!pAlive.assertingSurvive) return;
|
||||||
|
pAlive.assertingSurvive = false;
|
||||||
|
CurrentLevel.ChatLevel(pAlive.FullName + "%Sfailed the challenge of not being infected.");
|
||||||
|
pAlive.money = Math.Max(pAlive.money - 2, 0);
|
||||||
|
pAlive.OnMoneyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckBounty(Player pAlive, Player pKiller) {
|
||||||
|
BountyData bounty;
|
||||||
|
if (Bounties.TryGetValue(pAlive.name, out bounty))
|
||||||
|
Bounties.Remove(pAlive.name);
|
||||||
|
if (bounty != null) {
|
||||||
|
CurrentLevel.ChatLevel(pKiller.FullName + " %Scollected the bounty of &a" +
|
||||||
|
bounty.Amount + " %S" + Server.moneys + " on " + pAlive.FullName + "%S.");
|
||||||
|
bounty.Origin.money = Math.Max(0, bounty.Origin.money - bounty.Amount);
|
||||||
|
bounty.Origin.OnMoneyChanged();
|
||||||
|
pKiller.money += bounty.Amount;
|
||||||
|
pKiller.OnMoneyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void UpdatePlayerColor(Player p, string color) {
|
static void UpdatePlayerColor(Player p, string color) {
|
||||||
if (p.lastSpawnColor == color) return;
|
if (p.lastSpawnColor == color) return;
|
||||||
@ -240,8 +253,15 @@ namespace MCGalaxy.Games {
|
|||||||
foreach (Player pl in online)
|
foreach (Player pl in online)
|
||||||
ResetPlayer(pl, ref playersString);
|
ResetPlayer(pl, ref playersString);
|
||||||
} else {
|
} else {
|
||||||
foreach (Player pl in alive)
|
foreach (Player pl in alive) {
|
||||||
|
if (pl.assertingSurvive) {
|
||||||
|
pl.SendMessage("You received &a5 %3" + Server.moneys +
|
||||||
|
"%s for successfully asserting that you would survive.");
|
||||||
|
pl.money += 5;
|
||||||
|
pl.OnMoneyChanged();
|
||||||
|
}
|
||||||
ResetPlayer(pl, ref playersString);
|
ResetPlayer(pl, ref playersString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentLevel.ChatLevel(playersString);
|
CurrentLevel.ChatLevel(playersString);
|
||||||
@ -328,7 +348,7 @@ namespace MCGalaxy.Games {
|
|||||||
if (initialChangeLevel) {
|
if (initialChangeLevel) {
|
||||||
Server.votingforlevel = true;
|
Server.votingforlevel = true;
|
||||||
CurrentLevel.ChatLevel(" " + Colors.black + "Level Vote: %S" + selectedLevel1 + ", " + selectedLevel2 +
|
CurrentLevel.ChatLevel(" " + Colors.black + "Level Vote: %S" + selectedLevel1 + ", " + selectedLevel2 +
|
||||||
" or random " + "(" + Colors.lime + "1%S/" + Colors.red + "2%S/" + Colors.blue + "3%S)");
|
" or random " + "(" + Colors.lime + "1%S/" + Colors.red + "2%S/" + Colors.blue + "3%S)");
|
||||||
System.Threading.Thread.Sleep(15000);
|
System.Threading.Thread.Sleep(15000);
|
||||||
Server.votingforlevel = false;
|
Server.votingforlevel = false;
|
||||||
} else { Level1Vote = 1; Level2Vote = 0; Level3Vote = 0; }
|
} else { Level1Vote = 1; Level2Vote = 0; Level3Vote = 0; }
|
||||||
|
@ -178,6 +178,7 @@ namespace MCGalaxy.Games {
|
|||||||
online = PlayerInfo.Online.Items;
|
online = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in online) {
|
foreach (Player pl in online) {
|
||||||
pl.ratedMap = false;
|
pl.ratedMap = false;
|
||||||
|
pl.assertingSurvive = false;
|
||||||
if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) {
|
if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) {
|
||||||
pl.SendMessage("Going to the next map!");
|
pl.SendMessage("Going to the next map!");
|
||||||
Command.all.Find("goto").Use(pl, next);
|
Command.all.Find("goto").Use(pl, next);
|
||||||
@ -201,8 +202,10 @@ namespace MCGalaxy.Games {
|
|||||||
CurrentLevel = null;
|
CurrentLevel = null;
|
||||||
|
|
||||||
Player[] online = PlayerInfo.Online.Items;
|
Player[] online = PlayerInfo.Online.Items;
|
||||||
foreach (Player pl in online)
|
foreach (Player pl in online) {
|
||||||
pl.ratedMap = false;
|
pl.ratedMap = false;
|
||||||
|
pl.assertingSurvive = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePlayerStatus(Player p) {
|
void UpdatePlayerStatus(Player p) {
|
||||||
|
@ -195,6 +195,7 @@
|
|||||||
<Compile Include="Commands\Fun\ZombieSurvival\CmdDisinfect.cs" />
|
<Compile Include="Commands\Fun\ZombieSurvival\CmdDisinfect.cs" />
|
||||||
<Compile Include="Commands\Fun\ZombieSurvival\CmdEndRound.cs" />
|
<Compile Include="Commands\Fun\ZombieSurvival\CmdEndRound.cs" />
|
||||||
<Compile Include="Commands\Fun\ZombieSurvival\CmdFliphead.cs" />
|
<Compile Include="Commands\Fun\ZombieSurvival\CmdFliphead.cs" />
|
||||||
|
<Compile Include="Commands\Fun\ZombieSurvival\CmdHuman.cs" />
|
||||||
<Compile Include="Commands\Fun\ZombieSurvival\CmdInfect.cs" />
|
<Compile Include="Commands\Fun\ZombieSurvival\CmdInfect.cs" />
|
||||||
<Compile Include="Commands\Fun\ZombieSurvival\CmdInfected.cs" />
|
<Compile Include="Commands\Fun\ZombieSurvival\CmdInfected.cs" />
|
||||||
<Compile Include="Commands\Fun\ZombieSurvival\CmdQueue.cs" />
|
<Compile Include="Commands\Fun\ZombieSurvival\CmdQueue.cs" />
|
||||||
|
@ -198,6 +198,7 @@ namespace MCGalaxy {
|
|||||||
public int playersInfected = 0;
|
public int playersInfected = 0;
|
||||||
internal string lastSpawnColor = "";
|
internal string lastSpawnColor = "";
|
||||||
internal bool ratedMap = false;
|
internal bool ratedMap = false;
|
||||||
|
internal bool assertingSurvive = false;
|
||||||
|
|
||||||
//Tnt Wars
|
//Tnt Wars
|
||||||
public bool PlayingTntWars = false;
|
public bool PlayingTntWars = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user