CVar:
Code: Select all
user bool dk_color = true;
user int dk_low = 65;
user int dk_med = 129;
user int dk_hi = 225;
user float dk_step = 1.5;
Code: Select all
class darker_EventHandler : EventHandler
{
static const string texname[] =
{
"TLITE6_5", // red
"BLOOD1",
"BLOOD2",
"BLOOD3",
"TLITE6_1", // yellow
"TLITE6_4",
"TLITE6_6",
"NUKAGE1", // green
"NUKAGE2",
"NUKAGE2",
"LAVA1", // orange
"LAVA2",
"LAVA3",
"LAVA4"
};
static const string hexcolor[] =
{
"#ff0000", // red
"#ff0000",
"#ff0000",
"#ff0000",
"#ffff00", // yellow
"#ffff00",
"#ffff00",
"#00ff00", // green
"#00ff00",
"#00ff00",
"#ff8c00", // orange
"#ff8c00",
"#ff8c00"
};
override
void WorldLoaded(WorldEvent e)
{
int FLOOR = 0;
int CEILING = 1;
TexMan texture;
int dk_low = Cvar.FindCvar("dk_low").GetInt();
int dk_med = Cvar.FindCvar("dk_med").GetInt();
int dk_hi = Cvar.FindCvar("dk_hi").GetInt();
double dk_step = Cvar.FindCvar("dk_step").GetFloat();
Array<int> darker;
// fill darker array
for(int i = 0; i < Level.Sectors.Size(); i++)
{
int lightlevel = Level.Sectors[i].lightlevel;
int minadjacent = Level.Sectors[i].FindMinSurroundingLight(dk_hi);
int lightstep = lightlevel < dk_low ? 32 : lightlevel < dk_med ? 16 : lightlevel < dk_hi ? 8 : 0;
int newlightlevel = minadjacent < lightlevel ? lightlevel - (lightstep * dk_step) : lightlevel - lightstep;
darker.Push(newlightlevel);
}
// apply light levels and colors
for(int i = 0; i < Level.Sectors.Size(); i++)
{
Level.Sectors[i].SetLightLevel(darker[i]);
if (Cvar.FindCVar("dk_color").GetBool())
{
textureid floorid = Level.Sectors[i].GetTexture(FLOOR);
textureid ceilingid = Level.Sectors[i].GetTexture(CEILING);
string text_floor = texture.GetName(floorid);
string text_ceiling = texture.GetName(ceilingid);
for (int ii = 0; ii < texname.Size(); ii++)
{
if (text_floor == texname[ii] || text_ceiling == texname[ii])
{
Level.Sectors[i].SetColor(hexcolor[ii]);
break;
}
}
}
}
}
}
While structures can be defined, they can't be used as a dynamic array type that I can see, hence clunky dual arrays. This also crudely subtracts light. At this stage there's nothing fancy about it. I'm not competing with the excellent DarkDoomZ. I just wondered, What if the dark got darker? without completely changing the feel of a level. It's possible to add fog e.g. green fog for nukage, and I believe to add color based on sidedef textures. Still pondering.
Update 11/12/21:
Spoiler:Screenshots:
The dark gets darker.
https://i.postimg.cc/nrSZnw6V/Screensho ... 103521.png
With added colors.
https://i.postimg.cc/zDxqwVVm/Screensho ... 103535.png
https://i.postimg.cc/QxVhfhTF/Screensho ... 103648.png
Update 11/13/21
Spoiler: