From 9d05009ae0fe01ca0b653b5a460222fe0d80da51 Mon Sep 17 00:00:00 2001 From: Extremelyd1 Date: Fri, 6 Oct 2023 15:40:11 +0200 Subject: [PATCH] Add configurable damage for sharp shadow --- HKMP/Animation/Effects/DashBase.cs | 13 +++++++++++-- HKMP/Animation/Effects/DashEnd.cs | 9 ++++++--- HKMP/Api/Server/IServerSettings.cs | 5 +++++ HKMP/Game/Settings/ServerSettings.cs | 4 ++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/HKMP/Animation/Effects/DashBase.cs b/HKMP/Animation/Effects/DashBase.cs index 347bd2c..4b4ef1b 100644 --- a/HKMP/Animation/Effects/DashBase.cs +++ b/HKMP/Animation/Effects/DashBase.cs @@ -119,16 +119,25 @@ protected void Play(GameObject playerObject, bool[] effectInfo, bool shadowDash, // Start a coroutine with the recharge animation, since we need to wait in it MonoBehaviourUtil.Instance.StartCoroutine(PlayRechargeAnimation(playerObject, playerEffects)); + var damage = ServerSettings.SharpShadowDamage; if (!sharpShadow) { // Lastly, disable the player collider, since we are in a shadow dash // We only do this, if we don't have sharp shadow playerObject.GetComponent().enabled = false; - } else if (!ServerSettings.IsBodyDamageEnabled && ServerSettings.IsPvpEnabled && ShouldDoDamage) { + } else if ( + !ServerSettings.IsBodyDamageEnabled && + ServerSettings.IsPvpEnabled && + ShouldDoDamage && + damage != 0 + ) { // If body damage is disabled, but PvP is enabled and we are performing a sharp shadow dash // we need to enable the DamageHero component and move the player object to the correct layer // to allow the local player to collide with it playerObject.layer = 11; - playerObject.GetComponent().enabled = true; + + var damageHero = playerObject.GetComponent(); + damageHero.enabled = true; + damageHero.damageDealt = damage; } } else { // Instantiate the dash burst relative to the player effects diff --git a/HKMP/Animation/Effects/DashEnd.cs b/HKMP/Animation/Effects/DashEnd.cs index 59fe0bf..83df038 100644 --- a/HKMP/Animation/Effects/DashEnd.cs +++ b/HKMP/Animation/Effects/DashEnd.cs @@ -11,11 +11,14 @@ internal class DashEnd : AnimationEffect { public override void Play(GameObject playerObject, bool[] effectInfo) { // Enable the player collider again playerObject.GetComponent().enabled = true; - // Disable the DamageHero component and reset the layer if body damage is disabled, but PvP is enabled - // Because it might have been a shadow dash that was ended + // Disable the DamageHero component and reset the damage and the layer of the player if body damage is + // disabled, but PvP is enabled. Because it might have been a shadow dash that was ended if (!ServerSettings.IsBodyDamageEnabled && ServerSettings.IsPvpEnabled) { playerObject.layer = 9; - playerObject.GetComponent().enabled = false; + + var damageHero = playerObject.GetComponent(); + damageHero.damageDealt = 1; + damageHero.enabled = false; } var playerEffects = playerObject.FindGameObjectInChildren("Effects"); diff --git a/HKMP/Api/Server/IServerSettings.cs b/HKMP/Api/Server/IServerSettings.cs index 5b4ea34..dddfa32 100644 --- a/HKMP/Api/Server/IServerSettings.cs +++ b/HKMP/Api/Server/IServerSettings.cs @@ -114,4 +114,9 @@ public interface IServerSettings { /// The damage that the activation of Thorns of Agony from other players deals to the local player. /// public byte ThornOfAgonyDamage { get; } + + /// + /// The damage that a Sharp Shadow dash from others players deals to the local player. + /// + public byte SharpShadowDamage { get; } } diff --git a/HKMP/Game/Settings/ServerSettings.cs b/HKMP/Game/Settings/ServerSettings.cs index 2e6b5c0..0d4929c 100644 --- a/HKMP/Game/Settings/ServerSettings.cs +++ b/HKMP/Game/Settings/ServerSettings.cs @@ -96,6 +96,10 @@ public class ServerSettings : IServerSettings, IEquatable { [SettingAlias("thornsofagonydamage", "thornsofagonydmg", "thornsdamage", "thornsdmg")] public byte ThornOfAgonyDamage { get; set; } = 1; + /// + [SettingAlias("sharpshadowdmg")] + public byte SharpShadowDamage { get; set; } = 1; + /// /// Set all properties in this instance to the values from the given /// instance.