Jump to content
Sign in to follow this  
tpw

tpw_houselights - automatic house lighting for Arma2 and Arma3

Recommended Posts

The recent release of Arma3 alpha has inspired me to end my 6 month break from Arma coding and see if I could port some of my mods over from Arma2. First cab off the rank is tpw_houselights. This small mod enables lights to automatically come on in enterable buildings around the player after dark. It will work on any map with ALICE2 compatible enterable buildings, and will simply ignore unenterable ALICE buildings. Sick and tired of villages being pitch black after dark? This addon will create a flickering glow from houses at night which greatly increases immersion.

tpw_houselights comes in 2 versions: a single player version which dynamically calculates lights and will work on any map on Arma2 or Arma3 with enterable buildings; and a multiplayer version with precalculated lights for Arma3 Stratis and a number of popular Arma2 maps. This version ensures that all players running the mod will see the same lights at the same locations. Both versions can be run as either an addon which affects all missions, or a script version which can be run from your own missions.

Please download below, and read the documentation with detailed installation notes, usage, caveats, thanks etc.

If you find any bugs or can suggest improvements, please let me know.

Single player download: http://dl.dropbox.com/u/481663/TPW_HOUSELIGHTS_109.zip

Single player documentation:

TPW HOUSELIGHTS
==========================

Version: 1.09
Released: 20130322
Authors: tpw
Requires: CBA (Arma2 or Arma3 specific version)
Runs on : Arma2, Operation Arrowhead, Combined Operations, Arma3 alpha

Changelog: 
----------
1.00 - initial release 20120510
1.01 - Can now be configured from hpp file. Lights are removed from houses after player leaves area.
1.02 - Not released
1.03 - Lights can flicker. 3 different light types, each fully configurable for brightness, colour and flickering. Miscellaneous improvements.
1.04-1.06 - Not released
1.07 - Total overhaul of code for true dynamic lights. Lights only flicker within a configurable distance of player to save CPU. Distant lights are brighter to compensate for limitations in lighting engine.
1.08 - Minor bugfixes, initialisation hint is configurable     
1.081 - Config bugfixes 
1.09 - Minor tweaks, Arma3 compatibility.

Summary:
--------
This addon causes lights to automatically come on in enterable buildings around the player after dark. It will work on any map with ALICE2 compatible enterable buildings, and will simply ignore unenterable ALICE buildings. Sick and tired of villages being pitch black after dark? This addon will create a flickering glow from houses at night which greatly increases immersion. 

How to use it:
--------------
Addon version: Extract the @TPW_HOUSELIGHTS modfolder to your preferred mod location, and call it via command line or mod launcher. You must also copy userconfig/TPW_HOUSELIGHTS/TPW_HOUSELIGHTS.hpp to your Arma2 or Arma3 userconfig/TPW_HOUSELIGHTS/TPW_HOUSELIGHTS.hpp. This config file can be edited to taste and is well commented, so it's easy to change appropriately. The addon version will work for any and every mission.

Script version: Copy @TPW_HOUSELIGHTS/scripts/tpw_houselights109.sqf to your mission folder, and call it from the init line of the player or the mission's init.sqf with 0 = [] execvm "tpw_houselights109.sqf"; 

How it works:
-------------
At startup the script scans all houses within a 20km radius of the player, and any enterable houses are placed into a houses array.
Each house in the array is then given its own set of lighting parameters, and a lit/unlit status. If the sun is below the horizon, then every 15 seconds the houses array is scanned, and any unlit house within the player's specified radius has a light source created using the lighting parameters associated with that house. Any lit house outside the radius has its light removed.

Shortcomings:
-------------
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.

The addon works in SP and MP (but not on a dedicated server). Owing to the various randomisation features of the script, different MP players may see different lights even if at the same location on the map. If you are playing MP and require all players to see the same lights at the same point on a map, then please use the MP version of this addon.  The CPU and network overhead, and my coding inability, prevents me from implementing true light source synchronisation. You are welcome to examine the heavily commented code to see if there is a way a dedicated server synchronised MP solution is achievable. 

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 around the player, with 5-6 of them flickering. You may need to adjust the settings if you find your performance suffering.

Feedback:
---------
I'm a shit coder and no doubt this can be improved. I would value any feedback and suggestions, so give me your 2 cent's worth on the BIS forum.

Thanks:
-------
*Das Attorney for showing me how to create PBO addons, and for general advice. 
*CarlGustaffa for his excellent azimuth code. 
*Rydygier for his inspiration to write my own flickering code.
*RogueTrooper for improved enterable building code.
*Xeno for config and server advice.
*Demon Cleaner and Muzzleflash for code optimisation and cleanup.
*Twistking for excellent suggestions re light source uniformity for MP.
*Foxhound for dedication to supporting the Arma modding community.
*As always, thanks to BIS for a fantastic piece of software, and for the incredible community on the BIS froum. 

