use player->carry and player->mobj->tracer

This commit is contained in:
Lighto97 2025-03-11 02:03:35 -03:00
parent 54b14fea3f
commit ed5adc5b78
6 changed files with 8 additions and 20 deletions

View file

@ -150,6 +150,7 @@ typedef enum
CR_SLIDING,
CR_ZOOMTUBE,
CR_DASHRING,
CR_TRAPBUBBLE,
} carrytype_t; // carry
/*
@ -775,8 +776,6 @@ struct player_t
UINT8 curshield; // see kartshields_t
UINT8 bubblecool; // Bubble Shield use cooldown
UINT8 bubbleblowup; // Bubble Shield usage blowup
mobj_t *bubbletrap; // Bubble player is trapped inside
boolean gotbubbletrapped; //to know if player was got trapped
UINT16 flamedash; // Flame Shield dash power
UINT16 flamemeter; // Flame Shield dash meter left
UINT8 flamelength; // Flame Shield dash meter, number of segments

View file

@ -4671,6 +4671,7 @@ struct int_const_s const INT_CONST[] = {
// Carrying
{"CR_NONE",CR_NONE},
{"CR_ZOOMTUBE",CR_ZOOMTUBE},
{"CR_TRAPBUBBLE",CR_TRAPBUBBLE},
// Character flags (skinflags_t)
{"SF_MACHINE",SF_MACHINE},

View file

@ -726,10 +726,11 @@ static void K_DropDashWait(player_t *player)
if (player->pflags & PF_FAULT)
return;
// if player got trapped inside a ubble but lost its bubble object in a unintended way, remove no gravity flag
if ((P_MobjWasRemoved(player->bubbletrap) && player->gotbubbletrapped == true) && (player->mo->flags & MF_NOGRAVITY))
// if player got trapped inside a bubble but lost its bubble object in a unintended way, remove no gravity flag
if (((P_MobjWasRemoved(player->mo->tracer) || player->mo->tracer == NULL) && player->carry == CR_TRAPBUBBLE) && (player->mo->flags & MF_NOGRAVITY))
{
player->mo->flags &= ~MF_NOGRAVITY;
player->carry = CR_NONE;
}
if (leveltime % 8 == 0)

View file

@ -430,10 +430,6 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->bubblecool);
else if (fastcmp(field,"bubbleblowup"))
lua_pushinteger(L, plr->bubbleblowup);
else if (fastcmp(field,"bubbletrap"))
LUA_PushUserdata(L, plr->bubbletrap, META_MOBJ);
else if (fastcmp(field,"gotbubbletrapped"))
lua_pushboolean(L, plr->gotbubbletrapped);
else if (fastcmp(field,"flamedash"))
lua_pushinteger(L, plr->flamedash);
else if (fastcmp(field,"counterdash"))
@ -998,15 +994,6 @@ static int player_set(lua_State *L)
plr->bubblecool = luaL_checkinteger(L, 3);
else if (fastcmp(field,"bubbleblowup"))
plr->bubbleblowup = luaL_checkinteger(L, 3);
else if (fastcmp(field,"bubbletrap"))
{
mobj_t *mo = NULL;
if (!lua_isnil(L, 3))
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
P_SetTarget(&plr->bubbletrap, mo);
}
else if (fastcmp(field,"gotbubbletrapped"))
plr->gotbubbletrapped = luaL_checkboolean(L, 3);
else if (fastcmp(field,"flamedash"))
plr->flamedash = luaL_checkinteger(L, 3);
else if (fastcmp(field,"counterdash"))

View file

@ -642,8 +642,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
P_SetTarget(&special->tracer, toucher);
toucher->flags |= MF_NOGRAVITY;
toucher->momz = (8*toucher->scale) * P_MobjFlip(toucher);
toucher->player->gotbubbletrapped = true;
P_SetTarget(&toucher->player->bubbletrap, special); //allow it to access later on and to know if player is trapped
toucher->player->carry = CR_TRAPBUBBLE;
P_SetTarget(&toucher->tracer, special); //use tracer to acces the object
// Snap to the unfortunate player and quit moving laterally, or we can end up quite far away
special->momx = 0;

View file

@ -9387,7 +9387,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
S_StartSound(mobj->tracer, sfx_s3k77);
mobj->tracer->flags &= ~MF_NOGRAVITY;
mobj->tracer->player->gotbubbletrapped = false;
mobj->tracer->player->carry = CR_NONE;
P_KillMobj(mobj, mobj->tracer, mobj->tracer, DMG_NORMAL);
break;
}