Implement pohbee chain

Crashes when drawing the sprites after looking at it for like half a second and idk why tf
This commit is contained in:
Sally Coolatta 2022-09-15 01:03:08 -04:00
parent 72948ad49d
commit 71723a803d
4 changed files with 46 additions and 9 deletions

View file

@ -3760,6 +3760,7 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
// Shrink
"S_SHRINK_GUN",
"S_SHRINK_CHAIN",
"S_SHRINK_LASER",
"S_SHRINK_PARTICLE",

View file

@ -574,6 +574,7 @@ char sprnames[NUMSPRITES + 1][5] =
"FLMF", // Flame Shield flash
"HYUU", // Hyudoro
"GRWP", // Grow
"POHB", // Shrink Poh-Bee
"SHRG", // Shrink gun / laser
"SINK", // Kitchen Sink
"SITR", // Kitchen Sink Trail
@ -4319,6 +4320,7 @@ state_t states[NUMSTATES] =
{SPR_GRWP, FF_FULLBRIGHT|FF_ANIMATE, 13, {NULL}, 7, 1, S_NULL}, // S_GROW_PARTICLE
{SPR_SHRG, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_GUN
{SPR_POHB, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_CHAIN
{SPR_SHRG, FF_FULLBRIGHT|1, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_LASER
{SPR_SHRG, FF_FULLBRIGHT|2, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_PARTICLE
@ -24127,7 +24129,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
{ // MT_SHRINK_CHAIN
-1, // doomednum
S_SHRINK_GUN, // spawnstate
S_SHRINK_CHAIN, // spawnstate
1000, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
@ -24142,13 +24144,13 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
16*FRACUNIT, // radius
120*FRACUNIT, // height
26*FRACUNIT, // radius
26*FRACUNIT, // height
0, // display offset
0, // mass
0, // damage
sfx_None, // activesound
MF_NOTHINK|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags
MF_SCENERY|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags
S_NULL // raisestate
},

View file

@ -1120,6 +1120,7 @@ typedef enum sprite
SPR_FLMF, // Flame Shield flash
SPR_HYUU, // Hyudoro
SPR_GRWP, // Grow
SPR_POHB, // Shrink Poh-Bee
SPR_SHRG, // Shrink gun / laser
SPR_SINK, // Kitchen Sink
SPR_SITR, // Kitchen Sink Trail
@ -4752,6 +4753,7 @@ typedef enum state
// Shrink
S_SHRINK_GUN,
S_SHRINK_CHAIN,
S_SHRINK_LASER,
S_SHRINK_PARTICLE,

View file

@ -31,7 +31,7 @@
#define GUN_SWING (ANGLE_90 - ANG10)
#define GUN_SWINGTIME (4 * TICRATE)
#define CHAIN_SIZE (16)
#define CHAIN_SIZE (52)
#define EXTRA_FOR_FIRST (7)
@ -58,6 +58,8 @@ enum
#define gun_laser(o) ((o)->tracer)
#define gun_chains(o) ((o)->hprev)
#define chain_index(o) ((o)->extravalue1)
enum
{
LASER_SHRINK,
@ -333,6 +335,34 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser)
}
}
static void DoGunChains(mobj_t *gun, mobj_t *pohbee)
{
const fixed_t gunZ = P_GetMobjHead(gun);
const fixed_t beeZ = P_GetMobjFeet(pohbee);
const fixed_t offsetX = (pohbee->x - gun->x) / gun_numsegs(gun);
const fixed_t offsetY = (pohbee->y - gun->y) / gun_numsegs(gun);
const fixed_t offsetZ = (beeZ - gunZ) / gun_numsegs(gun);
mobj_t *chain = NULL;
fixed_t curX = gun->x + (offsetX / 2);
fixed_t curY = gun->y + (offsetY / 2);
fixed_t curZ = gunZ + (offsetZ / 2);
chain = gun_chains(gun);
while (chain != NULL && P_MobjWasRemoved(chain) == false)
{
PohbeeMoveTo(chain, curX, curY, curZ);
curX += offsetX;
curY += offsetY;
curZ += offsetZ;
chain = gun_chains(chain);
}
}
static void ShrinkGunThinker(mobj_t *gun)
{
mobj_t *pohbee = gun_pohbee(gun);
@ -352,6 +382,8 @@ static void ShrinkGunThinker(mobj_t *gun)
{
ShrinkLaserThinker(pohbee, gun, gun_laser(gun));
}
DoGunChains(gun, pohbee);
}
void Obj_PohbeeThinker(mobj_t *pohbee)
@ -612,7 +644,7 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI
mobj_t *gun = P_SpawnMobjFromMobj(pohbee, 0, 0, 0, MT_SHRINK_GUN);
mobj_t *laser = NULL;
//mobj_t *prevChain = NULL;
mobj_t *prevChain = NULL;
P_SetTarget(&gun_pohbee(gun), pohbee);
P_SetTarget(&pohbee_guns(prevGun), gun);
@ -623,16 +655,16 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI
laser = P_SpawnMobjFromMobj(gun, 0, 0, 0, MT_SHRINK_LASER);
P_SetTarget(&gun_laser(gun), laser);
/*
prevChain = gun;
for (j = 0; j < numSegs; j++)
{
mobj_t *chain = P_SpawnMobjFromMobj(gun, 0, 0, 0, MT_SHRINK_CHAIN);
P_SetTarget(&gun_chains(prevChain), chain);
chain_index(chain) = j;
prevChain = chain;
}
*/
(void)j;
prevGun = gun;
}