Refactor objects/orbinaut.c for Gacha Bom

- Add flags variable to toggle much of Orbinaut behavior.
- Don't spawn afterimages for Gacha Bom.
- Animate facing angle of Gacha Bom when thrown backward.
- Let tossed Gacha Bom drive forward after landing.
This commit is contained in:
James R 2023-02-20 20:55:17 -08:00
parent 3774346642
commit 1f496e05ec
4 changed files with 57 additions and 46 deletions

View file

@ -4552,7 +4552,6 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
switch (type)
{
case MT_ORBINAUT:
case MT_GACHABOM:
Obj_OrbinautThrown(th, finalspeed, dir);
break;
case MT_JAWZ:
@ -4575,6 +4574,9 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
case MT_GARDENTOP:
th->movefactor = finalspeed;
break;
case MT_GACHABOM:
Obj_GachaBomThrown(th, finalspeed, dir);
break;
default:
break;
}
@ -5475,12 +5477,7 @@ mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t mapthing,
if (mapthing == MT_GACHABOM)
{
// Set dropped flag
mo->flags2 |= MF2_AMBUSH;
mo->movecount = 2;
P_SetMobjState(mo, mo->info->deathstate);
mo->tics = -1;
mo->color = player->skincolor;
Obj_GachaBomThrown(mo, mo->radius, dir);
}
// this is the small graphic effect that plops in you when you throw an item:

View file

@ -47,7 +47,9 @@ mobj_t *Obj_MantaRingCreate(mobj_t *spb, mobj_t *owner, mobj_t *chase);
void Obj_OrbinautThink(mobj_t *th);
boolean Obj_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2);
void Obj_OrbinautThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir);
void Obj_GachaBomThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir);
void Obj_OrbinautJawzMoveHeld(player_t *player);
boolean Obj_GachaBomWasTossed(mobj_t *th);
/* Jawz */
void Obj_JawzThink(mobj_t *th);

View file

@ -30,7 +30,6 @@
#define orbinaut_speed(o) ((o)->movefactor)
#define orbinaut_selfdelay(o) ((o)->threshold)
#define orbinaut_dropped(o) ((o)->flags2 & MF2_AMBUSH)
#define orbinaut_droptime(o) ((o)->movecount)
#define orbinaut_turn(o) ((o)->extravalue1)
@ -39,17 +38,26 @@
#define orbinaut_shield_dist(o) ((o)->extravalue1)
enum {
ORBI_DROPPED = 0x01, // stationary hazard
ORBI_TOSSED = 0x02, // Gacha Bom tossed forward
ORBI_TRAIL = 0x04, // spawn afterimages
ORBI_SPIN = 0x08, // animate facing angle
};
#define orbinaut_flags(o) ((o)->movedir)
#define orbinaut_spin(o) ((o)->extravalue2)
void Obj_OrbinautThink(mobj_t *th)
{
boolean grounded = P_IsObjectOnGround(th);
mobj_t *ghost = NULL;
if (th->fuse > 0 && th->fuse <= TICRATE)
{
th->renderflags ^= RF_DONTDRAW;
}
if (orbinaut_dropped(th))
if (orbinaut_flags(th) & ORBI_DROPPED)
{
if (grounded && (th->flags & MF_NOCLIPTHING))
{
@ -72,8 +80,13 @@ void Obj_OrbinautThink(mobj_t *th)
return;
}
ghost = P_SpawnGhostMobj(th);
ghost->colorized = true; // already has color!
if (orbinaut_flags(th) & ORBI_TRAIL)
{
mobj_t *ghost = NULL;
ghost = P_SpawnGhostMobj(th);
ghost->colorized = true; // already has color!
}
th->angle = K_MomentumAngle(th);
if (orbinaut_turn(th) != 0)
@ -124,6 +137,12 @@ void Obj_OrbinautThink(mobj_t *th)
P_Thrust(th, th->angle, thrustamount);
}
if (orbinaut_flags(th) & ORBI_SPIN)
{
th->angle = orbinaut_spin(th);
orbinaut_spin(th) += ANGLE_22h;
}
/* todo: UDMFify
if (P_MobjTouchingSectorSpecialFlag(th, ?))
{
@ -281,6 +300,8 @@ void Obj_OrbinautThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir)
th->fuse = RR_PROJECTILE_FUSE;
orbinaut_speed(th) = finalSpeed;
orbinaut_flags(th) = ORBI_TRAIL;
if (dir == -1)
{
// Thrown backwards, init orbiting in place
@ -292,6 +313,24 @@ void Obj_OrbinautThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir)
}
}
void Obj_GachaBomThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir)
{
Obj_OrbinautThrown(th, finalSpeed, dir);
orbinaut_flags(th) &= ~(ORBI_TRAIL);
switch (dir)
{
case -1:
orbinaut_flags(th) |= ORBI_SPIN;
break;
case 1:
orbinaut_flags(th) |= ORBI_TOSSED;
break;
}
}
void Obj_OrbinautJawzMoveHeld(player_t *player)
{
fixed_t finalscale = K_ItemScaleForPlayer(player);
@ -391,3 +430,8 @@ void Obj_OrbinautJawzMoveHeld(player_t *player)
cur = cur->hnext;
}
}
boolean Obj_GachaBomWasTossed(mobj_t *th)
{
return (orbinaut_flags(th) & ORBI_TOSSED) == ORBI_TOSSED;
}

View file

@ -1196,9 +1196,9 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
gravityadd /= 2;
break;
case MT_GACHABOM:
if (!(mo->flags2 & MF2_AMBUSH))
// Use normal gravity, unless if it was tossed.
if (!Obj_GachaBomWasTossed(mo))
{
// Use normal gravity, unless if it was tossed.
break;
}
/*FALLTHRU*/
@ -7177,38 +7177,6 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
}
break;
case MT_GACHABOM:
{
if (mobj->flags2 & MF2_AMBUSH)
{
mobj->friction = ORIG_FRICTION/4;
if (mobj->momx || mobj->momy)
{
mobj_t *ghost = P_SpawnGhostMobj(mobj);
if (mobj->target && !P_MobjWasRemoved(mobj->target) && mobj->target->player)
{
ghost->color = mobj->target->player->skincolor;
ghost->colorized = true;
}
}
if (P_IsObjectOnGround(mobj))
{
if (mobj->movecount > 1)
{
S_StartSound(mobj, mobj->info->activesound);
mobj->momx = mobj->momy = 0;
mobj->movecount = 1;
}
}
if (mobj->threshold > 0)
mobj->threshold--;
break;
}
}
/* FALLTHRU */
case MT_ORBINAUT:
{
Obj_OrbinautThink(mobj);