Advertisement
Guest User

Untitled

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