[Not a bug] HitWater returns true (and spawns splash) when pos.z >floorz

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

HitWater returns true (and spawns splash) when pos.z >floorz

Postby Kzer-Za » Sat Jan 15, 2022 4:16 am

Well, I'm not sure if this is not a bug but the intended behavior, but it looks strange when a projectile hits a wall high above the floor level and spawns a splash at that height. Of course, one can always use it as if (pos.z <= floorz && HitWater(floorsector, pos)), but I thought I should report it in case it isn't the intended behavior.
Kzer-Za
 
Joined: 20 Aug 2017
Operating System: Other Linux 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: HitWater returns true (and spawns splash) when pos.z >fl

Postby Graf Zahl » Sat Jan 15, 2022 10:37 am

I've never seen this. How did you make it do such a thing?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: HitWater returns true (and spawns splash) when pos.z >fl

Postby Kzer-Za » Sat Jan 15, 2022 12:56 pm

Well, it can be easily tested with this (though I, of course, discovered it while using this function more sensibly):

Code: Select allExpand view
class Testball : DoomImpBall
{
   States
   {
   Spawn:
      BAL1 A 6 {HitWater(floorsector, pos);}
      Loop;
   }
}


In the game do summon Testball while standing on a solid floor, but facing a liquid terrain. As soon as the Testball crosses the line to the liquid, it starts spawning splashes at its own pos, whichever height above the liquid's surface it is. Of course, it can't be done in vanilla Doom since it lacks terrain definitions, so one needs either a mod with terrain definitions, or test it in Heretic or Hexen. In the latter case the Testball would be invisible, but it it only serves to better see the splashes at its coordinates.
Kzer-Za
 
Joined: 20 Aug 2017
Operating System: Other Linux 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: HitWater returns true (and spawns splash) when pos.z >fl

Postby Graf Zahl » Sun Jan 16, 2022 1:54 am

In that case the answer is: Don't do that! This function is not really what you want here. This is the internal function that gets called after it has already been decided that a splash should happen. What you probably want is CheckSplash which is a generic wrapper around HitWater that performs distance checking to the liquid surface. If that does not suffice, you have to write your own wrapper. Normally you should never need to call this, all engine movement functions already handle splashing themselves.

HitWater itself cannot be changed because all movement code depends on how it works.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: HitWater returns true (and spawns splash) when pos.z >fl

Postby Kzer-Za » Sun Jan 16, 2022 2:19 am

Okay, I'll just use it as if (pos.z <= floorz && HitWater(floorsector, pos)) then. CheckSplash won't do since it doesn't return anything, and I need to get the result. Like I said, I have absolutely no problem with that, just wanted to make sure that it's the intended behavior.
Kzer-Za
 
Joined: 20 Aug 2017
Operating System: Other Linux 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: HitWater returns true (and spawns splash) when pos.z >fl

Postby Graf Zahl » Sun Jan 16, 2022 3:33 am

What do you need this for? Normally this should never be called from user code because splashes already get handled inside the engine's core.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: HitWater returns true (and spawns splash) when pos.z >fl

Postby Kzer-Za » Sun Jan 16, 2022 4:09 am

Well, I use it in my grenades mod (viewtopic.php?f=43&t=74451). The idea is that a grenade is bouncing, but it needs to drown in liquids, so I want the splash when a grenade hits a liquid to be spawned only once: the first time. So I check the HitWater value, and if it's true, I give the grenade INVISIBLE and DONTSPLASH flags to imitate it going underwater: the first time the grenade bounces off the liquid, so when it touches it again I need it to not cause splashes anymore. And it needs to bounce the first time, because otherwise it dies, while I need it to exist and move for a short while after "drowning".
Kzer-Za
 
Joined: 20 Aug 2017
Operating System: Other Linux 64-bit
Graphics Processor: nVidia (Modern GZDoom)


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests