Hardcode Endless Mine faucet / rain

- Note: rain does not use the weather system
This commit is contained in:
James R 2023-12-07 00:57:17 -08:00
parent 69541b9422
commit b68947e636
8 changed files with 287 additions and 0 deletions

View file

@ -4890,6 +4890,15 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_EMROCKS_RESPAWN",
"S_EMROCKS_PARTICLE1",
"S_EMROCKS_PARTICLE2",
// MT_EMFAUCET
"S_EMFAUCET",
// MT_EMFAUCET_DRIP
"S_EMROCKS_DRIP",
// MT_EMFAUCET_PARTICLE
"S_EMFAUCET_PARTICLE",
};
// RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1",
@ -6147,6 +6156,11 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t
"MT_EMROCKS",
"MT_EMROCKS_PARTICLE",
"MT_EMFAUCET",
"MT_EMFAUCET_DRIP",
"MT_EMFAUCET_PARTICLE",
"MT_EMRAINGEN",
};
const char *const MOBJFLAG_LIST[] = {

View file

@ -1013,6 +1013,7 @@ char sprnames[NUMSPRITES + 1][5] =
"EMR1",
"EMR2",
"EMR3",
"EMFC",
// First person view sprites; this is a sprite so that it can be replaced by a specialized MD2 draw later
"VIEW",
@ -5764,6 +5765,15 @@ state_t states[NUMSTATES] =
{SPR_NULL, 0, -1, {NULL}, 0, 0, S_EMROCKS}, // S_EMROCKS_RESPAWN
{SPR_EMR2, 0, 5*TICRATE, {NULL}, 0, 0, S_NULL}, // S_EMROCKS_PARTICLE1
{SPR_EMR3, 0, 5*TICRATE, {NULL}, 0, 0, S_NULL}, // S_EMROCKS_PARTICLE2
// MT_EMFAUCET
{SPR_EMFC, 0, -1, {NULL}, 0, 0, S_EMFAUCET}, // S_EMFAUCET
// MT_EMFAUCET_DRIP
{SPR_EMFC, 1, -1, {NULL}, 0, 0, S_EMROCKS_DRIP}, // S_EMROCKS_DRIP
// MT_EMFAUCET_PARTICLE
{SPR_EMFC, 2, -1, {NULL}, 0, 0, S_EMFAUCET_PARTICLE}, // S_EMFAUCET_PARTICLE
};
mobjinfo_t mobjinfo[NUMMOBJTYPES] =
@ -32938,6 +32948,110 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
MF_NOCLIPHEIGHT|MF_SCENERY|MF_NOBLOCKMAP, // flags
S_NULL // raisestate
},
{ // MT_EMFAUCET
468, // doomednum
S_EMFAUCET, // spawnstate
1, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
0, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_NULL, // deathstate
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
24*FRACUNIT, // radius
24*FRACUNIT, // height
1, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY, // flags
S_NULL // raisestate
},
{ // MT_EMFAUCET_DRIP
-1, // doomednum
S_EMROCKS_DRIP, // spawnstate
1, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
0, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_NULL, // deathstate
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
4*FRACUNIT, // radius
8*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_NOCLIPHEIGHT|MF_SCENERY|MF_NOBLOCKMAP, // flags
S_NULL // raisestate
},
{ // MT_EMFAUCET_PARTICLE
-1, // doomednum
S_EMFAUCET_PARTICLE, // spawnstate
1, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
0, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_NULL, // deathstate
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
4*FRACUNIT, // radius
8*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_NOCLIPHEIGHT|MF_SCENERY|MF_NOBLOCKMAP, // flags
S_NULL // raisestate
},
{ // MT_EMRAINGEN
469, // doomednum
S_INVISIBLE, // spawnstate
1, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
0, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_NULL, // deathstate
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
0, // radius
0, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_NOGRAVITY|MF_NOBLOCKMAP|MF_SCENERY, // flags
S_NULL // raisestate
},
};

View file

@ -1567,6 +1567,7 @@ typedef enum sprite
SPR_EMR1,
SPR_EMR2,
SPR_EMR3,
SPR_EMFC,
// First person view sprites; this is a sprite so that it can be replaced by a specialized MD2 draw later
SPR_VIEW,
@ -6189,6 +6190,15 @@ typedef enum state
S_EMROCKS_PARTICLE1,
S_EMROCKS_PARTICLE2,
// MT_EMFAUCET
S_EMFAUCET,
// MT_EMFAUCET_DRIP
S_EMROCKS_DRIP,
// MT_EMFAUCET_PARTICLE
S_EMFAUCET_PARTICLE,
S_FIRSTFREESLOT,
S_LASTFREESLOT = S_FIRSTFREESLOT + NUMSTATEFREESLOTS - 1,
NUMSTATES
@ -7466,6 +7476,11 @@ typedef enum mobj_type
MT_EMROCKS,
MT_EMROCKS_PARTICLE,
MT_EMFAUCET,
MT_EMFAUCET_DRIP,
MT_EMFAUCET_PARTICLE,
MT_EMRAINGEN,
MT_FIRSTFREESLOT,
MT_LASTFREESLOT = MT_FIRSTFREESLOT + NUMMOBJFREESLOTS - 1,
NUMMOBJTYPES

