Add water particles

This commit is contained in:
Sally Coolatta 2022-06-05 06:24:55 -04:00
parent 6106ce1624
commit 0e96aeec84
4 changed files with 50 additions and 9 deletions

View file

@ -6744,6 +6744,7 @@ struct int_const_s const INT_CONST[] = {
// precipeffect_t // precipeffect_t
{"PRECIPFX_THUNDER",PRECIPFX_THUNDER}, {"PRECIPFX_THUNDER",PRECIPFX_THUNDER},
{"PRECIPFX_LIGHTNING",PRECIPFX_LIGHTNING}, {"PRECIPFX_LIGHTNING",PRECIPFX_LIGHTNING},
{"PRECIPFX_WATERPARTICLES",PRECIPFX_WATERPARTICLES},
{NULL,0} {NULL,0}
}; };

View file

@ -85,7 +85,8 @@ typedef enum
typedef enum typedef enum
{ {
PRECIPFX_THUNDER = 1, PRECIPFX_THUNDER = 1,
PRECIPFX_LIGHTNING = 1<<1 PRECIPFX_LIGHTNING = 1<<1,
PRECIPFX_WATERPARTICLES = 1<<2
} precipeffect_t; } precipeffect_t;
typedef struct typedef struct

View file

@ -3764,13 +3764,16 @@ void P_CalculatePrecipFloor(precipmobj_t *mobj)
{ {
// recalculate floorz each time // recalculate floorz each time
const sector_t *mobjsecsubsec; const sector_t *mobjsecsubsec;
boolean setWater = false;
if (mobj && mobj->subsector && mobj->subsector->sector) if (mobj && mobj->subsector && mobj->subsector->sector)
mobjsecsubsec = mobj->subsector->sector; mobjsecsubsec = mobj->subsector->sector;
else else
return; return;
mobj->precipflags &= ~PCF_INVISIBLE;
mobj->floorz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y); mobj->floorz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y);
mobj->ceilingz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y);
if (mobjsecsubsec->ffloors) if (mobjsecsubsec->ffloors)
{ {
@ -3783,14 +3786,44 @@ void P_CalculatePrecipFloor(precipmobj_t *mobj)
if (!(rover->flags & FF_EXISTS)) if (!(rover->flags & FF_EXISTS))
continue; continue;
if (!(rover->flags & FF_BLOCKOTHERS) && !(rover->flags & FF_SWIMMABLE)) if (precipprops[curWeather].effects & PRECIPFX_WATERPARTICLES)
continue; {
if (!(rover->flags & FF_SWIMMABLE))
continue;
height = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); if (setWater == false)
if (height > mobj->floorz) {
mobj->floorz = height; 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) void P_RecalcPrecipInSector(sector_t *sector)

View file

@ -1773,6 +1773,7 @@ void P_SwitchWeather(preciptype_t newWeather)
{ {
boolean purge = false; boolean purge = false;
mobjtype_t swap = MT_NULL; mobjtype_t swap = MT_NULL;
INT32 oldEffects = precipprops[curWeather].effects;
if (newWeather >= precip_freeslot) if (newWeather >= precip_freeslot)
{ {
@ -1797,6 +1798,8 @@ void P_SwitchWeather(preciptype_t newWeather)
} }
} }
curWeather = newWeather;
if (purge == true) if (purge == true)
{ {
thinker_t *think; thinker_t *think;
@ -1858,12 +1861,15 @@ void P_SwitchWeather(preciptype_t newWeather)
{ {
precipmobj->precipflags |= PCF_FLIP; precipmobj->precipflags |= PCF_FLIP;
} }
if ((oldEffects & PRECIPFX_WATERPARTICLES) != (precipprops[curWeather].effects & PRECIPFX_WATERPARTICLES))
{
P_CalculatePrecipFloor(precipmobj);
}
} }
} }
curWeather = newWeather; if (swap == MT_NULL && precipprops[curWeather].type != MT_NULL)
if (swap == MT_NULL && precipprops[newWeather].type != MT_NULL)
P_SpawnPrecipitation(); P_SpawnPrecipitation();
} }