Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.79 KB | None | 0 0
  1.  
  2. FS_SnowDensity = _this select 0;
  3.  
  4. FS_spawnSnowCube = {
  5. private ["_step", "_height", "_RelativePositions", "_source"];
  6.  
  7. FS_SnowSources = [];
  8. _step = 20;
  9. _height = 7;
  10. _RelativePositions = [
  11. [0, 0, _height],
  12. [_step, 0, _height], [-_step, 0, _height], // left and right
  13. [_step / 2, _step, _height], [-_step / 2, _step, _height], // front : left and right
  14. [_step / 2, -_step, _height], [-_step / 2, -_step, _height], // back : left and right
  15. [0, 0, _step / 2 + _height], [0, 0, -_step / 2 + _height] // up and down
  16. ];
  17.  
  18. for [{private _i = 0}, {_i < count _RelativePositions}, {_i = _i + 1}] do
  19. {
  20. _source = "#particlesource" createVehicleLocal getpos player;
  21. _source setDropInterval FS_SnowDensity;
  22. _source setParticleCircle [0.0, [0, 0, 0]];
  23. _source setParticleRandom [0, [10, 10, 7], [0, 0, 0], 0, 0.01, [0, 0, 0, 0.1], 0, 0];
  24. _source setParticleParams [
  25. /*Sprite*/ ["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 13,1], "",// [File,Ntieth,Index,Count,Loop(Bool)], "?"
  26. /*Type*/ "Billboard",
  27. /*TimmerPer*/ 1,
  28. /*Lifetime*/ 6,
  29. /*Position*/ _RelativePositions select _i,
  30. /*MoveVelocity*/ [0,0,0],
  31. /*Simulation*/ 1,0.0000001,0.000,1.7, //rotationVel,weight,volume,rubbing
  32. /*Scale*/ [0.07],
  33. /*Color*/ [[1,1,1,1]],
  34. /*AnimSpeed*/ [0,1],
  35. /*randDirPeriod*/ 0.2,
  36. /*randDirIntesity*/ 1.2,
  37. /*onTimerScript*/ "",
  38. /*DestroyScript*/ "",
  39. /*Follow*/ player
  40. /*Angle*/ //0,
  41. /*onSurface*/ //true,
  42. /*bounceOnSurface*/ //0.5,
  43. /*emissiveColor*/ //[[0,0,0,0]]
  44. ];
  45.  
  46. FS_SnowSources pushBack _source;
  47. };
  48.  
  49. };
  50.  
  51. FS_SnowPersistence = {
  52. private["_vel","_dir","_attached"];
  53.  
  54. while {alive player} do
  55. {
  56. _attached = player;
  57. if (vehicle player != player) then { _attached = vehicle player; } else { _attached = player; };
  58.  
  59. _vel = speed _attached;
  60. _dir = getdir _attached;
  61. {
  62. _x attachto [_attached, [0, _vel * 0.5, 8]];
  63. _x setDropInterval FS_SnowDensity;
  64. }
  65. forEach FS_SnowSources;
  66.  
  67. // Disable snow underwater. On by Default
  68. if (underwater player) then { snowEmitter setDropInterval 0; };
  69.  
  70. sleep 1;
  71. };
  72. {
  73. deleteVehicle _x;
  74. }
  75. forEach FS_SnowSources;
  76.  
  77. waitUntil {alive player};
  78. [] spawn FS_spawnSnowCube; // restarts snow
  79. };
  80.  
  81. /* Awesome steam from mouth script by Fess25Rus
  82.  
  83. This script is awesome because it calculates the head direction and turns steam particles velocity according to it. I had never seen something like this before (the scripts I found were pretty simple and without head tracking), so I had to create it myself. This script also changes particles velocity to make steam round the unit's head, i.e. there will be no steam from the neck when unit moves fast!
  84.  
  85. Summary, my glorius script :
  86. + Tracks the head direction
  87. + Makes steam round the neck
  88. + Creates steam only when unit actually made an exhale (sound of breathe was played)
  89. */
  90. FS_makeBreathe = {
  91. private ["_unit","_breathe","_source","_fog", "_v1", "_v2", "_cosA", "_cosB", "_sinA", "_sinB", "_velocity", "_volume"];
  92. _unit = _this select 0;
  93. _breathe = _this select 1;
  94.  
  95. if (!(_breathe in [1,2,4,6,14])) exitWith {};
  96. /*
  97. 1 : Breath
  98. 2 : Breath Injured
  99. 3 : Breath Scuba
  100. 4 : Injured
  101. 5 : Pulsation
  102. 6 : Hit Scream
  103. 7 : Burning
  104. 8 : Drowning
  105. 9 : Drown
  106. 10 : Gasping
  107. 11 : Stabilizing
  108. 12 : Healing
  109. 13 : Healing With Medikit
  110. 14 : Recovered
  111. */
  112. _source = "logic" createVehicleLocal (getpos _unit);
  113. _source attachto [_unit, [0,0.15,0], "neck"];
  114.  
  115. _fog = "#particlesource" createVehicleLocal getpos _source;
  116. _fog setParticleRandom [2, [0, 0, 0], [0.25, 0.25, 0.25], 0, 0.5, [0, 0, 0, 0.1], 0, 0, 10];
  117. _fog setDropInterval 0.001;
  118.  
  119. _fog setParticleParams [
  120. /*Sprite*/ ["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 13,0], "",
  121. /*Type*/ "Billboard",
  122. /*TimmerPer*/ 0.5,
  123. /*Lifetime*/ 0.5,
  124. /*Position*/ [0,0,0],
  125. /*MoveVelocity*/ [1.2, 1.2,-0.2],
  126. /*Simulation*/ 1, 1.275, 1, 0.2, //rotationVel,weight,volume,rubbing
  127. /*Scale*/ [0, 0.2,0],
  128. /*Color*/ [[1,1,1, 0.001], [1,1,1, 0.01], [1,1,1, 0]],
  129. /*AnimSpeed*/ [1000],
  130. /*randDirPeriod*/ 1,
  131. /*randDirIntesity*/ 0.04,
  132. /*onTimerScript*/ "",
  133. /*DestroyScript*/ "",
  134. /*Follow*/ _source
  135. ];
  136.  
  137. for [{_i = 0}, {_i < 10}, {_i = _i + 1}] do {
  138. _v1 = vectorDir _unit;
  139. _v2 = eyeDirection _unit;
  140. _cosA = [0,1,0] vectorCos _v1; // cos between north and body direction
  141. _cosB = _v1 vectorCos _v2; // cos between head- and body- directions
  142. _sinA = sqrt(1 - _cosA^2);
  143. _sinB = sqrt(1 - _cosB^2);
  144.  
  145. /* initial direction */
  146. _velocity = [0, 1.2, -0.2];
  147.  
  148. _volume = (_v1 select 0)*(_v2 select 1)-(_v1 select 1)*(_v2 select 0);
  149. // Which is equal to "(_v1 vectorCrossProduct _v2) select 2", but FASTER
  150. // We can find out which vector is on the right by calculating the volume of cross product
  151. // Volume will be negative if we turn head to the left and positive if turn to the right
  152.  
  153. /* direction when unit is running (to make steam round the neck && to prevent steam from the neck) */
  154. if (speed _unit > 5) then
  155. {
  156. if (_volume <= 0) then {
  157. _velocity = [2.2, 1.2, -0.2];
  158. } else {
  159. _velocity = [-2.2, 1.2, -0.2];
  160. };
  161. };
  162.  
  163. /* 1. Turn due to body direction */
  164. if (getDir _unit > 180 && getDir _unit <= 360) then {
  165. _velocity = [
  166. (_velocity select 0) * _cosA - (_velocity select 1) * _sinA,
  167. (_velocity select 0) * _sinA + (_velocity select 1) * _cosA,
  168. -0.2
  169. ];
  170. } else {
  171. _velocity = [
  172. (_velocity select 0) * _cosA + (_velocity select 1) * _sinA,
  173. -(_velocity select 0) * _sinA + (_velocity select 1) * _cosA,
  174. -0.2
  175. ];
  176. };
  177.  
  178. /* 2. Turn due to head direction */
  179. if (_volume <= 0) then { _sinB = -1 * _sinB; };
  180.  
  181. _velocity = [
  182. (_velocity select 0) * _cosB - (_velocity select 1) * _sinB,
  183. (_velocity select 0) * _sinB + (_velocity select 1) * _cosB,
  184. -0.2
  185. ];
  186.  
  187. _fog setParticleParams [
  188. /*Sprite*/ ["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 13,0], "",
  189. /*Type*/ "Billboard",
  190. /*TimmerPer*/ 0.5,
  191. /*Lifetime*/ 0.5,
  192. /*Position*/ [0,0,0],
  193. /*MoveVelocity*/ _velocity,
  194. /*Simulation*/ 1, 1.275, 1, 0.2, //rotationVel,weight,volume,rubbing
  195. /*Scale*/ [0, 0.2,0],
  196. /*Color*/ [[1,1,1, 0.001], [1,1,1, 0.01], [1,1,1, 0]],
  197. /*AnimSpeed*/ [1000],
  198. /*randDirPeriod*/ 1,
  199. /*randDirIntesity*/ 0.04,
  200. /*onTimerScript*/ "",
  201. /*DestroyScript*/ "",
  202. /*Follow*/ _source
  203. ];
  204.  
  205. sleep 0.05;
  206. };
  207.  
  208. _fog setDropInterval 1;
  209.  
  210. deleteVehicle _fog;
  211. deleteVehicle _source;
  212. };
  213.  
  214. // ====================================================================
  215.  
  216. 1 setFog 0.05;
  217. [] spawn FS_spawnSnowCube;
  218. {
  219. _x addEventHandler ["SoundPlayed", {_this spawn FS_makeBreathe; }];
  220. }
  221. forEach units group player;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement