From 95164cce5152b9eb0a60312e7cf923fc1e9c87ad Mon Sep 17 00:00:00 2001 From: "Dileep V. Reddy" Date: Sun, 18 May 2025 17:48:32 -0600 Subject: [PATCH] Exposed some skymist variables to zscript. Created zscript levellocals functions ChangeSkyMist(TextureID skymist, bool usemist = true), SetSkyFog(int density), and SetThickFog(float distance, float multiplier), so people aren't tied to MAPINFO for such things. --- src/gamedata/g_mapinfo.cpp | 4 +++- src/scripting/vmthunks.cpp | 28 ++++++++++++++++++++++++++++ wadsrc/static/zscript/constants.zs | 1 + wadsrc/static/zscript/doombase.zs | 7 +++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 8ee694878..c30fb4b0e 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -1588,7 +1588,9 @@ DEFINE_MAP_OPTION(thickfogmultiplier, false) { parse.ParseAssign(); parse.sc.MustGetFloat(); - info->thickfogmultiplier = (float)parse.sc.Float; + // [DVR] Negative multiplier does have a crazy saturated-white effect, like a nuke blastfront + // Could be useful for something some day + if ((float)parse.sc.Float > 0.0) info->thickfogmultiplier = (float)parse.sc.Float; } DEFINE_MAP_OPTION(pixelratio, false) diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 8db1e73ec..87a4858b2 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -1742,11 +1742,39 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset) { PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); PARAM_INT(skymist); + PARAM_BOOL(usemist); self->skymisttexture = FSetTextureID(skymist); + if (usemist) + { + self->flags3 |= LEVEL3_SKYMIST; + } + else + { + self->flags3 &= ~LEVEL3_SKYMIST; + } InitSkyMap(self); return 0; } + DEFINE_ACTION_FUNCTION(FLevelLocals, SetSkyFog) + { + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(fogdensity); + self->skyfog = fogdensity; + InitSkyMap(self); + return 0; + } + + DEFINE_ACTION_FUNCTION(FLevelLocals, SetThickFog) + { + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_FLOAT(distance); + PARAM_FLOAT(multiplier); + self->thickfogdistance = distance; + if (multiplier > 0.0) self->thickfogmultiplier = multiplier; + return 0; + } + DEFINE_ACTION_FUNCTION(FLevelLocals, StartIntermission) { PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index ba2598093..cf1140a10 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -1420,6 +1420,7 @@ enum ELevelFlags LEVEL3_LIGHTCREATED = 0x00080000, // a light had been created in the last frame LEVEL3_NOFOGOFWAR = 0x00100000, // disables effect of r_radarclipper CVAR on this map LEVEL3_SECRET = 0x00200000, // level is a secret level + LEVEL3_SKYMIST = 0x00400000, // level skyfog uses the skymist texture }; // [RH] Compatibility flags. diff --git a/wadsrc/static/zscript/doombase.zs b/wadsrc/static/zscript/doombase.zs index 4c5d4799c..185a27f2a 100644 --- a/wadsrc/static/zscript/doombase.zs +++ b/wadsrc/static/zscript/doombase.zs @@ -389,6 +389,7 @@ struct LevelInfo native native readonly String NextSecretMap; native readonly String SkyPic1; native readonly String SkyPic2; + native readonly String SkyMistPic; native readonly String F1Pic; native readonly int cluster; native readonly int partime; @@ -404,6 +405,7 @@ struct LevelInfo native native readonly int musicorder; native readonly float skyspeed1; native readonly float skyspeed2; + native readonly float skymistspeed; native readonly int cdtrack; native readonly double gravity; native readonly double aircontrol; @@ -496,8 +498,10 @@ struct LevelLocals native native readonly int musicorder; native readonly TextureID skytexture1; native readonly TextureID skytexture2; + native readonly TextureID skymisttexture; native float skyspeed1; native float skyspeed2; + native float skymistspeed; native int total_secrets; native int found_secrets; native int total_items; @@ -592,6 +596,9 @@ struct LevelLocals native native String GetChecksum() const; native void ChangeSky(TextureID sky1, TextureID sky2 ); + native void ChangeSkyMist(TextureID skymist, bool usemist = true); + native void SetSkyFog(int fogdensity); + native void SetThickFog(float distance, float multiplier); native void ForceLightning(int mode = 0, sound tempSound = ""); native clearscope Thinker CreateClientsideThinker(class type, int statnum = Thinker.STAT_DEFAULT);