Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BLACKBOX:IncludePrefixed("sh_auto.lua");
- AddCSLuaFile("cl_auto.lua");
- AddCSLuaFile("sh_auto.lua");
- -- Called when the entity initializes.
- function ENT:Initialize()
- self:SetModel("models/halokiller38/fallout/weapons/mines/cryomine.mdl");
- self:PhysicsInit( SOLID_VPHYSICS );
- self:SetMoveType( MOVETYPE_VPHYSICS );
- self:SetSolid( SOLID_VPHYSICS );
- self:SetUseType(SIMPLE_USE);
- self:SetColor(Color(255, 187, 0, 255) );
- self:DrawShadow( false );
- self:SetCollisionGroup( COLLISION_GROUP_WEAPON );
- self:SetHealth(200);
- self.timeleft = CurTime() + 3
- local physicsObject = self:GetPhysicsObject();
- if ( IsValid(physicsObject) ) then
- physicsObject:Wake();
- physicsObject:EnableMotion(true);
- end;
- end;
- -- Called each frame.
- function ENT:Think()
- if not IsValid(self) then return end
- if not IsValid(self.Entity) then return end
- if self.timeleft < CurTime() then
- for k, v in pairs( ents.FindInSphere(self:GetPos(), 128) ) do
- if ( v:IsPlayer() and v:Alive() and v:GetMoveType() == MOVETYPE_WALK and v:Name() != self:GetNWString("ownername") ) then
- if ( IsValid(self) ) then
- self:Explode();
- end;
- end;
- end;
- end;
- if ( !self:IsInWorld() ) then
- self:Remove();
- end;
- end;
- -- A function to explode the entity.
- function ENT:Explode()
- if not IsValid(self) then return end
- if not IsValid(self.Entity) then return end
- timer.Simple(1, function()
- timer.Simple(1, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(1, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.9, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.8, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.7, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.6, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.5, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.4, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.3, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.2, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.1, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.1, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.1, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- timer.Simple(0.1, function()
- self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- end);
- timer.Simple(2.5, function()
- for k, v in pairs( ents.FindInSphere(self:GetPos(), 128) ) do
- if ( v:IsPlayer() and v:Alive() and v:GetMoveType() == MOVETYPE_WALK ) then
- v:TakeDamageInfo( BLACKBOX:FakeDamageInfo( math.random(25,50), self, v, self:GetPos(), DMG_BURN, math.random(10,20) ) );
- elseif ( v:IsNPC() ) then
- v:TakeDamageInfo( BLACKBOX:FakeDamageInfo( math.random(25,50), self, v, self:GetPos(), DMG_BURN, math.random(10,20) ) );
- v:Ignite(math.random(10,15), 0);
- end;
- end;
- for i = 1, 20 do
- local a = math.Rand( 0, 2 * math.pi );
- local s = math.sin( a );
- local c = math.cos( a );
- local r = math.random( 0, 256 );
- local x = c * r;
- local y = s * r;
- local trace = { };
- trace.start = self:GetPos();
- trace.endpos = trace.start + Vector( x, y, 48 );
- trace.filter = self;
- local tr = util.TraceLine( trace );
- if( !tr.Hit ) then
- local trace = { };
- trace.start = tr.HitPos;
- trace.endpos = trace.start + Vector( 0, 0, -32768 );
- trace.filter = self;
- tr = util.TraceLine( trace );
- end
- local effectdata = EffectData()
- effectdata:SetOrigin(self:GetPos())
- util.Effect("HelicopterMegaBomb", effectdata)
- util.Effect("ThumperDust", effectdata)
- util.Effect("Explosion", effectdata)
- local del = math.Rand( 0, 1 );
- local fireEnt = ents.Create( "env_fire" );
- fireEnt:SetPos( tr.HitPos );
- fireEnt:SetKeyValue( "spawnflags", "1" );
- fireEnt:SetKeyValue( "attack", "4" );
- fireEnt:SetKeyValue( "firesize", "220" );
- fireEnt:Spawn();
- fireEnt:Activate();
- fireEnt:Fire( "Enable", "", del );
- fireEnt:Fire( "StartFire", "", del );
- SafeRemoveEntityDelayed( fireEnt, math.random( 28, 35 ) );
- end;
- self:Remove();
- end);
- end;
- -- Called when the entity is used.
- function ENT:Use(activator, caller)
- if not IsValid(self) then return end
- if not IsValid(self.Entity) then return end
- if (activator:Name() == self:GetNWString("ownername")) then
- if ( activator:IsPlayer() and activator:Alive() ) then
- self:EmitSound("fosounds/fix/wpn_mine_disarm.mp3")
- activator:UpdateInventory("Incendiary Mine", 1, true)
- blackbox.player.Notify(activator, "Mine successfully defused.")
- self:Remove();
- end;
- else
- blackbox.player.Notify(activator, "This mine doesn't belong to this character!")
- end;
- end;
- -- Called when the entity takes damage.
- function ENT:OnTakeDamage(damageInfo)
- self:SetHealth( math.max(self:Health() - damageInfo:GetDamage(), 0) );
- if (self:Health() <= 0) then
- self:Explode(); self:Remove();
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement