private void ApplyAura(DamageDetails details) { if (details.AuraToApply != null && !details.TargetHasEvaded) { _auraComponent.AddAura(details.AuraToApply); } }
private void ApplyDamage(DamageDetails details) { int actualValueDealt = 0; if (details.Damage == 0) { return; } if (details.Type != DamageType.Healing) { if (!details.TargetHasEvaded) { actualValueDealt = _healthComponent.TakeDamage(details.Damage, details.Type); if (actualValueDealt > 0) { _spriteDisplay.TintSprite(_damageTintColour); } } else { _spriteDisplay.TintSprite(_evadedTintColour); } } else { actualValueDealt = _healthComponent.Heal(details.Damage); } _onCombatActionEvent.TriggerEvent(EntityTransform.GetInstanceID(), new CombatActionDetails(actualValueDealt, GetCombatActionType(details), EntityTransform)); }
IEnumerator RunMove(BattleUnit sourceUnit, BattleUnit targetUnit, Move move) { move.PP--; yield return(_dialogueBox.TypeDialogue($"{sourceUnit.BattleNuzlon.Base.Name } used {move.Base.Name}")); sourceUnit.PlayAttackAnimation(); yield return(new WaitForSeconds(1f)); targetUnit.PlayHitAnimation(); DamageDetails damageDetails = targetUnit.BattleNuzlon.TakeDamage(move, sourceUnit.BattleNuzlon); yield return(targetUnit.Hud.UpdateHP()); yield return(ShowDamageDetails(damageDetails)); if (damageDetails.Fainted) { yield return(_dialogueBox.TypeDialogue($"{targetUnit.BattleNuzlon.Base.Name} fainted")); targetUnit.PlayFaintAnimation(); yield return(new WaitForSeconds(2f)); CheckForBattleOver(targetUnit); } }
public DamageDetails TakeDamage(Move move, Monster attacker) { float criticalModifer = 1.0f; if (Random.value * 100.0f < 6.25f) { criticalModifer = 2.0f; } float attributeModifer = AttributeChart.GetEffectiveness(move.MoveBase.Attribute, this.MonsterBase.MainAttribute) * AttributeChart.GetEffectiveness(move.MoveBase.Attribute, this.MonsterBase.SecondaryAttribute); DamageDetails damageDetails = new DamageDetails() { AttributeModifier = attributeModifer, CriticalModifier = criticalModifer, Fainted = false }; float modifiers = Random.Range(0.85f, 1.0f) * attributeModifer * criticalModifer; float a = (2 * attacker.Level + 10) / 250.0f; float d = a * move.MoveBase.Power * ((float)attacker.Attack / Defense) + 2; int damage = Mathf.FloorToInt(d * modifiers); UpdateHealth(damage); return(damageDetails); }
private void ApplyEffect(IDamageHandlerComponent target) { bool hasCrit = CalculateAndReturnCrit(); bool targetHasEvaded = target.HasEvaded(); Aura aura = null; if (_auraType != null) { aura = _auraFactory.Create(_auraType); } DamageType type = _isHealing ? DamageType.Healing : DamageType.Standard; DamageDetails details = new DamageDetails(CalculateAndReturnDamage(hasCrit), type, hasCrit, targetHasEvaded, aura); AttachmentEffectCommand weaponEffectCommand = new AttachmentEffectCommand(target, details); if (_vfx != null) { _vfx.Activate(weaponEffectCommand, _ownerTr, target.EntityTransform, targetHasEvaded); } else { weaponEffectCommand.Execute(); } }
//function that deals damage public DamageDetails TakeDamage(Ability ability, Piece attacker) { // critcal hit float crit = 1f; if (Random.value * 100f <= 6.25f) { crit = 2f; } //gets type weakness float type = TypeChart.GetWeakness(ability.Base.Type, this.Base.Type1) * TypeChart.GetWeakness(ability.Base.Type, this.Base.Type2); var damageDetails = new DamageDetails() { TypeWeakness = type, Crit = crit, Dead = false }; //checks if the move is ult or not float attack = (ability.Base.Category == AbilityCategory.Ultimate) ? attacker.UltAttack : attacker.Attack; float defense = (ability.Base.Category == AbilityCategory.Ultimate) ? UltDefense : Defense; // damage formula float modifiers = Random.Range(0.85f, 1f) * type * crit; float a = (2 * attacker.Level + 10) / 250f; float d = a * ability.Base.Power * ((float)attack / defense) + 2; int damage = Mathf.FloorToInt(d * modifiers); DecreaseHP(damage); return(damageDetails); }
public DamageDetails TakeDamage(Move move, Nuzlon attacker) { //this is the damage magic. This is where you must look at the numbers to see how much damage moves should do float typeEffect = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2); DamageDetails details = new DamageDetails() { TypeEffect = typeEffect, Fainted = false }; float attack = (move.Base.IsRanged) ? attacker.SpecialAttack : attacker.Attack; float defense = (move.Base.IsRanged) ? SpecialDefense : Defense; float modifiers = Random.Range(0.85f, 1f) * typeEffect; float a = (2f * attacker.Level + 10f) / 50f; float d = a * move.Base.Power * (attack / defense) + 2f; int damage = Mathf.FloorToInt(d * modifiers); CurrentHP -= damage; if (CurrentHP <= 0) { CurrentHP = 0; details.Fainted = true; } return(details); }
// Function to take damage public DamageDetails TakeDamage(SkillCalc skill, TerasCalcs attacker) { // check for critical hit float critical = 1f; if (Random.value * 100f <= 6.25) { critical = 2f; } // check element effectiveness float element = ElementEffectiveness.GetEffectiveness(skill.baseSkill.SkillElement, attacker._baseTeras.FirstElement) * ElementEffectiveness.GetEffectiveness(skill.baseSkill.SkillElement, attacker._baseTeras.SecondElement); // set details of damage var DMG_Details = new DamageDetails() { Critical = critical, ElementEffectiveness = element, Fainted = false }; // calculate damage float modifiers = 1 * element * critical; float a = (2 * attacker.level + 10) / 250f; float d = a * skill.baseSkill.Damage * ((float)attacker._baseTeras.Attack / _baseTeras.Defense); int damage = Mathf.FloorToInt(d * modifiers); // substract health this.Health -= damage; UpdateHP(damage); return(DMG_Details); }
////////////// DAMAGE AND STAT FUNCTIONS //////////////// /// <summary> /// Calculate how much damage is taken. /// </summary> /// <param name="move">Move the monster is hit with.</param> /// <param name="attacker">Monster who attacked.</param> /// <returns>Updated currentHP after damage and <see cref="DamageDetails"/>.</returns> public DamageDetails TakeDamage(MoveObj move, MonsterObj attacker) { // Critical hit chance is 6.25%. var critical = 1f; if (UnityEngine.Random.value * 100f <= 6.25f) { critical = 2f; } // Type effectiveness defined in TypeChart. float type = TypeChart.GetEffectiveness(move.Base.Type, Base.PrimaryType) * TypeChart.GetEffectiveness(move.Base.Type, Base.SecondaryType); var damageDetails = new DamageDetails() { Critical = critical, TypeEffectiveness = type, Downed = false }; float attack = (move.Base.Category == MoveCategory.Special) ? attacker.SpAttack : attacker.Attack; float defense = (move.Base.Category == MoveCategory.Special) ? SpDefense : Defense; // Damage calculation based on the original game's formula. float modifiers = UnityEngine.Random.Range(0.85f, 1f) * type * critical; float a = (2 * attacker.Level + 10) / 250f; float d = a * move.Base.Power * (attack / defense) + 2; int damage = Mathf.FloorToInt(d * modifiers); UpdateHp(damage); return(damageDetails); }
public DamageDetails TakeDamage(Move move, Character attacker) { float critical = 1f; if (Random.value * 100f <= 6.25f) { critical = 2f; } float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2); var damageDetails = new DamageDetails() { TypeEffectiveness = type, Critical = critical, Fainted = false }; float modifiers = Random.Range(0.85f, 1f) * type * critical; float a = (2 * attacker.Level + 10) / 250f; float d = a * move.Base.Power * ((float)attacker.Attack / Defense) + 2; int damage = Mathf.FloorToInt(d * modifiers); HP -= damage; if (HP <= 0) { HP = 0; damageDetails.Fainted = true; } return(damageDetails); }
public DamageDetails TakeDamage(Move move, Pokemon attacker) { float critical = 1f; if (UnityEngine.Random.value * 100f <= 6.25f) { critical = 2f; } float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2); var damageDetails = new DamageDetails() { Type = type, Critical = critical, Fainted = false }; float attack = (move.Base.IsSpecial) ? attacker.SpAttack : attacker.Attack; // aixo es com un if else pero mes curt float defense = (move.Base.IsSpecial) ? SpDefense : Defense; float modifiers = UnityEngine.Random.Range(0.85f, 1f) * type * critical; float a = (2 * attacker.Level + 10) / 250f; float d = a * move.Base.Power * ((float)attack / defense) + 2; int damage = Mathf.FloorToInt(d * modifiers); HP -= damage; if (HP <= 0) { HP = 0; damageDetails.Fainted = true; //pokemon = fainted } return(damageDetails); }
public DamageDetails TakeDamage(Move move, Pokemon attacker) { float critical = 1f; if (Random.value * 100f <= 6.25f) { critical = 2f; } float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2); var damageDetails = new DamageDetails() { TypeEffectiveness = type, Critical = critical, Fainted = false }; float attack = (move.Base.Category == MoveCategory.Special) ? attacker.SpAttack : attacker.Attack; float defense = (move.Base.Category == MoveCategory.Special) ? SpDefense : Defense; float modifiers = Random.Range(0.85f, 1f) * type * critical; float a = (2 * attacker.Level + 10) / 250f; float d = a * move.Base.Power * ((float)attack / defense) + 2; int damage = Mathf.FloorToInt(d * modifiers); UpdateHP(damage); return(damageDetails); }
IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.TypeEffectiveness > 1f) { yield return(dialogBox.TypeDialog("Es super effectivo!")); } else if (damageDetails.TypeEffectiveness < 1f) { yield return(dialogBox.TypeDialog("No es muy effectivo!")); } }
private void DealDamage() { DamageType damageType = _isHealing ? DamageType.Healing : DamageType.ArmorPiercing; if (_targetDamageHandler != null) { DamageDetails details = new DamageDetails(_amount, damageType, _DEAL_DAMAGE_AS_CRIT, _TARGET_HAS_EVADED, null); _targetDamageHandler.ProcessDamage(details); } }
IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Critical > 1f) { yield return(dialogBox.TypeDialog("A critical hit!")); } if (damageDetails.TypeEffectiveness > 1) { yield return(dialogBox.TypeDialog("It is super effective!")); } else if (damageDetails.TypeEffectiveness < 1f) { yield return(dialogBox.TypeDialog("It is not very effective!")); } }
IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.TypeEffect > 1) { yield return(_dialogueBox.TypeDialogue("It's extra damaging")); } else if (damageDetails.TypeEffect == 0) { yield return(_dialogueBox.TypeDialogue("It's not damaging at all")); } else if (damageDetails.TypeEffect < 1) { yield return(_dialogueBox.TypeDialogue("It's not very damaging")); } }
IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Critical > 1f) { yield return(dialogBox.TypeDialog("Coup critique !")); } if (damageDetails.TypeEffectiveness > 1) { yield return(dialogBox.TypeDialog("C'est super efficace !")); } else if (damageDetails.TypeEffectiveness < 1) { yield return(dialogBox.TypeDialog("Ce n'est pas très efficace...")); } }
private IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.CriticalModifier > 1.0f) { yield return(battleDialogueBox.TypeDialogue("A critical hit!")); } if (damageDetails.AttributeModifier > 1.0f) { yield return(battleDialogueBox.TypeDialogue("It's super effective!")); } else if (damageDetails.AttributeModifier < 1.0f) { yield return(battleDialogueBox.TypeDialogue("It's not very effective!")); } }
//shows damage Details in dialog box IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Crit > 1f) { yield return(dialogBox.TypeDialog("BIG DAMAGE")); } if (damageDetails.TypeWeakness > 1f) { yield return(dialogBox.TypeDialog("Weak")); } else if (damageDetails.TypeWeakness < 1f) { yield return(dialogBox.TypeDialog("resist")); } }
IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Critical > 1f) { yield return(dialogBox.WriteType("A critical hit!")); } if (damageDetails.TypeEfectiveness > 1) { yield return(dialogBox.WriteType("It's super effective!")); } else if (damageDetails.TypeEfectiveness < 1) { yield return(dialogBox.WriteType("It's not super effective!")); } }
//this shows in the dialogue box if there was a mulitplier applied to the attack IEnumerator ShowDamageDetails(DamageDetails damageDetails) { //if critical hit is over 0 it was call this coroutine, same but also with negative for effectiveness if (damageDetails.Critical > 1f) { yield return(dialogueBox.TypeDialog("A critical hit!")); } if (damageDetails.TypeEffectiveness > 1f) { yield return(dialogueBox.TypeDialog("It's super effective!")); } if (damageDetails.TypeEffectiveness < 1f) { yield return(dialogueBox.TypeDialog("It's not very effective!")); } }
private IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Critical > 1f) { yield return(_dialogBox.TypeDialog("That was a critical hit!")); } if (damageDetails.TypeEffectiveness > 1f) { yield return(_dialogBox.TypeDialog("That attack type is very strong!")); } else if (damageDetails.TypeEffectiveness < 1f) { yield return(_dialogBox.TypeDialog("That attack type is not very strong!")); } }
IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Critical > 1f) { yield return(dialogBox.TypeDialog("A critical hit!")); } if (damageDetails.Type > 1f) { yield return(dialogBox.TypeDialog("It's super effective!")); } if (damageDetails.Type < 1f) { yield return(dialogBox.TypeDialog("It's not very effective...")); } }
//Show Damage Details in the Dialog Box IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Critical > 1f) { yield return(dialogBox.TypeDialog("A critical hit!")); } if (damageDetails.TypeEffectiveness > 1f) { yield return(dialogBox.TypeDialog("It's super effective!")); } else if (damageDetails.TypeEffectiveness < 1f) { yield return(dialogBox.TypeDialog("It doesn't have much effect...")); } }
IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Critical > 1f) //Check the value of Critical to show a message saying we had a critical hit { yield return(dialogBox.TypeDialog("Coup critique!")); } if (damageDetails.TypeEffectiveness > 1) { yield return(dialogBox.TypeDialog("C'est super efficace!")); } else if (damageDetails.TypeEffectiveness < 1) { yield return(dialogBox.TypeDialog("Ce n'est pas très efficace...")); } }
// displays damage details such as: critical hit, super effective or not effective IEnumerator ShowDamageDetails(DamageDetails damageDetails) { if (damageDetails.Critical > 1f) { yield return(dialogBox.TypeDialog("It's a critical hit!")); } if (damageDetails.ElementEffectiveness > 1f) { yield return(dialogBox.TypeDialog("It's a super effective hit!")); } else if (damageDetails.ElementEffectiveness < 1f) { yield return(dialogBox.TypeDialog("It was not effective!")); } }
//this calculation is the same as the one preformed in a pokemon game, complicated. Yes. public DamageDetails TakeDamage(Move move, Creature attacker) { //crit hits happen only 6.25 percent of the time float critical = 1f; if (Random.value * 100f <= 6.25f) { critical = 2f; } //uses the type chart to get effectivenss of attacks float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2); var damageDetails = new DamageDetails() { TypeEffectiveness = type, Critical = critical, Fainted = false }; //conditional operator, in place of an if else float attack = (move.Base.Category == MoveCategory.Special) ? attacker.SpecialAttack : attacker.Attack; float defense = (move.Base.Category == MoveCategory.Special) ? SpecialDefense : Defense; //modifiers including random range, type bonus and critical bonus float modifiers = Random.Range(0.85f, 1f) * type * critical; float a = (2 * attacker.Level + 10) / 250f; float d = a * move.Base.Power * ((float)attack / defense) + 2; int damage = Mathf.FloorToInt(d * modifiers); //HP -= damage; //if(HP <= 0) //{ // HP = 0; // damageDetails.Fainted = true; //} UpdateHP(damage); return(damageDetails); }
public DamageDetails TakeDamage(Move move, Pokemon attacker) { float affinityMultiplier = TypeChart.GetEffectivness(move.Base.Affinity, this.Base.Affinity); var damageDetails = new DamageDetails() { TypeEffectiveness = affinityMultiplier, Fainted = false }; int damageValue = (attacker.Base.BaseAttack + move.Base.Power) * Mathf.FloorToInt(affinityMultiplier); HP -= damageValue; if (HP <= 0) { HP = 0; damageDetails.Fainted = true; } return(damageDetails); }
public DamageDetails TakeDamage(Move move, Pokemon attacker) { //Crtic hit prob float critical = 1f; if (Random.value * 100f <= criticalHitRate) { critical = 1.5f; } //Type efectivenes float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2); //STAB float stab = attacker.CalculateStab(move); float modifiers = Random.Range(0.85f, 1f) * type * critical * stab; var damageDetails = new DamageDetails() { Effectiveness = type, Critical = critical, Fainted = false }; //Determinamos la categoría del movimiento: float attack = (move.Base.Category == MoveCategory.Special) ? attacker.SpAttack : attacker.Attack; float defense = (move.Base.Category == MoveCategory.Special) ? attacker.SpDefense : attacker.Defense; //Formula real: float a = ((2 * attacker.Level) / 5) + 2; float d = ((a * move.Base.Power * (attack / defense)) / 50f) + 2; int damage = Mathf.FloorToInt(d * modifiers); UpdateHP(damage); return(damageDetails); }
public DamageDetails TakeDamage(Move move, PokemonLevel attacker) { float criticalhit = 1.0f; if (Random.value * 100.0f <= 6.25) // random value for critical hit { criticalhit = 2.0f; } float type = TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type1) * TypeChart.GetEffectiveness(move.Base.Type, this.Base.Type2); var damageDetails = new DamageDetails() { TypeEffectiveness = type, Critical = criticalhit, Fainted = false }; float attack = (move.Base.Category == MoveCategory.Special)? attacker.SpAttack : attacker.Attack; float defense = (move.Base.Category == MoveCategory.Special) ? SpDefense : Defense; float modifiers = Random.Range(0.85f, 1.0f) * type * criticalhit; // damage depend on the Level of the attacker // random range so that the damage is a lil bit different everytime float a = (2 * attacker.Level + 10) / 250f; float d = a * move.Base.Power * ((float)attack / defense) + 2; // depend the power of the move and the attack stats and the defense the pokemon. int damage = Mathf.FloorToInt(d * modifiers); UpdateHP(damage); //HP -= damage; // checking if the pokemon faint //if(HP <= 0) //{ // HP = 0; // damageDetails.Fainted = true; //} return(damageDetails); }