MT_BLENDEYE_PUYO, MT_SPIKEDTARGET: Hardcode simple thinkers/init/death behaviour

This commit is contained in:
toaster 2023-10-30 00:13:03 +00:00
parent c3380b8f5d
commit 7e362b1ee8
4 changed files with 104 additions and 0 deletions

View file

@ -1,3 +1,4 @@
target_sources(SRB2SDL2 PRIVATE
arena.c
blendeye.c
)

View file

@ -0,0 +1,67 @@
// DR. ROBOTNIK'S RING RACERS
//-----------------------------------------------------------------------------
// Copyright (C) 2018-2023 by Vivian "toastergrl" Grannell
// Copyright (C) 2018-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.
//-----------------------------------------------------------------------------
/// \file k_boss.h
/// \brief Blend Eye boss encounter
#include "../../p_local.h"
#include "../../m_random.h"
#include "../../k_boss.h"
#include "../../s_sound.h"
#include "../../r_main.h" // R_PointToAngle2, R_PointToDist2
boolean VS_PuyoTouched(mobj_t *special, mobj_t *toucher)
{
if (!special->health || !toucher->health)
return false; // too dead
if (special->state-states < S_BLENDEYE_PUYO)
return false; // too small
P_DamageMobj(toucher, special, special->tracer, 1, DMG_NORMAL);
special->momx = 0;
special->momy = 0;
special->momz = 0;
return true;
}
void VS_PuyoDeath(mobj_t *mobj)
{
mobjtype_t dusttype = (encoremode ? MT_BLENDEYE_PUYO_DUST : MT_BLENDEYE_PUYO_DUST_COFFEE);
UINT8 i;
fixed_t momx, momy;
mobj_t *dustmo;
mobj->renderflags &= ~RF_DONTDRAW;
mobj->rollangle = 0;
mobj->angle = FixedAngle(P_RandomKey(PR_DECORATION, 360)*FRACUNIT);
for (i = 0; i <= 2; i++)
{
momx = P_ReturnThrustX(mobj, mobj->angle, 3*mobj->scale);
momy = P_ReturnThrustY(mobj, mobj->angle, 3*mobj->scale);
dustmo = P_SpawnMobjFromMobj(mobj, 0, 0, 0, dusttype);
dustmo->momx = mobj->momx + momx;
dustmo->momy = mobj->momy + momy;
dustmo->momz = mobj->momz + 4*mobj->scale;
dustmo->movedir = dustmo->sprite = mobj->movedir;
dustmo = P_SpawnMobjFromMobj(mobj, 0, 0, 0, dusttype);
dustmo->momx = mobj->momx - momx;
dustmo->momy = mobj->momy - momy;
dustmo->momz = mobj->momz - 4*mobj->scale;
dustmo->movedir = dustmo->sprite = mobj->movedir;
mobj->angle += ANGLE_135;
}
S_StartSound(NULL, ((mobj->tracer && mobj->tracer->type != MT_SPIKEDTARGET) ? sfx_mbs4c : sfx_mbs45));
}

View file

@ -951,6 +951,13 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
return;
}
case MT_BLENDEYE_PUYO:
{
if (!VS_PuyoTouched(special, toucher))
return;
break;
}
default: // SOC or script pickup
P_SetTarget(&special->target, toucher);
break;
@ -2168,6 +2175,9 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
case MT_BATTLEUFO:
Obj_BattleUFODeath(target);
break;
case MT_BLENDEYE_PUYO:
VS_PuyoDeath(target);
break;
default:
break;
}

View file

@ -6795,6 +6795,17 @@ static void P_MobjSceneryThink(mobj_t *mobj)
break;
}
case MT_SPIKEDTARGET:
{
if (P_MobjWasRemoved(mobj->target) || (mobj->target->health <= 0) || (mobj->target->z == mobj->target->floorz))
{
P_RemoveMobj(mobj);
return;
}
mobj->angle += ANG2;
break;
}
case MT_VWREF:
case MT_VWREB:
{
@ -11440,6 +11451,21 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
case MT_BALLSWITCH_BALL:
Obj_BallSwitchInit(mobj);
break;
case MT_BLENDEYE_PUYO:
mobj->sprite = mobj->movedir = P_RandomRange(PR_DECORATION, SPR_PUYA, SPR_PUYE);
if (encoremode == false)
{
mobj->color = SKINCOLOR_LEATHER;
mobj->colorized = true;
}
break;
case MT_BLENDEYE_PUYO_DUST_COFFEE:
mobj->color = SKINCOLOR_LEATHER;
mobj->colorized = true;
// FALLTHRU
case MT_BLENDEYE_PUYO_DUST:
mobj->sprite = mobj->movedir = P_RandomRange(PR_DECORATION, SPR_PUYA, SPR_PUYE);
break;
default:
break;
}