mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-19 22:42:46 +00:00
Bubble: refactor collision code, goes in k_collide
This commit is contained in:
parent
30d7e94ece
commit
07ecf94999
3 changed files with 80 additions and 87 deletions
|
|
@ -744,6 +744,49 @@ void K_LightningShieldAttack(mobj_t *actor, fixed_t size)
|
|||
P_BlockThingsIterator(bx, by, PIT_LightningShieldAttack);
|
||||
}
|
||||
|
||||
boolean K_BubbleShieldCanReflect(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));
|
||||
}
|
||||
|
||||
boolean K_BubbleShieldReflect(mobj_t *t1, mobj_t *t2)
|
||||
{
|
||||
mobj_t *owner = t1->player ? t1 : t1->target;
|
||||
|
||||
if (t2->target != owner || !t2->threshold || t2->type == MT_DROPTARGET)
|
||||
{
|
||||
if (t1->player && K_PlayerGuard(t1->player))
|
||||
{
|
||||
K_KartSolidBounce(t1, t2);
|
||||
K_DoPowerClash(t1, t2);
|
||||
}
|
||||
if (!t2->momx && !t2->momy)
|
||||
{
|
||||
t2->momz += (24*t2->scale) * P_MobjFlip(t2);
|
||||
}
|
||||
else
|
||||
{
|
||||
t2->momx = -6*t2->momx;
|
||||
t2->momy = -6*t2->momy;
|
||||
t2->momz = -6*t2->momz;
|
||||
t2->angle += ANGLE_180;
|
||||
}
|
||||
if (t2->type == MT_JAWZ)
|
||||
P_SetTarget(&t2->tracer, t2->target); // Back to the source!
|
||||
P_SetTarget(&t2->target, owner); // Let the source reflect it back again!
|
||||
t2->threshold = 10;
|
||||
S_StartSound(t1, sfx_s3k44);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2)
|
||||
{
|
||||
if (t2->type == MT_PLAYER)
|
||||
|
|
@ -767,38 +810,20 @@ boolean K_BubbleShieldCollide(mobj_t *t1, mobj_t *t2)
|
|||
// Don't play from t1 else it gets cut out... for some reason.
|
||||
S_StartSound(t2, sfx_s3k44);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
if (K_BubbleShieldCanReflect(t1, t2))
|
||||
{
|
||||
mobj_t *owner = t1->player ? t1 : t1->target;
|
||||
|
||||
if (t2->target != owner || !t2->threshold || t2->type == MT_DROPTARGET)
|
||||
{
|
||||
if (t1->player && K_PlayerGuard(t1->player))
|
||||
{
|
||||
K_KartSolidBounce(t1, t2);
|
||||
K_DoPowerClash(t1, t2);
|
||||
}
|
||||
if (!t2->momx && !t2->momy)
|
||||
{
|
||||
t2->momz += (24*t2->scale) * P_MobjFlip(t2);
|
||||
}
|
||||
else
|
||||
{
|
||||
t2->momx = -6*t2->momx;
|
||||
t2->momy = -6*t2->momy;
|
||||
t2->momz = -6*t2->momz;
|
||||
t2->angle += ANGLE_180;
|
||||
}
|
||||
if (t2->type == MT_JAWZ)
|
||||
P_SetTarget(&t2->tracer, t2->target); // Back to the source!
|
||||
P_SetTarget(&t2->target, owner); // Let the source reflect it back again!
|
||||
t2->threshold = 10;
|
||||
S_StartSound(t1, sfx_s3k44);
|
||||
}
|
||||
return K_BubbleShieldReflect(t1, t2);
|
||||
}
|
||||
|
||||
if (t2->flags & MF_SHOOTABLE)
|
||||
{
|
||||
P_DamageMobj(t2, t1, t1->target, 1, DMG_NORMAL);
|
||||
}
|
||||
|
||||
// no interaction
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
83
src/p_map.c
83
src/p_map.c
|
|
@ -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,29 @@ 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)
|
||||
return BMIT_CONTINUE; // overhead
|
||||
if (tm.thing->z + tm.thing->height < thing->z)
|
||||
return BMIT_CONTINUE; // underneath
|
||||
|
||||
return K_BubbleShieldReflect(thing, tm.thing) ? BMIT_CONTINUE : BMIT_ABORT;
|
||||
}
|
||||
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)
|
||||
return BMIT_CONTINUE; // overhead
|
||||
if (tm.thing->z + tm.thing->height < thing->z)
|
||||
return BMIT_CONTINUE; // underneath
|
||||
|
||||
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)
|
||||
{
|
||||
// see if it went over / under
|
||||
if (tm.thing->z > thing->z + thing->height)
|
||||
|
|
@ -1019,7 +1030,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
|
|||
|
||||
return K_BubbleShieldCollide(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 (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)
|
||||
|
|
@ -1030,52 +1041,6 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
|
|||
return K_BubbleShieldCollide(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))
|
||||
{
|
||||
// see if it went over / under
|
||||
if (tm.thing->z > thing->z + thing->height)
|
||||
return BMIT_CONTINUE; // overhead
|
||||
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))
|
||||
{
|
||||
// see if it went over / under
|
||||
if (tm.thing->z > thing->z + thing->height)
|
||||
return BMIT_CONTINUE; // overhead
|
||||
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)
|
||||
return BMIT_CONTINUE;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue