Guest User

seatdmg

a guest
Jan 6th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. local PERCENT = 0.50
  2.  
  3. GoGoGarry = {}
  4. SeatDMG = {}
  5. function GoGoGarry.IsVehicle(enti)
  6. if enti then
  7. return type(enti.GetDriver)=="function"
  8. else
  9. return false
  10. end
  11. end
  12.  
  13. local wep = FindMetaTable("Entity")
  14.  
  15. // detour FireBullets
  16. if (wep._FireBBackup) then wep.FireBullets = wep._FireBBackup end
  17. wep.OldFireBullets = wep.FireBullets
  18. wep._FireBBackup = wep.FireBullets
  19.  
  20. wep.FireBullets = function( self, bullet )
  21.  
  22. // detour the callback function into the bullet
  23. local OldCallback = bullet.Callback
  24. bullet.Callback = function( attacker, tr, dmginfo )
  25.  
  26. local ent = tr.Entity
  27. if IsValid(ent) and ent:GetClass() == "prop_vehicle_prisoner_pod" then
  28. local driver = ent:GetDriver()
  29.  
  30. if IsValid(driver) then
  31. driver:TakeDamage( dmginfo:GetDamage()*PERCENT, attacker, nil )
  32. end
  33. end
  34.  
  35. // calls the old callback, if any
  36. if OldCallback then
  37. OldCallback( attacker, tr, dmginfo )
  38. end
  39. end
  40.  
  41. // call the old FireBullets function, passing the modified bullet
  42. self:OldFireBullets( bullet )
  43. end
  44.  
  45.  
  46.  
  47.  
  48. hook.Add("EntityTakeDamage","stdmg",function(tar,dinf)
  49.  
  50. if not GoGoGarry.IsVehicle(tar) then return dinf end
  51.  
  52. if dinf:IsExplosionDamage() then
  53. //print("HAAAA")
  54. dinf:ScaleDamage(0.7)
  55. dinf:SetAttacker(dinf:GetInflictor():CPPIGetOwner())
  56. if tar:GetDriver() then
  57. tar:GetDriver():TakeDamage( dinf:GetDamage(), dinf:GetInflictor():CPPIGetOwner() , dinf:GetInflictor() )
  58. end
  59. return dinf
  60. end
  61.  
  62.  
  63.  
  64. end,1)
Advertisement
Add Comment
Please, Sign In to add comment