Skip to content

Commit

Permalink
Merge pull request #21 from Mikihero/dev
Browse files Browse the repository at this point in the history
Added several new effects
  • Loading branch information
Mikihero authored Oct 1, 2023
2 parents b6f2f92 + 5211a51 commit aacf642
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 227 deletions.
3 changes: 3 additions & 0 deletions BetterCoinflips/BetterCoinflips.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\..\..\steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>..\..\..\..\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath>
</Reference>
Expand Down
80 changes: 52 additions & 28 deletions BetterCoinflips/Configs/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using Exiled.API.Enums;
using Exiled.API.Interfaces;
using PlayerRoles;

namespace BetterCoinflips.Configs
{
Expand Down Expand Up @@ -82,40 +83,63 @@ public class Config : IConfig
EffectType.Vitality
};

[Description("The % chance of receiving a Facility Manager keycard instead of a Containment Engineer keycard when that effect is chosen. Default: 15")]
[Description("The % chance of receiving a Facility Manager keycard instead of a Containment Engineer one.")]
public int RedCardChance { get; set; } = 15;

[Description("The kick reason.")]
public string KickReason { get; set; } = "The coin kicked your ass.";

[Description("The list of SCP's that you can turn into by using the coin.")]
public List<RoleTypeId> ValidScps = new()
{
RoleTypeId.Scp049,
RoleTypeId.Scp096,
RoleTypeId.Scp106,
RoleTypeId.Scp173,
RoleTypeId.Scp0492,
RoleTypeId.Scp939,
};

[Description("The chance of these good effects happening. It's a proportional chance not a % chance.")]
public int KeycardEffectChance { get; set; } = 20;
public int MedicalKitEffectChance { get; set; } = 35;
public int TpToEscapeEffectChance { get; set; } = 5;
public int HealEffectChance { get; set; } = 10;
public int MoreHpEffectChance { get; set; } = 10;
public int HatEffectChance { get; set; } = 10;
public int KeycardChance { get; set; } = 20;
public int MedicalKitChance { get; set; } = 35;
public int TpToEscapeChance { get; set; } = 5;
public int HealChance { get; set; } = 10;
public int MoreHpChance { get; set; } = 10;
public int HatChance { get; set; } = 10;
public int RandomGoodEffectChance { get; set; } = 30;
public int OneAmmoLogicerEffectChance { get; set; } = 1;
public int LightbulbEffectChance { get; set; } = 15;
public int PinkCandyEffectChance { get; set; } = 10;
public int BadRevoEffectChance { get; set; } = 5;
public int EmptyHidEffectChance { get; set; } = 5;
public int OneAmmoLogicerChance { get; set; } = 1;
public int LightbulbChance { get; set; } = 15;
public int PinkCandyChance { get; set; } = 10;
public int BadRevoChance { get; set; } = 5;
public int EmptyHidChance { get; set; } = 5;
public int ForceRespawnChance { get; set; } = 15;
public int SizeChangeChance { get; set; } = 20;

[Description("The chance of these bad effects happening. It's a proportional chance not a % chance.")]
public int HpReductionEffectChance { get; set; } = 20;
public int TpToClassDCellsEffectChance { get; set; } = 5;
public int HpReductionChance { get; set; } = 20;
public int TpToClassDCellsChance { get; set; } = 5;
public int RandomBadEffectChance { get; set; } = 20;
public int WarheadEffectChance { get; set; } = 10;
public int LightsOutEffectChance { get; set; } = 20;
public int LiveHeEffectChance { get; set; } = 30;
public int TrollGunEffectChance { get; set; } = 50;
public int TrollFlashEffectChance { get; set; } = 50;
public int ScpTpEffectChance { get; set; } = 20;
public int OneHpLeftEffectChance { get; set; } = 15;
public int PrimedVaseEffectChance { get; set; } = 20;
public int ShitPantsEffectChance { get; set; } = 40;
public int FakeCassieEffectChance { get; set; } = 50;
public int ZombieFcEffectChance { get; set; } = 30;
public int InventoryResetEffectChance { get; set; } = 20;
public int ClassSwapEffectChance { get; set; } = 10;
public int InstantExplosionEffectChance { get; set; } = 10;
public int WarheadChance { get; set; } = 10;
public int LightsOutChance { get; set; } = 20;
public int LiveHeChance { get; set; } = 30;
public int TrollGunChance { get; set; } = 50;
public int TrollFlashChance { get; set; } = 50;
public int ScpTpChance { get; set; } = 20;
public int OneHpLeftChance { get; set; } = 15;
public int PrimedVaseChance { get; set; } = 20;
public int ShitPantsChance { get; set; } = 40;
public int FakeCassieChance { get; set; } = 50;
public int TurnIntoScpChance { get; set; } = 30;
public int InventoryResetChance { get; set; } = 20;
public int ClassSwapChance { get; set; } = 10;
public int InstantExplosionChance { get; set; } = 10;
public int PlayerSwapChance { get; set; } = 20;
public int KickChance { get; set; } = 5;
public int SpectSwapChance { get; set; } = 10;
public int TeslaTpChance { get; set; } = 15;
public int InventorySwapChance { get; set; } = 20;
public int HandcuffChance { get; set; } = 10;
public int RandomTeleportChance { get; set; } = 15;
}
}
94 changes: 22 additions & 72 deletions BetterCoinflips/Configs/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,111 +5,61 @@ namespace BetterCoinflips.Configs
{
public class Translations : ITranslation
{
[Description("The message broadcast to a player trying to throw a coin during cooldown.")]
public string TossOnCooldownMessage { get; set; } = "You can't throw the coin yet.";
[Description("This is added to the effect message if the coin breaks.")]
public string CoinBreaksMessage { get; set; } = "\nAlso your coin was used too much and it broke down.";
[Description("The broadcast message when a coin is registered with no uses.")]
public string CoinNoUsesMessage { get; set; } = "Your coin had no uses to begin with!";

[Description("The message broadcast to a player when they receive a facility manager keycard (the red one) from the coin.")]
[Description("Here you can set the message for each of these good coin effects.")]
public string TossOnCooldownMessage { get; set; } = "You can't throw the coin yet.";
public string RedCardMessage { get; set; } = "You acquired a Facility Manager keycard!";

[Description("The message broadcast to a player when they receive a containment engineer keycard (the useless one) from the coin.")]
public string ContainmentEngineerCardMessage { get; set; } = "You acquired a Containment Engineer keycard!";

[Description("The message broadcast to a player when they receive a medi-kit from the coin.")]
public string MediKitMessage { get; set; } = "You received a Medical Kit!";

[Description("The message broadcast to a player when they get teleported to the escape area by the coin.")]
public string TpToEscapeMessage { get; set; } = "You can now escape! That's what you wanted right?";

[Description("The message broadcast to a player when they get magically healed by the coin.")]
public string MagicHealMessage { get; set; } = "You've been magically healed!";

[Description("The message broadcast to a player when they get their hp increased by 10% by the coin.")]
public string HealthIncreaseMessage { get; set; } = "You received 10% more hp!";

[Description("The message broadcast to a player when they receive an SCP-268 from the coin.")]
public string NeatHatMessage { get; set; } = "You got a neat hat!";

[Description("The message broadcast to a player when they receive a random good effect from the coin.")]
public string RandomGoodEffectMessage { get; set; } = "You got a random effect.";

[Description("The message broadcast to a player when they receive a logicer with 1 ammo from the coin.")]
public string OneAmmoLogicerMessage { get; set; } = "You got gun.";

[Description("The message broadcast to a player when they receive an SCP-2176 from the coin.")]
public string LightbulbMessage { get; set; } = "You got a shiny lightbulb!";

[Description("The message broadcast to a player when they receive a pink candy from the coin.")]
public string PinkCandyMessage { get; set; } = "You got a pretty candy!";

[Description("The message broadcast to a player when they receive the worst revolver possible from the coin.")]
public string BadRevoMessage { get; set; } = "What is this abomination!?";

[Description("The message broadcast to a player when they receive an empty micro hid from the coin.")]
public string EmptyHidMessage { get; set; } = "DID YOU JUST GET A MICRO HID!?";

public string ForceRespawnMessage { get; set; } = "Were they supposed to respawn this early?";
public string SizeChangeMessage { get; set; } = "You got gnomed.";


[Description("The message broadcast to a player when they get their hp reduced by 30% by the coin.")]

[Description("Here you can set the message for each of these bad coin effects.")]
public string HpReductionMessage { get; set; } = "Your hp got reduced by 30%.";

[Description("The message broadcast to a player when they get teleported to Class D cells by the coin.")]
public string TpToClassDCellsMessage { get; set; } = "You got teleported to Class D cells.";

[Description("The message broadcast to a player when they receive a random bad effect from the coin.")]
public string RandomBadEffectMessage { get; set; } = "You got a random effect.";

[Description("The message broadcast to a player when the warhead has been stopped by the coin.")]
public string WarheadStopMessage { get; set; } = "The warhead has been stopped.";

[Description("The message broadcast to a player when the warhead has been started by the coin.")]
public string WarheadStartMessage { get; set; } = "The warhead has been started.";

[Description("The message broadcast to a player when the lights have been turned off by the coin.")]
public string LightsOutMessage { get; set; } = "Lights out.";

[Description("The message broadcast to a player when a grenade has been dropped on their head by the coin.")]
public string LiveGrenadeMessage { get; set; } = "Watch your head!";

[Description("The message broadcast to a player when they receive a troll particle disruptor from the coin.")]
public string TrollGunMessage { get; set; } = "YOU GOT A WHAT!?";

[Description("The message broadcast to a player when a flash that can't blind them is dropped on their head by the coin.")]
public string TrollFlashMessage { get; set; } = "You heard something?";

[Description("The message broadcast to a player when they are teleported to a random SCP by the coin.")]
public string TpToRandomScpMessage { get; set; } = "You were teleported to an SCP.";

[Description("The message broadcast to a player when they are dealth 15 damage by the coin.")]
public string SmallDamageMessage { get; set; } = "You've lost 15hp.";

[Description("The message broadcast to a player when they are left on 1 hp by the coin.")]
public string HugeDamageMessage { get; set; } = "You've lost a lot of hp";

[Description("The message broadcast to a player when they a primed vase is spawned on their head.")]
public string PrimedVaseMessage { get; set; } = "Your grandma paid you a visit!";

[Description("The message broadcast to a player when an SCP-173 tantrum is spawned beneath their feet.")]
public string ShitPantsMessage { get; set; } = "You just shit your pants.";

[Description("The message broadcast to a player when the coin fakes a cassie of an SCP dying.")]
public string FakeScpKillMessage { get; set; } = "Did you just kill an SCP?!";

[Description("The message broadcast to a player when the are forceclassed to SCP-049-2 by the coin.")]
public string ZombieFcMessage { get; set; } = "Get zombified LOL";

[Description("The message broadcast to a player when their items are removed by the coin.")]
public string TurnIntoScpMessage { get; set; } = "Get SCP-fied LOL!";
public string InventoryResetMessage { get; set; } = "You lost your stuff.";

[Description("The message broadcast to a player when the are forceclassed to the opposite team by the coin.")]
public string ClassSwapMessage { get; set; } = "That's what I call an UNO reverse card!";

[Description("The message to be added the the chosen effect broadcast if the coin breaks after that throw.")]
public string CoinBreaksMessage { get; set; } = "\nAlso your coin was used too much and it broke down.";

[Description("The message to be broadcast if you try to throw a coin that rolled 0 uses.")]
public string CoinNoUsesMessage { get; set; } = "Your coin had no uses to begin with!";

[Description("The message broadcast to a player when they are exploded by the coin.")]
public string InstantExplosionMessage { get; set; } = "You got smoked.";
public string PlayerSwapMessage { get; set; } = "This could be a very awkward situation.";
public string PlayerSwapIfOneAliveMessage { get; set; } = "You were supposed to switch places with someone but no one else is alive!";
public string KickMessage { get; set; } = "Bye!";
public string SpectSwapPlayerMessage { get; set; } = "You just made someone's round better!";
public string SpectSwapSpectMessage { get; set; } = "You were chosen as a random spectator to replace this player!";
public string SpectSwapNoSpectsMessage { get; set; } = "You got lucky cause there are no spectators to take your place.";
public string TeslaTpMessage { get; set; } = "So you're a fan of electricity?";
[Description("This message will be broadcast to both players.")]
public string InventorySwapMessage { get; set; } = "Your inventory was swapped with a random player.";
public string RandomTeleportMessage { get; set; } = "You were randomly teleported.";
public string HandcuffMessage { get; set; } = "You were arrested for uhh commiting war crimes... or something.";
}
}
74 changes: 43 additions & 31 deletions BetterCoinflips/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,55 @@ public class EventHandlers
//Dict of all good coin effect chances with an index
private readonly Dictionary<int, int> _goodEffectChances = new()
{
{ 0, Cfg.KeycardEffectChance },
{ 1, Cfg.MedicalKitEffectChance },
{ 2, Cfg.TpToEscapeEffectChance },
{ 3, Cfg.HealEffectChance },
{ 4, Cfg.MoreHpEffectChance },
{ 5, Cfg.HatEffectChance },
{ 0, Cfg.KeycardChance },
{ 1, Cfg.MedicalKitChance },
{ 2, Cfg.TpToEscapeChance },
{ 3, Cfg.HealChance },
{ 4, Cfg.MoreHpChance },
{ 5, Cfg.HatChance },
{ 6, Cfg.RandomGoodEffectChance },
{ 7, Cfg.OneAmmoLogicerEffectChance },
{ 8, Cfg.LightbulbEffectChance },
{ 9, Cfg.PinkCandyEffectChance },
{ 10, Cfg.BadRevoEffectChance },
{ 11, Cfg.EmptyHidEffectChance }
{ 7, Cfg.OneAmmoLogicerChance },
{ 8, Cfg.LightbulbChance },
{ 9, Cfg.PinkCandyChance },
{ 10, Cfg.BadRevoChance },
{ 11, Cfg.EmptyHidChance },
{ 12, Cfg.ForceRespawnChance },
{ 13, Cfg.SizeChangeChance },
};

