Merge pull request #525 from andgregor/master

Lighting System
This commit is contained in:
vbawol
2013-09-02 10:14:44 -07:00
24 changed files with 399 additions and 17 deletions

View File

@@ -0,0 +1,64 @@
class CfgNonAIVehicles {
class StreetLamp {
brightness = 0;
simulation = "StreetLamp";
scope = 2;
};
class StreetLamp_BaseWeakYellow : StreetLamp {
brightness = 0;
};
class StreetLamp_BaseMediumOrange : StreetLamp {
brightness = 0;
};
class StreetLamp_BaseMediumPale : StreetLamp {
brightness = 0;
};
class StreetLamp_BaseStrongPale : StreetLamp {
brightness = 0;
};
class Land_Lamp_Small_EP1 : StreetLamp {
brightness = 0;
};
class Land_Lamp_Street1_EP1 : StreetLamp {
brightness = 0;
};
class Land_Lamp_Street2_EP1 : StreetLamp {
brightness = 0;
};
class Land_Lampa_Ind_EP1 : StreetLamp {
brightness = 0;
};
class Land_PowLines_Conc2L_EP1 : StreetLamp {
brightness = 0;
};
class Land_lampa_sidl : StreetLamp {
brightness = 0;
};
class Land_lampa_sidl_2 : StreetLamp {
brightness = 0;
};
class Land_lampa_sidl_3 : StreetLamp {
brightness = 0;
};
class Land_lampa_ind : StreetLamp {
brightness = 0;
};
class Land_lampa_ind_zebr : StreetLamp {
brightness = 0;
};
};

View File

@@ -0,0 +1,84 @@
axe_returnStreetLights={
private["_lights","_objName","_rng","_nrstGen"];
_rng = _this select 0;
_nrstGen = _this select 1;
_lights = ["a_fuelstation_sign.p3d","lampa_ind_zebr.p3d","lampa_ind.p3d","lampa_sidl_3.p3d","lampa_sidl_2.p3d","lampa_sidl.p3d","powlines_concl.p3d","powlines_woodl.p3d"];
axe_streetLamps=[];
axe_generators=[];
{
if("" != typeOf _x) then {
if (alive _x) then {
_objName = _x call DZE_getModelName;
if (_objName in _lights) then {
[axe_streetLamps , [_x]] call BIS_fnc_arrayPush;
};
};
};
} foreach nearestObjects [getPos _nrstGen, [], _rng];
[axe_streetLamps,axe_generators]
};
axe_newLightPoint={
private ["_lp","_pos","_col","_brt","_amb","_pos","_dir","_vect"];
_col = _this select 0;
_brt = _this select 1;
_amb = _this select 2;
_pos = _this select 3;
_dir = _this select 4;
_vect = _this select 5;
_lp = "#lightpoint" createVehicle _pos;
_lp setLightColor _col;
_lp setLightBrightness _brt;
_lp setLightAmbient _amb;
_lp setDir _dir;
_lp setVectorUp _vect;
};
axe_lightPoint={
private ["_lp","_col","_brt","_amb"];
_col = _this select 0;
_brt = _this select 1;
_amb = _this select 2;
_lp = _this select 3;
_lp setLightColor _col;
_lp setLightBrightness _brt;
_lp setLightAmbient _amb;
};
axe_towerLight={
private["_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{
[_lCol,_lbrt,_lamb,_x] call axe_lightPoint;
}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));
[_lCol,_lbrt,_lamb,[_a,_b,(_twrPos select 2) + 26],_ang,[0,0,-1]] call axe_newLightPoint;
sleep .4;
};
};
};
};

View File

@@ -0,0 +1,44 @@
/*
DayZ Epoch Lighting System
Made for DayZ Epoch please ask permission to use/edit/distrubute email axeman@thefreezer.co.uk.
*/
private ["_lightstate","_objLightPoint","_pos","_objHouse","_dir","_rng","_nrstGen"];
_rng = _this select 0;
_nrstGen = _this select 1;
_objHouse = nearestObjects [_nrstGen, ["House"], _rng];
if(!isNil "_objHouse")then{
{
_lightstate = _x animationPhase "Lights_1";//Window lights on or off
_pos = getPos _x;
_dir = getDir _x;
if(_lightstate==0) then
{
_x animate ["Lights_1",1];
if(65 <(random 100)) then{
_x animate ["Lights_2",1];
};
sleep .1;
};
if(_lightstate==1) then
{
_objLightPoint = nearestObject [_x, "#lightpoint"];
if((abs ([_pos, _objLightPoint] call BIS_fnc_distance2D))>1)then{
[[1, 1, 1],0.01,[5, 5, 5],[_pos select 0,_pos select 1,-3],_dir,[0,0,-1]] call axe_newLightPoint;
_x setVariable ["axeHLight", 1, false];
}else{
if((_x getVariable ["axeHLight", 0])<1)then{
[[1, 1, 1],0.01,[5, 5, 5],_objLightPoint] call axe_lightPoint;
_x setVariable ["axeHLight", 1, false];
};
};
};
} forEach _objHouse;
};

View File

@@ -0,0 +1,73 @@
/*
DayZ Epoch Lighting System
Made for DayZ Epoch please ask permission to use/edit/distrubute email axeman@thefreezer.co.uk.
*/
private ["_nrGen","_i","_doHouse","_doStreet","_doTower","_doAll","_fnHr","_stHr","_plyr","_hndlSLights","_hndlHLights","_hndlTLights","_tmpPlyrPos","_ndGen","_rngGen","_rngPlyr","_arrStreetLights","_rtnLights","_wait","_waitcmd","_trigDist"];
_stHr = 17;//Hour (in 24 hours) to start lights
_fnHr = 6;//Hour (in 24 hours) to stop lights
waitUntil {(daytime<_fnHr||daytime>_stHr)};
_doHouse=true;//House Lights ?
_doStreet=true;//Street Lights ?
_doTower=true;// Tower Lights ?
_ndGen = true;//Require a Generator ?
_rngGen = 120;//Generator power range.
_rngPlyr = 600;//Distance from player to search for generators.
_trigDist = 10;//Distance that player needs to move to trigger the routine.
//END OF EDIT VARS
_wait = [];
_doAll = true;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_lightFunctions.sqf";
axeTowerLights = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_lights_tower.sqf";
axeHouseLights = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_lights_house.sqf";
axeStreetLights = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_lights_street.sqf";
waitUntil {getPos Player select 0 > 0};
while {alive player}
do
{
if(daytime<_fnHr||daytime>_stHr)then{
_plyr = vehicle player;
_tmpPlyrPos = getPos _plyr;
_nrGen = nearestObjects [player, ["Generator_DZ"], _rngPlyr];
if(count _nrGen >0)then{
};
{
if(_ndGen && (count _nrGen)<1)then{_doAll = false;}else{_doAll=true;};
if(_doAll)then{
_rtnLights = [_rngGen,_x] call axe_returnStreetLights;
_arrStreetLights = _rtnLights select 0;
_waitcmd="";
_wait=[];
if(_doTower)then{
_hndlTLights = [_rngGen,_x] spawn axeTowerLights;
[_wait , "scriptDone _hndlTLights"] call BIS_fnc_arrayPush;
};
if(_doHouse)then{
_hndlHLights = [_rngGen,_x] spawn axeHouseLights;
[_wait , "scriptDone _hndlHLights"] call BIS_fnc_arrayPush;
};
if(_doStreet)then{
_hndlSLights = [_arrStreetLights,_x] spawn axeStreetLights;
[_wait , "scriptDone _hndlSLights"] call BIS_fnc_arrayPush;
};
for [{_i=0}, {_i<3}, {_i=_i+1}]do{_waitcmd=_waitcmd+format["%1",_wait select _i];if(_i<2)then{_waitcmd=_waitcmd+"&&";};};
call compile format ["waitUntil {%1}",_waitcmd];
};
}forEach _nrGen;
if( abs ([_tmpPlyrPos, getPos _plyr] call BIS_fnc_distance2D)<_trigDist)then{_doAll=false;};
};
};

View File

@@ -0,0 +1,39 @@
/*
DayZ Epoch Lighting System
Made for DayZ Epoch please ask permission to use/edit/distrubute email axeman@thefreezer.co.uk.
*/
private ["_streetLamps","_num","_location","_objLightPoint","_away","_objSLamp","_nrstGen","_dir"];
_streetLamps= _this select 0;
_nrstGen = _this select 1;
_num=0;
if(!isNil "_streetLamps")then{
//Illuminate
{
_objSLamp= _x select 0;
_location = getPos _objSLamp;
_objLightPoint = nearestObject [_location, "#lightpoint"];
_away= abs ([_objSLamp, _objLightPoint] call BIS_fnc_distance2D);
if(_away>1)then{
_dir = getDir _objSLamp;
_location set [1, (getPos _objSLamp select 1) + ((0.6)*sin(_dir))];
_location set [2,_location select 2 - 0.2];
[[1, 0.88, 0.73],0.04,[1, 0.88, 0.73],_location,_dir,[0,0,-1]] call axe_newLightPoint;
}else{
if((_nrstGen getVariable ["axeSLight",0])<1)then{
[[1, 0.88, 0.73],0.04,[1, 0.88, 0.73],_objLightPoint] call axe_lightPoint;
};
};
_num=_num+1;
}forEach _streetLamps;
_nrstGen setVariable ["axeSLight", 1, false];
};

View File

@@ -0,0 +1,26 @@
/*
DayZ Epoch Lighting System
Made for DayZ Epoch please ask permission to use/edit/distrubute email axeman@thefreezer.co.uk.
*/
private ["_nrTowers","_rng","_nrstGen","_lCol","_lbrt","_lamb","_twrCl","_doLit"];
_rng = (_this select 0)*2;
_nrstGen = _this select 1;
_lCol = [1, 0.88, 0.73];
_lbrt = 0.04;
_lamb = [1, 0.88, 0.73];
_twrCl = "Land_Ind_IlluminantTower";
_nrTowers = nearestObjects [_nrstGen, [_twrCl], _rng];
if(count _nrTowers >0)then{
{
_doLit=false;
if((_x getVariable ["axeTLight", 0])<1)then{
_doLit=true;
};
[_lCol,_lbrt,_lamb,[_x],[_doLit]] call axe_towerLight;
_x setVariable ["axeTLight", 1, false];
}forEach _nrTowers;
};

View File

@@ -14,6 +14,7 @@
#define EAST 0 // (Russian)
#include "Configs\basicdefines.hpp"
#include "Configs\CfgNonAIVehicles.hpp"
class CfgPatches {
class dayz_code {

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -114,5 +114,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -115,5 +115,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -82,4 +82,7 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
};
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -73,4 +73,7 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
};
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -103,5 +103,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -103,5 +103,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"

View File

@@ -102,5 +102,8 @@ if (!isDedicated) then {
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
_void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
//Lights
[] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
};
#include "\z\addons\dayz_code\system\REsec.sqf"
#include "\z\addons\dayz_code\system\REsec.sqf"