mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-05 22:42:54 +00:00
Store random states in mobjinfo instead of precipprops
My reasoning is that it wouldn't make much sense to have a weather type that has snow, but doesn't randomize the sprite it uses, so we don't need to copy-paste the same "randomstates" for each weather type.
This commit is contained in:
parent
80bb59031c
commit
6956e1d24e
5 changed files with 20 additions and 18 deletions
|
|
@ -68,7 +68,6 @@ typedef struct
|
|||
{
|
||||
mobjtype_t type;
|
||||
precipeffect_t effects;
|
||||
UINT8 randomstates;
|
||||
} precipprops_t;
|
||||
|
||||
extern precipprops_t precipprops[MAXPRECIP];
|
||||
|
|
|
|||
14
src/g_game.c
14
src/g_game.c
|
|
@ -89,13 +89,13 @@ UINT8 curWeather = PRECIP_NONE;
|
|||
|
||||
precipprops_t precipprops[MAXPRECIP] =
|
||||
{
|
||||
{MT_NULL, 0, 0}, // PRECIP_NONE
|
||||
{MT_RAIN, 0, 0}, // PRECIP_RAIN
|
||||
{MT_SNOWFLAKE, 0, 2}, // PRECIP_SNOW
|
||||
{MT_BLIZZARDSNOW, 0, 2}, // PRECIP_BLIZZARD
|
||||
{MT_RAIN, PRECIPFX_THUNDER|PRECIPFX_LIGHTNING, 0}, // PRECIP_STORM
|
||||
{MT_NULL, PRECIPFX_THUNDER|PRECIPFX_LIGHTNING, 0}, // PRECIP_STORM_NORAIN
|
||||
{MT_RAIN, PRECIPFX_THUNDER, 0} // PRECIP_STORM_NOSTRIKES
|
||||
{MT_NULL, 0}, // PRECIP_NONE
|
||||
{MT_RAIN, 0}, // PRECIP_RAIN
|
||||
{MT_SNOWFLAKE, 0}, // PRECIP_SNOW
|
||||
{MT_BLIZZARDSNOW, 0}, // PRECIP_BLIZZARD
|
||||
{MT_RAIN, PRECIPFX_THUNDER|PRECIPFX_LIGHTNING}, // PRECIP_STORM
|
||||
{MT_NULL, PRECIPFX_THUNDER|PRECIPFX_LIGHTNING}, // PRECIP_STORM_NORAIN
|
||||
{MT_RAIN, PRECIPFX_THUNDER} // PRECIP_STORM_NOSTRIKES
|
||||
};
|
||||
|
||||
INT32 cursaveslot = -1; // Auto-save 1p savegame slot
|
||||
|
|
|
|||
|
|
@ -11486,7 +11486,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
|
|||
4*FRACUNIT, // height
|
||||
0, // display offset
|
||||
0, // mass
|
||||
0, // damage
|
||||
2, // damage
|
||||
sfx_None, // activesound
|
||||
MF_NOBLOCKMAP, // flags
|
||||
S_NULL // raisestate
|
||||
|
|
@ -11513,7 +11513,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
|
|||
4*FRACUNIT, // height
|
||||
0, // display offset
|
||||
0, // mass
|
||||
0, // damage
|
||||
2, // damage
|
||||
sfx_None, // activesound
|
||||
MF_NOBLOCKMAP, // flags
|
||||
S_NULL // raisestate
|
||||
|
|
|
|||
12
src/p_mobj.c
12
src/p_mobj.c
|
|
@ -11005,6 +11005,8 @@ consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHE
|
|||
void P_SpawnPrecipitation(void)
|
||||
{
|
||||
INT32 i, j, k;
|
||||
mobjtype_t type = precipprops[curWeather].type;
|
||||
INT32 randomstates = mobjinfo[type].damage;
|
||||
fixed_t basex, basey, x, y, z, height;
|
||||
subsector_t *precipsector = NULL;
|
||||
precipmobj_t *rainmo = NULL;
|
||||
|
|
@ -11049,15 +11051,15 @@ void P_SpawnPrecipitation(void)
|
|||
|
||||
for (j = 0; j < numparticles; j++)
|
||||
{
|
||||
rainmo = P_SpawnPrecipMobj(x, y, z, precipprops[curWeather].type);
|
||||
rainmo = P_SpawnPrecipMobj(x, y, z, type);
|
||||
|
||||
if (precipprops[curWeather].randomstates > 0)
|
||||
if (randomstates > 0 && randomstates < UINT8_MAX)
|
||||
{
|
||||
UINT8 mrand = M_RandomByte();
|
||||
UINT8 threshold = UINT8_MAX / (precipprops[curWeather].randomstates + 1);
|
||||
statenum_t st = mobjinfo[precipprops[curWeather].type].spawnstate;
|
||||
UINT8 threshold = UINT8_MAX / (randomstates + 1);
|
||||
statenum_t st = mobjinfo[type].spawnstate;
|
||||
|
||||
for (k = 0; k < precipprops[curWeather].randomstates; k++)
|
||||
for (k = 0; k < randomstates; k++)
|
||||
{
|
||||
if (mrand < (threshold * (k+1)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2041,6 +2041,7 @@ void P_SwitchWeather(UINT8 newWeather)
|
|||
}
|
||||
else if (swap != MT_NULL) // Rather than respawn all that crap, reuse it!
|
||||
{
|
||||
INT32 randomstates = mobjinfo[swap].damage;
|
||||
thinker_t *think;
|
||||
precipmobj_t *precipmobj;
|
||||
statenum_t st;
|
||||
|
|
@ -2056,13 +2057,13 @@ void P_SwitchWeather(UINT8 newWeather)
|
|||
|
||||
st = mobjinfo[swap].spawnstate;
|
||||
|
||||
if (precipprops[curWeather].randomstates > 0)
|
||||
if (randomstates > 0 && randomstates < UINT8_MAX)
|
||||
{
|
||||
UINT8 mrand = M_RandomByte();
|
||||
UINT8 threshold = UINT8_MAX / (precipprops[curWeather].randomstates + 1);
|
||||
UINT8 threshold = UINT8_MAX / (randomstates + 1);
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < precipprops[curWeather].randomstates; i++)
|
||||
for (i = 0; i < randomstates; i++)
|
||||
{
|
||||
if (mrand < (threshold * (i+1)))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue