From 6f5114b495bc1e0ffd5929113d893afe7740c629 Mon Sep 17 00:00:00 2001 From: ProtoSharkk Date: Sun, 27 Oct 2024 00:18:18 -0700 Subject: [PATCH] Attack damage scales quadratic with time until at damageStrength --- Assets/Scripts C#/Ratbot.cs | 1 + Assets/Scripts C#/Teo.cs | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts C#/Ratbot.cs b/Assets/Scripts C#/Ratbot.cs index 692ccc1..94a3eba 100644 --- a/Assets/Scripts C#/Ratbot.cs +++ b/Assets/Scripts C#/Ratbot.cs @@ -33,6 +33,7 @@ public class Ratbot : MonoBehaviour // Die if health below zero public void Damage(float hurtyAmount) { + Debug.Log(hurtyAmount); health -= hurtyAmount; if (health <= 0) { Destroy(gameObject); diff --git a/Assets/Scripts C#/Teo.cs b/Assets/Scripts C#/Teo.cs index af79b9e..32d3042 100644 --- a/Assets/Scripts C#/Teo.cs +++ b/Assets/Scripts C#/Teo.cs @@ -10,7 +10,6 @@ public class Teo : MonoBehaviour public float swingDistance = 10; public float damageStrength = 10; public float attackCooldownSeconds = 10; - public float spamPunishMultiplier = 0.5F; public float dashDistance = 5F; public float dashCooldownSeconds = 5; public float lastAttackTime = 0; @@ -68,13 +67,15 @@ public class Teo : MonoBehaviour Input.mousePosition.x - Screen.width/2 )) > swingRangeDeg * Mathf.Deg2Rad ) continue; - // Apply a multiplier to damageStrength based on attack cooldown. - // If multiplier > 1, just do damageStrength - float damageAmount = damageStrength * (Time.fixedTime - lastAttackTime)/attackCooldownSeconds; + // Apply x^2 multiplier to damage if not fully charged + // Just use damageStrength if fully charged + float timeWaited = Time.fixedTime - lastAttackTime; ratbot.Damage( - (damageAmount > damageStrength) - ? damageStrength - : damageAmount * spamPunishMultiplier + (timeWaited < attackCooldownSeconds) + ? Mathf.Pow(timeWaited, 2) * + damageStrength / + Mathf.Pow(attackCooldownSeconds, 2) + : damageStrength ); } }