I was very grateful when damage factors were added, but I have always wanted a different method of handling damage resistance based more on D&D or GURPS based damage reduction, where a flat amount of damage was subtracted from the total before other effects. After looking through the code, I think this would be simple to do.
In info.cpp:
Code: Select all
void FActorInfo::SetDamageReduction(FName type, fixed_t factor)
{
if (DamageReductions == NULL)
{
DamageReductions = new DmgReductions;
}
DamageReductions->Insert(type, factor);
}
In info.h:
Code: Select all
struct DmgReductions : public TMap<FName, int>
{
int *CheckFactor(FName type);
};
Inside the definition of FActorInfo:
Code: Select all
void SetDamageReduction(FName type, fixed_t factor);
DmgReductions *DamageReductions;
In ABasicArmor::AbsorbDamage, directly after the check for whether an attack absorbs armor but before the definition of "full":
Code: Select all
const int* reduction = NULL;
DmgReductions *dr = PClass::FindClass(ArmorType)->ActorInfo->DamageReductions;
if (dr != NULL && dr->CountUsed() != 0)
{
reduction = dr->CheckFactor(damageType);
if (reduction != NULL)
{
damage = newdamage = damage-reduction;
if (damage < 0)
{
damage = newdamage = 0;
}
}
}
I think that would do it. Before assessing the save amount, you subtract damage from the incoming attack equal to the damage reduction given the damage type, and use the "reduced" damage to determine armor damage and so forth. The problem is, I'm not sure where to go to find the code for the decorate parser, so I don't know how to create armor to test it with. Is this enough to be considered a feature request? If not, could you point me to the relevant source files?
Thanks. I understand similar effects could be achieved (and indeed
have been) with more cumbersome ACS or decorate workarounds, but it seemed so easy to implement at the source level I thought I'd ask here.
Thanks! I've put more hours into enjoying doom than any other game ever!
I was very grateful when damage factors were added, but I have always wanted a different method of handling damage resistance based more on D&D or GURPS based damage reduction, where a flat amount of damage was subtracted from the total before other effects. After looking through the code, I think this would be simple to do.
In info.cpp:
[code]void FActorInfo::SetDamageReduction(FName type, fixed_t factor)
{
if (DamageReductions == NULL)
{
DamageReductions = new DmgReductions;
}
DamageReductions->Insert(type, factor);
}[/code]
In info.h:
[code]struct DmgReductions : public TMap<FName, int>
{
int *CheckFactor(FName type);
};[/code]
Inside the definition of FActorInfo:
[code]void SetDamageReduction(FName type, fixed_t factor);
DmgReductions *DamageReductions;[/code]
In ABasicArmor::AbsorbDamage, directly after the check for whether an attack absorbs armor but before the definition of "full":
[code]const int* reduction = NULL;
DmgReductions *dr = PClass::FindClass(ArmorType)->ActorInfo->DamageReductions;
if (dr != NULL && dr->CountUsed() != 0)
{
reduction = dr->CheckFactor(damageType);
if (reduction != NULL)
{
damage = newdamage = damage-reduction;
if (damage < 0)
{
damage = newdamage = 0;
}
}
}[/code]
I think that would do it. Before assessing the save amount, you subtract damage from the incoming attack equal to the damage reduction given the damage type, and use the "reduced" damage to determine armor damage and so forth. The problem is, I'm not sure where to go to find the code for the decorate parser, so I don't know how to create armor to test it with. Is this enough to be considered a feature request? If not, could you point me to the relevant source files?
Thanks. I understand similar effects could be achieved (and indeed [url=http://forum.zdoom.org/viewtopic.php?f=3&t=34089&p=644398&hilit=damage+reduction#p644398/]have been[/url]) with more cumbersome ACS or decorate workarounds, but it seemed so easy to implement at the source level I thought I'd ask here.
Thanks! I've put more hours into enjoying doom than any other game ever!