mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Add custom kill/death messages for bots.
This commit is contained in:
parent
1b094763b2
commit
1ee3a739b3
@ -255,7 +255,6 @@ namespace MCGalaxy {
|
||||
SetDeath(Block.StillWater, drowned, false);
|
||||
SetDeath(Block.Lava, drowned, false);
|
||||
SetDeath(Block.StillLava, drowned, false);
|
||||
SetDeath(Block.Invalid, "@p %Swas &cterminated.", false);
|
||||
}
|
||||
|
||||
static void SetDeath(byte block, string message, bool collideKill = true) {
|
||||
|
@ -93,6 +93,7 @@ namespace MCGalaxy.Bots {
|
||||
public string Model { get; set; }
|
||||
public string Color { get; set; }
|
||||
public string ClickedOnText { get; set; }
|
||||
public string DeathMessage { get; set; }
|
||||
|
||||
public string AI { get; set; }
|
||||
public bool Kill { get; set; }
|
||||
@ -115,7 +116,7 @@ namespace MCGalaxy.Bots {
|
||||
Kill = bot.kill; Hunt = bot.hunt;
|
||||
DisplayName = bot.DisplayName;
|
||||
CurInstruction = bot.cur; CurJump = bot.curJump;
|
||||
ClickedOnText = bot.ClickedOnText;
|
||||
ClickedOnText = bot.ClickedOnText; DeathMessage = bot.DeathMessage;
|
||||
|
||||
X = bot.Pos.X; Y = bot.Pos.Y; Z = bot.Pos.Z;
|
||||
RotX = bot.Rot.RotY; RotY = bot.Rot.HeadX;
|
||||
@ -134,7 +135,7 @@ namespace MCGalaxy.Bots {
|
||||
bot.DisplayName = DisplayName;
|
||||
|
||||
bot.cur = CurInstruction; bot.curJump = CurJump;
|
||||
bot.ClickedOnText = ClickedOnText;
|
||||
bot.ClickedOnText = ClickedOnText; bot.DeathMessage = DeathMessage;
|
||||
}
|
||||
|
||||
public BotProperties Copy() {
|
||||
@ -145,7 +146,7 @@ namespace MCGalaxy.Bots {
|
||||
|
||||
copy.AI = AI; copy.Kill = Kill; copy.Hunt = Hunt;
|
||||
copy.CurInstruction = CurInstruction; copy.CurJump = CurJump;
|
||||
copy.ClickedOnText = ClickedOnText;
|
||||
copy.ClickedOnText = ClickedOnText; copy.DeathMessage = DeathMessage;
|
||||
|
||||
copy.X = X; copy.Y = Y; copy.Z = Z;
|
||||
copy.RotX = RotX; copy.RotY = RotY;
|
||||
|
@ -109,7 +109,9 @@ namespace MCGalaxy.Bots {
|
||||
int dz = Math.Abs(bot.Pos.Z - p.Pos.Z);
|
||||
|
||||
if (dx <= 8 && dy <= 16 && dz <= 8) {
|
||||
p.HandleDeath(ExtBlock.Invalid);
|
||||
string msg = bot.DeathMessage;
|
||||
if (msg == null) msg = "@p %Swas &cterminated.";
|
||||
p.HandleDeath((ExtBlock)Block.Cobblestone, msg);
|
||||
}
|
||||
}
|
||||
bot.NextInstruction(); return true;
|
||||
|
@ -31,6 +31,7 @@ namespace MCGalaxy {
|
||||
public string AIName = "", color;
|
||||
public string name, DisplayName;
|
||||
public string ClickedOnText;
|
||||
public string DeathMessage;
|
||||
public string ColoredName { get { return color + DisplayName; } }
|
||||
|
||||
public byte id;
|
||||
|
@ -42,7 +42,10 @@ namespace MCGalaxy.Commands.Bots {
|
||||
} else if (args[0].CaselessEq("text")) {
|
||||
string text = args.Length > 2 ? args[2] : null;
|
||||
SetBotText(p, args[1], text);
|
||||
} else {
|
||||
} else if (args[0].CaselessEq("deathmsg") || args[0].CaselessEq("deathmessage")) {
|
||||
string text = args.Length > 2 ? args[2] : null;
|
||||
SetDeathMessage(p, args[1], text);
|
||||
} else {
|
||||
Help(p);
|
||||
}
|
||||
}
|
||||
@ -103,16 +106,32 @@ namespace MCGalaxy.Commands.Bots {
|
||||
}
|
||||
BotsFile.Save(bot.level);
|
||||
}
|
||||
|
||||
|
||||
void SetDeathMessage(Player p, string botName, string text) {
|
||||
PlayerBot bot = Matcher.FindBots(p, botName);
|
||||
if (bot == null) return;
|
||||
if (!LevelInfo.ValidateAction(p, p.level.name, "set kill message of that bot")) return;
|
||||
|
||||
if (text == null) {
|
||||
Player.Message(p, "Reset shown when bot {0} %Skills someone", bot.ColoredName);
|
||||
bot.DeathMessage = null;
|
||||
} else {
|
||||
if (!MessageBlock.Validate(p, text, false)) return;
|
||||
Player.Message(p, "Set message shown when bot {0} %Skills someone to {1}", bot.ColoredName, text);
|
||||
bot.DeathMessage = text;
|
||||
}
|
||||
BotsFile.Save(bot.level);
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/Bot add [name]");
|
||||
Player.Message(p, "%HAdds a new bot at your position.");
|
||||
Player.Message(p, "%T/Bot remove [name]");
|
||||
Player.Message(p, "%HRemove a bot on the same level as you");
|
||||
Player.Message(p, "%HIf [name] is \"all\", all bots on your map are removed");
|
||||
Player.Message(p, "%T/Bot add [name] %H- Adds a new bot at your position");
|
||||
Player.Message(p, "%T/Bot remove [name] %H- Removes the bot with that name");
|
||||
Player.Message(p, "%H If [name] is \"all\", removes all bots on your map");
|
||||
Player.Message(p, "%T/Bot text [name] <text>");
|
||||
Player.Message(p, "%HSets the text shown when a player clicks on this bot");
|
||||
Player.Message(p, "%HSee %T/help mb %Hfor more details on <text>");
|
||||
Player.Message(p, "%T/Bot deathmessage [name] <message>");
|
||||
Player.Message(p, "%HSets the message shown when this bot kills a player");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace MCGalaxy.Commands.Chatting {
|
||||
if (p != null && who.Rank > p.Rank) {
|
||||
MessageTooHighRank(p, "&cdeath-hug%S", true); return;
|
||||
}
|
||||
who.HandleDeath((ExtBlock)Block.Stone, " died from a %cdeadly hug.");
|
||||
who.HandleDeath((ExtBlock)Block.Stone, "@p %Sdied from a %cdeadly hug.");
|
||||
}
|
||||
TryMessageAction(p, args[0], "{0} %Sgave {1} %Sa " + hugType + " hug.", false); return;
|
||||
}
|
||||
|
@ -106,9 +106,9 @@ namespace MCGalaxy.Commands.Fun {
|
||||
ExtBlock stone = (ExtBlock)Block.Cobblestone;
|
||||
Player p = args.player;
|
||||
if (p.level.physics >= 3 && args.weaponType >= WeaponType.Explode) {
|
||||
pl.HandleDeath(stone, " was blown up by " + p.ColoredName, true);
|
||||
pl.HandleDeath(stone, "@p %Swas blown up by " + p.ColoredName, true);
|
||||
} else {
|
||||
pl.HandleDeath(stone, " was shot by " + p.ColoredName);
|
||||
pl.HandleDeath(stone, "@p %Swas shot by " + p.ColoredName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -125,9 +125,9 @@ namespace MCGalaxy.Commands.Fun {
|
||||
ExtBlock stone = (ExtBlock)Block.Cobblestone;
|
||||
Player p = args.player;
|
||||
if (p.level.physics >= 3 && args.weaponType >= WeaponType.Explode) {
|
||||
pl.HandleDeath(stone, " was blown up by " + p.ColoredName, true);
|
||||
pl.HandleDeath(stone, "@p %Swas blown up by " + p.ColoredName, true);
|
||||
} else {
|
||||
pl.HandleDeath(stone, " was hit by a missile from " + p.ColoredName);
|
||||
pl.HandleDeath(stone, "@p %Swas hit by a missile from " + p.ColoredName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
ExtBlock rock = (ExtBlock)Block.Stone;
|
||||
|
||||
if (target == null) {
|
||||
if (p != null) p.HandleDeath(rock, " killed themselves in their confusion");
|
||||
if (p != null) p.HandleDeath(rock, "@p %Skilled themselves in their confusion");
|
||||
return;
|
||||
}
|
||||
if (p != null && (target != p && target.Rank >= p.Rank)) {
|
||||
|
@ -359,7 +359,7 @@ namespace MCGalaxy {
|
||||
HandleDeath((ExtBlock)b, customMessage, explode, immediate);
|
||||
}
|
||||
|
||||
public void HandleDeath(ExtBlock block, string customMessage = "", bool explode = false, bool immediate = false) {
|
||||
public void HandleDeath(ExtBlock block, string customMsg = "", bool explode = false, bool immediate = false) {
|
||||
OnPlayerDeathEvent.Call(this, block);
|
||||
|
||||
if (Server.lava.active && Server.lava.HasPlayer(this) && Server.lava.IsPlayerDead(this)) return;
|
||||
@ -379,9 +379,9 @@ namespace MCGalaxy {
|
||||
if (block.BlockID == Block.Stone || block.BlockID == Block.Cobblestone) {
|
||||
if (explode) level.MakeExplosion(x, y, z, 1);
|
||||
if (block.BlockID == Block.Stone) {
|
||||
Chat.MessageGlobal(this, ColoredName + "%S" + customMessage, false);
|
||||
Chat.MessageGlobal(this, customMsg.Replace("@p", ColoredName), false);
|
||||
} else {
|
||||
Chat.MessageLevel(this, ColoredName + "%S" + customMessage, false, level);
|
||||
Chat.MessageLevel(this, customMsg.Replace("@p", ColoredName), false, level);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user