Advertisement
Exho

Untitled

Sep 26th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. ----// TTT Weapon Diversity //----
  2. -- Author: Exho
  3. -- V: 9/25/14
  4.  
  5. AddCSLuaFile()
  6. local RandomStats = {}
  7. math.randomseed(os.time())
  8.  
  9.  
  10. -- Example:
  11. RandomStats["weapon_garryomatic"] = { -- Weapon's class/file name
  12. -- It goes (Mim Value, Max Value) and all of these NEED to be in decimal format even if they are integers.
  13. dmg = math.Rand(0.0001, 10000 ), -- Damage
  14. recoil = math.Rand(1.0, 2.0), -- Recoil
  15. cone = math.Rand(0.01, 0.04), -- Spread between each bullet
  16. delay = math.Rand(0.2, 0.3), -- Delay between shots
  17. }
  18.  
  19. local function Randomize()
  20. -- Put custom weapon stat tables below this line
  21.  
  22. --// Default TTT //--
  23. RandomStats["weapon_ttt_m16"] = { -- M16
  24. dmg = math.Rand(20.0, 28.5),
  25. recoil = math.Rand(1.3, 2.0),
  26. cone = math.Rand(0.015, 0.023),
  27. delay = math.Rand(0.17, 0.23),
  28. }
  29. RandomStats["weapon_ttt_glock"] = { -- Glock
  30. dmg = math.Rand(7.0, 15.0),
  31. recoil = math.Rand(0.7,1.0),
  32. cone = math.Rand(0.015, 0.023),
  33. delay = math.Rand(0.1, 0.12),
  34. }
  35. RandomStats["weapon_zm_mac10"] = { -- Mac10
  36. dmg = math.Rand(9.0, 15.0),
  37. recoil = math.Rand(1.0, 1.5),
  38. cone = math.Rand(0.025, 0.035),
  39. delay = math.Rand(0.05, 0.07),
  40. }
  41. RandomStats["weapon_zm_shotgun"] = { -- Shotgun
  42. dmg = math.Rand(9.1, 12.0),
  43. recoil = math.Rand(5.1, 7.5),
  44. cone = math.Rand(0.07, 0.09),
  45. delay = math.Rand(0.6, 0.9),
  46. }
  47. RandomStats["weapon_zm_revolver"] = { -- Deagle
  48. dmg = math.Rand(35.0, 45.0),
  49. recoil = math.Rand(5.5, 6.8),
  50. cone = math.Rand(0.018, 0.025),
  51. delay = math.Rand(0.5, 0.7),
  52. }
  53. RandomStats["weapon_zm_rifle"] = { -- Rifle
  54. dmg = math.Rand(43.0, 60.0),
  55. recoil = math.Rand(6.0, 8.0),
  56. cone = math.Rand(0.003, 0.01),
  57. delay = math.Rand(1.4, 1.7),
  58. }
  59. RandomStats["weapon_zm_pistol"] = { -- Five Seven
  60. dmg = math.Rand(20.0, 30.0),
  61. recoil = math.Rand(1.3, 1.6),
  62. cone = math.Rand(0.015, 0.035),
  63. delay = math.Rand(0.3, 0.45),
  64. }
  65. RandomStats["weapon_zm_sledge"] = { -- HUGE
  66. dmg = math.Rand(6.0, 10.0),
  67. recoil = math.Rand(1.6, 2.0),
  68. cone = math.Rand(0.07, 0.09),
  69. delay = math.Rand(0.05, 0.08),
  70. }
  71. end
  72.  
  73.  
  74. -- This hook is called when each entity has become available to Lua so it will cycle through every entity in the map.
  75. local function WeaponStatChanger(ent)
  76. if not ent:IsWeapon() then return end -- First check to weed out any non-weapons
  77.  
  78. local class = ent:GetClass()
  79. Randomize() -- Its a weapon so we want to create our random variables
  80. for k,v in pairs(RandomStats) do
  81. if k == class then -- Its on the Stats table
  82. timer.Simple(0.5, function() -- Small delay to ensure it will work
  83. if not IsValid(ent) then return end
  84. if ent.Primary then
  85. -- And then setting the variables
  86. ent.Primary.Damage = math.Round(v.dmg)
  87. ent.Primary.Recoil = v.recoil
  88. ent.Primary.Cone = v.cone
  89. ent.Primary.Delay = v.delay
  90. end
  91. end)
  92. end
  93. end
  94. end
  95. hook.Add( "OnEntityCreated", "RandomizeTheWeapons", WeaponStatChanger )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement