EDIT 20120510: I have now released this as an addon called TPW_HOUSELIGHTS, no scripting necessary.
EDIT 20120516: Version 1.01 released. Addon version is configurable by HPP file.
EDIT 20120520: Version 1.03 released. Lights now flicker. 3 different fully configurable light sources. Lights are removed once player leaves the area.
EDIT 20120530: Version 1.07 released. Completely overhauled and optimised dynamic light code. Distant lights are now brighter, lights only flicker if close to the player.
EDIT 20120603: Version 1.08 released. Now comes in 2 flavours: SP (highly configurable dynamically calculated lights) and MP (precalculated lights, all players will see the same thing). Initialisation hint may now be configured off.
EDIT 20120604: SP addon version config error fixed -> v1.081. In other news, TPW will not be working at NASA any time soon.
EDIT 20120615: MP version config error fixed -> v1.081.
EDIT 20121020: Files now hosted on Dropbox, just the addon version for the time being.
McNools' recent magnificent Aliabad map has scaled the dizzy heights of realism as far as I'm concerned, and I've been playing it constantly lately. The immersive perfection of this map is only marred by the fact that ALICE2 won't light up Arrowhead houses at night. Which means that unless light sources are manually placed, every house and compound is pitch dark at night.
I know the region is meant to be poor, but you'd think they could at least burn a few candles or lanterns at night! To simulate this, I wrote a script which selects a percentage of all the enterable houses on the map and assigns the parameters of one of three not-too-bright light sources (ratios/colour/brightness/flickering are configurable) into each. These houses are periodically scanned, and any houses close enough to the player have a light source placed in them, using the parameters for each. Any houses outside the defined radius have their lights removed. Lights close enough to the player will flicker to simulate flames/tv's/dodgy electricity.
The effect is subtle but seeing a warm fllickering glow from houses really increases the sense that you're patrolling in an inhabited area.
TPW_HOUSELIGHTS, as I have egotistically labelled this system, will work on any map with ALICE2 enterable buildings. It simply ignores non enterable buildings, so you won't notice it do anything on Chernarus.
TPW_HOUSELIGHTS now comes in 2 versions
Version 1: Single player / dynamically calculated lights
This version allows lights to be dynamically calculated based on the various configuration options you provide.
- Works on any map. If there any enterable buildings on the map, they will be lit.
- Highly configurable light options: distance around player to light, light colour/brightness/ratio/flickering etc etc etc
- Can be configured to cause as much or as little stress to your CPU as you'd like
Every time the script initialises the player running the script will potentially see different lights.
Addon version: https://dl.dropbox.com/u/481663/TPW_...IGHTS_1081.zip 1.081 fixes a config error in this addon version.
Version 2: Multiplayer / precalculated lights
This version was written in response to those requesting a system for multiplayer, whereby all players running the script will see the same lights if they are at the same point on a given map. To do this, the lights for each house on the map have been precalculated for a number of commonly used maps:
- MP compatible without requiring network synchronisation of light sources
- All players see the same lights
- Yes it's a kludge fix to ensure MP uniformity in lieu of true network synchronisation of lights. See below disclaimer before complaining to me about it
- Out of the box the light configuration options are much more limited (intentionally, to ensure a "level playing field" as regards lighting). You trade flexibility for uniformity
- Light precalculations were performed using the default light parameters of tpw_houselights108. These might not be to everyone's taste.
- This version is quite a lot larger since it holds the light data for multiple maps
- Your preferred map may not be on the supported list of this release
Addon version: https://dl.dropbox.com/u/481663/TPW_...TS_1081_MP.zip
- The addon requires CBA to launch properly. If anyone knows of a way to convert a simple script into a PBO in a way that does not require CBA then I'd like to know about it.
- Neither the SP or MP version works on a dedicated server. The CPU and network overhead, and my coding inability, prevents me from implementing true network light source synchronisation in this version. DISCLAIMER: I don't play MP, and am not familiar with the concepts involved with running scripts from dedicated servers. You are welcome to look at the heavily commented code to see if there's a way to implement light source synchronisation from a dedicated server from the existing code base. I will do what I can, so in the mean time please don't hassle me about it unless you have help to offer
- Light sources don't seem to stress the engine too hard, but flickering light sources can. Default settings put lights into 30 or fewer houses near the player, with roughly 50% of them flickering. You may need to adjust the settings if you find your performance suffering.
This thread seems to have stimulated a few ideas on alternative implementations of house lighting systems. Think mine is crap? Then why not try:
- RogueTrooper's: http://forums.bistudio.com/showthrea...=1#post2151231
- Rockhount's: http://forums.bistudio.com/showthrea...=1#post2151875
I'm indebted to these guys for stimulating some further thoughts.
Here's what it looks like:
McLupo has kindly taken a couple of videos of 1.07 which show the flickering lights in action:
- Das Attorney, for originally showing me how to make PBO addons
- CarlGustaffa for the azimuth code
- Rydygier for the inspiration for the flickering code. Check out his incredible Rincewinder system http://forums.bistudio.com/showthrea...ht=rincewinder from which he kindly demonstrated/donated a magic (pun intended) flickering function.
- RogueTrooper for the improved code for determining enterable buildings
- Xeno for config and server help
- Demon Cleaner and Muzzleflash for code cleanup and optimisation tips
- Twistking for his excellent suggestions regarding synch-less uniformity of lights for MP
- BIS of course
- All of you who have given me feedback
Enjoy the dark!