HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4. #include <zombieplague>
  5.  
  6. new const paramodel[] = "models/parachute.mdl"
  7.  
  8. new bool:has_parachute[33], para_ent[33];
  9.  
  10. enum pcvar
  11. {
  12. humans = 1,
  13. survivors,
  14. zombies,
  15. nemesis,
  16. fallspeed,
  17. detach
  18. }
  19.  
  20. new pcvars[pcvar]
  21.  
  22. public plugin_init()
  23. {
  24. register_plugin("[ZP] Sub-Plugin: Parachute", "1.1", "Random1, 93()|29!/<")
  25.  
  26. pcvars[humans] = register_cvar("zp_parachute_humans", "1")
  27. pcvars[survivors] = register_cvar("zp_parachute_survivors", "1")
  28. pcvars[zombies] = register_cvar("zp_parachute_zombies", "1")
  29. pcvars[nemesis] = register_cvar("zp_parachute_nemesis", "1")
  30. pcvars[fallspeed] = register_cvar("zp_parachute_fallspeed", "75")
  31. pcvars[detach] = register_cvar("zp_parachute_detach", "1")
  32.  
  33. register_forward(FM_PlayerPreThink, "fw_PreThink")
  34. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  35. }
  36.  
  37. public plugin_precache()
  38. engfunc(EngFunc_PrecacheModel, paramodel)
  39.  
  40. public client_connect(id)
  41. parachute_reset(id)
  42.  
  43. public client_disconnect(id)
  44. parachute_reset(id)
  45.  
  46. parachute_reset(id, keep = 0)
  47. {
  48. if(para_ent[id] > 0)
  49. if (pev_valid(para_ent[id]))
  50. engfunc(EngFunc_RemoveEntity, para_ent[id]);
  51.  
  52. if (!keep)
  53. has_parachute[id] = false;
  54.  
  55. para_ent[id] = 0
  56.  
  57. if (!has_parachute[id])
  58. has_parachute[id] = true;
  59. }
  60.  
  61. // Ham Player Killed Forward
  62. public fw_PlayerKilled(victim, attacker, shouldgib)
  63. {
  64. engfunc(EngFunc_RemoveEntity, para_ent[victim]);
  65. para_ent[victim] = 0;
  66. }
  67.  
  68. public fw_PreThink(id)
  69. {
  70. //Parachute model animation information
  71. //0 - deploy - 84 frames
  72. //1 - idle - 39 frames
  73. //2 - detach - 29 frames
  74.  
  75. if (!is_user_alive(id) || !has_parachute[id]
  76. || !get_pcvar_num(pcvars[humans]) && !zp_get_user_zombie(id)
  77. && !zp_get_user_survivor(id) || !get_pcvar_num(pcvars[survivors])
  78. && zp_get_user_survivor(id) || !get_pcvar_num(pcvars[zombies])
  79. && zp_get_user_zombie(id) && !zp_get_user_nemesis(id)
  80. || !get_pcvar_num(pcvars[nemesis]) && zp_get_user_nemesis(id))
  81. return;
  82.  
  83. new Float:fallingspeed = get_pcvar_float(pcvars[fallspeed]) * -1.0;
  84. new Float:frame;
  85.  
  86. new button = pev(id, pev_button);
  87. new oldbutton = pev(id, pev_oldbuttons);
  88. new flags = pev(id, pev_flags);
  89.  
  90. if (para_ent[id] > 0 && (flags & FL_ONGROUND))
  91. {
  92. if (get_pcvar_num(pcvars[detach]))
  93. {
  94. if (pev(para_ent[id],pev_sequence) != 2)
  95. {
  96. set_pev(para_ent[id], pev_sequence, 2);
  97. set_pev(para_ent[id], pev_gaitsequence, 1);
  98. set_pev(para_ent[id], pev_frame, 0.0);
  99. set_pev(para_ent[id], pev_fuser1, 0.0);
  100. set_pev(para_ent[id], pev_animtime, 0.0);
  101. return;
  102. }
  103.  
  104. pev(para_ent[id],pev_fuser1, frame);
  105. frame += 2.0;
  106. set_pev(para_ent[id],pev_fuser1,frame);
  107. set_pev(para_ent[id],pev_frame,frame);
  108.  
  109. if (frame > 254.0)
  110. {
  111. engfunc(EngFunc_RemoveEntity, para_ent[id]);
  112. para_ent[id] = 0;
  113. }
  114. }
  115. else
  116. {
  117. engfunc(EngFunc_RemoveEntity, para_ent[id]);
  118. para_ent[id] = 0;
  119. }
  120.  
  121. return;
  122. }
  123.  
  124. if (button & IN_USE)
  125. {
  126.  
  127. new Float:velocity[3];
  128. pev(id, pev_velocity, velocity);
  129.  
  130. if (velocity[2] < 0.0)
  131. {
  132. if(para_ent[id] <= 0)
  133. {
  134. para_ent[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
  135.  
  136. if(para_ent[id] > 0)
  137. {
  138. set_pev(para_ent[id],pev_classname,"parachute");
  139. set_pev(para_ent[id], pev_aiment, id)
  140. set_pev(para_ent[id], pev_owner, id);
  141. set_pev(para_ent[id], pev_movetype, MOVETYPE_FOLLOW);
  142. engfunc(EngFunc_SetModel, para_ent[id], paramodel);
  143. set_pev(para_ent[id], pev_sequence, 0);
  144. set_pev(para_ent[id], pev_gaitsequence, 1);
  145. set_pev(para_ent[id], pev_frame, 0.0);
  146. set_pev(para_ent[id], pev_fuser1, 0.0);
  147. }
  148. }
  149.  
  150. if (para_ent[id] > 0)
  151. {
  152. set_pev(id, pev_sequence, 3)
  153. set_pev(id, pev_gaitsequence, 1)
  154. set_pev(id, pev_frame, 1.0)
  155. set_pev(id, pev_framerate, 1.0)
  156.  
  157. velocity[2] = (velocity[2] + 40.0 < fallingspeed) ? velocity[2] + 40.0 : fallingspeed
  158. set_pev(id, pev_velocity, velocity)
  159.  
  160. if (pev(para_ent[id],pev_sequence) == 0)
  161. {
  162.  
  163. pev(para_ent[id],pev_fuser1, frame);
  164. frame += 1.0;
  165. set_pev(para_ent[id],pev_fuser1,frame);
  166. set_pev(para_ent[id],pev_frame,frame);
  167.  
  168. if (frame > 100.0)
  169. {
  170. set_pev(para_ent[id], pev_animtime, 0.0);
  171. set_pev(para_ent[id], pev_framerate, 0.4);
  172. set_pev(para_ent[id], pev_sequence, 1);
  173. set_pev(para_ent[id], pev_gaitsequence, 1);
  174. set_pev(para_ent[id], pev_frame, 0.0);
  175. set_pev(para_ent[id], pev_fuser1, 0.0);
  176. }
  177. }
  178. }
  179. }
  180. else if (para_ent[id] > 0)
  181. {
  182. engfunc(EngFunc_RemoveEntity, para_ent[id]);
  183. para_ent[id] = 0;
  184. }
  185. }
  186. else if ((oldbutton & IN_USE) && para_ent[id] > 0)
  187. {
  188. engfunc(EngFunc_RemoveEntity, para_ent[id]);
  189. para_ent[id] = 0;
  190. }
  191. }
  192.  
  193. public zp_user_infected_post(id, nemesis)
  194. {
  195. if (!nemesis && get_pcvar_num(pcvars[zombies])
  196. || nemesis && get_pcvar_num(pcvars[nemesis]))
  197. return;
  198.  
  199. engfunc(EngFunc_RemoveEntity, para_ent[id]);
  200. para_ent[id] = 0;
  201. }
  202.  
  203. public zp_user_humanized_post(id, survivor)
  204. {
  205. if (!survivor && get_pcvar_num(pcvars[humans])
  206. || survivor && get_pcvar_num(pcvars[survivors]))
  207. return;
  208.  
  209. engfunc(EngFunc_RemoveEntity, para_ent[id]);
  210. para_ent[id] = 0;
  211. }
  212.