HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1.  
  2. #include <amxmodx>
  3.  
  4. /* Choose One */
  5. //#include <engine>
  6. #include <fakemeta>
  7.  
  8. #include "ojos.inc"
  9.  
  10. #define MAX_LIGHT_POINTS 3
  11.  
  12. new weather_ent
  13. new Float:g_strikedelay
  14. new g_lightpoints[MAX_LIGHT_POINTS]
  15. new g_fxbeam;
  16. new g_soundstate[33]
  17. new g_maxplayers;
  18. new g_stormintensity;
  19.  
  20. public plugin_precache()
  21. {
  22. register_plugin("RainySnowy", "2.0y", "OneEyed & teame06");
  23. register_cvar("rainysnowy", "2.0y", FCVAR_SERVER);
  24. register_cvar("weather_type", "1");
  25. register_cvar("weather_storm", "50");
  26.  
  27. g_maxplayers = get_maxplayers();
  28.  
  29. new type = get_cvar_num("weather_type");
  30. if(type == 3)
  31. type = random_num(0,2);
  32.  
  33. switch(type) {
  34. case 1:
  35. {
  36. g_fxbeam = precache_model("sprites/laserbeam.spr");
  37. precache_model("models/chick.mdl");
  38. precache_sound("ambience/rain.wav");
  39. precache_sound("ambience/thunder_clap.wav");
  40. weather_ent = CREATE_ENTITY("env_rain")
  41. THINK("env_rain","WeatherSystem")
  42. NEXTTHINK(weather_ent,1.0)
  43. }
  44. case 2:
  45. {
  46. weather_ent = CREATE_ENTITY("env_snow");
  47. }
  48. }
  49. }
  50.  
  51. public client_putinserver(id)
  52. client_cmd(id,"cl_weather 1");
  53.  
  54. //This is only for rain.
  55. public WeatherSystem(entid) {
  56. if(entid == weather_ent)
  57. {
  58. //Is weather_storm activated? ( 0 = OFF ) -- ( 1-100 = INTENSITY )
  59. g_stormintensity = get_cvar_num("weather_storm");
  60.  
  61. //Do our soundstate and picks random player.
  62. new victim = GetSomeoneUnworthy();
  63.  
  64. if(g_stormintensity)
  65. {
  66. //Is the delay up?
  67. if(g_strikedelay < get_gametime())
  68. {
  69. //We got player to create lightning from?
  70. if(victim)
  71. {
  72. //Do our Lightning Technique.
  73. CreateLightningPoints(victim);
  74. }
  75. }
  76. }
  77. NEXTTHINK(weather_ent,2.0)
  78. }
  79. return PLUGIN_CONTINUE
  80. }
  81.  
  82. GetSomeoneUnworthy() {
  83. new cnt, id, total[33];
  84. for(id=1;id<g_maxplayers;id++)
  85. if(is_user_alive(id))
  86. if(is_user_outside(id))
  87. {
  88. total[cnt++] = id;
  89.  
  90. if(!g_soundstate[id]) {
  91. g_soundstate[id] = 1;
  92. client_cmd(id, "speak ambience/rain.wav");
  93. }
  94. }
  95. else if(g_soundstate[id])
  96. {
  97. g_soundstate[id] = 0;
  98. client_cmd(id, "speak NULL")
  99. }
  100.  
  101. if(cnt)
  102. return total[random_num(0, (cnt-1))];
  103. return 0;
  104. }
  105.  
  106. CreateLightningPoints(victim)
  107. {
  108. if(IS_VALID_ENT(g_lightpoints[0]))
  109. return 0;
  110.  
  111. new ent, x, Float:tVel[3];
  112. new Float:vOrig[3];
  113. new Float:mins[3] = { -1.0, -1.0, -1.0 };
  114. new Float:maxs[3] = { 1.0, 1.0, 1.0 };
  115. new Float:dist = is_user_outside(victim)-5; //Get distance to set ents at.
  116.  
  117. GET_ORIGIN(victim,vOrig)
  118. if(dist > 700.0) { //cap distance.
  119. dist = 700.0;
  120. }
  121. vOrig[2] += dist;
  122.  
  123. //Create lightning bolts by spreading X entities randomly with velocity
  124. for(x=0;x<MAX_LIGHT_POINTS;x++)
  125. {
  126. ent = CREATE_ENTITY("env_sprite")
  127. SET_INT(ent,movetype,MOVETYPE_FLY)
  128. SET_INT(ent,solid,SOLID_TRIGGER)
  129. SET_FLOAT(ent,renderamt,0.0)
  130. SET_INT(ent,rendermode,kRenderTransAlpha)
  131. SET_MODEL(ent,"models/chick.mdl")
  132.  
  133. SET_VECTOR(ent,mins,mins)
  134. SET_VECTOR(ent,maxs,maxs)
  135. tVel[0] = random_float(-500.0,500.0);
  136. tVel[1] = random_float(-500.0,500.0);
  137. tVel[2] = random_float((dist<=700.0?0.0:-100.0),(dist<=700.0?0.0:50.0));
  138.  
  139. SET_VECTOR(ent,origin,vOrig)
  140. SET_VECTOR(ent,velocity,tVel)
  141. g_lightpoints[x] = ent;
  142. }
  143. emit_sound(ent, CHAN_STREAM, "ambience/thunder_clap.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  144. set_task(random_float(0.6,2.0),"Lightning",victim);
  145. return 1;
  146. }
  147.  
  148. // Creating a beam at each entity consecutively.
  149. // Player has 1 in 1000 chance of getting struck !
  150. public Lightning(victim)
  151. {
  152. new x, a, b, rand;
  153. new endpoint = MAX_LIGHT_POINTS-1;
  154. while(x < endpoint) {
  155. a = g_lightpoints[x];
  156. b = g_lightpoints[x+1];
  157. x++
  158. if(x == endpoint) {
  159. rand = random_num(1,1000); //One unlucky son of a bish.
  160. if(rand == 1) {
  161. b = victim;
  162. FAKE_DAMAGE(victim,"Lightning",100.0,1);
  163. }
  164. }
  165. CreateBeam(a,b);
  166. }
  167.  
  168. for(x=0;x<MAX_LIGHT_POINTS;x++)
  169. if(IS_VALID_ENT(g_lightpoints[x]))
  170. REMOVE_ENTITY(g_lightpoints[x])
  171.  
  172.  
  173. //Set up next lightning.
  174. if(g_stormintensity > 100) {
  175. set_cvar_num("weather_storm", 100);
  176. g_stormintensity = 100;
  177. }
  178. new Float:mins = 50.0-float(g_stormintensity/2);
  179. new Float:maxs = 50.0-float(g_stormintensity/3);
  180. g_strikedelay = get_gametime() + random_float(mins, maxs);
  181. }
  182.  
  183. //return distance above us to sky
  184. Float:is_user_outside(id) {
  185. new Float:origin[3], Float:dist;
  186. GET_ORIGIN(id, origin)
  187.  
  188. dist = origin[2];
  189.  
  190. while (POINTCONTENTS(origin) == -1)
  191. origin[2] += 5.0;
  192.  
  193. if (POINTCONTENTS(origin) == -6) return (origin[2]-dist);
  194. return 0.0;
  195. }
  196.  
  197. CreateBeam(entA, entB)
  198. {
  199. message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  200. write_byte( 8 );
  201. write_short( entA );
  202. write_short( entB );
  203. write_short( g_fxbeam );
  204. write_byte(0); //start frame
  205. write_byte(10); //framerate
  206. write_byte(5); //life
  207. write_byte(8); //width
  208. write_byte(100); //noise
  209. write_byte(255); //red
  210. write_byte(255); //green
  211. write_byte(255); //blue
  212. write_byte(255); //brightness
  213. write_byte(10); //scroll speed
  214. message_end();
  215. }