Bubble: refactor collision code, goes in k_collide

This commit is contained in:
James R 2024-01-17 21:09:04 -08:00
parent 30d7e94ece
commit 07ecf94999
3 changed files with 80 additions and 87 deletions

View file

@ -744,31 +744,18 @@ void K_LightningShieldAttack(mobj_t *actor, fixed_t size)
P_BlockThingsIterator(bx, by, PIT_LightningShieldAttack);
}
boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2)
boolean K_BubbleShieldCanReflect(mobj_t *t1, mobj_t *t2)
{
if (t2->type == MT_PLAYER)
{
// Counter desyncs
/*mobj_t *oldthing = thing;
mobj_t *oldtm.thing = tm.thing;
P_Thrust(tm.thing, R_PointToAngle2(thing->x, thing->y, tm.thing->x, tm.thing->y), 4*thing->scale);
thing = oldthing;
P_SetTarget(&tm.thing, oldtm.thing);*/
if (K_KartBouncing(t2, t1->target) == true)
{
if (t2->player && t1->target && t1->target->player)
{
K_PvPTouchDamage(t2, t1->target);
return (t2->type == MT_ORBINAUT || t2->type == MT_JAWZ || t2->type == MT_GACHABOM
|| t2->type == MT_BANANA || t2->type == MT_EGGMANITEM || t2->type == MT_BALLHOG
|| t2->type == MT_SSMINE || t2->type == MT_LANDMINE || t2->type == MT_SINK
|| t2->type == MT_GARDENTOP
|| t2->type == MT_DROPTARGET
|| t2->type == MT_KART_LEFTOVER
|| (t2->type == MT_PLAYER && t1->target != t2));
}
// Don't play from t1 else it gets cut out... for some reason.
S_StartSound(t2, sfx_s3k44);
}
}
else
boolean K_BubbleShieldReflect(mobj_t *t1, mobj_t *t2)
{
mobj_t *owner = t1->player ? t1 : t1->target;
@ -796,9 +783,47 @@ boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2)
t2->threshold = 10;
S_StartSound(t1, sfx_s3k44);
}
return true;
}
boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2)
{
if (t2->type == MT_PLAYER)
{
// Counter desyncs
/*mobj_t *oldthing = thing;
mobj_t *oldtm.thing = tm.thing;
P_Thrust(tm.thing, R_PointToAngle2(thing->x, thing->y, tm.thing->x, tm.thing->y), 4*thing->scale);
thing = oldthing;
P_SetTarget(&tm.thing, oldtm.thing);*/
if (K_KartBouncing(t2, t1->target) == true)
{
if (t2->player && t1->target && t1->target->player)
{
K_PvPTouchDamage(t2, t1->target);
}
// Don't play from t1 else it gets cut out... for some reason.
S_StartSound(t2, sfx_s3k44);
}
return true;
}
if (K_BubbleShieldCanReflect(t1, t2))
{
return K_BubbleShieldReflect(t1, t2);
}
if (t2->flags & MF_SHOOTABLE)
{
P_DamageMobj(t2, t1, t1->target, 1, DMG_NORMAL);
}
// no interaction
return true;
}

View file

@ -22,6 +22,9 @@ boolean K_LandMineCollide(mobj_t *t1, mobj_t *t2);
boolean K_DropTargetCollide(mobj_t *t1, mobj_t *t2);
void K_LightningShieldAttack(mobj_t *actor, fixed_t size);
boolean K_BubbleShieldCanReflect(mobj_t *t1, mobj_t *t2);
boolean K_BubbleShieldReflect(mobj_t *t1, mobj_t *t2);
boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2);
boolean K_InstaWhipCollide(mobj_t *shield, mobj_t *victim);

View file

