Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. AddCSLuaFile("cl_init.lua")
  2. AddCSLuaFile("shared.lua")
  3.  
  4. include("shared.lua")
  5.  
  6. function ENT:Initialize()
  7. self:SetModel("models/props_wasteland/rockgranite02b.mdl")
  8. self:PhysicsInit(SOLID_VPHYSICS)
  9. self:SetMoveType(MOVETYPE_VPHYSICS)
  10. self:SetSolid(SOLID_VPHYSICS)
  11. self.Replace = false
  12. self:SetNWInt("health", MGS_ROCK_HEALTH)
  13. self:SetNWInt("distance", MGS_DISTANCE)
  14. end
  15.  
  16.  
  17.  
  18. function ENT:Think()
  19.  
  20. if (!self.Replace) and (self:GetNWInt("health") <= 0) then
  21. local ores = math.Rand(1, 2)
  22. for i=1, math.Round(ores) do
  23. local ore = ents.Create("mgs_nsore")
  24. ore:SetPos(self:GetPos() + Vector(math.Rand(1,20), math.Rand(1,20),20))
  25. ore:Spawn()
  26. timer.Simple(100, function()
  27. if IsValid(ore) then
  28. ore:Remove()
  29. end
  30. end)
  31. end
  32. self.Replace = true
  33. self.ReplaceTime = CurTime() + 15
  34. self.Pos = self:GetPos()
  35. self:SetPos(self:GetPos() + Vector(0,0,-300))
  36. end;
  37.  
  38. if (self.Replace) and (self.ReplaceTime < CurTime()) then
  39. self:SetNWInt("health", 10)
  40. self.Replace = false
  41. self:SetPos(self.Pos)
  42. self:SetColor( Color( 255, 255, 255, 255 ) )
  43. end
  44. end
  45.  
  46. function ENT:OnTakeDamage(dmg)
  47.  
  48. if table.HasValue(MGS_MINING_TOOLS, dmg:GetInflictor():GetClass()) or table.HasValue(MGS_MINING_TOOLS, dmg:GetAttacker():GetActiveWeapon():GetClass()) then
  49. if !dmg:GetAttacker():GetActiveWeapon():GetClass() then return end
  50.  
  51. local miningskill = dmg:GetAttacker():getChar():getData("Skill_Mining")
  52. local xproll = math.random(0, (25 + math.random(0,miningskill)))
  53. local randomeventprobability = math.random(0, 1000)
  54.  
  55. self:SetNWInt("health", self:GetNWInt("health") - 1)
  56. dmg:GetAttacker():getChar():setData("EXP", dmg:GetAttacker():getChar():getData("EXP") + xproll)
  57. dmg:GetAttacker():AddXP(0)
  58. dmg:GetAttacker():notify("You've gained " .. xproll .. " EXP from mining!")
  59. print(randomeventprobability)
  60.  
  61.  
  62. if (randomeventprobability <= 999) then
  63. dmg:GetAttacker():notify("You hit a sulfur deposit in the rock!")
  64. self:SetColor( Color( 255, 0, 0, 230 ) )
  65. self:SetRenderMode( RENDERMODE_TRANSALPHA )
  66.  
  67. smoke = ents.Create("env_smoketrail")
  68. smoke:SetKeyValue("startsize","100")
  69. smoke:SetKeyValue("endsize","50")
  70. smoke:SetKeyValue("spawnradius","35")
  71. smoke:SetKeyValue("minspeed","0.1")
  72. smoke:SetKeyValue("maxspeed","0.5")
  73. smoke:SetKeyValue("startcolor","200 200 00")
  74. smoke:SetKeyValue("endcolor","255 191 0")
  75. smoke:SetKeyValue("opacity","1")
  76. smoke:SetKeyValue("spawnrate","15")
  77. smoke:SetKeyValue("lifetime","2")
  78. smoke:SetPos(self:GetPos())
  79. smoke:SetParent(self.Entity)
  80.  
  81. smoke:Spawn()
  82. smoke:Fire("kill","",3)
  83.  
  84. timer.Simple(3, function()
  85. local explosion = ents.Create("env_explosion")
  86. explosion:SetKeyValue("spawnflags", 144)
  87. explosion:SetKeyValue("iMagnitude", 85)
  88. explosion:SetKeyValue("iRadiusOverride", 256)
  89. explosion:SetPos(self:GetPos())
  90. explosion:Spawn()
  91. explosion:Fire("explode", "", 0)
  92. self.Entity:SetNWInt("health", 0)
  93. end)
  94. end
  95. end
  96. end
  97.  
  98. function ENT:OnRemove()
  99. if not IsValid(self) then return end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement