Advertisement
jaydawg

Untitled

Jan 2nd, 2014
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.50 KB | None | 0 0
  1. /*---------------------------------------------------------------------------
  2. This is an example of a custom entity.
  3. ---------------------------------------------------------------------------*/
  4. AddCSLuaFile("cl_init.lua")
  5. AddCSLuaFile("shared.lua")
  6. include("shared.lua")
  7.  
  8. ENT.SeizeReward = 950
  9.  
  10. local PrintMore
  11. function ENT:Initialize()
  12.     self:SetModel("models/props_c17/consolebox01a.mdl")
  13.     self:PhysicsInit(SOLID_VPHYSICS)
  14.     self:SetMoveType(MOVETYPE_VPHYSICS)
  15.     self:SetSolid(SOLID_VPHYSICS)
  16.     local phys = self:GetPhysicsObject()
  17.     phys:Wake()
  18.  
  19.     self.sparking = false
  20.     self.damage = 100
  21.     self.IsMoneyPrinter = true
  22.     timer.Simple(math.random(100, 350), function() PrintMore(self) end)
  23.  
  24.     self.sound = CreateSound(self, Sound(""))
  25.     self.sound:SetSoundLevel(52)
  26.     self.sound:PlayEx(1, 100)
  27. end
  28.  
  29. function ENT:OnTakeDamage(dmg)
  30.     if self.burningup then return end
  31.  
  32.     self.damage = (self.damage or 100) - dmg:GetDamage()
  33.     if self.damage <= 0 then
  34.         local rnd = math.random(1, 10)
  35.         if rnd < 3 then
  36.             self:BurstIntoFlames()
  37.         else
  38.             self:Destruct()
  39.             self:Remove()
  40.         end
  41.     end
  42. end
  43.  
  44. function ENT:Destruct()
  45.     local vPoint = self:GetPos()
  46.     local effectdata = EffectData()
  47.     effectdata:SetStart(vPoint)
  48.     effectdata:SetOrigin(vPoint)
  49.     effectdata:SetScale(1)
  50.     util.Effect("Explosion", effectdata)
  51.     DarkRP.notify(self:Getowning_ent(), 1, 4, DarkRP.getPhrase("bronze_printer_exploded"))
  52. end
  53.  
  54. function ENT:BurstIntoFlames()
  55.     DarkRP.notify(self:Getowning_ent(), 0, 4, DarkRP.getPhrase("bronze_printer_overheating"))
  56.     self.burningup = true
  57.     local burntime = math.random(8, 18)
  58.     self:Ignite(burntime, 0)
  59.     timer.Simple(burntime, function() self:Fireball() end)
  60. end
  61.  
  62. function ENT:Fireball()
  63.     if not self:IsOnFire() then self.burningup = false return end
  64.     local dist = math.random(20, 280) -- Explosion radius
  65.     self:Destruct()
  66.     for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
  67.         if not v:IsPlayer() and not v:IsWeapon() and v:GetClass() ~= "predicted_viewmodel" and not v.IsMoneyPrinter then
  68.             v:Ignite(math.random(5, 22), 0)
  69.         elseif v:IsPlayer() then
  70.             local distance = v:GetPos():Distance(self:GetPos())
  71.             v:TakeDamage(distance / dist * 100, self, self)
  72.         end
  73.     end
  74.     self:Remove()
  75. end
  76.  
  77. PrintMore = function(ent)
  78.     if not IsValid(ent) then return end
  79.  
  80.     ent.sparking = true
  81.     timer.Simple(3, function()
  82.         if not IsValid(ent) then return end
  83.         ent:CreateMoneybag()
  84.     end)
  85. end
  86.  
  87. function ENT:CreateMoneybag()
  88.     if not IsValid(self) or self:IsOnFire() then return end
  89.  
  90.     local MoneyPos = self:GetPos()
  91.  
  92.     if GAMEMODE.Config.printeroverheat then
  93.         local overheatchance
  94.         if GAMEMODE.Config.printeroverheatchance <= 3 then
  95.             overheatchance = 22
  96.         else
  97.             overheatchance = GAMEMODE.Config.printeroverheatchance or 22
  98.         end
  99.         if math.random(1, overheatchance) == 3 then self:BurstIntoFlames() end
  100.     end
  101.  
  102.     local amount = GAMEMODE.Config.mprintamount
  103.     if amount == 0 then
  104.         amount = 250
  105.     end
  106.  
  107.     DarkRP.createMoneyBag(Vector(MoneyPos.x + 15, MoneyPos.y, MoneyPos.z + 15), amount)
  108.     self.sparking = false
  109.     timer.Simple(math.random(100, 350), function() PrintMore(self) end)
  110. end
  111.  
  112. function ENT:Think()
  113.  
  114.     if self:WaterLevel() > 0 then
  115.         self:Destruct()
  116.         self:Remove()
  117.         return
  118.     end
  119.  
  120.     if not self.sparking then return end
  121.  
  122.     local effectdata = EffectData()
  123.     effectdata:SetOrigin(self:GetPos())
  124.     effectdata:SetMagnitude(1)
  125.     effectdata:SetScale(1)
  126.     effectdata:SetRadius(2)
  127.     util.Effect("Sparks", effectdata)
  128. end
  129.  
  130. function ENT:OnRemove()
  131.     if self.sound then
  132.         self.sound:Stop()
  133.     end
  134. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement