Merge branch 'skybox-improvements' into 'master'

Skybox improvements

Some improvements to skyboxes and new features for them:

* *The Thing's Z position now determines the relative z position of a skybox viewpoint from the ground, the Thing's angle no longer affects the Z position at all.* This should also fix objectplace breaking skyboxes after you place a Thing, and allow Z heights to be more easily controlled by custom skybox mobjs set by Lua's `P_SetSkyboxMobj`.
* The skybox viewpoint Thing's "Parameter" value (or the multiple of 4096 added to the Thing type, if you're still using SRB2DB) determines the ID number for a viewpoint or centerpoint, a value between 0 and 15. By default the game uses the viewpoint and centerpoint using ID 0. Note: this ID system does not apply to custom skybox mobjs set by Lua, only to `MT_SKYBOX` mobjs spawned by Things for a map.
* **Linedef type 448** has been added as a linedef executor special for changing the skybox viewpoint and/or centerpoint used, making use of the new ID system mentioned above:
 * By default, only the *viewpoint* will be changed. The front x offsets set the ID of the new viewpoint to use; if the number is out of range (numbers accepted are 0 to 15), the game will simply not use any viewpoint at all.
 * If the "*Block Enemies*" flag is set, the centerpoint will be changed as well. In this case the front y offsets set the new centerpoint ID to use.
 * If the "*Solid Midtexture*" flag is set, the viewpoint will **not** be changed at all. Combine this with Block Enemies to make the linedef type change only the centerpoint if needed (otherwise the linedef will do nothing lol).
 * By default, only the player who triggered the linedef will see the skybox being changed. If a player did not trigger the linedef executor directly, no change will be seen by anyone. If the "*Not Climbable*" flag is set, the skybox change will be "global", i.e. it will be seen by all players in the map.

In my folder on the FTP I've made a subfolder called "skybox improvements", and in it are the following files:
* srb2win-skyboximprov.exe - the test exe for this branch I've compiled myself
* skyboxchange-test.wad - an edit of my test map for my skybox change Lua script release on the MB, to test out the new skybox change linedef type.

See merge request !89
This commit is contained in:
Monster Iestyn 2017-05-01 14:38:33 -04:00
commit 1e59a807e4
5 changed files with 71 additions and 8 deletions

View File

@ -9717,11 +9717,10 @@ void P_SpawnMapThing(mapthing_t *mthing)
switch(mobj->type)
{
case MT_SKYBOX:
mobj->angle = 0;
if (mthing->options & MTF_OBJECTSPECIAL)
skyboxmo[1] = mobj;
skyboxcenterpnts[mthing->extrainfo] = mobj;
else
skyboxmo[0] = mobj;
skyboxviewpnts[mthing->extrainfo] = mobj;
break;
case MT_FAN:
if (mthing->options & MTF_OBJECTSPECIAL)

View File

@ -2276,6 +2276,17 @@ void P_LoadThingsOnly(void)
// Search through all the thinkers.
mobj_t *mo;
thinker_t *think;
INT32 i, viewid = -1, centerid = -1; // for skyboxes
// check if these are any of the normal viewpoint/centerpoint mobjs in the level or not
if (skyboxmo[0] || skyboxmo[1])
for (i = 0; i < 16; i++)
{
if (skyboxmo[0] && skyboxmo[0] == skyboxviewpnts[i])
viewid = i; // save id just in case
if (skyboxmo[1] && skyboxmo[1] == skyboxcenterpnts[i])
centerid = i; // save id just in case
}
for (think = thinkercap.next; think != &thinkercap; think = think->next)
{
@ -2293,6 +2304,10 @@ void P_LoadThingsOnly(void)
P_PrepareThings(lastloadedmaplumpnum + ML_THINGS);
P_LoadThings();
// restore skybox viewpoint/centerpoint if necessary, set them to defaults if we can't do that
skyboxmo[0] = skyboxviewpnts[(viewid >= 0) ? viewid : 0];
skyboxmo[1] = skyboxcenterpnts[(centerid >= 0) ? centerid : 0];
P_SpawnSecretItems(true);
}
@ -2728,6 +2743,9 @@ boolean P_SetupLevel(boolean skipprecip)
for (i = 0; i < 2; i++)
skyboxmo[i] = NULL;
for (i = 0; i < 16; i++)
skyboxviewpnts[i] = skyboxcenterpnts[i] = NULL;
P_MapStart();
P_PrepareThings(lastloadedmaplumpnum + ML_THINGS);
@ -2737,6 +2755,9 @@ boolean P_SetupLevel(boolean skipprecip)
#endif
P_LoadThings();
// skybox mobj defaults
skyboxmo[0] = skyboxviewpnts[0];
skyboxmo[1] = skyboxcenterpnts[0];
P_SpawnSecretItems(loademblems);

View File

@ -46,7 +46,9 @@
#include <errno.h>
#endif
mobj_t *skyboxmo[2];
mobj_t *skyboxmo[2]; // current skybox mobjs: 0 = viewpoint, 1 = centerpoint
mobj_t *skyboxviewpnts[16]; // array of MT_SKYBOX viewpoint mobjs
mobj_t *skyboxcenterpnts[16]; // array of MT_SKYBOX centerpoint mobjs
// Amount (dx, dy) vector linedef is shifted right to get scroll amount
#define SCROLL_SHIFT 5
@ -3159,6 +3161,47 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
}
break;
case 448: // Change skybox viewpoint/centerpoint
if ((mo && mo->player && P_IsLocalPlayer(mo->player)) || (line->flags & ML_NOCLIMB))
{
INT32 viewid = sides[line->sidenum[0]].textureoffset>>FRACBITS;
INT32 centerid = sides[line->sidenum[0]].rowoffset>>FRACBITS;
if ((line->flags & (ML_EFFECT4|ML_BLOCKMONSTERS)) == ML_EFFECT4) // Solid Midtexture is on but Block Enemies is off?
{
CONS_Alert(CONS_WARNING,
M_GetText("Skybox switch linedef (tag %d) doesn't have anything to do.\nConsider changing the linedef's flag configuration or removing it entirely.\n"),
line->tag);
}
else
{
// set viewpoint mobj
if (!(line->flags & ML_EFFECT4)) // Solid Midtexture turns off viewpoint setting
{
if (viewid >= 0 && viewid < 16)
skyboxmo[0] = skyboxviewpnts[viewid];
else
skyboxmo[0] = NULL;
}
// set centerpoint mobj
if (line->flags & ML_BLOCKMONSTERS) // Block Enemies turns ON centerpoint setting
{
if (centerid >= 0 && centerid < 16)
skyboxmo[1] = skyboxcenterpnts[centerid];
else
skyboxmo[1] = NULL;
}
}
CONS_Debug(DBG_GAMELOGIC, "Line type 448 Executor: viewid = %d, centerid = %d, viewpoint? = %s, centerpoint? = %s\n",
viewid,
centerid,
((line->flags & ML_EFFECT4) ? "no" : "yes"),
((line->flags & ML_BLOCKMONSTERS) ? "yes" : "no"));
}
break;
case 450: // Execute Linedef Executor - for recursion
P_LinedefExecute(line->tag, mo, NULL);
break;

View File

@ -17,7 +17,9 @@
#ifndef __P_SPEC__
#define __P_SPEC__
extern mobj_t *skyboxmo[2];
extern mobj_t *skyboxmo[2]; // current skybox mobjs: 0 = viewpoint, 1 = centerpoint
extern mobj_t *skyboxviewpnts[16]; // array of MT_SKYBOX viewpoint mobjs
extern mobj_t *skyboxcenterpnts[16]; // array of MT_SKYBOX centerpoint mobjs
// GETSECSPECIAL (specialval, section)
//

View File

@ -798,9 +798,7 @@ void R_SkyboxFrame(player_t *player)
viewx = viewmobj->x;
viewy = viewmobj->y;
viewz = 0;
if (viewmobj->spawnpoint)
viewz = ((fixed_t)viewmobj->spawnpoint->angle)<<FRACBITS;
viewz = viewmobj->z; // 26/04/17: use actual Z position instead of spawnpoint angle!
if (mapheaderinfo[gamemap-1])
{