diff --git a/src/deh_tables.c b/src/deh_tables.c index e421d2b4b..9a733141f 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -6744,6 +6744,7 @@ struct int_const_s const INT_CONST[] = { // precipeffect_t {"PRECIPFX_THUNDER",PRECIPFX_THUNDER}, {"PRECIPFX_LIGHTNING",PRECIPFX_LIGHTNING}, + {"PRECIPFX_WATERPARTICLES",PRECIPFX_WATERPARTICLES}, {NULL,0} }; diff --git a/src/doomstat.h b/src/doomstat.h index 5a2478b48..4e782e59c 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -85,7 +85,8 @@ typedef enum typedef enum { PRECIPFX_THUNDER = 1, - PRECIPFX_LIGHTNING = 1<<1 + PRECIPFX_LIGHTNING = 1<<1, + PRECIPFX_WATERPARTICLES = 1<<2 } precipeffect_t; typedef struct diff --git a/src/p_mobj.c b/src/p_mobj.c index 1f6dc93e2..f4e863449 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3764,13 +3764,16 @@ void P_CalculatePrecipFloor(precipmobj_t *mobj) { // recalculate floorz each time const sector_t *mobjsecsubsec; + boolean setWater = false; if (mobj && mobj->subsector && mobj->subsector->sector) mobjsecsubsec = mobj->subsector->sector; else return; + mobj->precipflags &= ~PCF_INVISIBLE; mobj->floorz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y); + mobj->ceilingz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y); if (mobjsecsubsec->ffloors) { @@ -3783,14 +3786,44 @@ void P_CalculatePrecipFloor(precipmobj_t *mobj) if (!(rover->flags & FF_EXISTS)) continue; - if (!(rover->flags & FF_BLOCKOTHERS) && !(rover->flags & FF_SWIMMABLE)) - continue; + if (precipprops[curWeather].effects & PRECIPFX_WATERPARTICLES) + { + if (!(rover->flags & FF_SWIMMABLE)) + continue; - height = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); - if (height > mobj->floorz) - mobj->floorz = height; + if (setWater == false) + { + mobj->ceilingz = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + mobj->floorz = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); + setWater = true; + } + else + { + height = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + if (height > mobj->ceilingz) + mobj->ceilingz = height; + + height = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); + if (height < mobj->floorz) + mobj->floorz = height; + } + } + else + { + if (!(rover->flags & FF_BLOCKOTHERS) && !(rover->flags & FF_SWIMMABLE)) + continue; + + height = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + if (height > mobj->floorz) + mobj->floorz = height; + } } } + + if ((precipprops[curWeather].effects & PRECIPFX_WATERPARTICLES) && setWater == false) + { + mobj->precipflags |= PCF_INVISIBLE; + } } void P_RecalcPrecipInSector(sector_t *sector) diff --git a/src/p_spec.c b/src/p_spec.c index 5d4f456de..8fe886c7d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1773,6 +1773,7 @@ void P_SwitchWeather(preciptype_t newWeather) { boolean purge = false; mobjtype_t swap = MT_NULL; + INT32 oldEffects = precipprops[curWeather].effects; if (newWeather >= precip_freeslot) { @@ -1797,6 +1798,8 @@ void P_SwitchWeather(preciptype_t newWeather) } } + curWeather = newWeather; + if (purge == true) { thinker_t *think; @@ -1858,12 +1861,15 @@ void P_SwitchWeather(preciptype_t newWeather) { precipmobj->precipflags |= PCF_FLIP; } + + if ((oldEffects & PRECIPFX_WATERPARTICLES) != (precipprops[curWeather].effects & PRECIPFX_WATERPARTICLES)) + { + P_CalculatePrecipFloor(precipmobj); + } } } - curWeather = newWeather; - - if (swap == MT_NULL && precipprops[newWeather].type != MT_NULL) + if (swap == MT_NULL && precipprops[curWeather].type != MT_NULL) P_SpawnPrecipitation(); }