public void RebuildTempStats() { AttackBonus = 0; MagicBonus = 0; DefenseBonus = 0; HealthBonus = 0; SpeedBonus = 0; DodgeBonus = 0; CritBonus = 0; ArcaneSkill = 0; DivineSkill = 0; foreach (SkillInstance skill in Skills) { skill.OnApply(this); } Speed = ((Attributes[Attribute.AttributeTypes.Agility].Level + SpeedBonus) * 1f) + 1f; HitPoints = Attributes[Attribute.AttributeTypes.Might].Level * 10 + HealthBonus; if (HitPoints < 5) { HitPoints = 5; } MagicPower = Attributes[Attribute.AttributeTypes.Smarts].Level * 5 + MagicBonus; PerceptionRange = (Attributes[Attribute.AttributeTypes.Smarts].Level + Attributes[Attribute.AttributeTypes.Agility].Level) * 2f; if (PerceptionRange < 5) { PerceptionRange = 5; } Initiative = 5; int smartAgiDiv = Attributes[Attribute.AttributeTypes.Smarts].Level + Attributes[Attribute.AttributeTypes.Agility].Level / 2; if (smartAgiDiv >= Initiative) { Initiative = Initiative / (smartAgiDiv - Initiative); } else { Initiative = Initiative / smartAgiDiv; } int weaponStatValue = Attributes[Attribute.AttributeTypes.Might].Level; if (EquipedItems.IsWielding(Weapon.WeaponTypes.Staff)) { weaponStatValue = Attributes[Attribute.AttributeTypes.Smarts].Level; } if (EquipedItems.IsWielding(Weapon.WeaponTypes.Bow)) { weaponStatValue = Attributes[Attribute.AttributeTypes.Agility].Level; } AttackBonus = weaponStatValue + AttackBonus; ArmorValue = EquipedItems.ArmorValue() + DefenseBonus; foreach (Buff buff in Buffs) { switch (buff.BuffType) { case BuffTypes.Attack: AttackBonus += (int)buff.Value; break; case BuffTypes.Defense: ArmorValue += (int)buff.Value; break; case BuffTypes.Health: HitPoints += (int)buff.Value; break; case BuffTypes.Speed: Speed += (int)buff.Value; break; case BuffTypes.Magic: MagicPower += (int)buff.Value; break; case BuffTypes.Dodge: DodgeBonus += buff.Value; break; case BuffTypes.Crit: CritBonus += buff.Value; break; } } }