//Dict of all bad coin effect chances with an index
private readonly Dictionary<int, int> _badEffectChances = new()
{
{ 0, Cfg.HpReductionEffectChance },
{ 1, Cfg.TpToClassDCellsEffectChance },
{ 0, Cfg.HpReductionChance },
{ 1, Cfg.TpToClassDCellsChance },
{ 2, Cfg.RandomBadEffectChance },
{ 3, Cfg.WarheadEffectChance },
{ 4, Cfg.LightsOutEffectChance },
{ 5, Cfg.LiveHeEffectChance },
{ 6, Cfg.TrollGunEffectChance },
{ 7, Cfg.TrollFlashEffectChance },
{ 8, Cfg.ScpTpEffectChance },
{ 9, Cfg.OneHpLeftEffectChance },
{ 10, Cfg.PrimedVaseEffectChance },
{ 11, Cfg.ShitPantsEffectChance },
{ 12, Cfg.FakeCassieEffectChance },
{ 13, Cfg.ZombieFcEffectChance },
{ 14, Cfg.InventoryResetEffectChance },
{ 15, Cfg.ClassSwapEffectChance },
{ 16, Cfg.InstantExplosionEffectChance }
{ 3, Cfg.WarheadChance },
{ 4, Cfg.LightsOutChance },
{ 5, Cfg.LiveHeChance },
{ 6, Cfg.TrollGunChance },
{ 7, Cfg.TrollFlashChance },
{ 8, Cfg.ScpTpChance },
{ 9, Cfg.OneHpLeftChance },
{ 10, Cfg.PrimedVaseChance },
{ 11, Cfg.ShitPantsChance },
{ 12, Cfg.FakeCassieChance },
{ 13, Cfg.TurnIntoScpChance },
{ 14, Cfg.InventoryResetChance },
{ 15, Cfg.ClassSwapChance },
{ 16, Cfg.InstantExplosionChance },
{ 17, Cfg.PlayerSwapChance },
{ 18, Cfg.KickChance },
{ 19, Cfg.SpectSwapChance },
{ 20, Cfg.TeslaTpChance },
{ 21, Cfg.InventorySwapChance },
{ 22, Cfg.RandomTeleportChance },
{ 23, Cfg.HandcuffChance },
};

private readonly Dictionary<string, DateTime> _cooldownDict = new();

//helper method
private void SendBroadcast(Player pl, string message) => pl.Broadcast(Cfg.BroadcastTime, message);
public static void SendBroadcast(Player pl, string message) => pl.Broadcast(new Exiled.API.Features.Broadcast(message, Cfg.BroadcastTime),true);

//main plugin logic
public void OnCoinFlip(FlippingCoinEventArgs ev)
Expand Down Expand Up @@ -135,7 +144,7 @@ public void OnCoinFlip(FlippingCoinEventArgs ev)

randomNum -= kvp.Value;
}

Log.Debug($"headsEvent = {headsEvent}");

//use headsevent to choose the effect and execute it
Expand All @@ -161,7 +170,7 @@ public void OnCoinFlip(FlippingCoinEventArgs ev)

randomNum -= kvp.Value;
}

Log.Debug($"tailsEvent = {tailsEvent}");

//use tailsevent to choose the effect and execute it
Expand All @@ -180,7 +189,10 @@ public void OnCoinFlip(FlippingCoinEventArgs ev)
message += _tr.CoinBreaksMessage;
}

SendBroadcast(ev.Player, message);
if (message != null)
{
SendBroadcast(ev.Player, message);
}
}

//removing default coins
Expand Down
2 changes: 1 addition & 1 deletion BetterCoinflips/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Plugin : Plugin<Config, Configs.Translations>
{
public static Plugin Instance;
public override Version RequiredExiledVersion => new(8, 2, 1, 0);
public override Version Version => new(4, 1, 0);
public override Version Version => new(4, 2, 0);
public override string Author => "Miki_hero";
public override string Name => "BetterCoinflips";
public override string Prefix => "better_cf";
Expand Down
Loading

0 comments on commit aacf642

Please sign in to comment.