Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.37 KB | None | 0 0
  1. /*
  2. File: fn_copLights.sqf
  3. Author: mindstorm,
  4. Link: http://forums.bistudio.com/showthread.php?157474-Offroad-Police-sirens-lights-and-underglow
  5.  
  6. Description:
  7. Adds an single light effect to cop and medic vehicles.
  8. ____________________________________________________________________________________________________________________
  9.  
  10. Private ["_vehicle","_lightBlue","_light","_lightOn"];
  11. _vehicle = _this select 0;
  12.  
  13. if(isNil "_vehicle" OR isNull _vehicle OR !(_vehicle getVariable "lights")) exitWith {};
  14. _lightBlue = [0.1, 0.1, 20];
  15.  
  16. _light = "#lightpoint" createVehicle getpos _vehicle;
  17. sleep 0.2;
  18. _light setLightColor _lightBlue;
  19. _light setLightBrightness 0.2;
  20. _light setLightAmbient [0.1,0.1,1];
  21.  
  22.  
  23. [x, y, z]
  24.  
  25. ^ <--------- y --------> _
  26. | ___________ |
  27. | / \ /
  28. z _____/ \ x
  29. | | \ /
  30. | |____________________| |_
  31. v
  32.  
  33.  
  34. switch (typeOf _vehicle) do
  35. {
  36. case "C_Offroad_01_F":
  37. {
  38. _light lightAttachObject [_vehicle, [0.0, 0.0, 0.56]];
  39. };
  40.  
  41. case "C_SUV_01_F":
  42. {
  43. _light lightAttachObject [_vehicle, [0.0,-0.6,0.42]];
  44. };
  45.  
  46. case "B_MRAP_01_F":
  47. {
  48. _light lightAttachObject [_vehicle, [0, -0.9, 0.55]];
  49. };
  50.  
  51. case "B_MRAP_01_hmg_F":
  52. {
  53. _light lightAttachObject [_vehicle, [0, -0.9, 0.55]];
  54. };
  55.  
  56.  
  57. case "C_Hatchback_01_sport_F":
  58. {
  59. _light lightAttachObject [_vehicle, [0,-0.1,0.3]];
  60. };
  61.  
  62. case "C_Hatchback_01_F":
  63. {
  64. _light lightAttachObject [_vehicle, [0,-0.1,0.3]];
  65. };
  66.  
  67. case "I_MRAP_03_F":
  68. {
  69. _light lightAttachObject [_vehicle, [0.0, 0.0, 0.56]];
  70. };
  71.  
  72. case "I_MRAP_03_hmg_F":
  73. {
  74. _light lightAttachObject [_vehicle, [0.0, 0.0, 0.56]];
  75. };
  76.  
  77. case "B_Heli_Light_01_F":
  78. {
  79. _light lightAttachObject [_vehicle, [0.0, 0.0, -0.95]];
  80. };
  81.  
  82. case "B_Heli_Transport_01_F":
  83. {
  84. _light lightAttachObject [_vehicle, [0.0, 0.6, -1.0]];
  85. };
  86.  
  87. case "O_Heli_Light_02_unarmed_F":
  88. {
  89. _light lightAttachObject [_vehicle, [0.0, 0.0,-0.95]];
  90. };
  91.  
  92. case "I_Heli_light_03_unarmed_F":
  93. {
  94. _light lightAttachObject [_vehicle, [0.0, 0.0,-0.95]];
  95. };
  96.  
  97. };
  98.  
  99. _light setLightAttenuation [0.181, 0, 1000, 130];
  100. _light setLightIntensity 10;
  101. _light setLightFlareSize 0.38;
  102. _light setLightFlareMaxDistance 150;
  103. _light setLightUseFlare true;
  104.  
  105.  
  106. //ARE YOU ALL HAPPY?!?!?!?!?!?!?!?!?%#?@WGD?TGD?BN?ZDHBFD?GA
  107. _light setLightDayLight true;
  108.  
  109. _lightOn = false;
  110. while{ (alive _vehicle)} do
  111. {
  112. if(!(_vehicle getVariable "lights")) exitWith {};
  113. if(_lightOn) then
  114. {
  115. _lightOn = false;
  116. _light setLightBrightness 0.0;
  117. }
  118. else
  119. {
  120. _lightOn = true;
  121. _light setLightBrightness 6;
  122. };
  123. sleep (_this select 1);
  124. };
  125. deleteVehicle _light;
  126. */
  127. /*
  128. File: fn_copLights.sqf
  129. Author: [GSN] Pager & [GSN] Paronity
  130. Website: GSNGaming.com
  131. Date Created: 2.24.2015
  132. Date Modified: 2.25.2015 v1.2
  133. */
  134.  
  135. private ["_veh","_lightRed","_lightWhite","_lightBlue","_leftRed","_brightnessHigh","_brightnessLow","_attach","_leftLights","_rightLights","_type","_attenuation"];
  136.  
  137. _veh = (_this select 0);
  138. _type = typeOf _veh;
  139. _sun = (sunOrMoon < 1);
  140.  
  141. if (isNil "_veh" || isNull _veh || !(_veh getVariable "lights")) exitWith {};
  142.  
  143. _lightRed = [255, 0, 0];
  144. _lightWhite = [255, 255, 255];
  145. _lightBlue = [0, 0, 255];
  146.  
  147. if (_sun) then
  148. {
  149. _brightnessLow = 0;
  150. _brightnessHigh = 2;
  151. _attenuation = [0.001, 3000, 0, 125000];
  152. } else {
  153. _brightnessLow = 0;
  154. _brightnessHigh = 200;
  155. _attenuation = [0.001, 3000, 0, 500000];
  156. };
  157.  
  158. _flashes = 2;
  159. _flashOn = 0.1;
  160. _flashOff = 0.05;
  161.  
  162. _leftLights = [];
  163. _rightLights = [];
  164.  
  165. _attach =
  166. {
  167. _isLight = _this select 0;
  168. _color = _this select 1;
  169. _position = _this select 2;
  170. _light = "#lightpoint" createVehicleLocal getPos _veh;
  171. _light setLightBrightness 0;
  172. _light setLightAmbient [0,0,0];
  173. _light setLightAttenuation _attenuation;
  174. _light setLightIntensity 1000;
  175. _light setLightFlareSize 1;
  176. _light setLightFlareMaxDistance 150;
  177. _light setLightUseFlare true;
  178. _light setLightDayLight true;
  179.  
  180. switch (_color) do
  181. {
  182. case "red": { _light setLightColor _lightRed; };
  183. case "white": { _light setLightColor _lightWhite; };
  184. case "blue": { _light setLightColor _lightBlue; };
  185. };
  186.  
  187. if (_isLight) then
  188. {
  189. _leftLights pushBack [_light, _position];
  190. } else {
  191. _rightLights pushBack [_light, _position];
  192. };
  193.  
  194. _light lightAttachObject [_veh, _position];
  195. };
  196.  
  197. switch (_type) do
  198. {
  199. case "C_Offroad_01_F":
  200. {
  201. [false, "red", [-0.44, 0, 0.525]] call _attach;
  202. [true, "blue", [0.345, 0, 0.525]] call _attach;
  203. [false, "red", [0.575, -2.95, -0.77]] call _attach;
  204. [true, "blue", [-0.645, -2.95, -0.77]] call _attach;
  205. [false, "white", [0.61, 2.2825, -0.355]] call _attach;
  206. [true, "white", [-0.695, 2.2825, -0.355]] call _attach;
  207. };
  208.  
  209. case "C_SUV_01_F":
  210. {
  211. [false, "red", [-0.39, 2.28, -0.52]] call _attach;
  212. [true, "blue", [0.38, 2.28, -0.52]] call _attach;
  213. [false, "red", [-0.86, -2.75, -0.18]] call _attach;
  214. [true, "blue", [0.86, -2.75, -0.18]] call _attach;
  215. [false, "white", [0.8, 1.95, -0.48]] call _attach;
  216. [true, "white", [-0.8, 1.95, -0.48]] call _attach;
  217.  
  218. };
  219.  
  220. case "C_Hatchback_01_sport_F":
  221. {
  222. [false, "red", [-0.03, -0, 0.2]] call _attach;
  223. [true, "blue", [-0.03, -0, 0.2]] call _attach;
  224. [false, "red", [-0.8, -2.25, -0.3]] call _attach;
  225. [true, "blue", [0.78, -2.25, -0.3]] call _attach;
  226. [false, "white", [0.75, 1.615, -0.52]] call _attach;
  227. [true, "white", [-0.8, 1.615, -0.525]] call _attach;
  228. };
  229.  
  230. case "C_Hatchback_01_F":
  231. {
  232. [false, "red", [-0.03, -0, 0.2]] call _attach;
  233. [true, "blue", [-0.03, -0, 0.2]] call _attach;
  234. [false, "red", [-0.8, -2.25, -0.3]] call _attach;
  235. [true, "blue", [0.78, -2.25, -0.3]] call _attach;
  236. [false, "white", [0.75, 1.615, -0.52]] call _attach;
  237. [true, "white", [-0.8, 1.615, -0.525]] call _attach;
  238. };
  239.  
  240. case "I_MRAP_03_F":
  241. {
  242. [false, "red", [-0.87, 2.2, -0.75]] call _attach;
  243. [true, "blue", [0.87, 2.2, -0.75]] call _attach;
  244. [false, "red", [-0.725, -3.15, 0.025]] call _attach;
  245. [true, "blue", [0.725, -3.15, 0.025]] call _attach;
  246. [false, "white", [1.05, 2.25, -0.3]] call _attach;
  247. [true, "white", [-1.05, 2.25, -0.3]] call _attach;
  248. };
  249.  
  250. case "B_MRAP_01_F":
  251. {
  252. [false, "red", [-0.87, 2.2, -0.75]] call _attach;
  253. [true, "blue", [0.87, 2.2, -0.75]] call _attach;
  254. [false, "red", [-0.725, -3.15, 0.025]] call _attach;
  255. [true, "blue", [0.725, -3.15, 0.025]] call _attach;
  256. [false, "white", [1.05, 2.25, -0.3]] call _attach;
  257. [true, "white", [-1.05, 2.25, -0.3]] call _attach;
  258. };
  259.  
  260. case "B_MRAP_01_hmg_F":
  261. {
  262. [false, "red", [-0.87, 2.2, -0.75]] call _attach;
  263. [true, "blue", [0.87, 2.2, -0.75]] call _attach;
  264. [false, "red", [-0.725, -3.15, 0.025]] call _attach;
  265. [true, "blue", [0.725, -3.15, 0.025]] call _attach;
  266. [false, "white", [1.05, 2.25, -0.3]] call _attach;
  267. [true, "white", [-1.05, 2.25, -0.3]] call _attach;
  268. };
  269. };
  270.  
  271. _lightsOn = true;
  272. while {(alive _veh)} do
  273. {
  274. if (!(_veh getVariable "lights")) exitWith {};
  275. if (_lightsOn) then
  276. {
  277. for [{_i=0}, {_i<_flashes}, {_i=_i+1}] do
  278. {
  279. { (_x select 0) setLightBrightness _brightnessHigh; } forEach _leftLights;
  280. uiSleep _flashOn;
  281. { (_x select 0) setLightBrightness _brightnessLow; } forEach _leftLights;
  282. uiSleep _flashOff;
  283. };
  284. { (_x select 0) setLightBrightness 0; } forEach _leftLights;
  285.  
  286. for [{_i=0}, {_i<_flashes}, {_i=_i+1}] do
  287. {
  288. { (_x select 0) setLightBrightness _brightnessHigh; } forEach _rightLights;
  289. uiSleep _flashOn;
  290. { (_x select 0) setLightBrightness _brightnessLow; } forEach _rightLights;
  291. uiSleep _flashOff;
  292. };
  293. { (_x select 0) setLightBrightness 0; } forEach _rightLights;
  294. };
  295. };
  296.  
  297. { deleteVehicle (_x select 0) } foreach _leftLights;
  298. { deleteVehicle (_x select 0) } foreach _rightLights;
  299.  
  300. _leftLights = [];
  301. _rightLights = [];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement