mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'dropstuff' into 'master'
Item drop code cleanup See merge request KartKrew/Kart!236
This commit is contained in:
commit
80ce1c7c6d
3 changed files with 62 additions and 60 deletions
94
src/k_kart.c
94
src/k_kart.c
|
|
@ -1445,7 +1445,7 @@ static void K_DebtStingPlayer(player_t *player, INT32 length)
|
||||||
if (player->mo->state != &states[S_KART_SPIN])
|
if (player->mo->state != &states[S_KART_SPIN])
|
||||||
P_SetPlayerMobjState(player->mo, S_KART_SPIN);
|
P_SetPlayerMobjState(player->mo, S_KART_SPIN);
|
||||||
|
|
||||||
K_DropHnextList(player);
|
K_DropHnextList(player, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2886,7 +2886,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto
|
||||||
if (cv_kartdebughuddrop.value && !modeattacking)
|
if (cv_kartdebughuddrop.value && !modeattacking)
|
||||||
K_DropItems(player);
|
K_DropItems(player);
|
||||||
else
|
else
|
||||||
K_DropHnextList(player);
|
K_DropHnextList(player, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3031,7 +3031,7 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor)
|
||||||
if (cv_kartdebughuddrop.value && !modeattacking)
|
if (cv_kartdebughuddrop.value && !modeattacking)
|
||||||
K_DropItems(player);
|
K_DropItems(player);
|
||||||
else
|
else
|
||||||
K_DropHnextList(player);
|
K_DropHnextList(player, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3237,7 +3237,7 @@ void K_StealBumper(player_t *player, player_t *victim, boolean force)
|
||||||
if (cv_kartdebughuddrop.value && !modeattacking)
|
if (cv_kartdebughuddrop.value && !modeattacking)
|
||||||
K_DropItems(victim);
|
K_DropItems(victim);
|
||||||
else
|
else
|
||||||
K_DropHnextList(victim);
|
K_DropHnextList(victim, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4700,54 +4700,58 @@ void K_UpdateHnextList(player_t *player, boolean clean)
|
||||||
|
|
||||||
nextwork = work->hnext;
|
nextwork = work->hnext;
|
||||||
|
|
||||||
while ((work = nextwork) && !P_MobjWasRemoved(work))
|
while ((work = nextwork) && !(work == NULL || P_MobjWasRemoved(work)))
|
||||||
{
|
{
|
||||||
nextwork = work->hnext;
|
nextwork = work->hnext;
|
||||||
|
|
||||||
if (!clean && (!work->movedir || work->movedir <= (UINT16)player->kartstuff[k_itemamount]))
|
if (!clean && (!work->movedir || work->movedir <= (UINT16)player->kartstuff[k_itemamount]))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
P_RemoveMobj(work);
|
P_RemoveMobj(work);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player->mo->hnext == NULL || P_MobjWasRemoved(player->mo->hnext))
|
||||||
|
{
|
||||||
|
// Like below, try to clean up the pointer if it's NULL.
|
||||||
|
// Maybe this was a cause of the shrink/eggbox fails?
|
||||||
|
P_SetTarget(&player->mo->hnext, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For getting hit!
|
// For getting hit!
|
||||||
void K_DropHnextList(player_t *player)
|
void K_DropHnextList(player_t *player, boolean keepshields)
|
||||||
{
|
{
|
||||||
mobj_t *work = player->mo, *nextwork, *dropwork;
|
mobj_t *work = player->mo, *nextwork, *dropwork;
|
||||||
INT32 flip;
|
INT32 flip;
|
||||||
mobjtype_t type;
|
mobjtype_t type;
|
||||||
boolean orbit, ponground, dropall = true;
|
boolean orbit, ponground, dropall = true;
|
||||||
|
INT32 shield = K_GetShieldFromItem(player->kartstuff[k_itemtype]);
|
||||||
|
|
||||||
if (!work || P_MobjWasRemoved(work))
|
if (work == NULL || P_MobjWasRemoved(work))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
flip = P_MobjFlip(player->mo);
|
flip = P_MobjFlip(player->mo);
|
||||||
ponground = P_IsObjectOnGround(player->mo);
|
ponground = P_IsObjectOnGround(player->mo);
|
||||||
|
|
||||||
if (player->kartstuff[k_itemtype] == KITEM_THUNDERSHIELD)
|
if (shield != KSHIELD_NONE && !keepshields)
|
||||||
|
{
|
||||||
|
if (shield == KSHIELD_THUNDER)
|
||||||
{
|
{
|
||||||
K_DoThunderShield(player);
|
K_DoThunderShield(player);
|
||||||
player->kartstuff[k_itemtype] = KITEM_NONE;
|
|
||||||
player->kartstuff[k_itemamount] = 0;
|
|
||||||
player->kartstuff[k_curshield] = KSHIELD_NONE;
|
|
||||||
}
|
}
|
||||||
else if (player->kartstuff[k_itemtype] == KITEM_BUBBLESHIELD)
|
|
||||||
{
|
|
||||||
player->kartstuff[k_itemtype] = KITEM_NONE;
|
|
||||||
player->kartstuff[k_itemamount] = 0;
|
|
||||||
player->kartstuff[k_curshield] = KSHIELD_NONE;
|
player->kartstuff[k_curshield] = KSHIELD_NONE;
|
||||||
}
|
|
||||||
else if (player->kartstuff[k_itemtype] == KITEM_FLAMESHIELD)
|
|
||||||
{
|
|
||||||
player->kartstuff[k_itemtype] = KITEM_NONE;
|
player->kartstuff[k_itemtype] = KITEM_NONE;
|
||||||
player->kartstuff[k_itemamount] = 0;
|
player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0;
|
||||||
player->kartstuff[k_curshield] = KSHIELD_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextwork = work->hnext;
|
nextwork = work->hnext;
|
||||||
|
|
||||||
while ((work = nextwork) && !P_MobjWasRemoved(work))
|
while ((work = nextwork) && !(work == NULL || P_MobjWasRemoved(work)))
|
||||||
{
|
{
|
||||||
nextwork = work->hnext;
|
nextwork = work->hnext;
|
||||||
|
|
||||||
|
|
@ -4776,20 +4780,20 @@ void K_DropHnextList(player_t *player)
|
||||||
orbit = false;
|
orbit = false;
|
||||||
type = MT_EGGMANITEM;
|
type = MT_EGGMANITEM;
|
||||||
break;
|
break;
|
||||||
// intentionally do nothing
|
|
||||||
case MT_SINK_SHIELD:
|
|
||||||
case MT_ROCKETSNEAKER:
|
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dropwork = P_SpawnMobj(work->x, work->y, work->z, type);
|
dropwork = P_SpawnMobj(work->x, work->y, work->z, type);
|
||||||
|
|
||||||
P_SetTarget(&dropwork->target, player->mo);
|
P_SetTarget(&dropwork->target, player->mo);
|
||||||
P_AddKartItem(dropwork); // needs to be called here so shrink can bust items off players in front of the user.
|
P_AddKartItem(dropwork); // needs to be called here so shrink can bust items off players in front of the user.
|
||||||
|
|
||||||
dropwork->angle = work->angle;
|
dropwork->angle = work->angle;
|
||||||
dropwork->flags2 = work->flags2;
|
|
||||||
dropwork->flags |= MF_NOCLIPTHING;
|
dropwork->flags |= MF_NOCLIPTHING;
|
||||||
|
dropwork->flags2 = work->flags2;
|
||||||
|
|
||||||
dropwork->floorz = work->floorz;
|
dropwork->floorz = work->floorz;
|
||||||
dropwork->ceilingz = work->ceilingz;
|
dropwork->ceilingz = work->ceilingz;
|
||||||
|
|
||||||
|
|
@ -4818,19 +4822,29 @@ void K_DropHnextList(player_t *player)
|
||||||
if (orbit) // splay out
|
if (orbit) // splay out
|
||||||
{
|
{
|
||||||
dropwork->flags2 |= MF2_AMBUSH;
|
dropwork->flags2 |= MF2_AMBUSH;
|
||||||
|
|
||||||
dropwork->z += flip;
|
dropwork->z += flip;
|
||||||
|
|
||||||
dropwork->momx = player->mo->momx>>1;
|
dropwork->momx = player->mo->momx>>1;
|
||||||
dropwork->momy = player->mo->momy>>1;
|
dropwork->momy = player->mo->momy>>1;
|
||||||
dropwork->momz = 3*flip*mapobjectscale;
|
dropwork->momz = 3*flip*mapobjectscale;
|
||||||
|
|
||||||
if (dropwork->eflags & MFE_UNDERWATER)
|
if (dropwork->eflags & MFE_UNDERWATER)
|
||||||
dropwork->momz = (117 * dropwork->momz) / 200;
|
dropwork->momz = (117 * dropwork->momz) / 200;
|
||||||
|
|
||||||
P_Thrust(dropwork, work->angle - ANGLE_90, 6*mapobjectscale);
|
P_Thrust(dropwork, work->angle - ANGLE_90, 6*mapobjectscale);
|
||||||
|
|
||||||
dropwork->movecount = 2;
|
dropwork->movecount = 2;
|
||||||
dropwork->movedir = work->angle - ANGLE_90;
|
dropwork->movedir = work->angle - ANGLE_90;
|
||||||
|
|
||||||
P_SetMobjState(dropwork, dropwork->info->deathstate);
|
P_SetMobjState(dropwork, dropwork->info->deathstate);
|
||||||
|
|
||||||
dropwork->tics = -1;
|
dropwork->tics = -1;
|
||||||
|
|
||||||
if (type == MT_JAWZ_DUD)
|
if (type == MT_JAWZ_DUD)
|
||||||
|
{
|
||||||
dropwork->z += 20*flip*dropwork->scale;
|
dropwork->z += 20*flip*dropwork->scale;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dropwork->color = work->color;
|
dropwork->color = work->color;
|
||||||
|
|
@ -4846,12 +4860,15 @@ void K_DropHnextList(player_t *player)
|
||||||
P_RemoveMobj(work);
|
P_RemoveMobj(work);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
// we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic...
|
// we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic...
|
||||||
P_SetTarget(&player->mo->hnext, NULL);
|
P_SetTarget(&player->mo->hnext, NULL);
|
||||||
|
|
||||||
player->kartstuff[k_bananadrag] = 0;
|
player->kartstuff[k_bananadrag] = 0;
|
||||||
|
|
||||||
if (player->kartstuff[k_eggmanheld])
|
if (player->kartstuff[k_eggmanheld])
|
||||||
|
{
|
||||||
player->kartstuff[k_eggmanheld] = 0;
|
player->kartstuff[k_eggmanheld] = 0;
|
||||||
|
}
|
||||||
else if (player->kartstuff[k_itemheld]
|
else if (player->kartstuff[k_itemheld]
|
||||||
&& (dropall || (--player->kartstuff[k_itemamount] <= 0)))
|
&& (dropall || (--player->kartstuff[k_itemamount] <= 0)))
|
||||||
{
|
{
|
||||||
|
|
@ -4859,26 +4876,17 @@ void K_DropHnextList(player_t *player)
|
||||||
player->kartstuff[k_itemtype] = KITEM_NONE;
|
player->kartstuff[k_itemtype] = KITEM_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// For getting EXTRA hit!
|
// For getting EXTRA hit!
|
||||||
void K_DropItems(player_t *player)
|
void K_DropItems(player_t *player)
|
||||||
{
|
{
|
||||||
INT32 shieldhack = 0;
|
K_DropHnextList(player, true);
|
||||||
|
|
||||||
if (player->kartstuff[k_curshield])
|
if (player->mo && !P_MobjWasRemoved(player->mo) && player->kartstuff[k_itemamount] > 0)
|
||||||
shieldhack = K_GetShieldFromItem(player->kartstuff[k_itemtype]);
|
|
||||||
|
|
||||||
if (shieldhack)
|
|
||||||
player->kartstuff[k_itemtype] = KITEM_NONE;
|
|
||||||
|
|
||||||
K_DropHnextList(player);
|
|
||||||
|
|
||||||
if (player->mo && !P_MobjWasRemoved(player->mo) && player->kartstuff[k_itemamount])
|
|
||||||
{
|
{
|
||||||
mobj_t *drop = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_FLOATINGITEM);
|
mobj_t *drop = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_FLOATINGITEM);
|
||||||
P_SetScale(drop, drop->scale>>4);
|
P_SetScale(drop, drop->scale>>4);
|
||||||
drop->destscale = (3*drop->destscale)/2;;
|
drop->destscale = (3*drop->destscale)/2;
|
||||||
|
|
||||||
drop->angle = player->mo->angle + ANGLE_90;
|
drop->angle = player->mo->angle + ANGLE_90;
|
||||||
P_Thrust(drop,
|
P_Thrust(drop,
|
||||||
|
|
@ -4888,13 +4896,7 @@ void K_DropItems(player_t *player)
|
||||||
if (drop->eflags & MFE_UNDERWATER)
|
if (drop->eflags & MFE_UNDERWATER)
|
||||||
drop->momz = (117 * drop->momz) / 200;
|
drop->momz = (117 * drop->momz) / 200;
|
||||||
|
|
||||||
switch (shieldhack)
|
drop->threshold = player->kartstuff[k_itemtype];
|
||||||
{
|
|
||||||
case KSHIELD_THUNDER: drop->threshold = KITEM_THUNDERSHIELD; break;
|
|
||||||
case KSHIELD_BUBBLE: drop->threshold = KITEM_BUBBLESHIELD; break;
|
|
||||||
case KSHIELD_FLAME: drop->threshold = KITEM_FLAMESHIELD; break;
|
|
||||||
default: drop->threshold = player->kartstuff[k_itemtype]; break;
|
|
||||||
}
|
|
||||||
drop->movecount = player->kartstuff[k_itemamount];
|
drop->movecount = player->kartstuff[k_itemamount];
|
||||||
|
|
||||||
drop->flags |= MF_NOCLIPTHING;
|
drop->flags |= MF_NOCLIPTHING;
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ void K_DoSneaker(player_t *player, INT32 type);
|
||||||
void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound);
|
void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound);
|
||||||
void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source);
|
void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source);
|
||||||
void K_UpdateHnextList(player_t *player, boolean clean);
|
void K_UpdateHnextList(player_t *player, boolean clean);
|
||||||
void K_DropHnextList(player_t *player);
|
void K_DropHnextList(player_t *player, boolean keepshields);
|
||||||
void K_RepairOrbitChain(mobj_t *orbit);
|
void K_RepairOrbitChain(mobj_t *orbit);
|
||||||
player_t *K_FindJawzTarget(mobj_t *actor, player_t *source);
|
player_t *K_FindJawzTarget(mobj_t *actor, player_t *source);
|
||||||
boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y);
|
boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y);
|
||||||
|
|
|
||||||
|
|
@ -542,7 +542,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
||||||
|
|
||||||
if (player->kartstuff[k_bubbleblowup] > 0)
|
if (player->kartstuff[k_bubbleblowup] > 0)
|
||||||
{
|
{
|
||||||
K_DropHnextList(player);
|
K_DropHnextList(player, false);
|
||||||
special->extravalue1 = 2; // WAIT...
|
special->extravalue1 = 2; // WAIT...
|
||||||
special->extravalue2 = 52; // Slightly over the respawn timer length
|
special->extravalue2 = 52; // Slightly over the respawn timer length
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue