From 1fadefba4c2cdd75f0f75ecbd92de704e7818e8b Mon Sep 17 00:00:00 2001 From: pWn3d Date: Tue, 17 Feb 2026 21:14:20 +0100 Subject: [PATCH] add water check to HeightDieUpdate --- .../Include/GameLogic/Module/HeightDieUpdate.h | 2 +- .../GameLogic/Object/Update/HeightDieUpdate.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/HeightDieUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/HeightDieUpdate.h index 20145b0e59..8f9fa928af 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/HeightDieUpdate.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/HeightDieUpdate.h @@ -51,7 +51,7 @@ class HeightDieUpdateModuleData: public UpdateModuleData Real m_destroyAttachedParticlesAtHeight; ///< HACK, destroy any attached particle system of object when below this height Bool m_snapToGroundOnDeath; ///< snap to the ground when killed UnsignedInt m_initialDelay; ///< Don't explode before this time - + Bool m_targetHeightIncludesWater; ///< target height considers water height instead of terrain }; //------------------------------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HeightDieUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HeightDieUpdate.cpp index f8eed1381f..367e52329b 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HeightDieUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HeightDieUpdate.cpp @@ -56,7 +56,7 @@ HeightDieUpdateModuleData::HeightDieUpdateModuleData( void ) m_destroyAttachedParticlesAtHeight = -1.0f; m_snapToGroundOnDeath = FALSE; m_initialDelay = 0; - + m_targetHeightIncludesWater = false; } //------------------------------------------------------------------------------------------------- @@ -76,6 +76,7 @@ void HeightDieUpdateModuleData::buildFieldParse(MultiIniFieldParse& p) { "DestroyAttachedParticlesAtHeight", INI::parseReal, nullptr, offsetof( HeightDieUpdateModuleData, m_destroyAttachedParticlesAtHeight ) }, { "SnapToGroundOnDeath", INI::parseBool, nullptr, offsetof( HeightDieUpdateModuleData, m_snapToGroundOnDeath ) }, { "InitialDelay", INI::parseDurationUnsignedInt, nullptr, offsetof( HeightDieUpdateModuleData, m_initialDelay ) }, + { "TargetHeightIncludesWater", INI::parseBool, nullptr, offsetof(HeightDieUpdateModuleData, m_targetHeightIncludesWater) }, { nullptr, nullptr, nullptr, 0 } }; @@ -161,7 +162,14 @@ UpdateSleepTime HeightDieUpdate::update( void ) } // get the terrain height - Real terrainHeightAtPos = TheTerrainLogic->getGroundHeight( pos->x, pos->y ); + Real terrainHeightAtPosNoWater = TheTerrainLogic->getGroundHeight(pos->x, pos->y); + Real terrainHeightAtPos{ terrainHeightAtPosNoWater }; + if (modData->m_targetHeightIncludesWater) { + Real waterz{ 0 }; + if (TheTerrainLogic->isUnderwater(pos->x, pos->y, &waterz)) { + terrainHeightAtPos = waterz; + } + } // if including structures, check for bridges if (modData->m_targetHeightIncludesStructures) @@ -240,13 +248,13 @@ UpdateSleepTime HeightDieUpdate::update( void ) // if we're supposed to snap us to the ground on death do so // AND: even if we're not snapping to ground, be sure we don't go BELOW ground - if( modData->m_snapToGroundOnDeath || pos->z < terrainHeightAtPos ) + if( modData->m_snapToGroundOnDeath || pos->z < terrainHeightAtPosNoWater ) { Coord3D ground; ground.x = pos->x; ground.y = pos->y; - ground.z = terrainHeightAtPos; + ground.z = terrainHeightAtPosNoWater; getObject()->setPosition( &ground ); }