Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. BLACKBOX:IncludePrefixed("sh_auto.lua");
  2.  
  3. AddCSLuaFile("cl_auto.lua");
  4. AddCSLuaFile("sh_auto.lua");
  5.  
  6. -- Called when the entity initializes.
  7. function ENT:Initialize()
  8.  
  9. self:SetModel("models/halokiller38/fallout/weapons/mines/cryomine.mdl");
  10. self:PhysicsInit( SOLID_VPHYSICS );
  11. self:SetMoveType( MOVETYPE_VPHYSICS );
  12. self:SetSolid( SOLID_VPHYSICS );
  13. self:SetUseType(SIMPLE_USE);
  14. self:SetColor(Color(255, 187, 0, 255) );
  15. self:DrawShadow( false );
  16. self:SetCollisionGroup( COLLISION_GROUP_WEAPON );
  17. self:SetHealth(200);
  18.  
  19. self.timeleft = CurTime() + 3
  20.  
  21. local physicsObject = self:GetPhysicsObject();
  22.  
  23. if ( IsValid(physicsObject) ) then
  24. physicsObject:Wake();
  25. physicsObject:EnableMotion(true);
  26. end;
  27. end;
  28.  
  29. -- Called each frame.
  30. function ENT:Think()
  31.  
  32. if not IsValid(self) then return end
  33. if not IsValid(self.Entity) then return end
  34.  
  35. if self.timeleft < CurTime() then
  36. for k, v in pairs( ents.FindInSphere(self:GetPos(), 128) ) do
  37. if ( v:IsPlayer() and v:Alive() and v:GetMoveType() == MOVETYPE_WALK and v:Name() != self:GetNWString("ownername") ) then
  38. if ( IsValid(self) ) then
  39. self:Explode();
  40. end;
  41. end;
  42. end;
  43. end;
  44.  
  45. if ( !self:IsInWorld() ) then
  46. self:Remove();
  47. end;
  48.  
  49. end;
  50.  
  51. -- A function to explode the entity.
  52. function ENT:Explode()
  53.  
  54. if not IsValid(self) then return end
  55. if not IsValid(self.Entity) then return end
  56.  
  57.  
  58. timer.Simple(1, function()
  59. timer.Simple(1, function()
  60. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  61. timer.Simple(1, function()
  62. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  63. timer.Simple(0.9, function()
  64. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  65. timer.Simple(0.8, function()
  66. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  67. timer.Simple(0.7, function()
  68. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  69. timer.Simple(0.6, function()
  70. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  71. timer.Simple(0.5, function()
  72. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  73. timer.Simple(0.4, function()
  74. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  75. timer.Simple(0.3, function()
  76. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  77. timer.Simple(0.2, function()
  78. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  79. timer.Simple(0.1, function()
  80. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  81. timer.Simple(0.1, function()
  82. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  83. timer.Simple(0.1, function()
  84. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  85. timer.Simple(0.1, function()
  86. self:EmitSound("fosounds/fix/wpn_mine_tick.wav")
  87.  
  88. end);
  89. end);
  90. end);
  91. end);
  92. end);
  93. end);
  94. end);
  95. end);
  96. end);
  97. end);
  98. end);
  99. end);
  100. end);
  101. end);
  102. end);
  103.  
  104. timer.Simple(2.5, function()
  105.  
  106. for k, v in pairs( ents.FindInSphere(self:GetPos(), 128) ) do
  107. if ( v:IsPlayer() and v:Alive() and v:GetMoveType() == MOVETYPE_WALK ) then
  108. v:TakeDamageInfo( BLACKBOX:FakeDamageInfo( math.random(25,50), self, v, self:GetPos(), DMG_BURN, math.random(10,20) ) );
  109. elseif ( v:IsNPC() ) then
  110. v:TakeDamageInfo( BLACKBOX:FakeDamageInfo( math.random(25,50), self, v, self:GetPos(), DMG_BURN, math.random(10,20) ) );
  111. v:Ignite(math.random(10,15), 0);
  112. end;
  113. end;
  114.  
  115. for i = 1, 20 do
  116.  
  117. local a = math.Rand( 0, 2 * math.pi );
  118. local s = math.sin( a );
  119. local c = math.cos( a );
  120. local r = math.random( 0, 256 );
  121.  
  122. local x = c * r;
  123. local y = s * r;
  124.  
  125. local trace = { };
  126. trace.start = self:GetPos();
  127. trace.endpos = trace.start + Vector( x, y, 48 );
  128. trace.filter = self;
  129. local tr = util.TraceLine( trace );
  130.  
  131. if( !tr.Hit ) then
  132.  
  133. local trace = { };
  134. trace.start = tr.HitPos;
  135. trace.endpos = trace.start + Vector( 0, 0, -32768 );
  136. trace.filter = self;
  137. tr = util.TraceLine( trace );
  138.  
  139. end
  140.  
  141. local effectdata = EffectData()
  142. effectdata:SetOrigin(self:GetPos())
  143. util.Effect("HelicopterMegaBomb", effectdata)
  144. util.Effect("ThumperDust", effectdata)
  145. util.Effect("Explosion", effectdata)
  146.  
  147.  
  148. local del = math.Rand( 0, 1 );
  149.  
  150. local fireEnt = ents.Create( "env_fire" );
  151. fireEnt:SetPos( tr.HitPos );
  152. fireEnt:SetKeyValue( "spawnflags", "1" );
  153. fireEnt:SetKeyValue( "attack", "4" );
  154. fireEnt:SetKeyValue( "firesize", "220" );
  155. fireEnt:Spawn();
  156. fireEnt:Activate();
  157. fireEnt:Fire( "Enable", "", del );
  158. fireEnt:Fire( "StartFire", "", del );
  159.  
  160. SafeRemoveEntityDelayed( fireEnt, math.random( 28, 35 ) );
  161. end;
  162. self:Remove();
  163. end);
  164. end;
  165.  
  166. -- Called when the entity is used.
  167. function ENT:Use(activator, caller)
  168.  
  169. if not IsValid(self) then return end
  170. if not IsValid(self.Entity) then return end
  171.  
  172. if (activator:Name() == self:GetNWString("ownername")) then
  173. if ( activator:IsPlayer() and activator:Alive() ) then
  174. self:EmitSound("fosounds/fix/wpn_mine_disarm.mp3")
  175. activator:UpdateInventory("Incendiary Mine", 1, true)
  176. blackbox.player.Notify(activator, "Mine successfully defused.")
  177. self:Remove();
  178. end;
  179. else
  180. blackbox.player.Notify(activator, "This mine doesn't belong to this character!")
  181. end;
  182. end;
  183.  
  184. -- Called when the entity takes damage.
  185. function ENT:OnTakeDamage(damageInfo)
  186. self:SetHealth( math.max(self:Health() - damageInfo:GetDamage(), 0) );
  187.  
  188. if (self:Health() <= 0) then
  189. self:Explode(); self:Remove();
  190. end;
  191. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement