by Kinsie » Mon Nov 04, 2019 6:52 am
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.
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]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);
}
}
}
[/code]
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.