Skip to content

Instantly share code, notes, and snippets.

@BaerMitUmlaut
Created January 7, 2016 13:00
Show Gist options
  • Save BaerMitUmlaut/f88d02240039a6f14373 to your computer and use it in GitHub Desktop.
Save BaerMitUmlaut/f88d02240039a6f14373 to your computer and use it in GitHub Desktop.
//PROOF OF CONCEPT
//Just put this in the initPlayerLocal.sqf, for MP you probably need to do some changes.
//Needs to be in scheduled environment - feel free to convert it to unscheduled.
_safeZones = [];
_dangerZones = [];
fncLightning = {
_pos = _this;
private ["_bolt", "_light", "_class", "_lightning", "_time"];
_bolt = createvehicle ["LightningBolt",_pos,[],0,"can collide"];
_bolt setposatl _pos;
_bolt setdamage 1;
_light = "#lightpoint" createvehicle _pos;
_light setposatl [_pos select 0,_pos select 1,(_pos select 2) + 10];
_light setLightDayLight true;
_light setLightBrightness 300;
_light setLightAmbient [0.05, 0.05, 0.1];
_light setlightcolor [1, 1, 2];
sleep 0.1;
_light setLightBrightness 0;
sleep (random 0.1);
_class = ["lightning1_F","lightning2_F"] call bis_Fnc_selectrandom;
_lightning = _class createvehicle [100,100,100];
_lightning setdir (random 360);
_lightning setpos _pos;
for "_i" from 0 to (3 + random 1) do {
_time = time + 0.1;
_light setLightBrightness (100 + random 100);
waituntil {
time > _time
};
};
deletevehicle _lightning;
deletevehicle _light;
0 setlightnings 0;
};
{
_unit = _x;
(getPos _unit) params ["_x", "_y"];
_squareCenterPos = [_x - (_x mod 50) + 25, _y - (_y mod 50) + 25, 0];
for "_mkX" from -50 to 50 step 50 do {
for "_mkY" from -50 to 50 step 50 do {
_pos = _squareCenterPos vectorAdd [_mkX, _mkY, 0];
_safeZones pushBack _pos;
_mk = createMarker ["mkClearance" + (name _unit) + (str [_mkX, _mkY]), _pos];
_mk setMarkerShape "RECTANGLE";
_mk setMarkerSize [25, 25];
_mk setMarkerBrush "SolidBorder";
_mk setMarkerColor "ColorIndependent";
};
};
for "_mkX" from -100 to 100 step 50 do {
for "_mkY" from -100 to 100 step 200 do {
_pos = _squareCenterPos vectorAdd [_mkX, _mkY, 0];
_dangerZones pushBack _pos;
_mk = createMarker ["mkDanger" + (name _unit) + (str [_mkX, _mkY]), _pos];
_mk setMarkerShape "RECTANGLE";
_mk setMarkerSize [25, 25];
_mk setMarkerBrush "Border";
_mk setMarkerColor "ColorOPFOR";
};
};
for "_mkY" from -50 to 50 step 50 do {
for "_mkX" from -100 to 100 step 200 do {
_pos = _squareCenterPos vectorAdd [_mkX, _mkY, 0];
_dangerZones pushBack _pos;
_mk = createMarker ["mkDanger" + (name _unit) + (str [_mkX, _mkY]), _pos];
_mk setMarkerShape "RECTANGLE";
_mk setMarkerSize [25, 25];
_mk setMarkerBrush "Border";
_mk setMarkerColor "ColorOPFOR";
};
};
_mkPos = createMarker ["mkPos" + (name _unit), getPos _unit];
_mkPos setMarkerShape "ICON";
_mkPos setMarkerType "mil_dot";
_mkPos setMarkerColor "ColorGrey";
false
} count allUnits;
_dangerZones = _dangerZones - (_dangerZones arrayIntersect _safeZones);
{
_mk = createMarker ["mkDangerActual" + (str _x), _x];
_mk setMarkerShape "RECTANGLE";
_mk setMarkerSize [25, 25];
_mk setMarkerBrush "SolidBorder";
_mk setMarkerColor "ColorOPFOR";
false
} count _dangerZones;
sleep 10;
[{
_lightningPos = ((_this select 0) call BIS_fnc_selectRandom) vectorAdd [(random 50) - 25, (random 50) - 25, 0];
_mkPos = createMarker ["mkLightningPos" + (str time), _lightningPos];
_mkPos setMarkerShape "ICON";
_mkPos setMarkerType "mil_dot";
_mkPos setMarkerColor "ColorYellow";
_lightningPos spawn fncLightning;
}, 1, _dangerZones] call CBA_fnc_addPerFrameHandler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment