Merge branch 'prisons-polish' into 'master'

Prison Egg polish: Spawn three Followers on hit

See merge request KartKrew/Kart!1595
This commit is contained in:
Oni 2023-11-13 13:29:43 +00:00
commit 790d26d29c
4 changed files with 115 additions and 18 deletions

View file

@ -136,7 +136,7 @@ void Obj_UpdateRingShooterFace(mobj_t *part);
/* Follower Audience */
void Obj_AudienceInit(mobj_t * mobj, mapthing_t *mthing, INT32 followerpick);
void Obj_AudienceThink(mobj_t * mobj, boolean focusonplayer);
void Obj_AudienceThink(mobj_t * mobj, boolean focusonplayer, boolean checkdeathpit);
/* Random Item Boxes */
void Obj_RandomItemVisuals(mobj_t *mobj);

View file

@ -29,6 +29,7 @@ Obj_AudienceInit
mapthing_t *mthing,
INT32 followerpick)
{
const boolean ourchoiceofvisuals = (followerpick < 0 || followerpick > numfollowers);
INT16 *reflist = NULL;
INT16 tempreflist[MAXHEADERFOLLOWERS];
UINT8 numref = 0;
@ -36,9 +37,9 @@ Obj_AudienceInit
audience_mainstate(mobj) = S_NULL;
// Pick follower
if (mthing != NULL)
if (ourchoiceofvisuals == true)
{
if (mthing->thing_stringargs[0] != NULL)
if (mthing != NULL && mthing->thing_stringargs[0] != NULL)
{
// From mapthing
char *stringcopy = Z_StrDup(mthing->thing_stringargs[0]);
@ -56,11 +57,23 @@ Obj_AudienceInit
*c = ' ';
}
if ((tempreflist[numref++] = K_FollowerAvailable(tok)) == -1)
if ((tempreflist[numref] = K_FollowerAvailable(tok)) == -1)
{
CONS_Alert(CONS_WARNING, "Mapthing %s: Follower \"%s\" is invalid!\n", sizeu1(mthing-mapthings), tok);
}
else
numref++;
tok = strtok(NULL, " ,");
}
if (!numref)
{
// This is the one thing a user should definitely be told about.
CONS_Alert(CONS_WARNING, "Mapthing %s: Follower audience has no valid followers to pick from!\n", sizeu1(mthing-mapthings));
// DO NOT RETURN HERE
}
Z_Free(stringcopy);
reflist = tempreflist;
@ -81,8 +94,8 @@ Obj_AudienceInit
if (!numref || !reflist)
{
// This is the one thing a user should definitely be told about.
CONS_Alert(CONS_WARNING, "Mapthing %s: Follower audience has no valid followers to pick from!\n", sizeu1(mthing-mapthings));
// Clean up after ourselves.
P_RemoveMobj(mobj);
return;
}
@ -137,11 +150,11 @@ Obj_AudienceInit
}
// Handle colors
if (mthing != NULL)
if (ourchoiceofvisuals == true)
{
UINT16 colorpick = SKINCOLOR_NONE;
if (mthing->thing_stringargs[1] != NULL)
if (mthing != NULL && mthing->thing_stringargs[1] != NULL)
{
if (!stricmp("Random", mthing->thing_stringargs[1]))
{
@ -189,8 +202,17 @@ Obj_AudienceInit
void
Obj_AudienceThink
( mobj_t * mobj,
boolean focusonplayer)
boolean focusonplayer,
boolean checkdeathpit)
{
boolean landed = false;
if (mobj->fuse && mobj->fuse < (TICRATE/2))
{
mobj->renderflags ^= RF_DONTDRAW;
return; // no jumping when you hit the floor, your gravity is weird
}
if (audience_mainstate(mobj) == S_NULL)
{
// Uninitialised, don't do anything funny.
@ -315,15 +337,23 @@ Obj_AudienceThink
}
else if (mobj->flags2 & MF2_OBJECTFLIP)
{
if (mobj->z + mobj->height >= mobj->ceilingz)
{
mobj->momz = -audience_bobamp(mobj);
P_SetMobjState(mobj, audience_mainstate(mobj));
}
landed = (mobj->z + mobj->height >= mobj->ceilingz);
}
else if (mobj->z <= mobj->floorz)
else
{
mobj->momz = audience_bobamp(mobj);
landed = (mobj->z <= mobj->floorz);
}
if (landed == true)
{
if (checkdeathpit && P_CheckDeathPitCollide(mobj))
{
P_RemoveMobj(mobj);
return;
}
mobj->momx = mobj->momy = 0;
mobj->momz = P_MobjFlip(mobj)*audience_bobamp(mobj);
P_SetMobjState(mobj, audience_mainstate(mobj));
}
}

View file

@ -2103,6 +2103,67 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
cur = cur->hnext;
}
// Spawn three Followers (if possible)
if (mapheaderinfo[gamemap-1]->numFollowers)
{
dir = FixedAngle(P_RandomKey(PR_RANDOMAUDIENCE, 360)*FRACUNIT);
const fixed_t launchmomentum = 7 * mapobjectscale;
const fixed_t jaggedness = 4;
angle_t launchangle;
UINT8 i;
for (i = 0; i < 6; i++, dir += ANG60)
{
cur = P_SpawnMobj(
target->x, target->y,
target->z + target->height/2,
MT_RANDOMAUDIENCE
);
// We check if you have some horrible Lua
if (P_MobjWasRemoved(cur))
break;
Obj_AudienceInit(cur, NULL, -1);
// We check again if the list is invalid
if (P_MobjWasRemoved(cur))
break;
cur->hitlag = target->hitlag;
cur->destscale /= 2;
P_SetScale(cur, cur->destscale/TICRATE);
cur->scalespeed = cur->destscale/TICRATE;
cur->z -= cur->height/2;
// flags are NOT from the target - just in case it's just been placed on the ceiling as a gimmick
cur->flags2 |= (source->flags2 & MF2_OBJECTFLIP);
cur->eflags |= (source->eflags & MFE_VERTICALFLIP);
launchangle = FixedAngle(
(
(
P_RandomRange(PR_RANDOMAUDIENCE, 12/jaggedness, 24/jaggedness) * jaggedness
) + (i & 1)*16
) * FRACUNIT
);
cur->momz = P_MobjFlip(target) // THIS one uses target!
* P_ReturnThrustY(cur, launchangle, launchmomentum);
cur->angle = dir;
P_InstaThrust(
cur, cur->angle,
P_ReturnThrustX(cur, launchangle, launchmomentum)
);
cur->fuse = (3*TICRATE)/2;
cur->flags |= MF_NOCLIPHEIGHT;
}
}
S_StartSound(target, sfx_mbs60);
P_AddBrokenPrison(target, inflictor, source);

View file

@ -1278,6 +1278,10 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
}
break;
}
case MT_RANDOMAUDIENCE:
if (mo->fuse)
gravityadd /= 10;
break;
default:
break;
}
@ -7270,7 +7274,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
if (mobj->flags2 & MF2_STRONGBOX)
{
Obj_AudienceThink(mobj, true);
Obj_AudienceThink(mobj, true, false);
if (P_MobjWasRemoved(mobj))
return false;
}
@ -10808,7 +10812,9 @@ void P_SceneryThinker(mobj_t *mobj)
if (mobj->type == MT_RANDOMAUDIENCE)
{
Obj_AudienceThink(mobj, !!(mobj->flags2 & MF2_AMBUSH));
Obj_AudienceThink(mobj, !!(mobj->flags2 & MF2_AMBUSH), !!(mobj->flags2 & MF2_DONTRESPAWN));
if (P_MobjWasRemoved(mobj))
return;
}
}