Here is the place to add them!
My weapon is a magical staff, so instead of weapons, I have to think a list of spells
I don’t know how to “make” an ammo pickup, maybe some kind of magical-energy reservoir?
I agree with aversion to spam shooters, so limited ammo…And damage limitations!
I’m usually a sniper, so my dread is up close fighting…So, that’s exactly what I need to push.(gasp)
So how about Exponential Decay of Damage?
[Tooltip("Full Damage Distance")]
[SerializeField] float optimalDamageDist = 4f;
[Tooltip("Short for Shotgun, Long for rifle")]
[SerializeField] float halfDamageDist = 6f;
//logarithmic decay: y(t) = a × e^(kt)
//a = weapondamage(Max), t = distance
// halfDamageDist = a / 2:
// And Move the scale to the optimal distance a = (halfDamageDist - optimalDamageDist)
// so to calc K at 1/2 damage:
// y(t) = a × e^(kt)
// weaponDamage/2 = weaponDamage * e^(k * (halfDamageDist - optimalDamageDist))
// reduce 1/2 = e^(k * (halfDamageDist - optimalDamageDist))
// ln(e^(k * (halfDamageDist - optimalDamageDist))) = ln(1/2)
// k * (halfDamageDist - optimalDamageDist) = ln(1/2)
// k = ln(1/2) / (halfDamageDist - optimalDamageDist)
//
//Do Not change Original Weapon Damage
private float CalculateDamage(RaycastHit hit, float currHitDamage)
{
float diffDist = Math.Abs(halfDamageDist - optimalDamageDist);
double k = Math.Log(0.5) / diffDist;
if (0 <= hit.distance && hit.distance <= optimalDamageDist)
{
currHitDamage = weaponDamage * Convert.ToSingle(Math.Exp(k * (diffDist - hit.distance)));
Debug.Log("Attack dist: Dist=" + hit.distance + " Tot Damage: " + currHitDamage);
}
else if (optimalDamageDist < hit.distance)
{
// remember y(t) = a × e^(kt)
currHitDamage = weaponDamage * Convert.ToSingle(Math.Exp(k * (hit.distance - diffDist)));
Debug.Log("Chase dist: Dist=" + hit.distance + " Tot Damage: " + currHitDamage);
}
else
{
//weaponDamage = 2;
Debug.Log("Range dist: Dist=" + hit.distance + " Tot Damage: " + currHitDamage);
}
return currHitDamage;
}
WooHoo,
David B
Snifer riple!