Update local_lights_off.sqf

Cleaned up to fit with other changes.
This commit is contained in:
Andrew Gregory
2013-09-11 00:37:08 +01:00
parent 48eb5c625f
commit d82bf40d16

View File

@@ -2,56 +2,57 @@
DayZ Epoch Lighting System - Fail / Switch Off Lights DayZ Epoch Lighting System - Fail / Switch Off Lights
Made for DayZ Epoch please ask permission to use/edit/distrubute email axeman@thefreezer.co.uk. Made for DayZ Epoch please ask permission to use/edit/distrubute email axeman@thefreezer.co.uk.
*/ */
private ["_rng","_nrstTrig","_objHouses","_objHouse","_nrLights","_nrTowers","_doRand","_rnd","_animlightpoint","_sleeptime","_brightness"]; private ["_hsRange","_rng","_pos","_hsCount","_nrstTrig","_objHouses","_objHouse","_nrLights","_nrTowers","_doRand","_rnd","_animlightpoint","_hasLight","_sleeptime","_lightstate","_cntNrGen"];
_rng = _this select 0; _rng = _this select 0;//Full distance to turn off all lights if required
_rng = _rng + 20;
_nrstTrig = _this select 1; _nrstTrig = _this select 1;
_doRand = _this select 2; _doRand = _this select 2;//Random if gen not required otherwise just switch thenm off,,
_nrLights = position _nrstTrig nearObjects ["#lightpoint",_rng]; _cntNrGen = _this select 3;
_objHouses = nearestObjects [_nrstTrig, ["House"], _rng]; _hsRange = _this select 4;//House range for randomly failing nearby (within lp distance)houses)
_nrTowers = nearestObjects [_nrstTrig, ["Land_Ind_IlluminantTower"], _rng]; _hasLight = false;
if(_doRand)then{//Randomly fail a nearby house
if(count _objHouses >0)then{ if(_doRand)then{//Randomly fail a nearby house - If generator skip and reset house variable so it can be lit again (reliability if gen nearby)
_rnd = random count _objHouses; _objHouses = nearestObjects [_nrstTrig, ["House"], _hsRange];
if(count _objHouses >3)then{
_hsCount = count _objHouses;
_rnd = random _hsCount;
_objHouse = _objHouses select _rnd; _objHouse = _objHouses select _rnd;
_animlightpoint = nearestObject [_objHouse, "#lightpoint"]; _pos = getPos _objHouse;
for "_s" from 1 to 5 do { _lightstate = _objHouse animationPhase "Lights_1";
if(_s%2==0)then if(_lightstate==1) then{
{ _animlightpoint = nearestObject [_objHouse, "#lightpoint"];
_brightness=0; if((abs ([_pos, _animlightpoint] call BIS_fnc_distance2D))<1)then{_hasLight=true;};
for "_l" from 1 to 2 do { for "_s" from 1 to 6 do {
_objHouse animate [format ["Lights_%1",_l],0]; if(_s%2==0)then{
}; if(_hasLight)then{_animlightpoint setLightBrightness 0;};
} _objHouse animate ["Lights_1",0];
else }else{
{ if(_hasLight)then{_animlightpoint setLightBrightness 0.01;};
_brightness=0.01; _objHouse animate ["Lights_1",1];
for "_l" from 1 to 2 do {
_objHouse animate [format ["Lights_%1",_l],1];
}; };
_sleeptime=(random 100)/100;
sleep _sleeptime;
}; };
_animlightpoint setLightBrightness _brightness; if(_hasLight)then{deleteVehicle _animlightpoint;};
_sleeptime=(random 100)/1200; _objHouse animate ["Lights_1",0];
sleep _sleeptime; _objHouse animate ["Lights_2",0];
_objHouse setVariable ["axeHLight", 0, true];//Fail light house leccy supply
}; };
_animlightpoint setLightBrightness 0;
_objHouse animate ["Lights_1",0];
_objHouse animate ["Lights_2",0];
_objHouse setVariable ["axeHLight", 0, false];
}; };
} }else{//Switch them all off
else{ _nrLights = position _nrstTrig nearObjects ["#lightpoint",_rng];
_nrTowers = nearestObjects [_nrstTrig, ["Land_Ind_IlluminantTower"], _rng];
if(count _nrLights >0)then{ if(count _nrLights >0)then{
{ {
deleteVehicle _x; deleteVehicle _x;
}forEach _nrLights; }forEach _nrLights;
}; };
_objHouses = nearestObjects [_nrstTrig, ["House"], _rng];
if(count _objHouses >0)then{ if(count _objHouses >0)then{
{ {
_x animate ["Lights_1",0]; _x animate ["Lights_1",0];
_x animate ["Lights_2",0]; _x animate ["Lights_2",0];
_x setVariable ["axeHLight", 0, false]; _x setVariable ["axeHLight", 0, true];
}forEach _objHouses; }forEach _objHouses;
}; };
@@ -61,3 +62,11 @@ else{
}forEach _nrTowers; }forEach _nrTowers;
}; };
}; };
{
/*
if(_cntNrGen>0)then{//reset house if gen nearby to help create reliability regardless of gen requirement ?
_x setVariable ["axeHLight", 0, false];
};
}forEach _objHouses;
*/