ModifyDamage called on Items but not on BasicArmor?

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
User avatar
merlin86
Posts: 146
Joined: Tue Jan 29, 2008 4:02 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Pro
Graphics Processor: nVidia with Vulkan support

ModifyDamage called on Items but not on BasicArmor?

Post by merlin86 »

Hello there, with this simple item

Code: Select all

version "4.12"

class MySuperArmor : BasicArmor
{

	override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags)
	{
		Console.printf("foo");
		if (passive && damage > 0)
		{
			Console.printf("bar!");
			newdamage = 0;
		}
	}
}
I've noticed if the item is derived from item such function is called and it works, but if I derive my class from BasicArmor is not called.
It this by design?
I've tested with the GIT version.
User avatar
Zhs2
Posts: 1294
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere

Re: ModifyDamage called on Items but not on BasicArmor?

Post by Zhs2 »

Short answer: Yes, this is by design.

Long answer: You have some mistaken assumptions about how BasicArmor works. A player can only ever have one BasicArmor class, and that's the BasicArmor class the player started with. The default BasicArmor class can be defined in MAPINFO: https://zdoom.org/wiki/MAPINFO/GameInfo ... ArmorClass

Further, the only time a player can carry BasicArmorPickups or BasicArmorBonuses is if they are intended to be used with the Use Inventory key to add armor stats to BasicArmor. Otherwise, whenever BasicArmorPickup or BasicArmorBonus items are collected BasicArmor conditionally absorbs all of their stats. BasicArmor basically acts as a be-all end-all global armor tracker. To use ModifyDamage or AbsorbDamage virtuals on it effectively you can check for the armor type it currently has and apply special effects based on that. Or you can forgo BasicArmor completely to engineer armor that understands when it is worn and when it is not. Just some suggestions.

Return to “Bugs [GZDoom]”