HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Formatright © 2009, ConnorMcLeod
  2.  
  3. LongJump Enabler is free software;
  4. you can redistribute it and/or modify it under the terms of the
  5. GNU General Public License as published by the Free Software Foundation.
  6.  
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11.  
  12. You should have received a copy of the GNU General Public License
  13. along with LongJump Enabler; if not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17.  
  18. #include <amxmodx>
  19. #include <engine>
  20. #include <fakemeta>
  21. #include <hamsandwich>
  22.  
  23. #define VERSION "1.0.0"
  24.  
  25. #define MAX_PLAYERS 32
  26.  
  27. #define m_Activity 73
  28. #define m_IdealActivity 74
  29. #define m_afButtonPressed 246
  30. #define m_fLongJump 356
  31.  
  32. #define PLAYER_SUPERJUMP 7
  33. #define ACT_LEAP 8
  34.  
  35. #define FBitSet(%1,%2) (%1 & %2)
  36.  
  37. new bool:g_bSuperJump[MAX_PLAYERS+1]
  38.  
  39. public plugin_init()
  40. {
  41. register_plugin("LongJump Enabler", VERSION, "ConnorMcLeod")
  42.  
  43. RegisterHam(Ham_Player_Jump, "player", "Player_Jump")
  44. RegisterHam(Ham_Player_Duck, "player", "Player_Duck")
  45. }
  46.  
  47. public Player_Duck(id)
  48. {
  49. if( g_bSuperJump[id] )
  50. {
  51. g_bSuperJump[id] = false
  52. return HAM_SUPERCEDE
  53. }
  54. return HAM_IGNORED
  55. }
  56.  
  57. public Player_Jump(id)
  58. {
  59. if( !is_user_alive(id) )
  60. {
  61. return HAM_IGNORED
  62. }
  63.  
  64. static iFlags ; iFlags = entity_get_int(id, EV_INT_flags)
  65.  
  66. if( FBitSet(iFlags, FL_WATERJUMP) || entity_get_int(id, EV_INT_waterlevel) >= 2 )
  67. {
  68. return HAM_IGNORED
  69. }
  70.  
  71. static afButtonPressed ; afButtonPressed = get_pdata_int(id, m_afButtonPressed)
  72.  
  73. if( !FBitSet(afButtonPressed, IN_JUMP) || !FBitSet(iFlags, FL_ONGROUND) )
  74. {
  75. return HAM_IGNORED
  76. }
  77.  
  78. if( (entity_get_int(id, EV_INT_bInDuck) || iFlags & FL_DUCKING)
  79. && get_pdata_int(id, m_fLongJump)
  80. && entity_get_int(id, EV_INT_button) & IN_DUCK
  81. && entity_get_int(id, EV_INT_flDuckTime) )
  82. {
  83. static Float:fVecTemp[3]
  84. entity_get_vector(id, EV_VEC_velocity, fVecTemp)
  85. if( vector_length(fVecTemp) > 50.0 )
  86. {
  87. entity_get_vector(id, EV_VEC_punchangle, fVecTemp)
  88. fVecTemp[0] = -5.0
  89. entity_set_vector(id, EV_VEC_punchangle, fVecTemp)
  90.  
  91. get_global_vector(GL_v_forward, fVecTemp)
  92. fVecTemp[0] *= 560.0
  93. fVecTemp[1] *= 560.0
  94. fVecTemp[2] = 299.33259094191531084669989858532
  95.  
  96. entity_set_vector(id, EV_VEC_velocity, fVecTemp)
  97.  
  98. set_pdata_int(id, m_Activity, ACT_LEAP)
  99. set_pdata_int(id, m_IdealActivity, ACT_LEAP)
  100. g_bSuperJump[id] = true
  101.  
  102. entity_set_int(id, EV_INT_oldbuttons, entity_get_int(id, EV_INT_oldbuttons) | IN_JUMP)
  103.  
  104. entity_set_int(id, EV_INT_gaitsequence, PLAYER_SUPERJUMP)
  105. entity_set_float(id, EV_FL_frame, 0.0)
  106.  
  107. set_pdata_int(id, m_afButtonPressed, afButtonPressed & ~IN_JUMP)
  108. return HAM_SUPERCEDE
  109. }
  110. }
  111. return HAM_IGNORED
  112. }