// ------------------------------------------------------------------------------- // HitInfo (Constructor) // ------------------------------------------------------------------------------- public HitInfo(DamageTemplate damage, Vector3 point, bool isShowEffect, Character source = null, float BaseAmount = 0) { this.baseAmount = BaseAmount; this.damage = damage; this.point = point; this.isShowEffect = isShowEffect; this.source = source; this.damage.Initalize(); }
// ----------------------------------------------------------------------------------- // Awake // ----------------------------------------------------------------------------------- protected virtual void Awake() { moveController = GetComponent <CharacterController>(); fallDamage = Obj.GetGame.configuration.fallDamage; attributes.Initalize(this); resistances.Initalize(this); statistics.Initalize(this); states.Initalize(this); }
// =================================================================================== // DAMAGE // =================================================================================== // ----------------------------------------------------------------------------------- // DamageFormula // ----------------------------------------------------------------------------------- public static DamageResult DamageFormula(DamageTemplate damage, List <Element> defence, Character source = null, Character target = null, float baseDamage = 0) { DamageResult damageResult = new DamageResult(); int index; float bonus_damage = 0; float bonus_probability = 0; float element_damage = 0; float bonus_critical; float total_damage = baseDamage; // -- summarize all bonus damage if (source != null) { bonus_damage += source.CalculateProperties(damage.attackModifiers, PropertyTypes.TotalValue); } // -- summarize all base damage and base defence foreach (Element element1 in damage.elements) { element_damage = (element1.TotalValue + bonus_damage) * 4; // factor ? // -- randomize damage by variance element_damage = randomizeDamage(element_damage, damage.damageVariance); index = defence.FindIndex(e => e.template == element1.template); if (index != -1) { element_damage -= (defence[index].TotalValue * 2); // factor ? } total_damage += element_damage; } // -- check for critical or glancing hit if (source != null) { bonus_probability = source.CalculateProperties(damage.probabilityModifiers, PropertyTypes.TotalValue); } if (Random.value <= damage.criticalProbability + bonus_probability) { bonus_critical = damage.criticalPower; if (source != null) { bonus_critical += source.CalculateProperties(damage.powerModifiers, PropertyTypes.TotalValue); } total_damage *= bonus_critical; damageResult.type = DamageTypes.Critical; } //damageResult.type = DamageTypes.Glancing; // -- Target Dodge??? damageResult.amount = (int)total_damage; return(damageResult); }