Merge branch 'crumble-FOF' into 'master'

Crumble fof

Basic (but kind of WIPish still) support for remote falling of FOFs by linedef execs or Lua. Originally started for Nev3r to use his dark magic on.

Making this MR so people actually remember I was doing something regarding crumbling FOFs, it's been months since I did stuff for this now mind...

* linedef type 446: basic setup is same as the remote shatter one (436), except the FOF of course falls down rather than shatters. By default the FOF respawns
 * *No Climb*: the FOF *doesn't* respawn
 * *Block Enemies*: respawning ability is determined by the FOF's flags (if it has FF_NORETURN it doesn't return, if it doesn't it does return)
 * *Block Enemies + No Climb*: inverted version of above
* EV_StartCrumble for lua, format: `EV_StartCrumble(controlsec, rover, [floating?, [player, [origalpha, [crumblereturn?]]]])`
 * *controlsec* is the FOF's control sector
 * *rover* is the FOF itself
 * (optional) *floating?* does the FOF float on water after crumbling? Defaults to false (NOTE: probably should be set to `rover.flags & FF_FLOATBOB` for best results currently, kind of weird otherwise)
 * (optional) *player* is the player that caused the FOF to fall; needed for some effects such as who to award points to if you killed someone =3 Defaults to nil
 * (optional) *origalpha* is the FOF's original alpha before crumbling (the thinker for respawning + floating crumbling FOFs tinkers with the alpha for some reason). Defaults to rover.alpha
 * (optional) *crumblereturn?* will the FOF respawn afterwards? Defaults to false (NOTE: probably should be set to `not (rover.flags & FF_NORETURN)` for best results currently, kind of weird otherwise)
 * the return value of EV_StartCrumble means something I forget offhand now ...it's either true or false though, mind

See MonsterIestyn/crumble-fof on the FTP for a test exe (srb2win-crumblefof.exe), a test map for the linedef, and a test lua script for EV_StartCrumble (which can also be tested in the map).

See merge request !55
This commit is contained in:
Monster Iestyn 2017-03-13 14:30:44 -04:00
commit 7a37794316
2 changed files with 73 additions and 0 deletions

View File

@ -1821,6 +1821,33 @@ static int lib_evCrumbleChain(lua_State *L)
return 0;
}
static int lib_evStartCrumble(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));
boolean floating = lua_optboolean(L, 3);
player_t *player = NULL;
fixed_t origalpha;
boolean crumblereturn = lua_optboolean(L, 6);
NOHUD
if (!sec)
return LUA_ErrInvalid(L, "sector_t");
if (!rover)
return LUA_ErrInvalid(L, "ffloor_t");
if (!lua_isnone(L, 4) && lua_isuserdata(L, 4))
{
player = *((player_t **)luaL_checkudata(L, 4, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
if (!lua_isnone(L,5))
origalpha = luaL_checkfixed(L, 5);
else
origalpha = rover->alpha;
lua_pushboolean(L, EV_StartCrumble(sec, rover, floating, player, origalpha, crumblereturn) != 0);
return 0;
}
// R_DEFS
////////////
@ -2406,6 +2433,7 @@ static luaL_Reg lib[] = {
{"P_SetSkyboxMobj",lib_pSetSkyboxMobj},
{"P_StartQuake",lib_pStartQuake},
{"EV_CrumbleChain",lib_evCrumbleChain},
{"EV_StartCrumble",lib_evStartCrumble},
// r_defs
{"R_PointToAngle",lib_rPointToAngle},

View File

@ -3111,6 +3111,51 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
}
break;
case 446: // Make block fall remotely (acts like FF_CRUMBLE)
{
INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS);
INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS);
sector_t *sec; // Sector that the FOF is visible in
ffloor_t *rover; // FOF that we are going to make fall down
player_t *player = NULL; // player that caused FOF to fall
boolean respawn = true; // should the fallen FOF respawn?
if (mo) // NULL check
player = mo->player;
if (line->flags & ML_NOCLIMB) // don't respawn!
respawn = false;
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
{
sec = sectors + secnum;
if (!sec->ffloors)
{
CONS_Debug(DBG_GAMELOGIC, "Line type 446 Executor: Target sector #%d has no FOFs.\n", secnum);
return;
}
for (rover = sec->ffloors; rover; rover = rover->next)
{
if (rover->master->frontsector->tag == foftag)
break;
}
if (!rover)
{
CONS_Debug(DBG_GAMELOGIC, "Line type 446 Executor: Can't find a FOF control sector with tag %d\n", foftag);
return;
}
if (line->flags & ML_BLOCKMONSTERS) // FOF flags determine respawn ability instead?
respawn = !(rover->flags & FF_NORETURN) ^ !!(line->flags & ML_NOCLIMB); // no climb inverts
EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), player, rover->alpha, respawn);
}
}
break;
case 450: // Execute Linedef Executor - for recursion
P_LinedefExecute(line->tag, mo, NULL);
break;