@ -522,17 +522,6 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object)
}
}
static boolean P_BubbleCanReflect(mobj_t *t1, mobj_t *t2)
{
return (t2->type == MT_ORBINAUT || t2->type == MT_JAWZ || t2->type == MT_GACHABOM
|| t2->type == MT_BANANA || t2->type == MT_EGGMANITEM || t2->type == MT_BALLHOG
|| t2->type == MT_SSMINE || t2->type == MT_LANDMINE || t2->type == MT_SINK
|| t2->type == MT_GARDENTOP
|| t2->type == MT_DROPTARGET
|| t2->type == MT_KART_LEFTOVER
|| (t2->type == MT_PLAYER && t1->target != t2));
}
//
// PIT_CheckThing
//
@ -1009,7 +998,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
if (tm.thing->type == MT_RANDOMITEM)
return BMIT_CONTINUE;
if (tm.thing->type != MT_PLAYER && thing->player && K_PlayerGuard(thing->player) && P_BubbleCanReflect(thing, tm.thing))
if (tm.thing->type != MT_PLAYER && thing->player && K_PlayerGuard(thing->player) && K_BubbleShieldCanReflect(thing, tm.thing))
{
// see if it went over / under
if (tm.thing->z > thing->z + thing->height)
@ -1017,9 +1006,9 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
if (tm.thing->z + tm.thing->height < thing->z)
return BMIT_CONTINUE; // underneath
return K_BubbleShieldCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT;
return K_BubbleShieldReflect(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT;
}
else if (thing->type != MT_PLAYER && tm.thing->player && K_PlayerGuard(tm.thing->player) && P_BubbleCanReflect(tm.thing, thing))
else if (thing->type != MT_PLAYER && tm.thing->player && K_PlayerGuard(tm.thing->player) && K_BubbleShieldCanReflect(tm.thing, thing))
{
// see if it went over / under
if (tm.thing->z > thing->z + thing->height)
@ -1027,12 +1016,11 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
if (tm.thing->z + tm.thing->height < thing->z)
return BMIT_CONTINUE; // underneath
return K_BubbleShieldCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT;
return K_BubbleShieldReflect(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT;
}
// Bubble Shield reflect
if ((thing->type == MT_BUBBLESHIELD && !P_MobjWasRemoved(thing->target) && thing->target->player && thing->target->player->bubbleblowup)
|| (thing->player && thing->player->bubbleblowup))
if (thing->type == MT_BUBBLESHIELD && !P_MobjWasRemoved(thing->target) && thing->target->player && thing->target->player->bubbleblowup)
{
// see if it went over / under
if (tm.thing->z > thing->z + thing->height)
@ -1040,21 +1028,9 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
if (tm.thing->z + tm.thing->height < thing->z)
return BMIT_CONTINUE; // underneath
if (P_BubbleCanReflect(thing, tm.thing))
{
// don't let player hitbox touch it too
if (thing->player)
return BMIT_CONTINUE;
return K_BubbleShieldCollide(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT;
}
else if ((tm.thing->flags & MF_SHOOTABLE) && !thing->player)
{
P_DamageMobj(tm.thing, thing, thing->target, 1, DMG_NORMAL);
return BMIT_CONTINUE;
}
}
else if ((tm.thing->type == MT_BUBBLESHIELD && !P_MobjWasRemoved(tm.thing->target) && tm.thing->target->player && tm.thing->target->player->bubbleblowup)
|| (tm.thing->player && tm.thing->player->bubbleblowup))
else if (tm.thing->type == MT_BUBBLESHIELD && !P_MobjWasRemoved(tm.thing->target) && tm.thing->target->player && tm.thing->target->player->bubbleblowup)
{
// see if it went over / under
if (tm.thing->z > thing->z + thing->height)
@ -1062,19 +1038,8 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
if (tm.thing->z + tm.thing->height < thing->z)
return BMIT_CONTINUE; // underneath
if (P_BubbleCanReflect(tm.thing, thing))
{
// don't let player hitbox touch it too
if (tm.thing->player)
return BMIT_CONTINUE;
return K_BubbleShieldCollide(tm.thing, thing) ? BMIT_CONTINUE : BMIT_ABORT;
}
else if ((thing->flags & MF_SHOOTABLE) && !tm.thing->player)
{
P_DamageMobj(thing, tm.thing, tm.thing->target, 1, DMG_NORMAL);
return BMIT_CONTINUE;
}
}
// double make sure bubbles won't collide with anything else
if (thing->type == MT_BUBBLESHIELD || tm.thing->type == MT_BUBBLESHIELD)