mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 15:32:33 +00:00
Expose sector flags to Lua and UDMF
This commit is contained in:
parent
ff4b68424f
commit
2fd6eafbcf
11 changed files with 84 additions and 34 deletions
|
@ -74,6 +74,11 @@ sectorflags
|
|||
colormapfog = "Fog Planes in Colormap";
|
||||
colormapfadesprites = "Fade Fullbright in Colormap";
|
||||
colormapprotected = "Protected Colormap";
|
||||
flipspecial_nofloor = "No Trigger on Floor Touch";
|
||||
flipspecial_ceiling = "Trigger on Ceiling Touch";
|
||||
triggerspecial_touch = "Trigger on Edge Touch";
|
||||
triggerspecial_headbump = "Trigger on Headbump";
|
||||
invertprecip = "Invert Precipitation";
|
||||
}
|
||||
|
||||
thingflags
|
||||
|
|
|
@ -338,6 +338,21 @@ static inline int lib_getenum(lua_State *L)
|
|||
if (mathlib) return luaL_error(L, "linedef flag '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("MSF_", word, 3)) {
|
||||
p = word + 4;
|
||||
for (i = 0; i < 4; i++)
|
||||
if (MSF_LIST[i] && fastcmp(p, MSF_LIST[i])) {
|
||||
lua_pushinteger(L, ((lua_Integer)1 << i));
|
||||
return 1;
|
||||
}
|
||||
if (fastcmp(p, "FLIPSPECIAL_BOTH"))
|
||||
{
|
||||
lua_pushinteger(L, (lua_Integer)MSF_FLIPSPECIAL_BOTH);
|
||||
return 1;
|
||||
}
|
||||
if (mathlib) return luaL_error(L, "sector flag '%s' could not be found.\n", word);
|
||||
return 0;
|
||||
}
|
||||
else if (fastncmp("S_",word,2)) {
|
||||
p = word+2;
|
||||
for (i = 0; i < NUMSTATEFREESLOTS; i++) {
|
||||
|
|
|
@ -4471,6 +4471,14 @@ const char *const ML_LIST[16] = {
|
|||
"TFERLINE"
|
||||
};
|
||||
|
||||
// Sector flags
|
||||
const char *const MSF_LIST[4] = {
|
||||
"FLIPSPECIAL_FLOOR",
|
||||
"FLIPSPECIAL_CEILING",
|
||||
"TRIGGERSPECIAL_TOUCH",
|
||||
"TRIGGERSPECIAL_HEADBUMP",
|
||||
};
|
||||
|
||||
const char *COLOR_ENUMS[] = {
|
||||
"NONE", // SKINCOLOR_NONE,
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ extern const char *const MAPTHINGFLAG_LIST[4];
|
|||
extern const char *const PLAYERFLAG_LIST[];
|
||||
extern const char *const GAMETYPERULE_LIST[];
|
||||
extern const char *const ML_LIST[16]; // Linedef flags
|
||||
extern const char* const MSF_LIST[4]; // Sector flags
|
||||
extern const char *COLOR_ENUMS[];
|
||||
extern const char *const POWERS_LIST[];
|
||||
extern const char *const HUDITEMS_LIST[];
|
||||
|
|
|
@ -48,7 +48,8 @@ enum sector_e {
|
|||
sector_lines,
|
||||
sector_ffloors,
|
||||
sector_fslope,
|
||||
sector_cslope
|
||||
sector_cslope,
|
||||
sector_flags,
|
||||
};
|
||||
|
||||
static const char *const sector_opt[] = {
|
||||
|
@ -72,6 +73,7 @@ static const char *const sector_opt[] = {
|
|||
"ffloors",
|
||||
"f_slope",
|
||||
"c_slope",
|
||||
"flags",
|
||||
NULL};
|
||||
|
||||
enum subsector_e {
|
||||
|
@ -649,6 +651,9 @@ static int sector_get(lua_State *L)
|
|||
case sector_cslope: // c_slope
|
||||
LUA_PushUserdata(L, sector->c_slope, META_SLOPE);
|
||||
return 1;
|
||||
case sector_flags: // flags
|
||||
lua_pushinteger(L, sector->flags);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -735,6 +740,9 @@ static int sector_set(lua_State *L)
|
|||
break;
|
||||
case sector_taglist:
|
||||
return LUA_ErrSetDirectly(L, "sector_t", "taglist");
|
||||
case sector_flags:
|
||||
sector->flags = luaL_checkinteger(L, 3);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3455,7 +3455,7 @@ static boolean PTR_SlideTraverse(intercept_t *in)
|
|||
// see if it is closer than best so far
|
||||
if (li->polyobj && slidemo->player)
|
||||
{
|
||||
if ((li->polyobj->lines[0]->backsector->flags & SF_TRIGGERSPECIAL_TOUCH) && !(li->polyobj->flags & POF_NOSPECIALS))
|
||||
if ((li->polyobj->lines[0]->backsector->flags & MSF_TRIGGERSPECIAL_TOUCH) && !(li->polyobj->flags & POF_NOSPECIALS))
|
||||
P_ProcessSpecialSector(slidemo->player, slidemo->subsector->sector, li->polyobj->lines[0]->backsector);
|
||||
}
|
||||
|
||||
|
|
|
@ -2324,9 +2324,9 @@ boolean P_CheckDeathPitCollide(mobj_t *mo)
|
|||
return false;
|
||||
|
||||
if (((mo->z <= mo->subsector->sector->floorheight
|
||||
&& ((mo->subsector->sector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(mo->eflags & MFE_VERTICALFLIP)) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR))
|
||||
&& ((mo->subsector->sector->flags & MSF_TRIGGERSPECIAL_HEADBUMP) || !(mo->eflags & MFE_VERTICALFLIP)) && (mo->subsector->sector->flags & MSF_FLIPSPECIAL_FLOOR))
|
||||
|| (mo->z + mo->height >= mo->subsector->sector->ceilingheight
|
||||
&& ((mo->subsector->sector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (mo->eflags & MFE_VERTICALFLIP)) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING)))
|
||||
&& ((mo->subsector->sector->flags & MSF_TRIGGERSPECIAL_HEADBUMP) || (mo->eflags & MFE_VERTICALFLIP)) && (mo->subsector->sector->flags & MSF_FLIPSPECIAL_CEILING)))
|
||||
&& (GETSECSPECIAL(mo->subsector->sector->special, 1) == 6
|
||||
|| GETSECSPECIAL(mo->subsector->sector->special, 1) == 7))
|
||||
return true;
|
||||
|
@ -11219,7 +11219,7 @@ void P_SpawnPrecipitation(void)
|
|||
if (curWeather == PRECIP_SNOW)
|
||||
{
|
||||
// Not in a sector with visible sky -- exception for NiGHTS.
|
||||
if ((!(maptol & TOL_NIGHTS) && (precipsector->sector->ceilingpic != skyflatnum)) == !(precipsector->sector->flags & SF_INVERTPRECIP))
|
||||
if ((!(maptol & TOL_NIGHTS) && (precipsector->sector->ceilingpic != skyflatnum)) == !(precipsector->sector->flags & MSF_INVERTPRECIP))
|
||||
continue;
|
||||
|
||||
rainmo = P_SpawnSnowMobj(x, y, height, MT_SNOWFLAKE);
|
||||
|
@ -11232,7 +11232,7 @@ void P_SpawnPrecipitation(void)
|
|||
else // everything else.
|
||||
{
|
||||
// Not in a sector with visible sky.
|
||||
if ((precipsector->sector->ceilingpic != skyflatnum) == !(precipsector->sector->flags & SF_INVERTPRECIP))
|
||||
if ((precipsector->sector->ceilingpic != skyflatnum) == !(precipsector->sector->flags & MSF_INVERTPRECIP))
|
||||
continue;
|
||||
|
||||
rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN);
|
||||
|
|
|
@ -963,7 +963,7 @@ static INT32 Polyobj_clipThings(polyobj_t *po, line_t *line)
|
|||
else
|
||||
Polyobj_pushThing(po, line, mo);
|
||||
|
||||
if (mo->player && (po->lines[0]->backsector->flags & SF_TRIGGERSPECIAL_TOUCH) && !(po->flags & POF_NOSPECIALS))
|
||||
if (mo->player && (po->lines[0]->backsector->flags & MSF_TRIGGERSPECIAL_TOUCH) && !(po->flags & POF_NOSPECIALS))
|
||||
P_ProcessSpecialSector(mo->player, mo->subsector->sector, po->lines[0]->backsector);
|
||||
|
||||
hitflags |= 1;
|
||||
|
|
|
@ -1001,7 +1001,6 @@ static void P_InitializeSector(sector_t *ss)
|
|||
|
||||
ss->gravity = NULL;
|
||||
ss->verticalflip = false;
|
||||
ss->flags = SF_FLIPSPECIAL_FLOOR;
|
||||
|
||||
ss->cullheight = NULL;
|
||||
|
||||
|
@ -1048,6 +1047,8 @@ static void P_LoadSectors(UINT8 *data)
|
|||
|
||||
ss->colormap_protected = false;
|
||||
|
||||
ss->flags = MSF_FLIPSPECIAL_FLOOR;
|
||||
|
||||
P_InitializeSector(ss);
|
||||
}
|
||||
}
|
||||
|
@ -1661,6 +1662,16 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
|
|||
}
|
||||
else if (fastcmp(param, "colormapprotected") && fastcmp("true", val))
|
||||
sectors[i].colormap_protected = true;
|
||||
else if (fastcmp(param, "flipspecial_nofloor") && fastcmp("true", val))
|
||||
sectors[i].flags &= ~MSF_FLIPSPECIAL_FLOOR;
|
||||
else if (fastcmp(param, "flipspecial_ceiling") && fastcmp("true", val))
|
||||
sectors[i].flags |= MSF_FLIPSPECIAL_CEILING;
|
||||
else if (fastcmp(param, "triggerspecial_touch") && fastcmp("true", val))
|
||||
sectors[i].flags |= MSF_TRIGGERSPECIAL_TOUCH;
|
||||
else if (fastcmp(param, "triggerspecial_headbump") && fastcmp("true", val))
|
||||
sectors[i].flags |= MSF_TRIGGERSPECIAL_HEADBUMP;
|
||||
else if (fastcmp(param, "invertprecip") && fastcmp("true", val))
|
||||
sectors[i].flags |= MSF_INVERTPRECIP;
|
||||
}
|
||||
|
||||
static void ParseTextmapSidedefParameter(UINT32 i, char *param, char *val)
|
||||
|
@ -1937,6 +1948,8 @@ static void P_LoadTextmap(void)
|
|||
|
||||
sc->colormap_protected = false;
|
||||
|
||||
sc->flags = MSF_FLIPSPECIAL_FLOOR;
|
||||
|
||||
textmap_colormap.used = false;
|
||||
textmap_colormap.lightcolor = 0;
|
||||
textmap_colormap.lightalpha = 25;
|
||||
|
|
40
src/p_spec.c
40
src/p_spec.c
|
@ -3945,8 +3945,8 @@ boolean P_IsFlagAtBase(mobjtype_t flag)
|
|||
|
||||
static boolean P_IsMobjTouchingPlane(mobj_t *mo, sector_t *sec, fixed_t floorz, fixed_t ceilingz)
|
||||
{
|
||||
boolean floorallowed = ((sec->flags & SF_FLIPSPECIAL_FLOOR) && ((sec->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(mo->eflags & MFE_VERTICALFLIP)) && (mo->z == floorz));
|
||||
boolean ceilingallowed = ((sec->flags & SF_FLIPSPECIAL_CEILING) && ((sec->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (mo->eflags & MFE_VERTICALFLIP)) && (mo->z + mo->height == ceilingz));
|
||||
boolean floorallowed = ((sec->flags & MSF_FLIPSPECIAL_FLOOR) && ((sec->flags & MSF_TRIGGERSPECIAL_HEADBUMP) || !(mo->eflags & MFE_VERTICALFLIP)) && (mo->z == floorz));
|
||||
boolean ceilingallowed = ((sec->flags & MSF_FLIPSPECIAL_CEILING) && ((sec->flags & MSF_TRIGGERSPECIAL_HEADBUMP) || (mo->eflags & MFE_VERTICALFLIP)) && (mo->z + mo->height == ceilingz));
|
||||
return (floorallowed || ceilingallowed);
|
||||
}
|
||||
|
||||
|
@ -4007,7 +4007,7 @@ static sector_t *P_MobjTouching3DFloorSpecial(mobj_t *mo, sector_t *sector, INT3
|
|||
|
||||
// This FOF has the special we're looking for, but are we allowed to touch it?
|
||||
if (sector == mo->subsector->sector
|
||||
|| (rover->master->frontsector->flags & SF_TRIGGERSPECIAL_TOUCH))
|
||||
|| (rover->master->frontsector->flags & MSF_TRIGGERSPECIAL_TOUCH))
|
||||
return rover->master->frontsector;
|
||||
}
|
||||
|
||||
|
@ -4031,7 +4031,7 @@ static sector_t *P_MobjTouchingPolyobjSpecial(mobj_t *mo, INT32 section, INT32 n
|
|||
if (GETSECSPECIAL(polysec->special, section) != number)
|
||||
continue;
|
||||
|
||||
touching = (polysec->flags & SF_TRIGGERSPECIAL_TOUCH) && P_MobjTouchingPolyobj(po, mo);
|
||||
touching = (polysec->flags & MSF_TRIGGERSPECIAL_TOUCH) && P_MobjTouchingPolyobj(po, mo);
|
||||
inside = P_MobjInsidePolyobj(po, mo);
|
||||
|
||||
if (!(inside || touching))
|
||||
|
@ -4071,7 +4071,7 @@ sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number)
|
|||
if (result)
|
||||
return result;
|
||||
|
||||
if (!(node->m_sector->flags & SF_TRIGGERSPECIAL_TOUCH))
|
||||
if (!(node->m_sector->flags & MSF_TRIGGERSPECIAL_TOUCH))
|
||||
continue;
|
||||
|
||||
if (GETSECSPECIAL(mo->subsector->sector->special, section) == number)
|
||||
|
@ -4120,7 +4120,7 @@ static sector_t *P_Check3DFloorTriggers(player_t *player, sector_t *sector, line
|
|||
|
||||
// This FOF has the special we're looking for, but are we allowed to touch it?
|
||||
if (sector == player->mo->subsector->sector
|
||||
|| (rover->master->frontsector->flags & SF_TRIGGERSPECIAL_TOUCH))
|
||||
|| (rover->master->frontsector->flags & MSF_TRIGGERSPECIAL_TOUCH))
|
||||
return rover->master->frontsector;
|
||||
}
|
||||
|
||||
|
@ -4147,7 +4147,7 @@ static sector_t *P_CheckPolyobjTriggers(player_t *player, line_t *sourceline)
|
|||
if (!Tag_Find(&sourceline->tags, Tag_FGet(&polysec->tags)))
|
||||
return false;
|
||||
|
||||
touching = (polysec->flags & SF_TRIGGERSPECIAL_TOUCH) && P_MobjTouchingPolyobj(po, player->mo);
|
||||
touching = (polysec->flags & MSF_TRIGGERSPECIAL_TOUCH) && P_MobjTouchingPolyobj(po, player->mo);
|
||||
inside = P_MobjInsidePolyobj(po, player->mo);
|
||||
|
||||
if (!(inside || touching))
|
||||
|
@ -4217,7 +4217,7 @@ sector_t *P_FindPlayerTrigger(player_t *player, line_t *sourceline)
|
|||
if (caller)
|
||||
return caller;
|
||||
|
||||
if (!(loopsector->flags & SF_TRIGGERSPECIAL_TOUCH))
|
||||
if (!(loopsector->flags & MSF_TRIGGERSPECIAL_TOUCH))
|
||||
continue;
|
||||
|
||||
if (P_CheckSectorTriggers(player, loopsector, sourceline))
|
||||
|
@ -5024,7 +5024,7 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector)
|
|||
|
||||
// This FOF has the special we're looking for, but are we allowed to touch it?
|
||||
if (sector == player->mo->subsector->sector
|
||||
|| (rover->master->frontsector->flags & SF_TRIGGERSPECIAL_TOUCH))
|
||||
|| (rover->master->frontsector->flags & MSF_TRIGGERSPECIAL_TOUCH))
|
||||
{
|
||||
P_ProcessSpecialSector(player, rover->master->frontsector, sector);
|
||||
if TELEPORTED(player->mo) return;
|
||||
|
@ -5050,7 +5050,7 @@ static void P_PlayerOnSpecialPolyobj(player_t *player)
|
|||
if (!polysec->special)
|
||||
continue;
|
||||
|
||||
touching = (polysec->flags & SF_TRIGGERSPECIAL_TOUCH) && P_MobjTouchingPolyobj(po, player->mo);
|
||||
touching = (polysec->flags & MSF_TRIGGERSPECIAL_TOUCH) && P_MobjTouchingPolyobj(po, player->mo);
|
||||
inside = P_MobjInsidePolyobj(po, player->mo);
|
||||
|
||||
if (!(inside || touching))
|
||||
|
@ -5102,7 +5102,7 @@ void P_PlayerInSpecialSector(player_t *player)
|
|||
P_PlayerOnSpecial3DFloor(player, loopsector);
|
||||
if TELEPORTED(player->mo) return;
|
||||
|
||||
if (!(loopsector->flags & SF_TRIGGERSPECIAL_TOUCH))
|
||||
if (!(loopsector->flags & MSF_TRIGGERSPECIAL_TOUCH))
|
||||
continue;
|
||||
|
||||
P_ProcessSpecialSector(player, loopsector, NULL);
|
||||
|
@ -5152,7 +5152,7 @@ static void P_CheckMobjPolyobjTrigger(mobj_t *mo)
|
|||
if (!polysec->special)
|
||||
continue;
|
||||
|
||||
touching = (polysec->flags & SF_TRIGGERSPECIAL_TOUCH) && P_MobjTouchingPolyobj(po, mo);
|
||||
touching = (polysec->flags & MSF_TRIGGERSPECIAL_TOUCH) && P_MobjTouchingPolyobj(po, mo);
|
||||
inside = P_MobjInsidePolyobj(po, mo);
|
||||
|
||||
if (!(inside || touching))
|
||||
|
@ -5994,9 +5994,9 @@ void P_SpawnSpecials(boolean fromnetsave)
|
|||
{
|
||||
case 5: // Spikes
|
||||
//Terrible hack to replace an even worse hack:
|
||||
//Spike damage automatically sets SF_TRIGGERSPECIAL_TOUCH.
|
||||
//Spike damage automatically sets MSF_TRIGGERSPECIAL_TOUCH.
|
||||
//Yes, this also affects other specials on the same sector. Sorry.
|
||||
sector->flags |= SF_TRIGGERSPECIAL_TOUCH;
|
||||
sector->flags |= MSF_TRIGGERSPECIAL_TOUCH;
|
||||
break;
|
||||
case 15: // Bouncy FOF
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Deprecated bouncy FOF sector type detected. Please use linedef type 76 instead.\n"));
|
||||
|
@ -6148,19 +6148,19 @@ void P_SpawnSpecials(boolean fromnetsave)
|
|||
{
|
||||
if (lines[i].flags & ML_NOCLIMB)
|
||||
{
|
||||
sectors[s].flags &= ~SF_FLIPSPECIAL_FLOOR;
|
||||
sectors[s].flags |= SF_FLIPSPECIAL_CEILING;
|
||||
sectors[s].flags &= ~MSF_FLIPSPECIAL_FLOOR;
|
||||
sectors[s].flags |= MSF_FLIPSPECIAL_CEILING;
|
||||
}
|
||||
else if (lines[i].flags & ML_EFFECT4)
|
||||
sectors[s].flags |= SF_FLIPSPECIAL_BOTH;
|
||||
sectors[s].flags |= MSF_FLIPSPECIAL_BOTH;
|
||||
|
||||
if (lines[i].flags & ML_EFFECT3)
|
||||
sectors[s].flags |= SF_TRIGGERSPECIAL_TOUCH;
|
||||
sectors[s].flags |= MSF_TRIGGERSPECIAL_TOUCH;
|
||||
if (lines[i].flags & ML_EFFECT2)
|
||||
sectors[s].flags |= SF_TRIGGERSPECIAL_HEADBUMP;
|
||||
sectors[s].flags |= MSF_TRIGGERSPECIAL_HEADBUMP;
|
||||
|
||||
if (lines[i].flags & ML_EFFECT1)
|
||||
sectors[s].flags |= SF_INVERTPRECIP;
|
||||
sectors[s].flags |= MSF_INVERTPRECIP;
|
||||
|
||||
if (lines[i].frontsector && GETSECSPECIAL(lines[i].frontsector->special, 4) == 12)
|
||||
sectors[s].camsec = sides[*lines[i].sidenum].sector-sectors;
|
||||
|
|
12
src/r_defs.h
12
src/r_defs.h
|
@ -276,14 +276,14 @@ typedef struct pslope_s
|
|||
typedef enum
|
||||
{
|
||||
// flipspecial - planes with effect
|
||||
SF_FLIPSPECIAL_FLOOR = 1,
|
||||
SF_FLIPSPECIAL_CEILING = 1<<1,
|
||||
SF_FLIPSPECIAL_BOTH = (SF_FLIPSPECIAL_FLOOR|SF_FLIPSPECIAL_CEILING),
|
||||
MSF_FLIPSPECIAL_FLOOR = 1,
|
||||
MSF_FLIPSPECIAL_CEILING = 1<<1,
|
||||
MSF_FLIPSPECIAL_BOTH = (MSF_FLIPSPECIAL_FLOOR|MSF_FLIPSPECIAL_CEILING),
|
||||
// triggerspecial - conditions under which plane touch causes effect
|
||||
SF_TRIGGERSPECIAL_TOUCH = 1<<2,
|
||||
SF_TRIGGERSPECIAL_HEADBUMP = 1<<3,
|
||||
MSF_TRIGGERSPECIAL_TOUCH = 1<<2,
|
||||
MSF_TRIGGERSPECIAL_HEADBUMP = 1<<3,
|
||||
// invertprecip - inverts presence of precipitation
|
||||
SF_INVERTPRECIP = 1<<4,
|
||||
MSF_INVERTPRECIP = 1<<4,
|
||||
} sectorflags_t;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue