Me and @Brian_Trotter have been having an ongoing discussion about implementing elemental damage into the stuff from these lectures.
At present, the code looks like this for Hit():
void Hit() // Anim Event
{
if(target == null) {return;}
float damage = GetComponent<BaseStats>().GetStat(Stats.PhysicalDamage);//eventually can check weapon for type and the modifiers the weapon should pull from via bools
BaseStats targetBaseStats = target.GetComponent<BaseStats>();
if (targetBaseStats != null)
{
float defence = targetBaseStats.GetStat(Stats.PhysicalDefense);
damage /= 1 + defence / damage;
}
if(currentWeapon.value != null)
{
currentWeapon.value.OnHit();
}
if(currentWeaponConfig.HasProjectile() != false)
{
currentWeaponConfig.LaunchProjectile(rightHandTransform, leftHandTransform, spellbookTransform, target, gameObject, damage);
return;
}
else
{
target.TakeDamage(gameObject, damage);
foreach (ElementalDamage elementalDamage in currentWeaponConfig.GetElementalDamages())
{
damage = elementalDamage.amount;
float boosts = 0;
foreach (IElementalDamageProvider provider in GetComponents<IElementalDamageProvider>())
{
foreach (float amount in provider.GetElementalDamageBoost(elementalDamage.damageType))
{
boosts += amount;
}
}
boosts /= 100f;
float resistances = 0;
foreach (IElementalResistanceProvider provider in target.GetComponents<IElementalResistanceProvider>())
{
foreach (float amount in provider.GetElementalResistance(elementalDamage.damageType))
{
resistances += amount;
}
}
resistances /= 100f;
damage += damage * boosts;
damage -= damage * resistances;
if (damage <= 0) continue;
//Line below changed to add damage type for elemental damage.
target.TakeDamage(gameObject, damage, elementalDamage.damageType.ToString());
}
}
}
I’m wondering if anyone (Brian included) may know the best way to implement some sort of defense system for a system like this. I’m not against it being like the one Sam uses here but I am not married to it being that way. Right now, I think what I had for elemental damage defense and resistance may be slightly incongruous with how “regular” defense works.