by Gez » Sun Jun 06, 2010 4:56 pm
InsanityBringer wrote:What exactly is the formula for absorb then?
The Slots[x] value correspond to the x5 scale, so if you have AC 10, savedPercent is 50.
Code: Select all
void AHexenArmor::AbsorbDamage (int damage, FName damageType, int &newdamage)
{
if (damageType != NAME_Drowning)
{
fixed_t savedPercent = Slots[0] + Slots[1] + Slots[2] + Slots[3] + Slots[4];
if (savedPercent)
{ // armor absorbed some damage
if (savedPercent > 100*FRACUNIT)
{
savedPercent = 100*FRACUNIT;
}
for (int i = 0; i < 4; i++)
{
if (Slots[i])
{
// 300 damage always wipes out the armor unless some was added
// with the dragon skin bracers.
if (damage < 10000)
{
Slots[i] -= Scale (damage, SlotsIncrement[i], 300);
if (Slots[i] < 2*FRACUNIT)
{
Slots[i] = 0;
}
}
else
{
Slots[i] = 0;
}
}
}
int saved = Scale (damage, savedPercent, 100*FRACUNIT);
if (saved > savedPercent >> (FRACBITS-1))
{
saved = savedPercent >> (FRACBITS-1);
}
newdamage -= saved;
damage = newdamage;
}
}
if (Inventory != NULL)
{
Inventory->AbsorbDamage (damage, damageType, newdamage);
}
}
[quote="InsanityBringer"]What exactly is the formula for absorb then?[/quote]
The Slots[x] value correspond to the x5 scale, so if you have AC 10, savedPercent is 50.
[code]void AHexenArmor::AbsorbDamage (int damage, FName damageType, int &newdamage)
{
if (damageType != NAME_Drowning)
{
fixed_t savedPercent = Slots[0] + Slots[1] + Slots[2] + Slots[3] + Slots[4];
if (savedPercent)
{ // armor absorbed some damage
if (savedPercent > 100*FRACUNIT)
{
savedPercent = 100*FRACUNIT;
}
for (int i = 0; i < 4; i++)
{
if (Slots[i])
{
// 300 damage always wipes out the armor unless some was added
// with the dragon skin bracers.
if (damage < 10000)
{
Slots[i] -= Scale (damage, SlotsIncrement[i], 300);
if (Slots[i] < 2*FRACUNIT)
{
Slots[i] = 0;
}
}
else
{
Slots[i] = 0;
}
}
}
int saved = Scale (damage, savedPercent, 100*FRACUNIT);
if (saved > savedPercent >> (FRACBITS-1))
{
saved = savedPercent >> (FRACBITS-1);
}
newdamage -= saved;
damage = newdamage;
}
}
if (Inventory != NULL)
{
Inventory->AbsorbDamage (damage, damageType, newdamage);
}
}
[/code]