// ------------------------------------------------------------------------------- // loadTemplate // ------------------------------------------------------------------------------- public void loadTemplate() { if (string.IsNullOrEmpty(name)) { return; } template = DictionaryCombatStyle.Get(name); }
// ------------------------------------------------------------------------------- // CalculateFinalDamage // ------------------------------------------------------------------------------- public static int CalculateFinalDamage(int damage, TemplateMetaCombatStyle attackType, TemplateMetaElement element, CharacterBase target, bool IsRearguard = false) { int defense = 0; damage = (int)(damage * RPGHelper.getElementalRelation(element, target)); defense = target.stats.combatStyles.FirstOrDefault(x => x.template == attackType).defenseValue; if (IsRearguard) { damage = (int)(damage * attackType.rearAttackModifier); } else { damage = (int)(damage * attackType.frontAttackModifier); } if (target.IsRearguard) { defense = (int)(defense * attackType.rearDefenseModifier); } else { defense = (int)(defense * attackType.frontDefenseModifier); } float variance = UnityEngine.Random.Range(1 - Finder.battle.maxDamageVariation, 1 + Finder.battle.maxDamageVariation); damage = (int)(damage * variance); damage -= defense; if (damage <= 0) { damage = 1; } return(damage); }