Advertisement
iFenomenal

Armuraaa

Apr 2nd, 2020
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <hamsandwich>
  3. #include <fakemeta>
  4.  
  5. #define PLUGIN "Armor block knife dmg"
  6. #define VERSION "1.0"
  7. #define AUTHOR "Nubo"
  8.  
  9. // Credits: cheap_suit - Biohazard ZM 3.1
  10.  
  11. new g_cAbsorbPercent
  12.  
  13. public plugin_init()
  14. {
  15. register_plugin( PLUGIN, VERSION, AUTHOR )
  16.  
  17. RegisterHam( Ham_TakeDamage, "player", "ham_takedamage_pre", 0 )
  18.  
  19. g_cAbsorbPercent = register_cvar( "armor_absorption_percent", "0.20" ) // 0.25 = 25% , 0.5 = 50% , etc.
  20. }
  21.  
  22. public ham_takedamage_pre( victim, inflictor, attacker, Float:damage, damagetype )
  23. {
  24. if( victim == attacker || !is_user_alive(victim) || !is_user_alive(attacker) )
  25. return HAM_IGNORED
  26.  
  27. if( attacker != inflictor )
  28. return HAM_IGNORED
  29.  
  30. static Float:armor
  31. pev( victim, pev_armorvalue, armor )
  32.  
  33. static Float:extra_dmg
  34. static Float:absorption
  35.  
  36. if( armor > 0.0 )
  37. {
  38. absorption = damage * get_pcvar_float(g_cAbsorbPercent)
  39.  
  40. extra_dmg = damage - absorption
  41.  
  42. armor -= absorption
  43.  
  44. if( armor < 0.0 )
  45. {
  46. extra_dmg -= armor
  47. armor = 0.0
  48. }
  49.  
  50. set_pev( victim, pev_armorvalue, armor )
  51.  
  52. SetHamParamFloat( 4, extra_dmg )
  53. }
  54.  
  55. return HAM_HANDLED
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement