Add floors that can also damage monsters

Moderator: GZDoom Developers

Post Reply
User avatar
inkoalawetrust
Posts: 70
Joined: Mon Aug 26, 2019 9:18 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Add floors that can also damage monsters

Post by inkoalawetrust »

While it's possible to make floors hurt monsters too with one or a few simple ACS scripts that use SectorDamage i (And i'm sure a lot of other people) would prefer if the ability for damaging floors to also harm monsters was implemented in the engine natively since it's a pretty obvious thing to add to GZDoom/LZDoom.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Add floors that can also damage monsters

Post by Graf Zahl »

This was never implemented because it won't work without altering the monster AI. The ACS special at least requires the mapper to think about the scenario but with a sector special it'd be far too easy to use and end up in broken maps.
User avatar
Kinsie
Posts: 7401
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Re: Add floors that can also damage monsters

Post by Kinsie »

This isn't a generic map feature, but my most recent mod has monsters that take floor damage. Here's the code I used, in a base actor that the monsters inherit from:

Code: Select all

int sectordmgtimer;

	override void Tick()
	{
		// These have all been broken into seperate functions so that individual
		// actors can disable or override them for whatever reason.
		
		// ...
		DoHurtFloorDamage();
		
		// ...
		
		Super.Tick();
	}

	virtual void DoHurtFloorDamage()
	{
		// If on a hurtfloor... get hurt by it.
		if (sectordmgtimer < self.CurSector.damageinterval)
		{
			sectordmgtimer++;
		} else {
			sectordmgtimer = 0;
		}
		
		// Handle things a little differently depending on whether the actor is
		// in water or not. If they're not, only damage them if they're actually
		// on the floor. If they are, assume they're swimming in toxic waste or
		// nukage or some shit and ding them at any time.
		if (self.CurSector.damageamount != 0 && sectordmgtimer >= self.CurSector.damageinterval)
		{
			if (waterlevel == 0 && pos.z == GetZAt(pos.x, pos.y))
			{
				sectordmgtimer = 0;
				DamageMobj(self, self, self.CurSector.damageamount, self.CurSector.damagetype, 0, 0);
			}
			
			if (waterlevel > 0)
			{
				sectordmgtimer = 0;
				DamageMobj(self, self, self.CurSector.damageamount, self.CurSector.damagetype, 0, 0);
			}
		}
	}
It isn't perfect - I still need to handle swimmable 3D floors - but as far as starts go it's pretty decent. I'm sure someone way cleverer than I am could universalise it.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”