mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-16 09:42:57 +00:00
Merge branch 'bustables_misc' into 'master'
Bustables and landing events Closes #157 and #162 See merge request STJr/SRB2Internal!262
This commit is contained in:
commit
af38c0e227
6 changed files with 117 additions and 63 deletions
|
@ -2047,12 +2047,22 @@ static int lib_pStartQuake(lua_State *L)
|
|||
|
||||
static int lib_evCrumbleChain(lua_State *L)
|
||||
{
|
||||
sector_t *sec = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
|
||||
ffloor_t *rover = *((ffloor_t **)luaL_checkudata(L, 2, META_FFLOOR));
|
||||
sector_t *sec = NULL;
|
||||
ffloor_t *rover = NULL;
|
||||
NOHUD
|
||||
INLEVEL
|
||||
if (!sec)
|
||||
return LUA_ErrInvalid(L, "sector_t");
|
||||
if (!lua_isnone(L, 2))
|
||||
{
|
||||
if (!lua_isnil(L, 1))
|
||||
{
|
||||
sec = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
|
||||
if (!sec)
|
||||
return LUA_ErrInvalid(L, "sector_t");
|
||||
}
|
||||
rover = *((ffloor_t **)luaL_checkudata(L, 2, META_FFLOOR));
|
||||
}
|
||||
else
|
||||
rover = *((ffloor_t **)luaL_checkudata(L, 1, META_FFLOOR));
|
||||
if (!rover)
|
||||
return LUA_ErrInvalid(L, "ffloor_t");
|
||||
EV_CrumbleChain(sec, rover);
|
||||
|
|
|
@ -719,6 +719,8 @@ void T_ContinuousFalling(levelspecthink_t *faller)
|
|||
}
|
||||
}
|
||||
|
||||
P_CheckSector(faller->sector, false); // you might think this is irrelevant. you would be wrong
|
||||
|
||||
faller->sector->floorspeed = faller->speed*faller->direction;
|
||||
faller->sector->ceilspeed = 42;
|
||||
faller->sector->moved = true;
|
||||
|
@ -3029,20 +3031,40 @@ INT32 EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed)
|
|||
|
||||
void EV_CrumbleChain(sector_t *sec, ffloor_t *rover)
|
||||
{
|
||||
size_t i;
|
||||
size_t leftmostvertex = 0, rightmostvertex = 0;
|
||||
size_t topmostvertex = 0, bottommostvertex = 0;
|
||||
fixed_t leftx, rightx;
|
||||
fixed_t topy, bottomy;
|
||||
fixed_t topz, bottomz;
|
||||
fixed_t widthfactor = FRACUNIT, heightfactor = FRACUNIT;
|
||||
fixed_t a, b, c;
|
||||
mobjtype_t type = MT_ROCKCRUMBLE1;
|
||||
fixed_t spacing = (32<<FRACBITS);
|
||||
tic_t lifetime = 3*TICRATE;
|
||||
INT16 flags = 0;
|
||||
size_t i, leftmostvertex, rightmostvertex, topmostvertex, bottommostvertex;
|
||||
fixed_t leftx, rightx, topy, bottomy, topz, bottomz, widthfactor, heightfactor, a, b, c, spacing;
|
||||
mobjtype_t type;
|
||||
tic_t lifetime;
|
||||
INT16 flags;
|
||||
|
||||
#define controlsec rover->master->frontsector
|
||||
sector_t *controlsec = rover->master->frontsector;
|
||||
|
||||
if (sec == NULL)
|
||||
{
|
||||
if (controlsec->numattached)
|
||||
{
|
||||
for (i = 0; i < controlsec->numattached; i++)
|
||||
{
|
||||
sec = §ors[controlsec->attached[i]];
|
||||
if (!sec->ffloors)
|
||||
continue;
|
||||
|
||||
for (rover = sec->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if (rover->master->frontsector == controlsec)
|
||||
EV_CrumbleChain(sec, rover);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
leftmostvertex = rightmostvertex = topmostvertex = bottommostvertex = 0;
|
||||
widthfactor = heightfactor = FRACUNIT;
|
||||
spacing = (32<<FRACBITS);
|
||||
type = MT_ROCKCRUMBLE1;
|
||||
lifetime = 3*TICRATE;
|
||||
flags = 0;
|
||||
|
||||
if (controlsec->tag != 0)
|
||||
{
|
||||
|
|
|
@ -142,7 +142,7 @@ boolean P_IsObjectOnGround(mobj_t *mo);
|
|||
boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec);
|
||||
boolean P_InSpaceSector(mobj_t *mo);
|
||||
boolean P_InQuicksand(mobj_t *mo);
|
||||
boolean P_PlayerHitFloor(player_t *player);
|
||||
boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff);
|
||||
|
||||
void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative);
|
||||
void P_RestoreMusic(player_t *player);
|
||||
|
|
|
@ -2820,7 +2820,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y)
|
|||
static boolean P_ThingHeightClip(mobj_t *thing)
|
||||
{
|
||||
boolean floormoved;
|
||||
fixed_t oldfloorz = thing->floorz;
|
||||
fixed_t oldfloorz = thing->floorz, oldz = thing->z;
|
||||
ffloor_t *oldfloorrover = thing->floorrover;
|
||||
ffloor_t *oldceilingrover = thing->ceilingrover;
|
||||
boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz);
|
||||
|
@ -2879,6 +2879,12 @@ static boolean P_ThingHeightClip(mobj_t *thing)
|
|||
thing->z = thing->ceilingz - thing->height;
|
||||
}
|
||||
|
||||
if (thing->z != oldz)
|
||||
{
|
||||
if (thing->player)
|
||||
P_PlayerHitFloor(thing->player, false);
|
||||
}
|
||||
|
||||
// debug: be sure it falls to the floor
|
||||
thing->eflags &= ~MFE_ONGROUND;
|
||||
|
||||
|
|
|
@ -1784,7 +1784,7 @@ static void P_PushableCheckBustables(mobj_t *mo)
|
|||
continue;
|
||||
}
|
||||
|
||||
EV_CrumbleChain(node->m_sector, rover);
|
||||
EV_CrumbleChain(NULL, rover); // node->m_sector
|
||||
|
||||
// Run a linedef executor??
|
||||
if (rover->master->flags & ML_EFFECT5)
|
||||
|
@ -3047,7 +3047,7 @@ static void P_PlayerZMovement(mobj_t *mo)
|
|||
}
|
||||
}
|
||||
|
||||
clipmomz = P_PlayerHitFloor(mo->player);
|
||||
clipmomz = P_PlayerHitFloor(mo->player, true);
|
||||
|
||||
if (!(mo->player->pflags & PF_SPINNING) && mo->player->powers[pw_carry] != CR_NIGHTSMODE)
|
||||
mo->player->pflags &= ~PF_STARTDASH;
|
||||
|
@ -3129,7 +3129,7 @@ nightsdone:
|
|||
{
|
||||
// DO THE MARIO!
|
||||
if (rover->flags & FF_SHATTERBOTTOM) // Brick block!
|
||||
EV_CrumbleChain(node->m_sector, rover);
|
||||
EV_CrumbleChain(NULL, rover); // node->m_sector
|
||||
else // Question block!
|
||||
EV_MarioBlock(rover, node->m_sector, mo);
|
||||
}
|
||||
|
|
98
src/p_user.c
98
src/p_user.c
|
@ -2031,7 +2031,7 @@ boolean P_InSpaceSector(mobj_t *mo) // Returns true if you are in space
|
|||
//
|
||||
// Handles player hitting floor surface.
|
||||
// Returns whether to clip momz.
|
||||
boolean P_PlayerHitFloor(player_t *player)
|
||||
boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff)
|
||||
{
|
||||
boolean clipmomz;
|
||||
|
||||
|
@ -2039,22 +2039,31 @@ boolean P_PlayerHitFloor(player_t *player)
|
|||
|
||||
if ((clipmomz = !(P_CheckDeathPitCollide(player->mo))) && player->mo->health && !player->spectator)
|
||||
{
|
||||
if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_THOKKED) && (player->cmd.buttons & BT_USE) && (FixedHypot(player->mo->momx, player->mo->momy) > (5*player->mo->scale)))
|
||||
if (dorollstuff)
|
||||
{
|
||||
player->pflags |= PF_SPINNING;
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_ROLL);
|
||||
S_StartSound(player->mo, sfx_spin);
|
||||
if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_THOKKED) && (player->cmd.buttons & BT_USE) && (FixedHypot(player->mo->momx, player->mo->momy) > (5*player->mo->scale)))
|
||||
{
|
||||
player->pflags |= PF_SPINNING;
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_ROLL);
|
||||
S_StartSound(player->mo, sfx_spin);
|
||||
}
|
||||
else
|
||||
player->pflags &= ~PF_SPINNING;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->pflags &= ~PF_SPINNING;
|
||||
|
||||
if (player->pflags & PF_GLIDING) // ground gliding
|
||||
if (player->pflags & PF_GLIDING) // ground gliding
|
||||
{
|
||||
if (dorollstuff)
|
||||
{
|
||||
player->skidtime = TICRATE;
|
||||
player->mo->tics = -1;
|
||||
}
|
||||
else if (player->charability2 == CA2_MELEE && (player->panim == PA_ABILITY2 && player->mo->state-states != S_PLAY_MELEE_LANDING))
|
||||
else
|
||||
player->pflags &= ~PF_GLIDING;
|
||||
}
|
||||
else if (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)
|
||||
{
|
||||
if (player->mo->state-states != S_PLAY_MELEE_LANDING)
|
||||
{
|
||||
mobjtype_t type = player->revitem;
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_MELEE_LANDING);
|
||||
|
@ -2086,45 +2095,48 @@ boolean P_PlayerHitFloor(player_t *player)
|
|||
P_ReturnThrustY(missile, throwang, mu)); // side to side component
|
||||
P_Thrust(missile, player->drawangle, mu2); // forward component
|
||||
P_SetObjectMomZ(missile, (4 + ((i&1)<<1))*FRACUNIT, true);
|
||||
missile->momz += player->mo->pmomz;
|
||||
missile->fuse = TICRATE/2;
|
||||
missile->extravalue2 = ev;
|
||||
|
||||
i++;
|
||||
throwang += ANG30;
|
||||
}
|
||||
if (mobjinfo[type].seesound)
|
||||
if (mobjinfo[type].seesound && missile)
|
||||
S_StartSound(missile, missile->info->seesound);
|
||||
}
|
||||
}
|
||||
else if (player->pflags & PF_JUMPED || !(player->pflags & PF_SPINNING)
|
||||
}
|
||||
else if (player->charability2 == CA2_GUNSLINGER && player->panim == PA_ABILITY2)
|
||||
;
|
||||
else if (player->pflags & PF_JUMPED || !(player->pflags & PF_SPINNING)
|
||||
|| player->powers[pw_tailsfly] || player->mo->state-states == S_PLAY_FLY_TIRED)
|
||||
{
|
||||
if (player->cmomx || player->cmomy)
|
||||
{
|
||||
if (player->cmomx || player->cmomy)
|
||||
{
|
||||
if (player->charflags & SF_DASHMODE && player->dashmode >= 3*TICRATE && player->panim != PA_DASH)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_DASH);
|
||||
else if (player->speed >= FixedMul(player->runspeed, player->mo->scale)
|
||||
&& (player->panim != PA_RUN || player->mo->state-states == S_PLAY_FLOAT_RUN))
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_RUN);
|
||||
else if ((player->rmomx || player->rmomy)
|
||||
&& (player->panim != PA_WALK || player->mo->state-states == S_PLAY_FLOAT))
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_WALK);
|
||||
else if (!player->rmomx && !player->rmomy && player->panim != PA_IDLE)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_STND);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player->charflags & SF_DASHMODE && player->dashmode >= 3*TICRATE && player->panim != PA_DASH)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_DASH);
|
||||
else if (player->speed >= FixedMul(player->runspeed, player->mo->scale)
|
||||
&& (player->panim != PA_RUN || player->mo->state-states == S_PLAY_FLOAT_RUN))
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_RUN);
|
||||
else if ((player->mo->momx || player->mo->momy)
|
||||
&& (player->panim != PA_WALK || player->mo->state-states == S_PLAY_FLOAT))
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_WALK);
|
||||
else if (!player->mo->momx && !player->mo->momy && player->panim != PA_IDLE)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_STND);
|
||||
}
|
||||
if (player->charflags & SF_DASHMODE && player->dashmode >= 3*TICRATE && player->panim != PA_DASH)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_DASH);
|
||||
else if (player->speed >= FixedMul(player->runspeed, player->mo->scale)
|
||||
&& (player->panim != PA_RUN || player->mo->state-states == S_PLAY_FLOAT_RUN))
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_RUN);
|
||||
else if ((player->rmomx || player->rmomy)
|
||||
&& (player->panim != PA_WALK || player->mo->state-states == S_PLAY_FLOAT))
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_WALK);
|
||||
else if (!player->rmomx && !player->rmomy && player->panim != PA_IDLE)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_STND);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player->charflags & SF_DASHMODE && player->dashmode >= 3*TICRATE && player->panim != PA_DASH)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_DASH);
|
||||
else if (player->speed >= FixedMul(player->runspeed, player->mo->scale)
|
||||
&& (player->panim != PA_RUN || player->mo->state-states == S_PLAY_FLOAT_RUN))
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_RUN);
|
||||
else if ((player->mo->momx || player->mo->momy)
|
||||
&& (player->panim != PA_WALK || player->mo->state-states == S_PLAY_FLOAT))
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_WALK);
|
||||
else if (!player->mo->momx && !player->mo->momy && player->panim != PA_IDLE)
|
||||
P_SetPlayerMobjState(player->mo, S_PLAY_STND);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2344,7 +2356,7 @@ static void P_CheckBustableBlocks(player_t *player)
|
|||
//if (metalrecording)
|
||||
// G_RecordBustup(rover);
|
||||
|
||||
EV_CrumbleChain(node->m_sector, rover);
|
||||
EV_CrumbleChain(NULL, rover); // node->m_sector
|
||||
|
||||
// Run a linedef executor??
|
||||
if (rover->master->flags & ML_EFFECT5)
|
||||
|
@ -2561,7 +2573,7 @@ static void P_CheckQuicksand(player_t *player)
|
|||
player->mo->z = ceilingheight - player->mo->height;
|
||||
|
||||
if (player->mo->momz <= 0)
|
||||
P_PlayerHitFloor(player);
|
||||
P_PlayerHitFloor(player, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2573,7 +2585,7 @@ static void P_CheckQuicksand(player_t *player)
|
|||
player->mo->z = floorheight;
|
||||
|
||||
if (player->mo->momz >= 0)
|
||||
P_PlayerHitFloor(player);
|
||||
P_PlayerHitFloor(player, false);
|
||||
}
|
||||
|
||||
friction = abs(rover->master->v1->y - rover->master->v2->y)>>6;
|
||||
|
@ -4434,6 +4446,10 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd)
|
|||
{
|
||||
player->mo->z += P_MobjFlip(player->mo);
|
||||
P_SetObjectMomZ(player->mo, player->mindash, false);
|
||||
if (P_MobjFlip(player->mo)*player->mo->pmomz > 0)
|
||||
player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump.
|
||||
else
|
||||
player->mo->pmomz = 0;
|
||||
if (player->mo->eflags & MFE_UNDERWATER)
|
||||
player->mo->momz >>= 1;
|
||||
#if 0
|
||||
|
|
Loading…
Reference in a new issue