///////////////////////////////////////////////////////////////////////////////////// //void TakeDamage(CharacterData.CharacterEntry, int float, bool // //Takes damage using the appropriate stats // //CharacterData.CharacterEntry other - The CharacterEntry representing the attacker// //int otherWeapon - The attacker's weapon attack // //float attackBase - The base attack multiplier of the attack // //bool isMagical - is the attack magical? // ///////////////////////////////////////////////////////////////////////////////////// public void TakeDamage(CharacterData.CharacterEntry other, float attackBase, bool isMagical) { int damage; if (isMagical) { damage = DamageCalculator.CalculateMagicalDamage(other.GetMATK(), attackBase, stats.enemyMDEF); } else { damage = DamageCalculator.CalculatePhysicalDamage(other.GetATK(), attackBase, stats.enemyDEF); } currentHP -= damage; Debug.Log("Damage Taken: " + damage); if (currentHP < 0) { currentHP = 0; } if (currentHP == 0) { Debug.Log("Enemy Defeated!"); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //void TakeDamage(EnemyEntry, float, bool) // //Calculates damage from an enemy attack // //For balancing difficulty, I am considering allowing only certain enemies to crit, so LUCK is not considered for now// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void TakeDamage(EnemyEntry otherStats, float baseDamage, bool isMagical) { if (iframesTimer < iframes) { //iframes are active, take no damage// return; } int damage = 0; if (DamageCalculator.Hits(stats.GetAGI(), otherStats.enemyAGI)) { if (isMagical) { damage = DamageCalculator.CalculateMagicalDamage(otherStats.enemyMATK, baseDamage, stats.GetMDEF()); } else { damage = DamageCalculator.CalculatePhysicalDamage(otherStats.enemyATK, baseDamage, stats.GetDEF()); } } currentHP -= damage; if (currentHP <= 0) { currentHP = 0; HandleDeath(); } iframesTimer = 0; }
public override List <AbilityResult> Process(List <Combatant> targets) { List <AbilityResult> results = new List <AbilityResult>(); // It's a physical attack, so let's do some physical damage! if (this.model.PhysicalDamageModifier != 0) { foreach (Combatant target in targets) { results.Add(DamageCalculator.CalculatePhysicalDamage(this.actingCombatant, target, this.model.PhysicalDamageModifier)); } } if (this.model.MagicalDamageModifier != 0) { if (this.model.TargetingType == Spells.Abilities.TargetingType.DEFENSIVE_SINGLE || this.model.TargetingType == Spells.Abilities.TargetingType.DEFENSIVE_ALL) { foreach (Combatant target in targets) { results.Add(DamageCalculator.CalculateHealing(this.actingCombatant, target, this.model.MagicalDamageModifier)); } } else { foreach (Combatant target in targets) { } } } return(results); }
// Processes the attack. The attack effect is modified by the number of momentum applied. public override List <AbilityResult> Process(List <Combatant> targets) { this.damageDealt.Clear(); foreach (Combatant target in targets) { damageDealt.Add(DamageCalculator.CalculatePhysicalDamage(this.actingCombatant, target, this.physicalDamageModifier)); } return(null); }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //void TakeTouchDamage(EnemyEntry) // //Calculates enemy touch damage (contact with the enemy hitbox) // //For balancing difficulty, I am considering allowing only certain enemies to crit, so LUCK is not considered for now// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void TakeTouchDamage(EnemyEntry otherStats) { if (iframesTimer < iframes) { //iframes are active, take no damage// return; } if (DamageCalculator.Hits(otherStats.enemyAGI, stats.GetAGI())) { int damage = DamageCalculator.CalculatePhysicalDamage(otherStats.enemyATK, 1f, stats.GetDEF()); currentHP -= damage; if (currentHP <= 0) { currentHP = 0; HandleDeath(); } } iframesTimer = 0; }