Fix Leaf Storm Eggball

- Map object num was incorrectly copypasted onto the Dead Line Ring Vaccuum as well
- Was getting destroyed instantly because its first spawnpoint is a deathpit. Now it only kills itself when it lands on a deathpit, not if it started on one
- Use destscale instead of scaling every frame
- Reduce duplicate P_IsObjectOnGround calls
- Now has its own state
This commit is contained in:
toaster 2023-10-07 23:15:27 +01:00
parent b2bbde290b
commit dbcb39d7ed
4 changed files with 28 additions and 18 deletions

View file

@ -4687,6 +4687,8 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_RIDEROID",
"S_RIDEROID_ICON",
"S_EGGBALL",
"S_DLZHOVER",
"S_DLZROCKET_L",
"S_DLZROCKET_R",

View file

@ -5459,6 +5459,9 @@ state_t states[NUMSTATES] =
{SPR_RDRD, 0, -1, {NULL}, 0, 0, S_RIDEROID}, // S_RIDEROID
{SPR_RDRC, FF_ANIMATE|FF_FULLBRIGHT|FF_TRANS30, -1, {NULL}, 3, 2, S_RIDEROID_ICON}, // S_RIDEROID_ICON
// Leaf Storm
{SPR_LSZB, 0, -1, {NULL}, 0, 0, S_EGGBALL}, // S_EGGBALL
// Dead Line
{SPR_DLZH, 0, -1, {NULL}, 0, 0, S_DLZHOVER}, // S_DLZHOVER
@ -30603,8 +30606,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
},
{ // MT_LSZ_EGGBALL
-1, // doomednum
S_INVISIBLE, // spawnstate
-1, // doomednum
S_EGGBALL, // spawnstate
1000, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
@ -30765,7 +30768,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
},
{ // MT_DLZ_RINGVACCUM,
3443, // doomednum
3433, // doomednum
S_INVISIBLE, // spawnstate
1000, // spawnhealth
S_NULL, // seestate

View file

@ -5884,6 +5884,9 @@ typedef enum state
S_RIDEROID,
S_RIDEROID_ICON,
// leaf storm
S_EGGBALL,
// dead line zone
S_DLZHOVER,
S_DLZROCKET_L,

View file

@ -31,12 +31,14 @@
// spawns balls every BALLMINSPAWNTIME to BALLMAXSPAWNTIME seconds.
void Obj_EggBallSpawnerThink(mobj_t *mo)
{
if (!mo->extravalue1)
{
mobj_t *ball = P_SpawnMobj(mo->x, mo->y, mo->z, MT_LSZ_EGGBALL);
ball->angle = mo->angle;
P_SetScale(ball, 6*mapobjectscale);
if (P_MobjWasRemoved(ball) == false)
{
ball->angle = mo->angle;
P_SetScale(ball, (ball->destscale = 6*mapobjectscale));
}
mo->extravalue1 = P_RandomRange(PR_TRACKHAZARD, TICRATE*BALLMINSPAWNTIME, TICRATE*BALLMAXSPAWNTIME);
}
@ -50,13 +52,17 @@ void Obj_EggBallSpawnerThink(mobj_t *mo)
void Obj_EggBallThink(mobj_t *mo)
{
const boolean onground = P_IsObjectOnGround(mo);
P_SetScale(mo, 6*mapobjectscale);
if (mo->eflags & MFE_JUSTHITFLOOR
&& mo->threshold)
if (mo->eflags & MFE_JUSTHITFLOOR)
{
if (mo->threshold < -10*mapobjectscale)
if (mo->extravalue1 && P_CheckDeathPitCollide(mo))
{
P_RemoveMobj(mo);
return;
}
if (mo->threshold && mo->threshold < -10*mapobjectscale)
{
UINT8 i;
@ -80,17 +86,16 @@ void Obj_EggBallThink(mobj_t *mo)
if (!mo->extravalue1)
{
if (P_IsObjectOnGround(mo))
if (onground)
{
mo->extravalue1 = 1;
mo->cusval = 24*mapobjectscale;
mo->movedir = mo->z;
mo->sprite = SPR_LSZB;
}
}
else
{
if (P_IsObjectOnGround(mo) && mo->extravalue2 &1)
if (onground && (mo->extravalue2 & 1))
{
fixed_t dx = mo->x + P_RandomRange(PR_DECORATION, -96, 96)*mapobjectscale - mo->momx*2;
fixed_t dy = mo->y + P_RandomRange(PR_DECORATION, -96, 96)*mapobjectscale - mo->momy*2;
@ -107,7 +112,7 @@ void Obj_EggBallThink(mobj_t *mo)
mo->frame = mo->extravalue2 % (24 * 2) / 2; // 24 is for frame Y.
// build up speed
if (P_IsObjectOnGround(mo))
if (onground)
{
if (mo->eflags & MFE_VERTICALFLIP)
{
@ -128,7 +133,4 @@ void Obj_EggBallThink(mobj_t *mo)
mo->movedir = mo->z;
}
mo->threshold = mo->momz;
if (P_CheckDeathPitCollide(mo))
P_RemoveMobj(mo);
}