vbawol/DayZ-Epoch — pull request #532 by andgregor (2013-09-08 00:08:04+00:00)
Title: Latest Additions to Lights

Changes / Updates:

Fixed light deletion, now deletes at full range. Moved options to init.sqf.

Added new options to allow server admins to edit. Added random element to light creation - Houses will remember if they have failed to create a light, street lights will eventually all light up in the area if the player hangs around, tower lights not included in the randomness.

Streetlights and houses will be reset if generator switched off (with generator requirement). This means the randomness will start again for them.

Added random light failure (for house lights only) Lights flicker and go out, if a generator is put down you may see house lights flickering before the generator is started, is a bug but does add a spooky effect and is rarely seen.

Options:

in the init.sqf the lights function is now called with (a couple of examples):

//Lights - Without Generator
[17,6,true,true,true,false,42,450,600,10,[0.80, 0.74, 0.57],"Generator_DZ"] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";

//Lights - With Generator
[17,6,true,true,true,true,42,250,600,10,[0.698, 0.556, 0.419],"Generator_DZ"] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";

The variables (in order):

Start time in 24hr
Finish time in 24hr
Do House Lights ?
Do Street Lights ?
Do Tower Lights ?
Generator Required for Lights ?
Chance (out of 100) if light will work (is randomised individually for each light creation)
Range from Generator or Player to light objects eg. houses, steetlights
Range from player to search for generators (Not used if generator not required - Code reverts to using above range to light objects at that distance from the player)
Trigger Distance (NOT USED CURRENTLY) - The idea is to only trigger the code if the player has moved this distance, need to work a way to skip this if the player starts the generator and doesn't move..
Array for light colour for houses and street lights, towers are white, just because.. Am going with a whiter shade of rust.
Generator Class - Class of object that must have a variable of GeneratorRunning set to true to trigger the lights (if generator required). Technically any object could be used as a 'generator' so long as it has the variable set..

Essentially, with generator requirement, you want the search range to be large enough to encompass the range that lights will come on from the generator. If no generator requirement then the first range can be increased as the code will just light everything that distance from the player.

There is a balance of how far to look against how long it will take to light those objects, is why the generator option is superior as the player can look for 1500m for the odd generator and by the time they reach the lit area all the lights will be on..