Page 1 of 1

brighter maps

Posted: Wed Aug 09, 2023 9:59 pm
by Kappes Buur
What would be an easy way to make all maps in a multimap pwad brighter by a certain amount of brightness, instead of doing this one map at a time in an editor?

Re: brighter maps

Posted: Wed Aug 30, 2023 5:16 pm
by Kappes Buur
Anybody have some 'bright' idea how this could be done?

I tried various options but none work with specifying the value of brightness.
But then my programming skills are almost non-existing.

Re: brighter maps

Posted: Thu Aug 31, 2023 9:00 pm
by Xeotroid
This ZScript works:

Code: Select all

int im = Level.Sectors.Size(); //calling .Size() every loop iteration can get slow in my experience, and the Sectors array's size should be fixed
for(int i = 0; i < im; i++) {
	Level.Sectors[i].lightlevel += 128;
}
You can put it in an event handler's WorldLoaded() method and replace the constant with some table lookup (via Map) that stores what light value to add for each map. This looks pretty off as it loads up the Map<> on each level load, but putting the map and .Insert into a static handler would be overkill.

Code: Select all

class MyHandler : EventHandler {
	Map<string, int> LightShifts;
	
	override void WorldLoaded(WorldEvent e) {
		LightShifts.Insert("MAP01", 64);
		LightShifts.Insert("MAP02", -94);
		
		LightShifts.Get(Level.MapName);
		//if map name is not in the map, you get 0, meaning no change		
		int im = Level.Sectors.Size();
		for(int i = 0; i < im; i++) {
			Level.Sectors[i].lightlevel += amount;
		}
	}
}

Re: brighter maps

Posted: Tue Sep 05, 2023 8:41 am
by Kappes Buur
Xeotroid wrote: Thu Aug 31, 2023 9:00 pm This ZScript works:
.....
That is confusing to me.
I guess that needs to be imported into a pwad.

I was thinking more in line of a separate utility into which I can specify the pwad and the amount of brightness.

But thank you for responding.
Meanwhile I just do it map by map in UDB.

Re: brighter maps

Posted: Tue Sep 05, 2023 1:22 pm
by Caligari87
ZSCRIPT.txt

Code: Select all

class LightLevelBooster : EventHandler {	
	override void WorldLoaded(WorldEvent e) {
		int im = Level.Sectors.Size();
		for(int i = 0; i < im; i++) {
			int boost = int((256 - Level.Sectors[i].lightlevel) / 2);
			Level.Sectors[i].lightlevel += boost;
		}
	}
}
MAPINFO.txt

Code: Select all

GameInfo {
	AddEventHandlers = "LightLevelBooster";
}
Just put these two files into a pk3 or wad and load after your pwads. It boosts the light level of all sectors in a map by half the distance to the maximum (so a light level of 0 would be boosted to 128, a light level of 128 would be boosted to 192, 160 would become 208, etc.

Changing the divide by 2 to a larger number (like divide by 4) would make the boost less aggressive.

There's absolutely no reason to edit the light levels by hand.

8-)