Personal note:
--------------
Due to some significant personal difficulties I basically took a 6 month break from Arma, coding, and computers in general. I'd like to extend a special thank you to Ollem for continuing to work on and extend some of my other coding projects (TPWCAS especially) during this time, and for his support and belief in me. 

tpw

Multiplayer download: http://dl.dropbox.com/u/481663/TPW_HOUSELIGHTS_109_MP.zip

Multiplayer documentation:

TPW HOUSELIGHTS MP
==========================

Version: 1.09 MP
Released: 20130322
Authors: tpw
Requires: CBA (Arma2 or Arma3 specific version)
Runs on : Arma2, Operation Arrowhead, Combined Operations, Arma3 alpha

Changelog: 
----------
1.00 - initial release 20120510
1.01 - Can now be configured from hpp file. Lights are removed from houses after player leaves area.
1.02 - Not released
1.03 - Lights can flicker. 3 different light types, each fully configurable for brightness, colour and flickering. Miscellaneous improvements.
1.04-1.06 - Not released
1.07 - Total overhaul of code for true dynamic lights. Lights only flicker within a configurable distance of player to save CPU. Distant lights are brighter to compensate for limitations in lighting engine.
1.08 - Minor bugfixes, initialisation hint is configurable
1.08MP - Multiplayer compatible version with light parameters hard coded, so that all players will see the same lights at the same point on a map.     
1.09MP - Minor tweaks, Arma3 compatibility.

Summary:
--------
This addon causes lights to automatically come on in enterable buildings around the player after dark. It will work on any map with ALICE2 compatible enterable buildings, and will simply ignore unenterable ALICE buildings. Sick and tired of villages being pitch black after dark? This addon will create a flickering glow from houses at night which greatly increases immersion. 

How to use it:
--------------
Addon version: Extract the @TPW_HOUSELIGHTS_MP modfolder to your preferred mod location, and call it via command line or mod launcher. You must also copy userconfig/TPW_HOUSELIGHTS/TPW_HOUSELIGHTS.hpp to your Arma2 or Arma3 userconfig/TPW_HOUSELIGHTS/TPW_HOUSELIGHTS.hpp. This config file can be edited to taste and is well commented, so it's easy to change appropriately.

Script version: Copy @TPW_HOUSELIGHTS_MP/scripts/tpw_houselights109-mp.sqf to your mission folder, and call it from the init line of the player or the mission's init.sqf with 0 = [] execvm "tpw_houselights109-mp.sqf"; 

How it works:
-------------
Unlike the single player version of this script which dynamically calculates light parameters for any map each time it is initialised, this MP version has hard coded house and light parameters. These parameters are simply a (very large) array of arrays of position data for each house, with the lighting parameters for that house. Depending on the map, the appropriate array is processed and the final array of lightable houses generated for the script to use. Every player using this script will see the same lights at the same spot on the map. No synchronisation necessary. 

I've set it up with house data from some of the most common maps with enterable buildings:

Aliabad
Clafghan
Fallujah
Fayshkhabur
Hazarkot
Lingor
Qom
Sangin
Shapur
Stratis
Takistan
Tigeria
Torabora
Tropica
Zargabad

If you would like to add your own map or change the lighting parameters, then please use the script version: tpw_houselights-scan.sqf can be used to generate a lighting array for the map, which can then be pasted from the clipboard into tpw_houselights109-mp.sqf.

Or, please let me know via the BIS forum and I can add them into a future addon version.

Shortcomings:
-------------
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.

This version of the addon works in SP and MP (but not on a dedicated server). Because the randomisation of lights, brightnesses, colours and flickering has been precalculated, different MP players will see the same lights at the same location on the map. However, each player is required to run this addon inidividually. The CPU and network overhead, and my coding inability, prevents me from implementing true light source synchronisation. You are welcome to examine the heavily commented code to see if there is a way a dedicated server synchronised MP solution is achievable. 

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 around the player, with 5-6 of them flickering. This version of the addons does not easily allow changing of light parameters, in the interests of a uniform experience betwen players. If you require configuration, please either use the script version of this addon, or use the SP version.

Feedback:
---------
I'm a shit coder and no doubt this can be improved. I would value any feedback and suggestions, so give me your 2 cent's worth on the BIS forum.

Thanks:
-------
*Das Attorney for showing me how to create PBO addons, and for general advice. 
*CarlGustaffa for his excellent azimuth code. 
*Rydygier for his inspiration to write my own flickering code.
*RogueTrooper for improved enterable building code.
*Xeno for config and server advice.
*Demon Cleaner and Muzzleflash for code optimisation and cleanup.
*Twistking for excellent suggestions re light source uniformity for MP.
*Foxhound for dedication to supporting the Arma modding community.
*As always, thanks to BIS for a fantastic piece of software, and for the incredible community on the BIS froum. 

Personal note:
--------------
Due to some significant personal difficulties I basically took a 6 month break from Arma, coding, and computers in general. I'd like to extend a special thank you to Ollem for continuing to work on and extend some of my other coding projects (TPWCAS especially) during this time, and for his support and belief in me. 

tpw

My mods:

TPW CIVS: Ambient civs and traffic

TPW FALL: Realistic infantry falling from height and bullet hits

TPW LOS: AI Line of sight system for enhanced CQB

TPW EBS: Engine based AI/player suppression

TPW HOUSELIGHTS: Automatic house lighting

TPW BLEEDOUT: Realistic bleeding system

Edited by tpw

Share this post


Link to post
Share on other sites

This time my "before/after" shots aren't that good, but i have some good shots on buildings with good lightning and on some with still too dark lightning (in my opinion):

https://dl.dropbox.com/u/106806270/Saku%20Lights/original1.png

https://dl.dropbox.com/u/106806270/Saku%20Lights/houselight1.png

https://dl.dropbox.com/u/106806270/Saku%20Lights/original2.png

https://dl.dropbox.com/u/106806270/Saku%20Lights/houselight2.png

Good ones:

https://dl.dropbox.com/u/106806270/Saku%20Lights/houselightsgood1.png

https://dl.dropbox.com/u/106806270/Saku%20Lights/houselightsgood2.png

https://dl.dropbox.com/u/106806270/Saku%20Lights/houselightsgood3.png

Too dark ones:

https://dl.dropbox.com/u/106806270/Saku%20Lights/houselighttoodark1.png

https://dl.dropbox.com/u/106806270/Saku%20Lights/houselighttoodark2.png

https://dl.dropbox.com/u/106806270/Saku%20Lights/houselighttoodark3.png

Some general feedback:

Could you increase the lightstrength on the very dark buildings? And maybe you could set the lightning to a default position at the ceiling,

some building have their light, come out of the middle of a wall (i.e. houselighttoodark1.png).

Share this post


Link to post
Share on other sites

There is a general problem with lighting still in ArmA3 (IMO) that will probably fix a lot of things like this. Darkest night is not too bad, but anywhere close to dusk or dawn and the lighting engine acts inconsistently.

Share this post


Link to post
Share on other sites

Thanks for the kind words and feedback gents, I knew there was a reason why I liked Arma coding!

@Predator.v2, thanks for the screenshots. I will try to take a few of my own shortly, at the moment my priority is just getting it working and online. DMarkwick is correct, there are significant differences between the lighting engines of A2 and A3. Houselights generally appear brighter throughout evening-night-predawn in A2, and can appear quite faint during the evening and predawn in A3. Until the A3 lighting engine is finalised I don't see much point trying to compensate. Regarding lights in individual houses: basically every house has a light placed inside 1.5m off the floor. For most houses this is good enough, provided you don't ask yourself where the lamp or candle is. For some houses the light is not centered properly. Adjusting the lighting on a per house basis could potentially be done but would be a simply enormous job since there are so many house models.

Share this post


Link to post
Share on other sites

If i may comment on those picture posted by predator.

first off those lights that seem really dim are the "candle" simulation.. "Candles" are not that bright ... I personally think that the candle Sim is very accurate. I say again, candles are not bright... remember that this simulates "candle", "incandescent", and "Television" light.. the Incandescent light will most likely be the brightest...

A lot of the light sources appear at eye level... however, would probably cause the light to bleed out from walls more then usual if moved around.

Would it be possible to look for houses that have a certain amount of positioning available and maybe have two lights if its a "candle"? Ie two story house. or a large building like an appt. etc.

Share this post


Link to post
Share on other sites

@Lordprimate. Firstly, thanks for inspiring me to finally release the A2&A3 version of the mod, and for showing up on this thread to keep helping out!

I should give you a bit of background to put the lighting into perspective. When I initially wrote the mod I was simply trying to recreate the ambient house lighting effect as seen in Arma2, where lights would randomly appear in the windows of the mostly non-enterable buildings on Utes and Chernarus. I tend to not play CQB style, and was happy just to see lights in buildings as I ran around outside at night. Once you actually enter the buildings there's a lot of suspension of disbelief that has to happen because there's no visible light source. I tried placing lights closer to ceilings but found that the light just bled through to outside and looked even worse. Because most OA maps tended to be poorer desert/central asian with lots of small mud huts, I went for a single light per hut, rather than trying to realistically place multiple sources into each dwelling.

So what you are seeing is a bit of a compromise at the moment. I can certainly look into placing additional lights in buildings with more buildingpositions. In the mean time, it's easy enough to change the lighting parameters for increased brightness, fewer candles etc.

Share this post


Link to post
Share on other sites
Guest

Release frontpaged on the Armaholic homepage.

As discussed I made different pages for the Arma 2 and the Arma 3 versions. Both pages show the same info except for Arma 2 or Arma 3 specific info. The pages also link to the correct CBA version to use.

Edited by Guest
fixed news link

Share this post


Link to post
Share on other sites

Nice to see you back tpw! This combined with Sakura_Chan's work may just be what the doctor ordered... will test tomorrow!

And also thanks to our own Foxhound for hosting the files :)

/KC

Share this post


Link to post
Share on other sites

might want to put a lamp or lightbulb object at the source of these lights.

Share this post


Link to post
Share on other sites
might want to put a lamp or lightbulb object at the source of these lights.

Perfectly doable, except that the lamp would be floating in mid air. I'm not sure how to write a function that would place the lamp at ceiling height (and in any case the light would just bleed through).

Share this post


Link to post
Share on other sites
Perfectly doable, except that the lamp would be floating in mid air. I'm not sure how to write a function that would place the lamp at ceiling height (and in any case the light would just bleed through).

So long as it's not that far away from the wall that would be ok. A lightbulb hanging from the ceiling would be ok, the wall mounted/fluorescent style ones on the other hand...

Share this post


Link to post
Share on other sites

tpw, i have a question about your new release, about the flickering, and how to adjust it?

in the older version the flickering was set in the param's for the light. I was wondering if it would be possible to change the param's for the effects of the lights?

This was my setup :

_candle = [255,127,24,50,25,100,80];//candles flicker rapidly most of the time, are not bright

_incan = [255,200,100,100,80,5,5];//bright full light mostly flicker free

_tv = [100,200,255,80,60,100,80];//flickers, fairly bright

These settings looked just amazing at night the lights came alive. Is there any way to get this level of control again?

Edited by Lordprimate

Share this post


Link to post
Share on other sites
tpw, i have a question about your new release, about the flickering, and how to adjust it?

in the older version the flickering was set in the param's for the light. I was wondering if it would be possible to change the param's for the effects of the lights?

This was my setup :

_candle = [255,127,24,50,25,100,80];//candles flicker rapidly most of the time, are not bright

_incan = [255,200,100,100,80,5,5];//bright full light mostly flicker free

_tv = [100,200,255,80,60,100,80];//flickers, fairly bright

These settings looked just amazing at night the lights came alive. Is there any way to get this level of control again?

LP I never removed any control, depending on the version you are using you have full access to all those parameters to get the light settings you enjoy.

Which version are you using? SP or MP, script or addon?

If you are using the MP addon version then the lights are hard coded in with the following settings

_candle =[255,127,24,60,30,80,10]; // warm yellow/orange (candle or fire)
_incan = [255,200,100,80,40,20,5]; // yellow/white (incandesecent)
_tv = [100,200,255,60,30,100,30]; // blue/white (television or fluorescent)
_ratio = [4,2,1]; // ratio of candle:incan:tv

If you want to change them in the script version then you'll need to run tpw_houselights-scan.sqf for your map, using your settings:

_candle = [255,127,24,50,25,100,80];//candles flicker rapidly most of the time, are not bright 
_incan = [255,200,100,100,80,5,5];//bright full light mostly flicker free
_tv =  [100,200,255,80,60,100,80];//flickers, fairly bright 

and then paste from the clipboard back into tpw_houselights109-mp.sqf

In the SP version you can edit either the TPW_HOUSLIGHTS.cpp if using the addon version :

TPW_CANDLE[] = {255,127,24,60,20,80,10}; //Warm yellow/orange flame
TPW_INCAN[] = {255,200,100,60,20,20,5}; //Yellow white incandescent or lantern
TPW_TV[] = {100,200,255,60,20,100,30}; //Blue/white television
TPW_RATIO[] = {4,2,1}; //Ratio of candle:incan:tv

or these lines in tpw_houselights109.sqf if you want to use the script version:

_candle =[255,127,24,60,30,80,10]; // warm yellow/orange (candle or fire)
_incan = [255,200,100,80,40,20,5]; // yellow/white (incandesecent)
_tv = [100,200,255,60,30,100,30]; // blue/white (television or fluorescent)
_ratio = [4,2,1]; // ratio of candle:incan:tv

And just for your reference, here is the blurb from the config

LIGHT-TYPE VALUES
Light-type will be picked at random.
Each individual light array consists of: [red,green,blue,maximum brightness,minimum brightness,%chance of flickering,%brightness to flicker]
Example: [255,127,24,60,30,80,10] = warm yellow, brightness between 30-60, 80% chance of flickering, 10% brightness variation when flickering 
Red, green and blue values are 0-255
Brightness values are 0-255
Flickering values are 0-100
Light sources don't really stress the engine, but flickering lightsources can.
If you want no flickering, set all %chance of flickering values to 0.

Edited by tpw

Share this post


Link to post
Share on other sites

ok i must have passed over something or been looking at the wrong file or something .. Thanks a bunch!!

Share this post


Link to post
Share on other sites

TPW, we always use your script! But like the others say the default version is quite dark. I ported the old 1.08 version for myself some time ago and changed a few things. There are two new light commands (or more) that affect how the cone of the light looks, also the attenuation of the light.

With these values I think I found a pretty nice setup for lights. Note that I do not use flicker and I also ignore the different light settings such as color and different brightness. The brightness will differ anyway since the reflection on surfaces makes light more or less bright. White walls will make the room much brighter than brown walls, using the same settings for both lights.

_lp setLightColor [1,0.784314,0.392157]; //Color
_lp setLightBrightness 0.05; // Set its brightness
_lp setLightIntensity 10; //How bright is the light
_lp setLightAttenuation [2, 1, 1, 20]; //[Range, Constant (0.0 = bright and higher value dims), Linear (fade quick with distance!), range (change brightness when out of distance)

Share this post


Link to post
Share on other sites

So for the multiplayer version, as long as the host is running the mod, everyone will see the same lights? Or does everyone connected have to have the mod?

Share this post


Link to post
Share on other sites

I totally understand. No one should be complaining haha. Good job on this mod I like it!

Share this post


Link to post
Share on other sites

Thanks for the addon!

unfortunately, I saw it load once in stratis,

but later, after reloading ARMA again it stopped working for although it is loaded (Hint is loaded).

I use it with Saku lightsfx (also tried without) and selected 100% of houses lighted.

strange thing is that with NV on I can see as if the lights inside a house are lit, but removing NV - pitch dark.

Any ideas??

Thanks!

Share this post


Link to post
Share on other sites

It seems to be a bug in the A3 lighting at this stage. Start an editor mission at 2030 and it will be pitch black, even the streetlights are barely visible. Start a mission at 0100 and everything looks great and well lit.

Thanks for the addon!

unfortunately, I saw it load once in stratis,

but later, after reloading ARMA again it stopped working for although it is loaded (Hint is loaded).

I use it with Saku lightsfx (also tried without) and selected 100% of houses lighted.

strange thing is that with NV on I can see as if the lights inside a house are lit, but removing NV - pitch dark.

Any ideas??

Thanks!

---------- Post added at 06:38 ---------- Previous post was at 06:37 ----------

So for the multiplayer version, as long as the host is running the mod, everyone will see the same lights? Or does everyone connected have to have the mod?

It's client side only, so everyone playing will need the mod.

---------- Post added at 06:46 ---------- Previous post was at 06:38 ----------

TPW, we always use your script! But like the others say the default version is quite dark. I ported the old 1.08 version for myself some time ago and changed a few things. There are two new light commands (or more) that affect how the cone of the light looks, also the attenuation of the light.

With these values I think I found a pretty nice setup for lights. Note that I do not use flicker and I also ignore the different light settings such as color and different brightness. The brightness will differ anyway since the reflection on surfaces makes light more or less bright. White walls will make the room much brighter than brown walls, using the same settings for both lights.

_lp setLightColor [1,0.784314,0.392157]; //Color
_lp setLightBrightness 0.05; // Set its brightness
_lp setLightIntensity 10; //How bright is the light
_lp setLightAttenuation [2, 1, 1, 20]; //[Range, Constant (0.0 = bright and higher value dims), Linear (fade quick with distance!), range (change brightness when out of distance)

Good stuff mate. If you PM me with the code I will see about implementing it (if you'd like to share).

The A3 lighting engine is a little strange at this point, and I hope it changes. Late at night the lights seem quite bright. Earlier in the evening everything can seem very dark. I tried experimenting with a Stratis variable which doubles the brightness of lights for this map, but then they seem too bright at certain times of night...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×