Skip to content

Commit

Permalink
Add configurable damage for sharp shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
Extremelyd1 committed Oct 6, 2023
1 parent b15279c commit 9d05009
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
13 changes: 11 additions & 2 deletions HKMP/Animation/Effects/DashBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BoxCollider2D>().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<DamageHero>().enabled = true;

var damageHero = playerObject.GetComponent<DamageHero>();
damageHero.enabled = true;
damageHero.damageDealt = damage;
}
} else {
// Instantiate the dash burst relative to the player effects
Expand Down
9 changes: 6 additions & 3 deletions HKMP/Animation/Effects/DashEnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ internal class DashEnd : AnimationEffect {
public override void Play(GameObject playerObject, bool[] effectInfo) {
// Enable the player collider again
playerObject.GetComponent<BoxCollider2D>().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<DamageHero>().enabled = false;

var damageHero = playerObject.GetComponent<DamageHero>();
damageHero.damageDealt = 1;
damageHero.enabled = false;
}

var playerEffects = playerObject.FindGameObjectInChildren("Effects");
Expand Down
5 changes: 5 additions & 0 deletions HKMP/Api/Server/IServerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@ public interface IServerSettings {
/// The damage that the activation of Thorns of Agony from other players deals to the local player.
/// </summary>
public byte ThornOfAgonyDamage { get; }

/// <summary>
/// The damage that a Sharp Shadow dash from others players deals to the local player.
/// </summary>
public byte SharpShadowDamage { get; }
}
4 changes: 4 additions & 0 deletions HKMP/Game/Settings/ServerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public class ServerSettings : IServerSettings, IEquatable<ServerSettings> {
[SettingAlias("thornsofagonydamage", "thornsofagonydmg", "thornsdamage", "thornsdmg")]
public byte ThornOfAgonyDamage { get; set; } = 1;

/// <inheritdoc />
[SettingAlias("sharpshadowdmg")]
public byte SharpShadowDamage { get; set; } = 1;

/// <summary>
/// Set all properties in this <see cref="ServerSettings"/> instance to the values from the given
/// <see cref="ServerSettings"/> instance.
Expand Down

0 comments on commit 9d05009

Please sign in to comment.