Add sector type that flips gravity upon jumping

This commit is contained in:
spherallic 2022-09-07 23:15:38 +02:00
parent f0adc71f9b
commit 9fabddd4bb
7 changed files with 68 additions and 5 deletions

View file

@ -438,6 +438,7 @@ sectortypes
160 = "Special Stage Time/Spheres Parameters <deprecated>";
176 = "Custom Global Gravity <deprecated>";
1280 = "Speed Pad";
1536 = "Flip Gravity on Jump";
4096 = "Star Post Activator";
8192 = "Exit/Special Stage Pit/Return Flag";
12288 = "CTF Red Team Base";
@ -496,6 +497,7 @@ gen_sectortypes
{
0 = "Normal";
1280 = "Speed Pad";
1536 = "Flip Gravity on Jump";
}
fourth

View file

@ -28,6 +28,7 @@ sectortypes
160 = "Special Stage Time/Spheres Parameters <deprecated>";
176 = "Custom Global Gravity <deprecated>";
1280 = "Speed Pad";
1536 = "Flip Gravity on Jump";
4096 = "Star Post Activator";
8192 = "Exit/Special Stage Pit/Return Flag";
12288 = "CTF Red Team Base";
@ -84,6 +85,7 @@ gen_sectortypes
{
0 = "Normal";
1280 = "Speed Pad";
1536 = "Flip Gravity on Jump";
}
fourth
@ -102,4 +104,4 @@ gen_sectortypes
45056 = "Rope Hang";
49152 = "Intangible to the Camera";
}
}
}

View file

@ -1290,6 +1290,17 @@ static int lib_pInSpaceSector(lua_State *L)
return 1;
}
static int lib_pInJumpFlipSector(lua_State *L)
{
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
//HUDSAFE
INLEVEL
if (!mo)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_InJumpFlipSector(mo));
return 1;
}
static int lib_pInQuicksand(lua_State *L)
{
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -4008,6 +4019,7 @@ static luaL_Reg lib[] = {
{"P_IsObjectInGoop",lib_pIsObjectInGoop},
{"P_IsObjectOnGround",lib_pIsObjectOnGround},
{"P_InSpaceSector",lib_pInSpaceSector},
{"P_InJumpFlipSector",lib_pInJumpFlipSector},
{"P_InQuicksand",lib_pInQuicksand},
{"P_SetObjectMomZ",lib_pSetObjectMomZ},
{"P_PlayJingle",lib_pPlayJingle},

View file

@ -149,6 +149,7 @@ boolean P_PlayerShouldUseSpinHeight(player_t *player);
boolean P_IsObjectInGoop(mobj_t *mo);
boolean P_IsObjectOnGround(mobj_t *mo);
boolean P_InSpaceSector(mobj_t *mo);
boolean P_InJumpFlipSector(mobj_t *mo);
boolean P_InQuicksand(mobj_t *mo);
boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff);

View file

@ -1725,6 +1725,8 @@ static void ParseTextmapSectorParameter(UINT32 i, const char *param, const char
sectors[i].specialflags |= SSF_FINISHLINE;
else if (fastcmp(param, "ropehang") && fastcmp("true", val))
sectors[i].specialflags |= SSF_ROPEHANG;
else if (fastcmp(param, "jumpflip") && fastcmp("true", val))
sectors[i].specialflags |= SSF_JUMPFLIP;
else if (fastcmp(param, "friction"))
sectors[i].friction = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "gravity"))
@ -2578,6 +2580,8 @@ static void P_WriteTextmap(void)
fprintf(f, "finishline = true;\n");
if (wsectors[i].specialflags & SSF_ROPEHANG)
fprintf(f, "ropehang = true;\n");
if (wsectors[i].specialflags & SSF_JUMPFLIP)
fprintf(f, "jumpflip = true;\n");
if (wsectors[i].friction != ORIG_FRICTION)
fprintf(f, "friction = %f;\n", FIXED_TO_FLOAT(wsectors[i].friction));
if (wsectors[i].gravity != FRACUNIT)
@ -5936,6 +5940,9 @@ static void P_ConvertBinarySectorTypes(void)
case 5: //Speed pad
sectors[i].specialflags |= SSF_SPEEDPAD;
break;
case 6: //Gravity flip on jump
sectors[i].specialflags |= SSF_JUMPFLIP;
break;
default:
break;
}

View file

@ -1966,22 +1966,22 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
ghost->angle = (mobj->player ? mobj->player->drawangle : mobj->angle);
ghost->rollangle = mobj->rollangle;
ghost->sprite = mobj->sprite;
ghost->sprite2 = mobj->sprite2;
ghost->frame = mobj->frame;
ghost->tics = -1;
ghost->frame &= ~FF_TRANSMASK;
ghost->frame |= tr_trans50<<FF_TRANSSHIFT;
ghost->renderflags = mobj->renderflags;
ghost->blendmode = mobj->blendmode;
ghost->spritexscale = mobj->spritexscale;
ghost->spriteyscale = mobj->spriteyscale;
ghost->spritexoffset = mobj->spritexoffset;
ghost->spriteyoffset = mobj->spriteyoffset;
ghost->fuse = ghost->info->damage;
ghost->skin = mobj->skin;
@ -2484,6 +2484,41 @@ boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand
return false; // No sand here, Captain!
}
boolean P_InJumpFlipSector(mobj_t *mo) // Returns true if you are in a jumpflip sector
{
sector_t *sector = mo->subsector->sector;
fixed_t topheight, bottomheight;
if (sector->specialflags & SSF_JUMPFLIP)
return true;
if (sector->ffloors)
{
ffloor_t *rover;
for (rover = sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->master->frontsector->specialflags & SSF_JUMPFLIP))
continue;
topheight = P_GetFFloorTopZAt (rover, mo->x, mo->y);
bottomheight = P_GetFFloorBottomZAt(rover, mo->x, mo->y);
if (mo->z + (mo->height/2) > topheight)
continue;
if (mo->z + (mo->height/2) < bottomheight)
continue;
return true;
}
}
return false; // No jumpflip here, Captain!
}
static boolean P_PlayerCanBust(player_t *player, ffloor_t *rover)
{
if (!(rover->flags & FF_EXISTS))
@ -4449,6 +4484,9 @@ void P_DoJump(player_t *player, boolean soundandstate)
if (player->charflags & SF_NOJUMPDAMAGE)
player->pflags &= ~PF_SPINNING;
if (P_InJumpFlipSector(player->mo))
player->mo->flags2 ^= MF2_OBJECTFLIP;
if (soundandstate)
{
if (!player->spectator)

View file

@ -314,6 +314,7 @@ typedef enum
SSF_ZOOMTUBEEND = 1<<16,
SSF_FINISHLINE = 1<<17,
SSF_ROPEHANG = 1<<18,
SSF_JUMPFLIP = 1<<19,
} sectorspecialflags_t;
typedef enum