View file

@ -346,6 +346,11 @@ void Obj_TouchRocks(mobj_t *special, mobj_t *toucher);
void Obj_UpdateRocks(void);
void Obj_AnimateEndlessMineRocks(mobj_t *mo);
/* Enldess Mine Faucet */
void Obj_EMZFaucetThink(mobj_t *mo);
void Obj_EMZDripDeath(mobj_t *mo);
void Obj_EMZRainGenerator(mobj_t *mo);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -48,6 +48,7 @@ target_sources(SRB2SDL2 PRIVATE
spear.cpp
fuel.cpp
rocks.cpp
emz-faucet.cpp
)
add_subdirectory(versus)

123
src/objects/emz-faucet.cpp Normal file
View file

@ -0,0 +1,123 @@
// DR. ROBOTNIK'S RING RACERS
//-----------------------------------------------------------------------------
// Copyright (C) 2023 by Kart Krew.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
// Original Lua script by Sal
// Hardcoded by jartha
// Faucet & rain effect
// I actually thought these were a hazard until I went back and looked at the original game...
// I just never got hit by 'em, so I assumed they were hazardous!
// In that same research session, I noticed the tiny droplet effect at the only "exposed" sky area...
#include "../mobj.hpp"
#include "../doomdef.h"
#include "../info.h"
#include "../k_objects.h"
#include "../m_fixed.h"
#include "../m_random.h"
#include "../tables.h"
#include "../p_slopes.h"
#include "../r_defs.h"
#include "../r_main.h"
#include "../r_sky.h"
using srb2::Mobj;
namespace
{
struct Drip : Mobj
{
void splatter()
{
vfx(0);
vfx(90);
vfx(180);
vfx(270);
}
private:
void vfx(int deg)
{
Mobj* h = spawn<Mobj>(pos(), MT_EMFAUCET_PARTICLE);
h->angle = (deg + P_RandomKey(PR_DECORATION, 90)) * ANG1;
h->instathrust(h->angle, 8 * h->scale());
h->momz = h->flip(4 * h->scale());
}
};
struct Faucet : Mobj
{
void tick()
{
if (leveltime % (4*TICRATE) == 0)
{
spawn<Drip>(pos(), MT_EMFAUCET_DRIP);
}
}
};
struct RainGenerator : Mobj
{
void tick()
{
if (leveltime % 2)
{
return;
}
for (int i = 0; i < 16; ++i)
{
if (rain())
{
break;
}
}
}
private:
bool rain()
{
auto rng = [](int x, int y) { return P_RandomRange(PR_DECORATION, x, y); };
const fixed_t x = this->x + (rng(-15, 15) * 256 * scale());
const fixed_t y = this->y + (rng(-15, 15) * 256 * scale());
const sector_t* sector = R_PointInSubsector(x, y)->sector;
if (sector->ceilingpic != skyflatnum)
{
return false;
}
Mobj* h = spawn<Mobj>({x, y, P_GetSectorCeilingZAt(sector, x, y)}, MT_EMFAUCET_PARTICLE);
h->angle = rng(0, 359) * ANG1;
h->instathrust(h->angle, 4 * h->scale());
return true;
}
};
}; // namespace
void Obj_EMZFaucetThink(mobj_t* mo)
{
static_cast<Faucet*>(mo)->tick();
}
void Obj_EMZDripDeath(mobj_t* mo)
{
static_cast<Drip*>(mo)->splatter();
}
void Obj_EMZRainGenerator(mobj_t* mo)
{
static_cast<RainGenerator*>(mo)->tick();
}

View file

@ -2353,6 +2353,9 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
case MT_BLENDEYE_PUYO:
VS_PuyoDeath(target);
break;
case MT_EMFAUCET_DRIP:
Obj_EMZDripDeath(target);
break;
default:
break;
}

View file

@ -3157,6 +3157,8 @@ boolean P_SceneryZMovement(mobj_t *mo)
}
break;
case MT_EMROCKS_PARTICLE:
case MT_EMFAUCET_DRIP:
case MT_EMFAUCET_PARTICLE:
// Hits the ground
if (mo->momz <= 0 && mo->z + mo->momz <= mo->floorz - mo->height)
{
@ -6894,6 +6896,16 @@ static void P_MobjSceneryThink(mobj_t *mobj)
Obj_AnimateEndlessMineRocks(mobj);
break;
}
case MT_EMFAUCET:
{
Obj_EMZFaucetThink(mobj);
return;
}
case MT_EMRAINGEN:
{
Obj_EMZRainGenerator(mobj);
return;
}
case MT_VWREF:
case MT_VWREB:
{