mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-28 07:56:20 -04:00
Add custom infection messages to zombie survival, also fix /rp rainbow 2+ not working when the block is not a wool to start with.
This commit is contained in:
parent
f227631255
commit
daa003db1e
@ -133,7 +133,7 @@ namespace MCGalaxy.Commands
|
|||||||
SetBool(p, lvl, ref lvl.leafDecay, "Leaf deacy: "); break;
|
SetBool(p, lvl, ref lvl.leafDecay, "Leaf deacy: "); break;
|
||||||
case "flow":
|
case "flow":
|
||||||
case "randomflow":
|
case "randomflow":
|
||||||
SetBool(p, lvl, ref lvl.randomFlow, "Ranbow flow: "); break;
|
SetBool(p, lvl, ref lvl.randomFlow, "Random flow: "); break;
|
||||||
case "tree":
|
case "tree":
|
||||||
case "growtrees":
|
case "growtrees":
|
||||||
SetBool(p, lvl, ref lvl.growTrees, "Tree growing: "); break;
|
SetBool(p, lvl, ref lvl.growTrees, "Tree growing: "); break;
|
||||||
|
@ -61,5 +61,17 @@ namespace MCGalaxy {
|
|||||||
public static void SetLogoutMessage(string name, string value) {
|
public static void SetLogoutMessage(string name, string value) {
|
||||||
CP437Writer.WriteAllText("text/logout/" + name.ToLower() + ".txt", value);
|
CP437Writer.WriteAllText("text/logout/" + name.ToLower() + ".txt", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<string> GetInfectMessages(Player p) {
|
||||||
|
if (p.name == null || !Directory.Exists("text/infect")) return null;
|
||||||
|
string path = "text/infect/" + p.name.ToLower() + ".txt";
|
||||||
|
return File.Exists(path) ? CP437Reader.ReadAllLines(path) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AppendInfectMessage(string name, string value) {
|
||||||
|
if (!Directory.Exists("text/infect"))
|
||||||
|
Directory.CreateDirectory("text/infect");
|
||||||
|
CP437Writer.AppendLine("text/infect/" + name.ToLower() + ".txt", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -150,7 +150,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public static Item[] Items = { new ColorItem(), new TitleColorItem(),
|
public static Item[] Items = { new ColorItem(), new TitleColorItem(),
|
||||||
new TitleItem(), new RankItem(), new LevelItem(), new LoginMessageItem(),
|
new TitleItem(), new RankItem(), new LevelItem(), new LoginMessageItem(),
|
||||||
new LogoutMessageItem(), new BlocksItem(), new QueueLevelItem() };
|
new LogoutMessageItem(), new BlocksItem(), new QueueLevelItem(), new InfectMessageItem() };
|
||||||
|
|
||||||
public static Item GetItem(string name) {
|
public static Item GetItem(string name) {
|
||||||
foreach (Item item in Items) {
|
foreach (Item item in Items) {
|
||||||
|
@ -118,7 +118,8 @@ namespace MCGalaxy.Eco {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected internal override void OnStoreCommand(Player p) {
|
protected internal override void OnStoreCommand(Player p) {
|
||||||
Player.SendMessage(p, Name + "s cost %f" + Price + " %3" + Server.moneys + " %Seach");
|
string plural = Name[Name.Length - 1] == 's' ? Name : Name + "s";
|
||||||
|
Player.SendMessage(p, plural + " cost %f" + Price + " %3" + Server.moneys + " %Seach");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,9 @@ namespace MCGalaxy.Eco {
|
|||||||
Group maxrank = Group.Find(MaxRank);
|
Group maxrank = Group.Find(MaxRank);
|
||||||
Player.SendMessage(p, "%fThe maximum buyable rank is: " + maxrank.color + maxrank.name);
|
Player.SendMessage(p, "%fThe maximum buyable rank is: " + maxrank.color + maxrank.name);
|
||||||
Player.SendMessage(p, "%cRanks purchased will be bought in order.");
|
Player.SendMessage(p, "%cRanks purchased will be bought in order.");
|
||||||
Player.SendMessage(p, "%fRanks cost:");
|
|
||||||
|
|
||||||
foreach (Rank rnk in RanksList) {
|
foreach (Rank rnk in RanksList) {
|
||||||
Player.SendMessage(p, rnk.group.color + rnk.group.name + ": %f" + rnk.price + " %3" + Server.moneys);
|
Player.SendMessage(p, rnk.group.color + rnk.group.name + " costs&f" + rnk.price + " &3" + Server.moneys);
|
||||||
if (rnk.group.name.CaselessEq(maxrank.name)) break;
|
if (rnk.group.name.CaselessEq(maxrank.name)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MCGalaxy.Eco {
|
namespace MCGalaxy.Eco {
|
||||||
|
|
||||||
@ -64,4 +65,43 @@ namespace MCGalaxy.Eco {
|
|||||||
MakePurchase(p, Price, "%3QueueLevel: " + message);
|
MakePurchase(p, Price, "%3QueueLevel: " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class InfectMessageItem : SimpleItem {
|
||||||
|
|
||||||
|
public InfectMessageItem() {
|
||||||
|
Aliases = new[] { "infectmessage", "infectmsg" };
|
||||||
|
Price = 150;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Name { get { return "InfectMessage"; } }
|
||||||
|
|
||||||
|
static char[] trimChars = { ' ' };
|
||||||
|
protected override void OnBuyCommand(Player p, string message, string[] args) {
|
||||||
|
string text = message.Split(trimChars, 2)[1]; // keep spaces this way
|
||||||
|
bool hasAToken = false;
|
||||||
|
for (int i = 0; i < text.Length; i++) {
|
||||||
|
if (!CheckEscape(text, i, ref hasAToken)) {
|
||||||
|
Player.SendMessage(p, "You can only use {0} and {1} for tokens in infect messages."); return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasAToken) {
|
||||||
|
Player.SendMessage(p, "You need to include a \"{0}\" (placeholder for zombie player) " +
|
||||||
|
"and/or a \"{1}\" (placeholder for human player) in the infect message."); return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerDB.AppendInfectMessage(p.name, text);
|
||||||
|
if (p.infectMessages == null) p.infectMessages = new List<string>();
|
||||||
|
p.infectMessages.Add(text);
|
||||||
|
Player.SendMessage(p, "%aAdded infect message: %f" + text);
|
||||||
|
MakePurchase(p, Price, "%3InfectMessage: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool CheckEscape(string text, int i, ref bool hasAToken) {
|
||||||
|
// Only {0} and {1} are allowed in infect messages for the Format() call
|
||||||
|
if (text[i] != '{') return true;
|
||||||
|
hasAToken = true;
|
||||||
|
if ((i + 2) >= text.Length) return false;
|
||||||
|
return (text[i + 1] == '0' || text[i + 1] == '1') && text[i + 2] == '}';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,11 +186,7 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
lastPlayerToInfect = pKiller.name;
|
lastPlayerToInfect = pKiller.name;
|
||||||
pKiller.playersInfected++;
|
pKiller.playersInfected++;
|
||||||
CurLevel.ChatLevel(String.Format(
|
ShowInfectMessage(random, pAlive, pKiller);
|
||||||
messages[random.Next(messages.Length)],
|
|
||||||
Colors.red + pKiller.DisplayName + Colors.yellow,
|
|
||||||
Colors.red + pAlive.DisplayName + Colors.yellow));
|
|
||||||
|
|
||||||
CheckHumanPledge(pAlive);
|
CheckHumanPledge(pAlive);
|
||||||
CheckBounty(pAlive, pKiller);
|
CheckBounty(pAlive, pKiller);
|
||||||
UpdatePlayerColor(pAlive, InfectCol);
|
UpdatePlayerColor(pAlive, InfectCol);
|
||||||
@ -210,6 +206,19 @@ namespace MCGalaxy.Games {
|
|||||||
pAlive.OnMoneyChanged();
|
pAlive.OnMoneyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShowInfectMessage(Random random, Player pAlive, Player pKiller) {
|
||||||
|
string text = null;
|
||||||
|
List<string> infectMsgs = pKiller.infectMessages;
|
||||||
|
if (infectMsgs != null && random.Next(0, 10) < 5)
|
||||||
|
text = infectMsgs[random.Next(infectMsgs.Count)];
|
||||||
|
else
|
||||||
|
text = messages[random.Next(messages.Length)];
|
||||||
|
|
||||||
|
CurLevel.ChatLevel(String.Format(text,
|
||||||
|
Colors.red + pKiller.DisplayName + Colors.yellow,
|
||||||
|
Colors.red + pAlive.DisplayName + Colors.yellow));
|
||||||
|
}
|
||||||
|
|
||||||
void CheckBounty(Player pAlive, Player pKiller) {
|
void CheckBounty(Player pAlive, Player pKiller) {
|
||||||
BountyData bounty;
|
BountyData bounty;
|
||||||
if (Bounties.TryGetValue(pAlive.name, out bounty))
|
if (Bounties.TryGetValue(pAlive.name, out bounty))
|
||||||
|
@ -179,7 +179,7 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
if (rainbownum > 2) {
|
if (rainbownum > 2) {
|
||||||
byte block = lvl.blocks[C.b];
|
byte block = lvl.blocks[C.b];
|
||||||
if (block < Block.red || block > Block.darkpink) {
|
if (block < Block.red || block > Block.darkpink) {
|
||||||
lvl.AddUpdate(C.b, Block.red, true);
|
lvl.AddUpdate(C.b, Block.red, true, C.data);
|
||||||
} else {
|
} else {
|
||||||
byte next = block == Block.darkpink ? Block.red : (byte)(block + 1);
|
byte next = block == Block.darkpink ? Block.red : (byte)(block + 1);
|
||||||
lvl.AddUpdate(C.b, next);
|
lvl.AddUpdate(C.b, next);
|
||||||
|
@ -532,6 +532,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Server.s.Log(name + " [" + ip + "] has joined the server.");
|
Server.s.Log(name + " [" + ip + "] has joined the server.");
|
||||||
|
infectMessages = PlayerDB.GetInfectMessages(this);
|
||||||
Server.zombie.PlayerJoinedServer(this);
|
Server.zombie.PlayerJoinedServer(this);
|
||||||
try {
|
try {
|
||||||
ushort x = (ushort)((0.5 + level.spawnx) * 32);
|
ushort x = (ushort)((0.5 + level.spawnx) * 32);
|
||||||
|
@ -188,17 +188,18 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
//Zombie
|
//Zombie
|
||||||
public bool referee = false;
|
public bool referee = false;
|
||||||
public int blockCount = 50;
|
internal int blockCount = 50;
|
||||||
public bool voted = false;
|
public bool voted = false;
|
||||||
public int blocksStacked = 0;
|
internal int blocksStacked = 0;
|
||||||
public int lastYblock = 0, lastXblock = 0, lastZblock = 0;
|
internal int lastYblock = 0, lastXblock = 0, lastZblock = 0;
|
||||||
public bool infected = false;
|
public bool infected = false;
|
||||||
public bool aka = false;
|
public bool aka = false;
|
||||||
public bool flipHead = false;
|
public bool flipHead = false;
|
||||||
public int playersInfected = 0;
|
internal int playersInfected = 0;
|
||||||
internal string lastSpawnColor = "";
|
internal string lastSpawnColor = "";
|
||||||
internal bool ratedMap = false;
|
internal bool ratedMap = false;
|
||||||
internal bool pledgeSurvive = false;
|
internal bool pledgeSurvive = false;
|
||||||
|
internal List<string> infectMessages = null;
|
||||||
|
|
||||||
//Tnt Wars
|
//Tnt Wars
|
||||||
public bool PlayingTntWars = false;
|
public bool PlayingTntWars = false;
|
||||||
|
@ -63,6 +63,13 @@ namespace MCGalaxy {
|
|||||||
writer.Write(text);
|
writer.Write(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AppendLine(string file, string text) {
|
||||||
|
using (CP437Writer writer = new CP437Writer(file, true)) {
|
||||||
|
writer.Write(text);
|
||||||
|
writer.WriteLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string ConvertToUnicode(string text) {
|
public static string ConvertToUnicode(string text) {
|
||||||
if (text == null) return null;
|
if (text == null) return null;
|
||||||
if (text.Length == 0) return "";
|
if (text.Length == 0) return "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user