122 lines
4.6 KiB
C#
122 lines
4.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace Invector
|
|
{
|
|
[System.Serializable]
|
|
public class vDamage
|
|
{
|
|
[Tooltip("Apply damage to the Character Health")]
|
|
public int damageValue = 15;
|
|
[Tooltip("How much stamina the target will lost when blocking this attack")]
|
|
public float staminaBlockCost = 5;
|
|
[Tooltip("How much time the stamina of the target will wait to recovery")]
|
|
public float staminaRecoveryDelay = 1;
|
|
[Tooltip("Apply damage even if the Character is blocking")]
|
|
public bool ignoreDefense;
|
|
[Tooltip("Activated Ragdoll when hit the Character")]
|
|
public bool activeRagdoll;
|
|
[vHideInInspector("activeRagdoll"), Tooltip("Time to keep Ragdoll active")]
|
|
public float senselessTime;
|
|
[HideInInspector]
|
|
public Transform sender;
|
|
[HideInInspector]
|
|
public Transform receiver;
|
|
[HideInInspector]
|
|
public Vector3 hitPosition;
|
|
public bool hitReaction = true; // To pole Invectora pozostaje
|
|
[HideInInspector]
|
|
public int recoil_id = 0;
|
|
[HideInInspector]
|
|
public int reaction_id = 0;
|
|
public string damageType;
|
|
[HideInInspector] public Vector3 force;
|
|
|
|
// >>> NASZE NOWE POLE <<<
|
|
[Tooltip("If true, will attempt to bypass standard hit reaction animations, sounds, and events like OnReceiveDamage.")]
|
|
public bool ignoreAllHitEffects = false;
|
|
|
|
public vDamage()
|
|
{
|
|
this.damageValue = 15;
|
|
this.staminaBlockCost = 5;
|
|
this.staminaRecoveryDelay = 1;
|
|
this.hitReaction = true;
|
|
this.ignoreAllHitEffects = false; // Domyślnie efekty są włączone
|
|
}
|
|
|
|
public vDamage(int value)
|
|
{
|
|
this.damageValue = value;
|
|
this.hitReaction = true;
|
|
this.ignoreAllHitEffects = false; // Domyślnie efekty są włączone
|
|
}
|
|
|
|
// Ten konstruktor już istniał, zmodyfikujemy go lekko
|
|
// lub dodamy nowy, jeśli chcemy zachować stary w niezmienionej formie.
|
|
// Dla uproszczenia, zmodyfikujmy ten, aby przyjmował naszą nową flagę.
|
|
// Jeśli `ignoreReactionOrEffects` jest true, ustawiamy obie flagi.
|
|
public vDamage(int value, bool ignoreReactionAndAllEffects)
|
|
{
|
|
this.damageValue = value;
|
|
this.ignoreAllHitEffects = ignoreReactionAndAllEffects; // Ustawiamy naszą nową flagę
|
|
|
|
if (ignoreReactionAndAllEffects)
|
|
{
|
|
this.hitReaction = false; // Jeśli ignorujemy wszystkie efekty, to reakcję też
|
|
this.recoil_id = -1;
|
|
this.reaction_id = -1;
|
|
}
|
|
else
|
|
{
|
|
this.hitReaction = true; // W przeciwnym razie standardowa reakcja
|
|
}
|
|
}
|
|
|
|
// Możesz też dodać bardziej specyficzny konstruktor tylko dla naszej flagi,
|
|
// jeśli chcesz mieć większą kontrolę:
|
|
/*
|
|
public vDamage(int value, bool setHitReaction, bool setIgnoreAllHitEffects)
|
|
{
|
|
this.damageValue = value;
|
|
this.hitReaction = setHitReaction;
|
|
this.ignoreAllHitEffects = setIgnoreAllHitEffects;
|
|
if (!setHitReaction) // Jeśli hitReaction jest false
|
|
{
|
|
this.recoil_id = -1;
|
|
this.reaction_id = -1;
|
|
}
|
|
}
|
|
*/
|
|
|
|
|
|
public vDamage(vDamage damage) // Konstruktor kopiujący
|
|
{
|
|
this.damageValue = damage.damageValue;
|
|
this.staminaBlockCost = damage.staminaBlockCost;
|
|
this.staminaRecoveryDelay = damage.staminaRecoveryDelay;
|
|
this.ignoreDefense = damage.ignoreDefense;
|
|
this.activeRagdoll = damage.activeRagdoll;
|
|
this.sender = damage.sender;
|
|
this.receiver = damage.receiver;
|
|
this.recoil_id = damage.recoil_id;
|
|
this.reaction_id = damage.reaction_id;
|
|
this.damageType = damage.damageType;
|
|
this.hitPosition = damage.hitPosition;
|
|
this.senselessTime = damage.senselessTime;
|
|
this.force = damage.force;
|
|
this.hitReaction = damage.hitReaction; // Skopiuj oryginalne pole hitReaction
|
|
// >>> SKOPIUJ NASZE NOWE POLE <<<
|
|
this.ignoreAllHitEffects = damage.ignoreAllHitEffects;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Calc damage Resuction percentage
|
|
/// </summary>
|
|
/// <param name="damageReduction"></param>
|
|
public void ReduceDamage(float damageReduction)
|
|
{
|
|
int result = (int)(this.damageValue - ((this.damageValue * damageReduction) / 100));
|
|
this.damageValue = result;
|
|
}
|
|
}
|
|
} |