Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile("cl_init.lua")
- AddCSLuaFile("shared.lua")
- include("shared.lua")
- function ENT:Initialize()
- self:SetModel("models/props_wasteland/rockgranite02b.mdl")
- self:PhysicsInit(SOLID_VPHYSICS)
- self:SetMoveType(MOVETYPE_VPHYSICS)
- self:SetSolid(SOLID_VPHYSICS)
- self.Replace = false
- self:SetNWInt("health", MGS_ROCK_HEALTH)
- self:SetNWInt("distance", MGS_DISTANCE)
- end
- function ENT:Think()
- if (!self.Replace) and (self:GetNWInt("health") <= 0) then
- local ores = math.Rand(1, 2)
- for i=1, math.Round(ores) do
- local ore = ents.Create("mgs_nsore")
- ore:SetPos(self:GetPos() + Vector(math.Rand(1,20), math.Rand(1,20),20))
- ore:Spawn()
- timer.Simple(100, function()
- if IsValid(ore) then
- ore:Remove()
- end
- end)
- end
- self.Replace = true
- self.ReplaceTime = CurTime() + 15
- self.Pos = self:GetPos()
- self:SetPos(self:GetPos() + Vector(0,0,-300))
- end;
- if (self.Replace) and (self.ReplaceTime < CurTime()) then
- self:SetNWInt("health", 10)
- self.Replace = false
- self:SetPos(self.Pos)
- self:SetColor( Color( 255, 255, 255, 255 ) )
- end
- end
- function ENT:OnTakeDamage(dmg)
- if table.HasValue(MGS_MINING_TOOLS, dmg:GetInflictor():GetClass()) or table.HasValue(MGS_MINING_TOOLS, dmg:GetAttacker():GetActiveWeapon():GetClass()) then
- if !dmg:GetAttacker():GetActiveWeapon():GetClass() then return end
- local miningskill = dmg:GetAttacker():getChar():getData("Skill_Mining")
- local xproll = math.random(0, (25 + math.random(0,miningskill)))
- local randomeventprobability = math.random(0, 1000)
- self:SetNWInt("health", self:GetNWInt("health") - 1)
- dmg:GetAttacker():getChar():setData("EXP", dmg:GetAttacker():getChar():getData("EXP") + xproll)
- dmg:GetAttacker():AddXP(0)
- dmg:GetAttacker():notify("You've gained " .. xproll .. " EXP from mining!")
- print(randomeventprobability)
- if (randomeventprobability <= 999) then
- dmg:GetAttacker():notify("You hit a sulfur deposit in the rock!")
- self:SetColor( Color( 255, 0, 0, 230 ) )
- self:SetRenderMode( RENDERMODE_TRANSALPHA )
- smoke = ents.Create("env_smoketrail")
- smoke:SetKeyValue("startsize","100")
- smoke:SetKeyValue("endsize","50")
- smoke:SetKeyValue("spawnradius","35")
- smoke:SetKeyValue("minspeed","0.1")
- smoke:SetKeyValue("maxspeed","0.5")
- smoke:SetKeyValue("startcolor","200 200 00")
- smoke:SetKeyValue("endcolor","255 191 0")
- smoke:SetKeyValue("opacity","1")
- smoke:SetKeyValue("spawnrate","15")
- smoke:SetKeyValue("lifetime","2")
- smoke:SetPos(self:GetPos())
- smoke:SetParent(self.Entity)
- smoke:Spawn()
- smoke:Fire("kill","",3)
- timer.Simple(3, function()
- local explosion = ents.Create("env_explosion")
- explosion:SetKeyValue("spawnflags", 144)
- explosion:SetKeyValue("iMagnitude", 85)
- explosion:SetKeyValue("iRadiusOverride", 256)
- explosion:SetPos(self:GetPos())
- explosion:Spawn()
- explosion:Fire("explode", "", 0)
- self.Entity:SetNWInt("health", 0)
- end)
- end
- end
- end
- function ENT:OnRemove()
- if not IsValid(self) then return end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement