Jump to content
Sign in to follow this  
tpw

TPW HOUSELIGHTS - automatic house light addon

Recommended Posts

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.

Introduction:

Hi all.

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.

Files (v1.08):

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.

Advantages:

  • 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

Disadvantages:

Every time the script initialises the player running the script will potentially see different lights.

Addon version: https://dl.dropbox.com/u/481663/TPW_HOUSELIGHTS_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:

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

Advantages:

  • MP compatible without requiring network synchronisation of light sources
  • All players see the same lights

Disadvantages

  • 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_HOUSELIGHTS_1081_MP.zip

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.
  • 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.

Alternatives:

This thread seems to have stimulated a few ideas on alternative implementations of house lighting systems. Think mine is crap? Then why not try:

I'm indebted to these guys for stimulating some further thoughts.

Visuals:

Here's what it looks like:

houselights.jpg

houselights2.jpg

McLupo has kindly taken a couple of videos of 1.07 which show the flickering lights in action:

Zargabad:

Aliabad:

Takistan:

Thanks:

  • 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/showthread.php?134360-RINCEWINDER-Combat-Effective-Magick-System&highlight=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!

Edited by tpw

Share this post


Link to post
Share on other sites

That looks great bro, I been playing the map nonstop, so will definitely use this for the night missions, thanks!

Share this post


Link to post
Share on other sites
Wow, awesome script!

Thanks Ice, that means a lot. It works nicely on Lingor too!

Share this post


Link to post
Share on other sites

Hello tpw!

I am very interested in your "house lights Simple script".

Unfortunately I have no idea how to run scripts at all. :386:

Would it be possible, to upload a short example mission within you did use the script?

Located in the great Aliabad-Region.

Then I could peek out how to run scripts at all .

Thanks for the script and for your help!

Share this post


Link to post
Share on other sites

That is really very nice indeed, works perfectly. Thank you very much for sharing.

Share this post


Link to post
Share on other sites

Good one tpw! :)

Maybe an explanation on how to activate the script for newcomers in the first post/readme would be good?

EDIT (How to):

- Start the editor, and put a unit on it. Add the below line into your units "init" field:

script = [] execVM "Simple_house_lights_script.sqf"

- Save the "mission", and when its saved you will get a mission folder - drop the script in that folder.

Start the mission again and voila.

Changed the above to an even simpler method.

Edited by Alex72

Share this post


Link to post
Share on other sites

Thanks everyone for the feedback. I put the script up just as a proof of principle not a fully finished polished product, so sorry to anyone who had trouble getting it to work. I'll post a more complete implementation shortly.

Share this post


Link to post
Share on other sites

OK I have added the more fully developed version to the first post. Happy night fighting!

Share this post


Link to post
Share on other sites

Stupid question, is it MP compatible?

Share this post


Link to post
Share on other sites

I'd definitely be interested in pbo version. Would it also be possible to configure it? E.g. radius in which houses are illuminated, time at which illumination starts/ends, type of illumination (static vs flickering flame), etc.

Share this post


Link to post
Share on other sites
Stupid question, is it MP compatible?

Yes it's working in MP.

Share this post


Link to post
Share on other sites
Jman;2147005']Yes it's working in MP.

Thanks.

Share this post


Link to post
Share on other sites
I'd definitely be interested in pbo version. Would it also be possible to configure it? E.g. radius in which houses are illuminated, time at which illumination starts/ends, type of illumination (static vs flickering flame), etc.

Some interesting points there domokun.

1 - It doesn't really matter about the radius, the engine seems to decide how far away to display the lights

2 - The script as is just works out if the sun is below the horizon, and turns on lights if so. So lights will come on at dusk and predawn, even when the sky is still light.

3 - I'm thinking about a flickering lightsource, just need to work out how to do it.

I will definitely make the pbo configurable.

Thanks for the input!

Share this post


Link to post
Share on other sites

Hello tpw!

I´m filled with wonder about your great idea!

It´s working perfectly and what an atmosphere...

Btw: A small error has crept in the "follow the player" script:

original: 0 = [] execvmv "tpw_houselights.sqf" - the underlined v is too much, i think?

Thx for the amazing work!

Best regards

McLupo

Share this post


Link to post
Share on other sites
Hello tpw!

I´m filled with wonder about your great idea!

It´s working perfectly and what an atmosphere...

Btw: A small error has crept in the "follow the player" script:

original: 0 = [] execvmv "tpw_houselights.sqf" - the underlined v is too much, i think?

Thx for the amazing work!

Best regards

McLupo

Thanks McLupo, I've edited the post.

Share this post


Link to post
Share on other sites

Wonderful script! Adds real atmosphere. Well done mate.

Have already put the initial script into my mission, but will sort the updated one this evening.

Share this post


Link to post
Share on other sites
Wonderful script! Adds real atmosphere. Well done mate.

Have already put the initial script into my mission, but will sort the updated one this evening.

Thanks Kremator, positive feedback from the experts is very good for my ego!

I hope to have a PBO version up soon.

Share this post


Link to post
Share on other sites

Hello tpw,

...me once again:cool:

At first; take your time!

Second, i want support your idea providing a pbo to the community, because after a preview about your

"simple house lights script" i´ve written, the german community at ArmA2Base would prefer the pbo.

Thank you one more time for this outstanding work!

Best regards

McLupo

Share this post


Link to post
Share on other sites

Hello tpw,

and you must be a workoholic ;)

I´m out of words, to discribe how much i appreciate your action!

It´s just great how do you provide the community...

Kudos to tpw!:icon_eek:

Before i get lost in high praises...thanks a lot

Cheers

McLupo

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  

×