From dd645dba2a630691441197a32fa0f3e9825db75e Mon Sep 17 00:00:00 2001 From: Ny Bruker <robinhs@stud.ntnu.no> Date: Sat, 1 Oct 2022 15:08:07 +0200 Subject: [PATCH] Added cooldown to the four eyes item. --- .../Assets/Code/Item/Items/ItemFourEyes.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/MrBigsock/Assets/Code/Item/Items/ItemFourEyes.cs b/MrBigsock/Assets/Code/Item/Items/ItemFourEyes.cs index 03ae1178..f3401629 100644 --- a/MrBigsock/Assets/Code/Item/Items/ItemFourEyes.cs +++ b/MrBigsock/Assets/Code/Item/Items/ItemFourEyes.cs @@ -13,11 +13,26 @@ namespace BigSock.Item { public class ItemFourEyes : OnHitItemBase { public override ulong Id => 201; public override string Name => "Four Eyes"; - public override string Description => "30% chance to deal double dammage."; + public override string Description => "30% chance to deal double dammage. Has a 2 second cooldown."; public static readonly double CHANCE = 0.3; + public static readonly TimeSpan COOLDOWN = new TimeSpan(0, 0, 0, 2, 0); + + /* + Stores the next time the character can recieve damage. + */ + public DateTime NextTimeCanTrigger { get; private set; } = DateTime.Now; + + public ItemFourEyes() { } public override void Handler(Character source, Character target, AttackStats attack) { + // Check if the cooldown has happened yet. + if(NextTimeCanTrigger > DateTime.Now) return; + + // Start new trigger time. + NextTimeCanTrigger = DateTime.Now + COOLDOWN; + + // Check if it triggers. var roll = RND.NextDouble(); if(roll >= CHANCE) { attack.Damage *= 2; -- GitLab