Working House Lighting

I see, will get the map loaded up later and have a look. Have done some more work on the script. Put your landing lights in chernarus, they do glow on their own.

Market stalls might work well with some flickering candle(s) lighting, might have to dismantle the fire to see how they do that for the best method.

Also, has been mentioned in this thread, two types of light, a brighter one for eg. Supermarkets, and a dimmer yellowy light for industrial, military.

Family day today, will get on it tonight..
 
Very much appreciated, toss me your paypal whenever your done and ill toss you 5 or 10 for the effort, I know Namalsk is a bit difficult to work around, but your addition would obviously be greatly appreciated.
 
Here is the updated version of the House Lighting Mission for dayZ:
Code:
//House / Building / Object Lighting for dayZ by axeman
while {alive player}
do
{
    if(daytime<6||daytime>17)//EDITABLE - Change the stop and start times for the script. No need to create lights in the day. If server set to Static time then assume time is 12.
    then { 
    private ["_strMessage","_brightness","_objLightPoint","_awayx","_awayy","_lp","_test","_hcount","_animlightpoint","_switching","_switchpercent"];
    //
    //VARIABLES
    //
    //These can be edited to change the behaviour and style of the lighting.
    //
    //_range | Distance to scan for buildings / houses in metres.
    _range=600;
    //_switchpercent | Percentage for reliability of power supply. eg. 65 will be 65% chance of lights coming on in each house (for lit house a 65% chance of second lights coming on if house has them) and 35% chance that lights will fail and flicker off.
    _switchpercent = 85;
    // _objHouse | The array of houses, generally non enterable, that have windows that light up. Add more custom buildings within the square brackets []. Must be contained in double quotes and separated by a comma.
    // House lighting does a special check to see if there is a window that is lit up before creating the ambient light point. Check the building config and ensure your house has a class of 'Lights_1' before adding here. If not sure use one of the next arrays (Industrial or Misc)
    _objHouse = nearestObjects [player, ["House","Land_HouseV_1I2"], _range];
    // _houseColour | Set the colour for the house lighting
    _houseColour=[1, 1, 1];
    // _objIndustrial | The array of industrial buildings to add a light source to. Add more custom buildings within the square brackets []. Must be contained in double quotes and separated by a comma.
    // No checks are done on this beyond looking for an existing lighpoint and animating that. Add any object here to emit an industrial light..
    _objIndustrial = nearestObjects [player, ["Land_Shed_wooden","Land_Ind_Garage01","Land_Ind_Workshop01_01","Land_Ind_Workshop01_02","Land_Ind_Workshop01_03","Land_Ind_Workshop01_04","Land_Ind_Workshop01_box","Land_Ind_Workshop01_L","Land_stodola_old_open","Land_stodola_open"], _range];
    //_indColour | Set the colour for the industrial building lighting
    _indColour=[1, 1, 0]; 
    // _objMisc | The array of misc. objects to add a light source to. Add more custom buildings within the square brackets []. Must be contained in double quotes and separated by a comma.
    // No checks are done on this beyond looking for an existing lighpoint and animating that. Add any object here to emit an misc light..
    _objMisc = nearestObjects [player, ["Land_A_FuelStation_Build","Land_Hlidac_budka","Land_A_FuelStation_Shed","Land_Mil_Barracks","Land_Mil_Barracks_L","Land_Mil_Barracks_i","Land_Mil_ControlTower","Land_a_stationhouse","Land_sara_hasic_zbroj","Land_sara_domek_zluty","Land_pumpa"], _range];
    //_miscColour | Set the colour for the misc. building lighting
    _miscColour=[1, 0, 0];
 
    //
    //NO NEED TO EDIT BELOW HERE
    //BUT FEEL FREE TO PLAY :) 
    //
     
        {
        _switching = random 100;
            [_miscColour,0.01,[3, 3, 3],[_x],0] call fnc_lightpoint;
        } forEach _objMisc;
     
        {
        _switching = random 100;
            [_indColour,0.01,[3, 3, 3],[_x],0] call fnc_lightpoint;
        } forEach _objIndustrial;
     
        {
        _switching = random 100;
        _switching2 = random 100;//Second random to mix it up, eg. some houses have two lots of windows that light up..
     
        _lightstate = _x animationPhase "Lights_1";//Current Lightstate of windows IMPORTANT first run lights are off !
     
            if(_lightstate==0) then
            {
            [[_x]] call fnc_lightson; 
            };
            [_houseColour,0.01,[5, 5, 5],[_x],1] call fnc_lightpoint;
 
            if(_lightstate==1) then
            {
            [[_x]] call fnc_lightfail;
            };
         
        } forEach _objHouse;
     
       // hint format ["All buildings within %1 metres dealt with.",_range];
        //sleep 0.5;
     
        //
        //FUNCTIONS
        //
        //Switch glowing windows on in houses that have them
        fnc_lightson={
        _building = _this select 0 select 0;
     
            if(_switching <_switchpercent) then
            {
            _building animate ["Lights_1",1];
                if(_switching2 <_switchpercent) then
                {
                _building animate ["Lights_2",1];
                };
            sleep 0.1;//REQUIRED
            };
        };
        //flicker lights off (for houses with glowing windows only) Runs after all other light sources have been switched on.
        fnc_lightfail={
        _building = _this select 0 select 0;
     
            if(_switching>_switchpercent)then
            {
            _animlightpoint = nearestObject [_building, "#lightpoint"];
                for "_s" from 1 to 5 do {
                    if(_s%2==0)then
                    {
                    _brightness=0;
                        for "_l" from 1 to 2 do {
                        _building animate [format ["Lights_%1",_l],0];
                        };
                    }
                    else
                    {
                    _brightness=0.01;
                        for "_l" from 1 to 2 do {
                        _building animate [format ["Lights_%1",_l],1];
                        };
                    };
                _animlightpoint setLightBrightness _brightness;
                _sleeptime=(random 100)/800;
                //_sleeptime=_sleeptime/500;
                sleep _sleeptime;
                };
                for "_l" from 1 to 2 do {
                _building animate [format ["Lights_%1",_l],0];
                };
            _animlightpoint setLightBrightness 0;
            //hint format ["Failing light for:%1 | Last Sleeptime:%2",_building,_sleeptime];
            sleep 6;
            };
        };
        //Create a lightpoint when called
        //eg. [_indColour,0.01,[3, 3, 3],[_x],0] call fnc_lightpoint;
        // array is [colour array,brightness,ambience array,this building / house object, run check to see if window lit first(for houses only)]
        fnc_lightpoint={
        _building = _this select 3 select 0;
        _doCheck =  _this select 4;
        _runfunc=true;
     
        if(_doCheck==1&&_building animationPhase "Lights_1"<1)then{
        _runfunc=false;
        //hint format ["Do Check:%1 | Light Phase:%2",_doCheck,_building animationPhase "Lights_1"];
        //sleep 0.5;
        };
            if(_runfunc)then
            {
            _lightColour = _this select 0;
            _lightBrightness = _this select 1;
            _lightAmbient = _this select 2;
            _objLightPoint = nearestObject [_building, "#lightpoint"];
            _xpos = getPos _building select 0;
            _ypos = getPos _building select 1;
            _lightposX = getPos _objLightPoint select 0;
            _lightposY = getPos _objLightPoint select 1;
            _awayx=_xpos-_lightposX;
            _awayy=_ypos-_lightposY;
                if((_awayx>1 or _awayx<-1)or(_awayy>1 or _awayy<-1))then
                {
                    if(_switching<_switchpercent)then
                    {
                    _lp = "#lightpoint" createVehicle [0,0,0];
                    _lp setLightColor _lightColour;
                    _lp setLightBrightness _lightBrightness;
                    _lp setLightAmbient _lightAmbient;
                    _lp setPos [getPos _building select 0,getPos _building select 1,-3];
                    _lp setDir getDir _building;
                    //sleep 0.5;
                    };
                }
                else
                {
                _objLightPoint setLightColor _lightColour;
                _objLightPoint setLightBrightness _lightBrightness;
                _objLightPoint setLightAmbient _lightAmbient;
                //sleep 0.5;
                };
            //hint format["X:%1 | Y:%2 | AwayX:%3 | Building:%4 | Lightpoint:%5 | Switching:%6 | ",_xpos,_ypos,_awayx,_building,_objLightPoint,_switching];
            //sleep 0.5;//for hint
            };
        }; 
    };
}

Just replace the old code, in change_streetlights.sqf, with this
The code has been left with comments and commented out debug hints for now and I would rather get some feedback before making this the official release.

This version still does the normal house lighting and all of the checks and lights failing that come with it, but I have added the option of two new arrays, called industrial and miscellaneous.

This allows the addition of custom buildings and objects and the ability to edit the light colour for each. Personally, I can't see any difference in the light colour though I think that may be down to some graphics setting.

The top section has all of the editable bits in, just add your building class names into one of the arrays _objIndustrial or _objMisc. You can do this by adding it inbetween the square brackets [] making sure it is contained in double quotes and they are all separated with a comma. I would stick to these two and leave the original house array as these require a secondary class of Lights_1 to work fully..

Any problems or bugs please let me know, I look forward to hearing how you get on with it.. I am just about to update my server with it also.
 
Could this scripts substantially increase ping on the server? Just installed this script and the ping has jumped hugely, but we also had a hacker do some crazy colour effects so could be either, going to do a restart soon :p
 
The script should work on all maps, you can add your own buildings and objects in to apply a light source to, you just need to know the class names.

I can't see it having any effect on pings, needs testing. I haven't noticed any increase in server fps as yet. If you think this is causing issues please let me know after your restart..
 
I cant find it could you send me a link to where you covered it?

