Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. // copypasta from microwave.
  2.  
  3. AddCSLuaFile("cl_init.lua")
  4. AddCSLuaFile("shared.lua")
  5. include('shared.lua')
  6.  
  7. function ENT:SpawnFunction( ply, tr )
  8.  
  9. if ( !tr.Hit ) then return end
  10.  
  11. local SpawnPos = tr.HitPos + tr.HitNormal * 42
  12.  
  13. local ent = ents.Create( "healthdispenser" )
  14. ent:SetPos( SpawnPos )
  15. ent:Spawn()
  16. ent:Activate()
  17. return ent
  18.  
  19. end
  20.  
  21. function ENT:Initialize()
  22.  
  23. self.Entity:SetModel( "models/props_lab/reciever_cart.mdl")
  24. self.Entity:PhysicsInit(SOLID_VPHYSICS)
  25. self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
  26. self.Entity:SetNWInt("upgrade", 0)
  27. self.Entity:SetSolid(SOLID_VPHYSICS)
  28. local phys = self.Entity:GetPhysicsObject()
  29. if(phys:IsValid()) then phys:Wake() end
  30. self.Entity:SetNWBool("sparking",false)
  31. self.Entity:SetNWInt("damage",500)
  32. local ply = self.Entity:GetNWEntity( "owner" )
  33. ply:GetTable().maxdispensers=ply:GetTable().maxhealthdispensers + 1
  34. self.Entity:SetNWInt("power",0)
  35. self.scrap = false
  36. end
  37.  
  38.  
  39. function ENT:MakeScraps()
  40. if !self.scrap then
  41. self.scrap = true
  42. local value = CfgVars["healthdispensercost"]/8
  43. if value<5 then value = 5 end
  44. for i=0, 5, 1 do
  45. local scrap = ents.Create("prop_physics")
  46. scrap:SetModel( "models/gibs/metal_gib" .. math.random(1,5) .. ".mdl" );
  47. local randpos = Vector(math.random(-5,5), math.random(-5,5), math.random(0,5))
  48. scrap:SetNWEntity("owner", self.Entity:GetNWEntity("owner"))
  49. scrap:SetPos(self.Entity:GetPos()+randpos)
  50. scrap:Spawn()
  51. scrap:GetTable().ScrapMetal = true
  52. scrap:GetTable().Amount = math.random(3,value)
  53. scrap:Activate()
  54. scrap:GetPhysicsObject():SetVelocity(randpos*35)
  55.  
  56. end
  57. end
  58. end
  59.  
  60. function ENT:Use(activator,caller)
  61. if self.Entity:GetNWBool("sparking") == true then return end
  62. plgun = activator:GetActiveWeapon()
  63. if activator:Health()<activator:GetMaxHealth() then
  64. activator:SetHealth(activator:Health()+25)
  65. activator:SetArmor(activator:Armor()+15)
  66. if (activator:Armor()>100) then activator:SetArmor(100) end
  67. if (activator:Health()>activator:GetMaxHealth()) then activator:SetHealth(activator:GetMaxHealth()) end
  68. end
  69. self.Entity:SetNWBool("sparking",true)
  70. if (self.Entity:GetNWInt("upgrade")>0) then
  71.  
  72. activator:SetHealth(activator:Health()+25)
  73. activator:SetArmor(activator:Armor()+20)
  74. if (activator:Armor()>100) then activator:SetArmor(100) end
  75. if (activator:Health()>activator:GetMaxHealth()) then activator:SetHealth(activator:GetMaxHealth()) end
  76.  
  77. timer.Create( tostring(self.Entity) .. "resup", 0.75, 1, self.resupply, self)
  78. end
  79. if (self.Entity:GetNWInt("upgrade")==2) then
  80. activator:SetHealth(activator:Health()+25)
  81. activator:SetArmor(activator:Armor()+25)
  82. if (activator:Armor()>100) then activator:SetArmor(100) end
  83. end
  84. end
  85.  
  86. function ENT:resupply()
  87. self.Entity:SetNWBool("sparking",false)
  88. end
  89.  
  90. function ENT:Think()
  91. if (ValidEntity(self.Entity:GetNWEntity("owner"))!=true) then
  92. self.Entity:Remove()
  93. end
  94. end
  95.  
  96. function ENT:OnRemove( )
  97. timer.Destroy(tostring(self.Entity))
  98. local ply = self.Entity:GetNWEntity( "owner" )
  99. if ValidEntity(ply) then
  100. ply:GetTable().maxhealthdispensers=ply:GetTable().maxhealthdispensers - 1
  101. end
  102. timer.Destroy(tostring(self.Entity) .. "resup")
  103. end
Add Comment
Please, Sign In to add comment