Extend ModifyDamage to have target information

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: Extend ModifyDamage to have target information

Re: Extend ModifyDamage to have target information

by Major Cooke » Mon Jan 27, 2020 8:01 pm

No problem. That reminds me though I should add it to AbsorbDamage as well for armor...

Re: Extend ModifyDamage to have target information

by SanyaWaffles » Mon Jan 27, 2020 7:34 pm

This is in fact correct. I just tried it.

I guess this can be marked as 'Already In'.

By the way, thanks for explaining this to me a bit more in depth.

Re: Extend ModifyDamage to have target information

by Major Cooke » Mon Jan 27, 2020 6:25 pm

Source is what you want. And you would do a check to make sure passive is false first.

Here's the relevant code from DamageMobj internally.

Code: Select all

if (damage > 0 && source != NULL)
{
	damage = int(damage * source->DamageMultiply);

	// Handle active damage modifiers (e.g. PowerDamage)
	if (damage > 0 && !(flags & DMG_NO_ENHANCE))
	{
		damage = source->GetModifiedDamage(mod, damage, false, inflictor, target, flags);
	}
}
// Handle passive damage modifiers (e.g. PowerProtection), provided they are not afflicted with protection penetrating powers.
if (damage > 0 && !(flags & DMG_NO_PROTECT))
{
	damage = target->GetModifiedDamage(mod, damage, true, inflictor, source, flags);
}
Pairing those parameters up to ModifyDamage, you can see that source becomes the actor that's being damaged. There's no point in it being the owner in this case because it'd be redundant when you have the "owner" variable already at your disposal.

So check the source, make sure it isn't null, and then check to see if it has the boss flag. But again, make sure the passive boolean is false.

Re: Extend ModifyDamage to have target information

by SanyaWaffles » Mon Jan 27, 2020 5:18 pm

Can you explain to me which one I'd need to use to get the +Boss flag from the enemy being attacked? That's what I'm lost on. I don't think either inflictor nor source serve my purpose. I want a field on the thing being attacked, not the attacker.

Re: Extend ModifyDamage to have target information

by Major Cooke » Mon Jan 27, 2020 5:11 pm

This has been in for a while now. Includes the inflictor, source, and damage flags.

Code: Select all

virtual void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor = null, Actor source = null, int flags = 0) {}

Extend ModifyDamage to have target information

by SanyaWaffles » Mon Jan 27, 2020 5:07 pm

I was kind of shocked to see ModifyDamage in the Powerups section didn't have any information about the enemy you are damaging... I had an idea for a powerup that won't QuadDamage any enemies with the +Boss flag. Problem is right now it seems there's no easy way to get this info.

I'm sure there's a way to do this without this, but this would be more convenient. I dunno how it'd be extended though.

Top