Is here, also a link to something I found when looking at this. The main issue I had was that the streetlights, currently in Chernarus, don't even show up as objects. I run a test nearestObjects that returns everything, even bits of dust floating past, no street lights.

That doesn't stop you adding your own in, using the Buildings addon, and then adding the streetlight class names to the new script.. I have noticed that the runway lights glow on their own, not ideal but I wouldn't want to add a streetlight that has light around it yet the bulb doesn't glow.. just wrong :)
 
just curious if this is possible, but can you change to the lighting to a more natural colour like a light orange?
 
just curious if this is possible, but can you change to the lighting to a more natural colour like a light orange?

The editable colour fields are red, green, blue arrays. Experiment with those, the miscColour is set to blue, it seems to just change the ambient glow..
 
Does anybody know the classnames for the buildings and street lights in Oring map? or have a copy they can post with the Oring classnames included? Would be much appreciated. Love this sc ript, and it would be awesome to get it working with Oring too.
 
Does anybody know the classnames for the buildings and street lights in Oring map? or have a copy they can post with the Oring classnames included? Would be much appreciated. Love this sc ript, and it would be awesome to get it working with Oring too.

Have unpacked the mission.sqm from the missions .pbo and they look pretty standard. Here's a bit of code to help discover objects:

init.sqf
Code:
if (!isDedicated) then {
    //Reveal Objects
    [] execVM "test\all_objects.sqf";
 
};
test\all_objects.sqf
Code:
private["_nrObjs"];
while {alive player}
do
{
/*
//Show all within 3m of player.
_nrObjs = position player nearObjects 3;
    {
    hint format["Near Objects:%1",_nrObjs];
 
    } forEach _nrObjs;
sleep 0.4;
*/
//Shows object under cursor
_nrObjs = cursorTarget;
    if(!isNull _nrObjs)then
    {
    hint format["Near Objects:%1",_nrObjs];
    };
};
This will run for all people on the server so best run it on a test server. It shows the object under your cursor, as a hint. The commented code shows all objects within a radius (currently 3m).

The cursorTarget one doesn't show all things, signposts being one, and lampposts, neither show lampposts o_O It does work for buildings, scrap, agents etc.
 
Have unpacked the mission.sqm from the missions .pbo and they look pretty standard. Here's a bit of code to help discover objects:

init.sqf
Code:
if (!isDedicated) then {
    //Reveal Objects
    [] execVM "test\all_objects.sqf";
 
};
test\all_objects.sqf
Code:
private["_nrObjs"];
while {alive player}
do
{
/*
//Show all within 3m of player.
_nrObjs = position player nearObjects 3;
    {
    hint format["Near Objects:%1",_nrObjs];
 
    } forEach _nrObjs;
sleep 0.4;
*/
//Shows object under cursor
_nrObjs = cursorTarget;
    if(!isNull _nrObjs)then
    {
    hint format["Near Objects:%1",_nrObjs];
    };
};
This will run for all people on the server so best run it on a test server. It shows the object under your cursor, as a hint. The commented code shows all objects within a radius (currently 3m).

The cursorTarget one doesn't show all things, signposts being one, and lampposts, neither show lampposts o_O It does work for buildings, scrap, agents etc.
Damn, the streetlights are the primary thing I wanted to add. How do I go about finding the classnames for those?
 
Damn, the streetlights are the primary thing I wanted to add. How do I go about finding the classnames for those?
What is needed is to create a new mod, that should be able to run server side, that reclassifies the banned items to allow streetlamps, something I am looking into, along with certain requirements to allow the lighting with new items in the latest dayZ release.

Or, add your own items, using the Reality Building option, and then apply the lighting, to custom objects. with the latest release of the house lighting mission..

What houses do you have lit already ?
 
"20e9e400# 19497:dum_mest3.p3d","241ccd00# 20139: housev2_03.p3d","20cd6400# 20227: housev2_03b.p3d","20fa8800# 48170: statek_hl_bud.p3d"

So these are the buildings ive found so far that I want to light up. i'm assuming I only use the words inbetween the colon and the period, but I saved the whole thing just in case. For the last one, would I just add "statek_hl_bud"? Thanks for the responsive support by the way, you're awesome.
 
Cheers, you're exactly right, from that output I would go with : dum_mest3, housev2_03, housev2_03b and statek_hl_bud as the house objects. Include them in the _objIndustrial or _objMisc arrays. The only difference between them is the colour.
 
I dont know what dum_mest3 or statek_hl_bud are, but Im pretty sure the other 2 should be Land_HouseV2_03 and Land_HouseV2_03
 
Back
Top