Jump to content

Photo
- - - - -

TPW HOUSELIGHTS - automatic house light addon


  • Please log in to reply
140 replies to this topic
Thread Starter
tpw
tpw

    Warrant Officer

  • Members
  • 2452 posts

#1

Posted 08 May 2012 - 12:02

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.c...LIGHTS_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.c...HTS_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:
Posted Image

Posted Image

McLupo has kindly taken a couple of videos of 1.07 which show the flickering lights in action:
Zargabad:
Aliabad:
Takistan: http://www.youtube.com/watch?feature=youtube_gdata&v=J8VrnmY2AiU&gl=DE

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.bistud...ght=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, 20 October 2012 - 00:17.


icebreakr
icebreakr

    Captain

  • Members
  • 6207 posts

#2

Posted 08 May 2012 - 12:10

Wow, awesome script!

IceBreakr, C/O [SBP] - Slovenian Black Panthers (www.vojak.si)

OUT NOW for A3: Isla Duala 3.35 | Island Panthera v3.1
WIP: Isla Abramia, Lingor, Tonal Legend, Isla Balkania, Keystone, Jade Groove 3, Ibis World, Rowalla.

sigbif.jpg


katipo66
katipo66

    Warrant Officer

  • Members
  • 2589 posts

#3

Posted 08 May 2012 - 12:23

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

Thread Starter
tpw
tpw

    Warrant Officer

  • Members
  • 2452 posts

#4

Posted 08 May 2012 - 13:14

Wow, awesome script!


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

foxhound
foxhound

    Retired Moderator

  • Members
  • 11346 posts

#5

Posted 08 May 2012 - 18:13

Great little scripts like this deserve more attention :)

Release frontpaged on the Armaholic homepage.

Posted Image
Simple house lights script


Edited by Foxhound, 09 May 2012 - 09:25.
updated with "follow player" version

Visit Armaholic.com | Visit Carriercommandaholic.com
Posted Image
Public FTP available, just check the Armaholic.com FAQ.

HMM........wonder what it is huh?

kremator
kremator

    Major

  • Members
  • 7519 posts

#6

Posted 08 May 2012 - 19:52

Works very well .... thanks mate !

Pantheraguy
Pantheraguy

    Private

  • Members
  • 10 posts

#7

Posted 08 May 2012 - 20:21

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!

Orcinus
Orcinus

    Sergeant Major

  • Members
  • 1571 posts

#8

Posted 08 May 2012 - 20:26

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

Alex72
Alex72

    Moderator

  • 5101 posts

#9

Posted 08 May 2012 - 20:32

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, 08 May 2012 - 20:55.

Posted Image

Pantheraguy
Pantheraguy

    Private

  • Members
  • 10 posts

#10

Posted 08 May 2012 - 21:03

Yeaai!
Thanks Alex72.
Manage to use it now!
[execVM Very Happy!] :o

Thread Starter
tpw
tpw

    Warrant Officer

  • Members
  • 2452 posts

#11

Posted 08 May 2012 - 22:09

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.

Thread Starter
tpw
tpw

    Warrant Officer

  • Members
  • 2452 posts

#12

Posted 09 May 2012 - 09:15

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

Mersu
Mersu

    Lance Corporal

  • Members
  • 49 posts

#13

Posted 09 May 2012 - 10:17

Stupid question, is it MP compatible?

domokun
domokun

    Sergeant Major

  • Members
  • 1731 posts

#14

Posted 09 May 2012 - 11:03

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.

-KH-Jman
-KH-Jman

    First Sergeant

  • Members
  • 861 posts

#15

Posted 09 May 2012 - 11:56

Stupid question, is it MP compatible?


Yes it's working in MP.
[KH]Jman - Kellys Heroes ArmA Clan Leader
Posted ImageDedi Server Guide | PersistentDB
Posted Image
Posted ImagePosted ImagePosted Image

Mersu
Mersu

    Lance Corporal

  • Members
  • 49 posts

#16

Posted 09 May 2012 - 12:59

Jman;2147005']Yes it's working in MP.

Thanks.

Thread Starter
tpw
tpw

    Warrant Officer

  • Members
  • 2452 posts

#17

Posted 09 May 2012 - 13:01

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!

McLupo
McLupo

    Sergeant

  • Members
  • 206 posts
  • LocationRight behind you

#18

Posted 09 May 2012 - 13:14

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

Author of : MLI (Marks, Labels and Insignia)German Hind

f6fyn7pi.jpgfxo9jn2z.pngibvdfvq6.png

Show respect to all modders and mission makers working for free!

____________________________________________

Intel I7-4790K@4.5/Corsair Hydro/Gigabyte GTX980/16GB G.E.I.L.


Thread Starter
tpw
tpw

    Warrant Officer

  • Members
  • 2452 posts

#19

Posted 09 May 2012 - 13:56

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.

kremator
kremator

    Major

  • Members
  • 7519 posts

#20

Posted 09 May 2012 - 14:46

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.