56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using CommandSystem;
|
|
using LabApi.Features.Wrappers;
|
|
using PlayerRoles;
|
|
using ICommand = CommandSystem.ICommand;
|
|
|
|
namespace GrowingZombies;
|
|
|
|
[CommandHandler(typeof(ClientCommandHandler))]
|
|
public class SacrificeCommand: ICommand
|
|
{
|
|
public string Command => "sacrifice";
|
|
public string[] Aliases => ["sac"];
|
|
public string Description => "Sacrifice yourself to give another zombie an extra corpse count";
|
|
|
|
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
|
|
{
|
|
if (!Player.TryGet(sender, out var player))
|
|
{
|
|
response = "You must be a player to use this command!";
|
|
return false;
|
|
}
|
|
|
|
if (player.Role != RoleTypeId.Scp0492)
|
|
{
|
|
response = "You must be a zombie to use this command!";
|
|
return false;
|
|
}
|
|
|
|
var zombies = Player.List.Where(p => p.Role == RoleTypeId.Scp0492 && p != player).ToList();
|
|
if (!zombies.Any())
|
|
{
|
|
response = "There are no other zombies to receive your sacrifice!";
|
|
return false;
|
|
}
|
|
|
|
// Select random zombie to receive the bonus
|
|
var luckyZombie = zombies[UnityEngine.Random.Range(0, zombies.Count)];
|
|
|
|
// Add corpse count to the lucky zombie
|
|
GrowingZombies.Instance.AteCorpse(luckyZombie);
|
|
|
|
// Remove corpse count from the sacrificing player
|
|
GrowingZombies.Instance.ZombieCorpseCount[player] = 0;
|
|
|
|
// Kill the sacrificing player
|
|
player.Kill("Sacrificed themselves for their zombie brethren");
|
|
|
|
luckyZombie.SendHint($"You received the sacrifice of {player.Nickname}!", 5);
|
|
response = "You sacrificed yourself to give another zombie an extra corpse count!";
|
|
|
|
var scp049 = Player.List.FirstOrDefault(p => p.Role == RoleTypeId.Scp049);
|
|
scp049?.SendHint($"Your zombie {player.Nickname} sacrificed themselves to give {luckyZombie.Nickname} another corpse they ate!", 5);
|
|
|
|
return true;
|
|
}
|
|
} |