Damage Reduction

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Damage Reduction

Re: Damage Reduction

by Graf Zahl » Mon Jul 22, 2013 2:40 pm

OK, one month has passed without response, off this goes...

Re: Damage Reduction

by Graf Zahl » Sun Jun 23, 2013 10:43 am

Please repost this as a ready to use patch file, this looks incomplete.

Re: Damage Reduction

by Sir Cyril Fudgelot » Wed May 29, 2013 10:04 am

Gez wrote:Look in thingdef_properties.cpp. You should use the DEFINE_PROPERTY(name, parameters, class) macro, based on the many examples in that file. The parameters are declared as single letters, look at ParsePropertyParams() in thingdef_parse.cpp for their list and explanation.
Perfect. I'll look there. I looked over other code submissions, and noticed they were in patch format. If I get it working, I'll update my original post. I found a wonderful guide to building ZDoom on the wiki; I'm glad I looked there first before asking about it.
Xaser wrote:I'm still tickled that Sir Cyril Fudgelot officially adopted his auto-generated royal nomenclature.
Yeah, well... I'm actually in self-imposed exile after a particularly immature action on these forums caused me profound embarrassment. I still wanted to post that bug report, though, and found I could do so without registering, so I went with it. Your story tickled my fancy, so I figured it was as suitable an appellation as any, and decided (when I found another bug to report) that I might as well stick with it so you would all know the same person reported both bugs. Besides, I've always disliked trying to come up with proper nouns.

Re: Damage Reduction

by Xaser » Tue May 28, 2013 8:31 pm

I'm still tickled that Sir Cyril Fudgelot officially adopted his auto-generated royal nomenclature. :P

Re: Damage Reduction

by Gez » Tue May 28, 2013 3:07 pm

Sir Cyril Fudgelot wrote: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.
Look in thingdef_properties.cpp. You should use the DEFINE_PROPERTY(name, parameters, class) macro, based on the many examples in that file. The parameters are declared as single letters, look at ParsePropertyParams() in thingdef_parse.cpp for their list and explanation.

Damage Reduction

by Sir Cyril Fudgelot » Tue May 28, 2013 1:22 pm

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!

Top