dayZ Illuminant Tower Lighting

axeman

OpenDayZ Rockstar!
Yet another lights thread :cool: This one has the option to require a nearby Power Generator. You will need some additional base building or to add a generator in manually, on your server, as I haven't included the means to build the power generator. Without this option all the tower lights are lit within a range from the survivor.

Four lightpoints are created just above the corners of the top of the tower. The usual time option is available so the script only runs during the night, starting at dusk.

tower_lights_axeman.jpg


INSTALLATION

init.sqf
Code:
if (!isDedicated) then {
//TowerLights
[] execVM "lights\tower_lights.sqf";
};

Create a directory lights (or use existing one from other light scripts) and add:

tower_lights.sqf
Code:
//All rights reserved Andrew Gregory aka axeman [email protected]
waitUntil {!isNull player};
private ["_nrTowers","_rng","_nrPl","_lCol","_lbrt","_lamb","_twrCl","_stHr","_fnHr","_ndGen","_nrGen","_rngGen","_genCls","_doLit","_gnCnt"];
//Can edit these values
_rng = 1200; //Distance from survivor to detect towers.
_lCol = [1, 0.88, 0.73]; // Colour of lights on tower when directly looked at | RGB Value from 0 to 1.
_lbrt = 0.04;//Brightness (also visible distance) of light source.
_lamb = [1, 0.88, 0.73]; // Colour of surrounding (ambient) light | RGB Value from 0 to 1.
_twrCl = "Land_Ind_IlluminantTower";
_stHr = 17;//Hour (in 24 hours) to start lighting up tower
_fnHr = 6;//Hour (in 24 hours) to stop lighting up tower
_ndGen = false;//Require a Generator ? An entity, set by _genCls, must be within a radius (in metres), set by_rngGen, for the towerlights to be lit.
_rngGen = 1800;//Generator range (Generator must be within this radius from the tower for towerlights to be lit)
_genCls = "PowerGenerator_EP1";//Class name of generator (TEsted PowerGenerator_EP1 & PowerGenerator)
//End Edit Values
fnc_axeTl = compile preprocessFileLineNumbers "lights\fnc_tower_lights.sqf";
while {alive player}
do
{
    if(daytime<_fnHr||daytime>_stHr)then{
    _nrPl = vehicle player;
    _nrTowers = nearestObjects [_nrPl, [_twrCl], _rng];
        {
        _doLit=true;
            if(_ndGen)then{
            _nrGen = (position _x) nearEntities [_genCls,_rngGen];
            _gnCnt = count _nrGen;
                if(_gnCnt < 1)then{
                _doLit=false;
                };
            };
        [_lCol,_lbrt,_lamb,[_x],[_doLit]] call fnc_axeTl;
        }forEach _nrTowers;
    };
sleep .5;
};

In the same lights directory add:

fnc_tower_lights.sqf
Code:
private["_tl","_twr","_lCol","_lbrt","_lamb","_oset","_twrPos","_rad","_a","_b","_ang","_nrTLs","_doLit"];
_twr = _this select 3 select 0;
_lCol = _this select 0;
_lbrt = _this select 1;
_lamb = _this select 2;
_doLit = _this select 4 select 0;
_twrPos =  getPos _twr;
_rad=2.65;
_oset=14;
_nrTLs= position _twr nearObjects ["#lightpoint",30];
if(count _nrTLs > 3)then{
{
    if(_doLit)then{
    _x setLightColor _lCol;
    _x setLightBrightness _lbrt;
    _x setLightAmbient _lamb;
    }else{
    deleteVehicle _x;
    };
sleep .2;
}forEach _nrTLs;
}else{
    if(_doLit)then{
        for "_tls" from 1 to 4 do {
        _ang=(360 * _tls / 4)-_oset;
        _a = (_twrPos select 0)+(_rad * cos(_ang));
        _b = (_twrPos select 1)+(_rad * sin(_ang));
        _tl = "#lightpoint" createVehicle [_a,_b,(_twrPos select 2) + 26] ;
        _tl setLightColor _lCol;
        _tl setLightBrightness _lbrt;
        _tl setLightAmbient _lamb;
        _tl setDir _ang;
        _tl setVectorUp [0,0,-1];
        sleep .4;
        };
    };
};


AVAILABLE OPTIONS

You can change various options, they are available in tower_lights.sqf, as follows:
  • _rng (Range) | Distance from the survivor to look for towers.
  • _lCol (Colour) | Light colour.
  • _lbrt (Brightness) | Light brightness, this can also effect viewable distance.
  • _lamb (Ambience) | Surrounding ambient light colour.
  • _twrCl (Tower Class) | The class name of the tower to look for.
  • _stHr (Start Hour) | The hour (Game time) to start running the script.
  • _fnHr (FinishHour) | The hour (Game time) to stop running the script.
The last options are for the generator requirement:
  • _ndGen (Need Generator) | Require a generator to light up the towers
  • _rngGen (Generator Range) | The distance, from each tower, to look for a generator.
  • _genCls (Generator Class) | The class name of the generator you want to use, have tested: PowerGenerator_EP1 & PowerGenerator.
GENERATOR OPTIONS: If using this option you will require another means to add the generator, either a base building script or add them in manually on the server. I have notincluded the means to build a generator.

EDIT:This generator addon is currently being applied to the Epoch mod..



BATTLEYE
I am using my custom scripts.txt, I would make sure that fnc_tower_lights.sqf is filtered out for: createVehicle & deleteVehicle.

Enjoy..

>>OTHER DAYZ LIGHTING SCRIPTS: <<
 
Back
Top