Merge branch 'master' of https://git.do.srb2.org/KartKrew/Kart into tutorial-pass

This commit is contained in:
toaster 2023-12-09 17:33:47 +00:00
commit 97f39abef3
12 changed files with 972 additions and 6 deletions

View file

@ -4864,6 +4864,41 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_BETA_PARTICLE_WHEEL",
"S_BETA_PARTICLE_ICON",
"S_BETA_PARTICLE_EXPLOSION",
// MT_AIZ_REDFERN
"S_AIZFL1",
"S_AIZFR1",
"S_AIZFR2",
"S_AIZTRE",
"S_AIZFR3",
"S_AIZDB1",
"S_AIZDB2",
"S_AIZDB3",
"S_AIZDB4",
"S_AIZDB5",
"S_AIZDB6",
"S_AIZDB7",
"S_AIZDB8",
// MT_AZROCKS
"S_AZROCKS",
"S_AZROCKS_RESPAWN",
"S_AZROCKS_PARTICLE1",
// MT_EMROCKS
"S_EMROCKS",
"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",
@ -6108,6 +6143,24 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t
"MT_BETA_PARTICLE_PHYSICAL",
"MT_BETA_PARTICLE_VISUAL",
"MT_BETA_PARTICLE_EXPLOSION",
"MT_AIZ_REDFERN",
"MT_AIZ_FERN1",
"MT_AIZ_FERN2",
"MT_AIZ_TREE",
"MT_AIZ_FERN3",
"MT_AIZ_DDB",
"MT_AZROCKS",
"MT_AZROCKS_PARTICLE",
"MT_EMROCKS",
"MT_EMROCKS_PARTICLE",
"MT_EMFAUCET",
"MT_EMFAUCET_DRIP",
"MT_EMFAUCET_PARTICLE",
"MT_EMRAINGEN",
};
const char *const MOBJFLAG_LIST[] = {

View file

@ -1001,6 +1001,20 @@ char sprnames[NUMSPRITES + 1][5] =
"LCLA",
"AIZ1",
"AIZ2",
"AIZ3",
"AIZ4",
"AIZ5",
"AIZ6",
"AZR1",
"AZR2",
"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",
};
@ -3299,8 +3313,8 @@ state_t states[NUMSTATES] =
{SPR_BUMP, FF_ANIMATE|4, 12, {A_Pain}, 1, 3, S_BUMPER}, //S_BUMPERHIT
// Balloons
{SPR_BLON, FF_ANIMATE, -1, {NULL}, 2, 5, S_NULL}, // S_BALLOON
{SPR_BLON, 3, 0, {A_RemoteDamage}, 0, 1, S_BALLOONPOP2}, // S_BALLOONPOP1
{SPR_BLON, FF_ANIMATE|FF_RANDOMANIM, -1, {NULL}, 7, 5, S_BALLOON}, // S_BALLOON
{SPR_NULL, 0, 2, {NULL}, 0, 0, S_BALLOONPOP2}, // S_BALLOONPOP1
{SPR_BLON, 3, 1, {A_Pain}, 0, 0, S_BALLOONPOP3}, // S_BALLOONPOP2
{SPR_BLON, 4, 1, {NULL}, 0, 0, S_BALLOONPOP4}, // S_BALLOONPOP3
{SPR_NULL, 0, TICRATE, {A_CheckFlags2}, MF2_AMBUSH, S_BALLOONPOP5, S_NULL}, // S_BALLOONPOP4
@ -5725,6 +5739,41 @@ state_t states[NUMSTATES] =
{SPR_LCLA, 0|FF_FULLBRIGHT|FF_PAPERSPRITE, -1, {NULL}, 0, 0, S_NULL}, // S_BETA_PARTICLE_WHEEL
{SPR_LCLA, 1|FF_FULLBRIGHT|FF_PAPERSPRITE, -1, {NULL}, 0, 0, S_NULL}, // S_BETA_PARTICLE_ICON
{SPR_LCLA, 2|FF_FULLBRIGHT, -1, {NULL}, 0, 0, S_NULL}, // S_BETA_PARTICLE_EXPLOSION
// MT_AIZ_REDFERN
{SPR_AIZ1, 0, 1, {NULL}, 0, 0, S_AIZFL1}, // S_AIZFL1
{SPR_AIZ2, 0, 1, {NULL}, 0, 0, S_AIZFR1}, // S_AIZFR1
{SPR_AIZ3, 0, 1, {NULL}, 0, 0, S_AIZFR2}, // S_AIZFR2
{SPR_AIZ4, 0, 1, {NULL}, 0, 0, S_AIZTRE}, // S_AIZTRE
{SPR_AIZ5, 0, 1, {NULL}, 0, 0, S_AIZFR3}, // S_AIZFR3
{SPR_AIZ6, 0, 10, {NULL}, 0, 0, S_AIZDB2}, // S_AIZDB1
{SPR_AIZ6, 1, 8, {NULL}, 0, 0, S_AIZDB3}, // S_AIZDB2
{SPR_AIZ6, 2, 6, {NULL}, 0, 0, S_AIZDB4}, // S_AIZDB3
{SPR_AIZ6, 3, 6, {NULL}, 0, 0, S_AIZDB5}, // S_AIZDB4
{SPR_AIZ6, 4, 6, {NULL}, 0, 0, S_AIZDB6}, // S_AIZDB5
{SPR_AIZ6, 5, 8, {NULL}, 0, 0, S_AIZDB7}, // S_AIZDB6
{SPR_AIZ6, 6, 8, {NULL}, 0, 0, S_AIZDB8}, // S_AIZDB7
{SPR_AIZ6, 7, 10, {NULL}, 0, 0, S_AIZDB1}, // S_AIZDB8
// MT_AZROCKS
{SPR_AZR1, 0, -1, {NULL}, 0, 0, S_AZROCKS}, // S_AZROCKS
{SPR_NULL, 0, -1, {NULL}, 0, 0, S_AZROCKS}, // S_AZROCKS_RESPAWN
{SPR_AZR2, 0, 5*TICRATE, {NULL}, 0, 0, S_NULL}, // S_AZROCKS_PARTICLE1
// MT_EMROCKS
{SPR_EMR1, 0, -1, {NULL}, 0, 0, S_EMROCKS}, // S_EMROCKS
{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] =
@ -32639,6 +32688,370 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_SCENERY|MF_DONTENCOREMAP|MF_NOHITLAGFORME|MF_SPECIAL|MF_DONTPUNT, // flags
S_NULL // raisestate
},
{ // MT_AIZ_REDFERN
2910, // doomednum
S_AIZFL1, // spawnstate
1000, // 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
12*FRACUNIT, // radius
64*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_SCENERY, // flags
S_NULL // raisestate
},
{ // MT_AIZ_FERN1
2911, // doomednum
S_AIZFR1, // spawnstate
1000, // 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
16*FRACUNIT, // radius
72*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_SCENERY, // flags
S_NULL // raisestate
},
{ // MT_AIZ_FERN2
2912, // doomednum
S_AIZFR2, // spawnstate
1000, // 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
16*FRACUNIT, // radius
64*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_SCENERY, // flags
S_NULL // raisestate
},
{ // MT_AIZ_TREE
2913, // doomednum
S_AIZTRE, // spawnstate
1000, // 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
9*FRACUNIT, // radius
115*FRACUNIT, // height
0, // dispoffset
100, // mass
0, // damage
sfx_None, // activesound
MF_SCENERY|MF_SOLID, // flags
S_NULL // raisestate
},
{ // MT_AIZ_FERN3
2914, // doomednum
S_AIZFR3, // spawnstate
1000, // 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
16*FRACUNIT, // radius
24*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_SCENERY, // flags
S_NULL // raisestate
},
{ // MT_AIZ_DDB
2915, // doomednum
S_AIZDB1, // spawnstate
1000, // 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
8*FRACUNIT, // radius
20*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_SCENERY, // flags
S_NULL // raisestate
},
{ // MT_AZROCKS
470, // doomednum
S_AZROCKS, // 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_s3k59, // deathsound
0, // speed
48*FRACUNIT, // radius
96*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_SPECIAL|MF_NOGRAVITY, // flags
S_NULL // raisestate
},
{ // MT_AZROCKS_PARTICLE
-1, // doomednum
S_AZROCKS_PARTICLE1, // 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
16*FRACUNIT, // radius
32*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_NOCLIPHEIGHT|MF_SCENERY|MF_NOBLOCKMAP, // flags
S_NULL // raisestate
},
{ // MT_EMROCKS
467, // doomednum
S_EMROCKS, // 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_s3k59, // deathsound
0, // speed
48*FRACUNIT, // radius
96*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
MF_SPECIAL|MF_NOGRAVITY, // flags
S_NULL // raisestate
},
{ // MT_EMROCKS_PARTICLE
-1, // doomednum
S_EMROCKS_PARTICLE1, // 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
16*FRACUNIT, // radius
32*FRACUNIT, // height
0, // dispoffset
0, // mass
0, // damage
sfx_None, // activesound
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

@ -1555,6 +1555,20 @@ typedef enum sprite
SPR_LCLA,
SPR_AIZ1,
SPR_AIZ2,
SPR_AIZ3,
SPR_AIZ4,
SPR_AIZ5,
SPR_AIZ6,
SPR_AZR1,
SPR_AZR2,
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,
@ -6150,6 +6164,41 @@ typedef enum state
S_BETA_PARTICLE_ICON,
S_BETA_PARTICLE_EXPLOSION,
// MT_AIZ_REDFERN
S_AIZFL1,
S_AIZFR1,
S_AIZFR2,
S_AIZTRE,
S_AIZFR3,
S_AIZDB1,
S_AIZDB2,
S_AIZDB3,
S_AIZDB4,
S_AIZDB5,
S_AIZDB6,
S_AIZDB7,
S_AIZDB8,
// MT_AZROCKS
S_AZROCKS,
S_AZROCKS_RESPAWN,
S_AZROCKS_PARTICLE1,
// MT_EMROCKS
S_EMROCKS,
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,
S_FIRSTFREESLOT,
S_LASTFREESLOT = S_FIRSTFREESLOT + NUMSTATEFREESLOTS - 1,
NUMSTATES
@ -7414,6 +7463,24 @@ typedef enum mobj_type
MT_BETA_PARTICLE_VISUAL,
MT_BETA_PARTICLE_EXPLOSION,
MT_AIZ_REDFERN,
MT_AIZ_FERN1,
MT_AIZ_FERN2,
MT_AIZ_TREE,
MT_AIZ_FERN3,
MT_AIZ_DDB,
MT_AZROCKS,
MT_AZROCKS_PARTICLE,
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

@ -341,6 +341,18 @@ void Obj_FuelCanisterTouch(mobj_t *special, mobj_t *toucher);
void Obj_FuelCanisterExplosionTouch(mobj_t *special, mobj_t *toucher);
boolean Obj_FuelCanisterExplosionThink(mobj_t *mo);
/* Bustable Rocks */
void Obj_LinkRocks(mobj_t *mo);
void Obj_UnlinkRocks(mobj_t *mo);
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

@ -47,6 +47,8 @@ target_sources(SRB2SDL2 PRIVATE
crate.cpp
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();
}

210
src/objects/rocks.cpp Normal file
View file

@ -0,0 +1,210 @@
// 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
#include <array>
#include <cstdlib>
#include "../math/fixed.hpp"
#include "../math/vec.hpp"
#include "../mobj.hpp"
#include "../mobj_list.hpp"
#include "../d_player.h"
#include "../doomstat.h"
#include "../info.h"
#include "../k_objects.h"
#include "../m_fixed.h"
#include "../p_pspr.h"
#include "../sounds.h"
#include "../tables.h"
using srb2::Mobj;
using srb2::MobjList;
using srb2::math::Fixed;
using srb2::math::Vec2;
extern mobj_t* svg_rocks;
namespace
{
struct AngelIsland
{
static constexpr statenum_t kRespawnState = S_AZROCKS_RESPAWN;
static constexpr mobjtype_t kParticleType = MT_AZROCKS_PARTICLE;
static constexpr std::array<statenum_t, 2> kParticleStates = {S_AZROCKS_PARTICLE1, S_AZROCKS_PARTICLE1};
};
struct EndlessMine
{
static constexpr statenum_t kRespawnState = S_EMROCKS_RESPAWN;
static constexpr mobjtype_t kParticleType = MT_EMROCKS_PARTICLE;
static constexpr std::array<statenum_t, 2> kParticleStates = {S_EMROCKS_PARTICLE1, S_EMROCKS_PARTICLE2};
};
struct AnyRocks : Mobj
{
void hnext() = delete;
AnyRocks* next() const { return Mobj::hnext<AnyRocks>(); }
void next(AnyRocks* n) { Mobj::hnext(n); }
template <typename F>
bool visit(F&& visitor);
};
template <class Config>
struct Rocks : AnyRocks
{
bool busted() const { return state()->num() == Config::kRespawnState; }
void respawn()
{
if (busted())
{
tics = 2; // respawn soon
}
}
void touch(Mobj* toucher)
{
if (busted())
{
if (tics > 0)
{
tics = 2; // postpone respawn
}
}
else
{
slow(toucher);
bust(toucher);
}
}
private:
static void slow(Mobj* toucher)
{
const player_t* p = toucher->player;
if (p->sneakertimer || p->invincibilitytimer || p->growshrinktimer > 0 || p->hyudorotimer)
{
return;
}
toucher->momx /= 2;
toucher->momy /= 2;
toucher->momz = toucher->flip(std::abs(2 * toucher->momz / 3));
}
void bust(Mobj* toucher)
{
vfx(toucher, 1);
vfx(toucher, 2);
vfx(toucher, 3);
voice(info->deathsound);
state(Config::kRespawnState);
}
void vfx(Mobj* toucher, int i)
{
fixed_t zvar = flip((i + 1) * 4 * mapobjectscale);
angle_t avar = ANGLE_45 * (i - 2);
auto part = [&](angle_t angle, statenum_t state)
{
Mobj* h = spawn_from<Mobj>({Vec2<Fixed> {}, zvar}, Config::kParticleType);
h->state(state);
h->angle = angle;
h->instathrust(angle, 4 * mapobjectscale);
h->momz = zvar;
return h;
};
static_assert(Config::kParticleStates.size() == 2);
part(toucher->angle + ANGLE_90 - avar, Config::kParticleStates[0]);
part(toucher->angle - ANGLE_90 + avar, Config::kParticleStates[1]);
}
};
struct AngelIslandRocks : Rocks<AngelIsland>
{
};
struct EndlessMineRocks : Rocks<EndlessMine>
{
};
template <typename F>
bool AnyRocks::visit(F&& visitor)
{
switch (type)
{
case MT_AZROCKS:
visitor(static_cast<AngelIslandRocks*>(this));
break;
case MT_EMROCKS:
visitor(static_cast<EndlessMineRocks*>(this));
break;
default:
return false;
}
return true;
}
MobjList<AnyRocks, svg_rocks> rocks_list;
}; // namespace
void Obj_LinkRocks(mobj_t* mo)
{
rocks_list.push_front(static_cast<AnyRocks*>(mo));
}
void Obj_UnlinkRocks(mobj_t* mo)
{
rocks_list.erase(static_cast<AnyRocks*>(mo));
}
void Obj_TouchRocks(mobj_t* special, mobj_t* toucher)
{
static_cast<AnyRocks*>(special)->visit([&](auto rocks) { rocks->touch(static_cast<Mobj*>(toucher)); });
}
void Obj_UpdateRocks(void)
{
for (AnyRocks* h : rocks_list)
{
h->visit([](auto rocks) { rocks->respawn(); });
}
}
void Obj_AnimateEndlessMineRocks(mobj_t *mo)
{
// sync colors with sky animation
constexpr int kFrames = 8;
constexpr int kDiff = kFrames - 2;
constexpr int kTotal = kFrames + kDiff;
UINT8 f = ((leveltime / 6) % kTotal);
if (f >= kFrames)
{
f = kTotal - f;
}
mo->frame = (mo->frame & ~FF_FRAMEMASK) | f;
}

View file

@ -1007,6 +1007,13 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
return;
}
case MT_AZROCKS:
case MT_EMROCKS:
{
Obj_TouchRocks(special, toucher);
return;
}
default: // SOC or script pickup
P_SetTarget(&special->target, toucher);
break;
@ -2350,6 +2357,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

