Implement the sector special-like effects

Offroad, sneaker panels, trick panels, and damaging floors can now be set via terrain.
This commit is contained in:
Sally Coolatta 2021-12-09 03:20:45 -05:00 committed by SinnamonLat
parent 4d08194fc7
commit e4c04169d7
5 changed files with 137 additions and 14 deletions

View file

@ -33,6 +33,7 @@
#include "k_waypoint.h" #include "k_waypoint.h"
#include "k_bot.h" #include "k_bot.h"
#include "k_hud.h" #include "k_hud.h"
#include "k_terrain.h"
// SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H: // SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H:
// gamespeed is cc (0 for easy, 1 for normal, 2 for hard) // gamespeed is cc (0 for easy, 1 for normal, 2 for hard)
@ -1605,6 +1606,7 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo)
} }
} }
return 0; // couldn't find any offroad return 0; // couldn't find any offroad
} }
@ -1616,7 +1618,17 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo)
*/ */
static void K_UpdateOffroad(player_t *player) static void K_UpdateOffroad(player_t *player)
{ {
fixed_t offroadstrength = (K_CheckOffroadCollide(player->mo) << FRACBITS); terrain_t *terrain = player->mo->terrain;
fixed_t offroadstrength = 0;
if (terrain != NULL && terrain->offroad > 0)
{
offroadstrength = (terrain->offroad << FRACBITS);
}
else
{
offroadstrength = (K_CheckOffroadCollide(player->mo) << FRACBITS);
}
// If you are in offroad, a timer starts. // If you are in offroad, a timer starts.
if (offroadstrength) if (offroadstrength)

View file

@ -25,6 +25,8 @@
#include "w_wad.h" #include "w_wad.h"
#include "z_zone.h" #include "z_zone.h"
#include "k_kart.h" // on the chopping block...
t_splash_t *splashDefs = NULL; t_splash_t *splashDefs = NULL;
UINT16 numSplashDefs = 0; UINT16 numSplashDefs = 0;
@ -119,20 +121,25 @@ terrain_t *K_GetTerrainForTextureNum(INT32 textureNum)
return K_GetTerrainForTextureName(tex->name); return K_GetTerrainForTextureName(tex->name);
} }
void K_UpdateMobjTerrain(mobj_t *mo, INT32 flatID) terrain_t *K_GetTerrainForFlatNum(INT32 flatID)
{ {
levelflat_t *levelFlat = NULL; levelflat_t *levelFlat = NULL;
if (mo == NULL || P_MobjWasRemoved(mo) == true)
{
// Invalid object.
return;
}
if (flatID < 0 || flatID >= (signed)numlevelflats) if (flatID < 0 || flatID >= (signed)numlevelflats)
{ {
// Clearly invalid floor... // Clearly invalid floor...
mo->terrain = NULL; return NULL;
}
levelFlat = &levelflats[flatID];
return K_GetTerrainForTextureName(levelFlat->name);
}
void K_UpdateMobjTerrain(mobj_t *mo, INT32 flatID)
{
if (mo == NULL || P_MobjWasRemoved(mo) == true)
{
// Invalid object.
return; return;
} }
@ -144,12 +151,84 @@ void K_UpdateMobjTerrain(mobj_t *mo, INT32 flatID)
} }
// Update the object's terrain pointer. // Update the object's terrain pointer.
levelFlat = &levelflats[flatID]; mo->terrain = K_GetTerrainForFlatNum(flatID);
mo->terrain = K_GetTerrainForTextureName(levelFlat->name); }
void K_ProcessTerrainEffect(mobj_t *mo)
{
player_t *player = NULL;
terrain_t *terrain = NULL;
if (mo == NULL || P_MobjWasRemoved(mo) == true)
{
// Invalid object.
return;
}
if (mo->terrain == NULL)
{
// No terrain type.
return;
}
terrain = mo->terrain;
player = mo->player;
if (player == NULL)
{
// maybe can support regualar mobjs later? :)
return;
}
// Damage effects
if (terrain->damageType > 0)
{
UINT8 dmg = (terrain->damageType & 0xFF);
P_DamageMobj(mo, NULL, NULL, 1, dmg);
}
// Sneaker panel
if (terrain->flags & TRF_SNEAKERPANEL)
{
if (!player->floorboost)
player->floorboost = 3;
else
player->floorboost = 2;
K_DoSneaker(player, 0);
}
// Trick panel
if (terrain->trickPanel > 0 && !(mo->eflags & MFE_SPRUNG))
{
const fixed_t hscale = mapobjectscale + (mapobjectscale - mo->scale);
const fixed_t minspeed = 24*hscale;
fixed_t speed = FixedHypot(mo->momx, mo->momy);
fixed_t upwards = 16 * FRACUNIT * terrain->trickPanel;
player->trickpanel = 1;
player->pflags |= PF_TRICKDELAY;
K_DoPogoSpring(mo, upwards, 1);
if (speed < minspeed)
{
speed = minspeed;
}
P_InstaThrust(mo, mo->angle, speed);
}
// (Offroad is handled elsewhere!)
} }
void K_SetDefaultFriction(mobj_t *mo) void K_SetDefaultFriction(mobj_t *mo)
{ {
if (mo == NULL || P_MobjWasRemoved(mo) == true)
{
// Invalid object.
return;
}
mo->friction = ORIG_FRICTION; mo->friction = ORIG_FRICTION;
if (mo->player != NULL) if (mo->player != NULL)

View file

@ -102,8 +102,10 @@ terrain_t *K_GetTerrainByName(const char *checkName);
terrain_t *K_GetDefaultTerrain(void); terrain_t *K_GetDefaultTerrain(void);
terrain_t *K_GetTerrainForTextureName(const char *checkName); terrain_t *K_GetTerrainForTextureName(const char *checkName);
terrain_t *K_GetTerrainForTextureNum(INT32 textureNum); terrain_t *K_GetTerrainForTextureNum(INT32 textureNum);
terrain_t *K_GetTerrainForFlatNum(INT32 flatID);
void K_UpdateMobjTerrain(mobj_t *mo, INT32 flatID); void K_UpdateMobjTerrain(mobj_t *mo, INT32 flatID);
void K_ProcessTerrainEffect(mobj_t *mo);
void K_SetDefaultFriction(mobj_t *mo); void K_SetDefaultFriction(mobj_t *mo);
void K_InitTerrain(UINT16 wadNum); void K_InitTerrain(UINT16 wadNum);

View file

@ -43,6 +43,7 @@
#include "k_kart.h" #include "k_kart.h"
#include "console.h" // CON_LogMessage #include "console.h" // CON_LogMessage
#include "k_respawn.h" #include "k_respawn.h"
#include "k_terrain.h"
#ifdef HW3SOUND #ifdef HW3SOUND
#include "hardware/hw3sound.h" #include "hardware/hw3sound.h"
@ -4333,7 +4334,9 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
// Conveyor stuff // Conveyor stuff
if (section3 == 2 || section3 == 4) if (section3 == 2 || section3 == 4)
{
player->onconveyor = section3; player->onconveyor = section3;
}
special = section1; special = section1;
@ -5050,6 +5053,7 @@ void P_PlayerInSpecialSector(player_t *player)
if (!player->mo) if (!player->mo)
return; return;
K_ProcessTerrainEffect(player->mo);
originalsector = player->mo->subsector->sector; originalsector = player->mo->subsector->sector;
P_PlayerOnSpecial3DFloor(player, originalsector); // Handle FOFs first. P_PlayerOnSpecial3DFloor(player, originalsector); // Handle FOFs first.

View file

@ -23,6 +23,8 @@
#include "z_zone.h" // Check R_Prep3DFloors #include "z_zone.h" // Check R_Prep3DFloors
#include "taglist.h" #include "taglist.h"
#include "k_terrain.h"
seg_t *curline; seg_t *curline;
side_t *sidedef; side_t *sidedef;
line_t *linedef; line_t *linedef;
@ -67,11 +69,35 @@ boolean R_IsRipplePlane(sector_t *sector, ffloor_t *rover, int ceiling)
static void R_PlaneLightOverride(sector_t *sector, boolean ceiling, INT32 *lightlevel) static void R_PlaneLightOverride(sector_t *sector, boolean ceiling, INT32 *lightlevel)
{ {
if (GETSECSPECIAL(sector->special, 4) == 6) // Fullbright sneaker panels terrain_t *t = NULL;
if (ceiling == true)
{ {
if ((ceiling && (sector->flags & SF_FLIPSPECIAL_CEILING)) t = K_GetTerrainForFlatNum(sector->ceilingpic);
|| (!ceiling && (sector->flags & SF_FLIPSPECIAL_FLOOR))) }
else
{
t = K_GetTerrainForFlatNum(sector->floorpic);
}
if (t != NULL)
{
if (t->flags & TRF_SNEAKERPANEL)
{
*lightlevel = 255; *lightlevel = 255;
}
}
else
{
// Sector effect sneaker panels (DEPRECATED)
if (GETSECSPECIAL(sector->special, 4) == 6)
{
if ((ceiling && (sector->flags & SF_FLIPSPECIAL_CEILING))
|| (!ceiling && (sector->flags & SF_FLIPSPECIAL_FLOOR)))
{
*lightlevel = 255;
}
}
} }
} }