dayZ Illuminant Tower Lighting (Power Generator Option)

axeman

OpenDayZ Rockstar!
Another lights thread 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 not included the means to build a generator..

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

Enjoy..
 
Very cool! Will test it out for sure, good as always! Do you have a method of placing the lights or are they attached/placed on certain coordinates? I would love to add lights in custom spots, haven't looked through your other code much.. I can figure this out on my own, but I was just wondering what you use when setting this all up
 
Very cool! Will test it out for sure, good as always! Do you have a method of placing the lights or are they attached/placed on certain coordinates? I would love to add lights in custom spots, haven't looked through your other code much.. I can figure this out on my own, but I was just wondering what you use when setting this all up
in fnc_tower_lights.sqf there is a variable _rad, this is the radius of the circle where the lights are placed, they are placed at 45, 135, 225 and 315 degrees, the 'corners'. have added an offset (_oset) as the tower model seems to be slightly off.. These could be changed. To test add
Code:
_test = createVehicle ["Rabbit", [_a,_b,(_twrPos select 2) + 26], [], 0, "CAN_COLLIDE"];
after the lightpoint creation, this will add a rabbit at the lightpoint position so you can see where they are. The rabbit will fall to the ground but gives a good indicati0n. Essentially, the lightpoints are relative to the tower position rather than being attached to it..

There is also a height setting, the +26 on the z axis sets the lightpoints 26m above the centre of the model, this can be edited also to change the height of the lights.

Have found it is best to have them a bit above the eye level of the player when player is not in a vehicle. Have set the lights to point directly down to avoid glare..

Using these tweaks lights could be created for castle towers (as above) I would experiment with positioning, placing inside walls / floors does seem to help with the glare sometimes.
 
Cool stuff :)

There are portable generators you can find in Epoch....do you know if those can be used for this?

edit: I'm guessing I could just add whatever class that portable generator is to _genCls
 
Cool stuff :)

There are portable generators you can find in Epoch....do you know if those can be used for this?

edit: I'm guessing I could just add whatever class that portable generator is to _genCls
So long as they can be placed properly. I have added the portable generator spawn item to my server, on the ground though it shows as a 'dummy weapon', am guessing this is the default loot object..

Is why I went for the power generator as it has it's own class, even then I couldn't find it with nearestObject, I had to use nearestEntites.. (Not tested nearestEntities with the personal generator loot item, might be worth trying)..

EDIT: Just tested nearestEntities on the itemGenerator / dummy weapon, doesn't find it..
 
Nice work again axeman, thanks for your work! i will be adding a lot of these to our Celle server very soon :D
 
Ended up just using the normal power generator for now, will test with the portable generator some other time. Looks pretty good though :)

towerlights2.png
 
AXEMAN DOES IT AGAIN. You sir, are brilliant. Looking to add these plus the generators to my be building catalog.
 
Thx!!!
Exactly what weve searched for around the last 2 months....
But where can i add the portable generator , if i do this on the editor i fail with an error msg on editor.

Galaxy S2 using tapatalk


Btw my next olsha airport update will include a part from the cod containermap with a drone over it :eek:
 
I now have this working through Base Building, adding the Generator within 250M activates the Tower. It's a GREAT addition to my already huge recipe book. Big thumbs up Axe
 
I was wondering if there is a way you can add parts that can be damaged to the power generator?

My thoughts are that you would need an engine, 6 tires (or number of tires on the generator) and 2 pieces of scrap to get it fully working... Like it would still work fine if the engine was green but if it were say yellow the lights may flicker or some wouldn't turn on at all and if it were red the lights would just shut off all together.

I dont kow how hard it would be to script something like this
 
I was wondering if there is a way you can add parts that can be damaged to the power generator?

My thoughts are that you would need an engine, 6 tires (or number of tires on the generator) and 2 pieces of scrap to get it fully working... Like it would still work fine if the engine was green but if it were say yellow the lights may flicker or some wouldn't turn on at all and if it were red the lights would just shut off all together.

I dont kow how hard it would be to script something like this
working on fuel for generators and incorporating all the lights into one script. Will look at parts also.
 
No apparent error, I host the server at dayz.st,
isla Duala map:
right click on the map (dayz.st)
-> "Up vehicle" ---> "custom object" ---> Land_Ind_IlluminantTower
-> "Up vehicle" ---> "custom object" ---> PowerGenerator_EP1
-> "Up vehicle" ---> "custom object" ---> PowGen_Big

When in doubt I put two different and scripts that you notify highest

dayz_1_isladuala.pbo (219 KB)
https://mega.co.nz/#!eI51hbQA!N8O6FDFyIlzbKCk2r8Ci00EacaMMPcwj29Nnt8H9dzY
dayz_server.pbo (55 KB)
https://mega.co.nz/#!KUJWQDxZ!fo3ygEk8TJ8UJxWw14N_4QpbysBxu5PnE5CH75EVvoE

Server working but no lights
 
I used the mini map from control panel dayz.st


because nobody answers I deduce that this is not the right solution
 
Back
Top