@ -16,7 +16,8 @@
#define LINK_PACK \
svg_battleUfoSpawners,\
svg_checkpoints
svg_checkpoints,\
svg_rocks
using link = mobj_t*;

View file

@ -3156,6 +3156,17 @@ boolean P_SceneryZMovement(mobj_t *mo)
return false;
}
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)
{
P_KillMobj(mo, NULL, NULL, DMG_NORMAL);
if (P_MobjWasRemoved(mo))
return false;
}
break;
default:
break;
}
@ -6880,6 +6891,21 @@ static void P_MobjSceneryThink(mobj_t *mobj)
}
break;
}
case MT_EMROCKS_PARTICLE:
{
Obj_AnimateEndlessMineRocks(mobj);
break;
}
case MT_EMFAUCET:
{
Obj_EMZFaucetThink(mobj);
return;
}
case MT_EMRAINGEN:
{
Obj_EMZRainGenerator(mobj);
return;
}
case MT_VWREF:
case MT_VWREB:
{
@ -10285,6 +10311,19 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
}
break;
}
case MT_EMROCKS:
{
Obj_AnimateEndlessMineRocks(mobj);
break;
}
case MT_BALLOON:
{
fixed_t sine = FixedMul(16 * FSIN((M_TAU_FIXED * (4*TICRATE)) * (leveltime + mobj->extravalue2)), mobj->scale);
mobj->z = (mobj->extravalue1 - (16 * mobj->scale)) + sine;
break;
}
default:
// check mobj against possible water content, before movement code
@ -11070,6 +11109,13 @@ fixed_t P_GetMobjDefaultScale(mobj_t *mobj)
return 2*FRACUNIT;
case MT_BETA_EMITTER:
return 4*FRACUNIT;
case MT_AIZ_REDFERN:
case MT_AIZ_FERN1:
case MT_AIZ_FERN2:
case MT_AIZ_FERN3:
case MT_AIZ_TREE:
case MT_AIZ_DDB:
return 4*FRACUNIT;
default:
break;
}
@ -11117,6 +11163,7 @@ static void P_DefaultMobjShadowScale(mobj_t *thing)
case MT_SPB:
case MT_DUELBOMB:
case MT_GACHABOM:
case MT_BALLOON:
thing->shadowscale = 3*FRACUNIT/2;
break;
case MT_BANANA_SHIELD:
@ -11168,6 +11215,9 @@ static void P_DefaultMobjShadowScale(mobj_t *thing)
case MT_AIRIVOBALL:
thing->shadowscale = FRACUNIT/2;
break;
case MT_BUMPER:
thing->shadowscale = 7*FRACUNIT/4;
break;
default:
if (thing->flags & (MF_ENEMY|MF_BOSS))
thing->shadowscale = FRACUNIT;
@ -11439,6 +11489,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
};
mobj->color = BALLOONCOLORS[P_RandomKey(PR_DECORATION, sizeof(BALLOONCOLORS))];
mobj->extravalue1 = mobj->z;
mobj->extravalue2 = P_RandomRange(PR_DECORATION, 0, 4*TICRATE);
}
break;
case MT_POGOSPRING:
@ -11779,6 +11832,10 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
case MT_GPZ_SEASAW_SPAWN:
Obj_GPZSeasawSpawn(mobj);
break;
case MT_AZROCKS:
case MT_EMROCKS:
Obj_LinkRocks(mobj);
break;
default:
break;
}
@ -12053,6 +12110,12 @@ void P_RemoveMobj(mobj_t *mobj)
Obj_UnlinkCheckpoint(mobj);
break;
}
case MT_AZROCKS:
case MT_EMROCKS:
{
Obj_UnlinkRocks(mobj);
break;
}
default:
{
break;

View file

@ -1933,12 +1933,14 @@ static void K_HandleLapIncrement(player_t *player)
{
size_t i = 0;
UINT8 nump = 0;
UINT8 lowestLap;
UINT8 lowestLap = UINT8_MAX;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (players[i].laps < lowestLap)
lowestLap = players[i].laps;
nump++;
}
@ -2090,7 +2092,17 @@ static void K_HandleLapIncrement(player_t *player)
}
thwompsactive = true; // Lap 2 effects
lowestLap = P_FindLowestLap();
{
UINT8 prevLowest = lowestLap;
lowestLap = P_FindLowestLap();
if (lowestLap > prevLowest) // last place finished the lap
{
Obj_UpdateRocks();
}
}
for (i = 0; i < numlines; i++)
{

View file

@ -978,7 +978,7 @@ void P_Ticker(boolean run)
if (!Music_Playing("level_nosync"))
{
// Do not stop level_nosync
Music_Play(Music_Song("level_nosync")[0] ? "level_nosync" : "level");
Music_Play((gametyperules & GTR_NOPOSITION) ? "level_nosync" : "level");
}
}
else if (starttime != introtime)