Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. AddCSLuaFile()
  2.  
  3. DEFINE_BASECLASS( "gf2_base_adv" )
  4.  
  5. ENT.Spawnable = true
  6. ENT.AdminOnly = false
  7.  
  8. ENT.PrintName = "6Inch Mortar Tube"
  9. ENT.Author = "Rogue Cheney"
  10. ENT.Contact = "baldursgate3@gmail.com"
  11. ENT.Category = "G-Works 2 - Mortars + Shells"
  12.  
  13. ENT.Model = "models/models/gf2/rogue_cheney/mortars/mortar_03.mdl"
  14.  
  15. ENT.Mass = 150
  16.  
  17. ENT.GBOWNER = nil
  18.  
  19.  
  20. function ENT:SpawnFunction( ply, tr )
  21. if ( !tr.Hit ) then return end
  22. self.GBOWNER = ply
  23. local ent = ents.Create( self.ClassName )
  24. ent:SetPhysicsAttacker(ply)
  25. ent:SetPos( tr.HitPos + tr.HitNormal * 16 )
  26. ent:Spawn()
  27. ent:Activate()
  28.  
  29. return ent
  30. end
  31.  
  32.  
  33. function ENT:Initialize()
  34.  
  35. if (SERVER) then
  36. self:LoadModel()
  37. self:PhysicsInit( SOLID_VPHYSICS )
  38. self:SetSolid( SOLID_VPHYSICS )
  39. self:SetMoveType( MOVETYPE_VPHYSICS )
  40. self:SetUseType( ONOFF_USE )
  41. local phys = self:GetPhysicsObject()
  42. local skincount = self:SkinCount()
  43.  
  44. if (phys:IsValid()) then
  45. phys:SetMass(self.Mass)
  46. phys:Wake()
  47. end
  48.  
  49. self.Armed = false
  50. self.Exploded = false
  51. self.Used = false
  52. self.Arming = false
  53. self:SetSkin(0)
  54.  
  55. self.IgnitionStack = 0
  56. self.BurningTime = 0
  57. self.HasBurned = false
  58. self.RequestTime = CurTime()
  59.  
  60. if !(WireAddon == nil) then self.Inputs = Wire_CreateInputs(self, { "Launch" }) end
  61.  
  62. end
  63. end
  64.  
  65. if ( CLIENT ) then
  66.  
  67. function ENT:Draw()
  68. self:DrawModel()
  69. local squad = self:GetNetworkedString( 12 )
  70. if ( LocalPlayer():GetEyeTrace().Entity == self.Entity && EyePos():Distance( self.Entity:GetPos() ) < 156 ) then
  71. AddWorldTip( self.Entity:EntIndex(), ( "Place one shell inside of me and press E" ), 0.5, self.Entity:GetPos(), self.Entity )
  72. end
  73. if !(WireAddon == nil) then Wire_Render(self.Entity) end
  74. end
  75. end
  76.  
  77. function ENT:TriggerInput(iname, value)
  78. if (!self:IsValid()) then return end
  79. if (iname == "Launch") then
  80. if (value >= 1) then
  81. self:Launch()
  82. end
  83. end
  84.  
  85. end
  86.  
  87.  
  88.  
  89. function ENT:Think()
  90.  
  91. if (SERVER) then
  92. if !self:IsValid() then return end
  93.  
  94. end
  95. end
  96.  
  97. function ENT:Explode()
  98. end
  99.  
  100. function ENT:OnTakeDamage(dmginfo)
  101. if self.Exploded then return end
  102. end
  103.  
  104. function ENT:PhysicsCollide( data, physobj )
  105. end
  106.  
  107. function ENT:Arm()
  108.  
  109.  
  110. end
  111.  
  112. function ENT:CanLaunch()
  113.  
  114. if (self.RequestTime+1) < CurTime()then
  115. self.RequestTime=CurTime()
  116. return true
  117. else
  118.  
  119. return false
  120. end
  121.  
  122.  
  123.  
  124.  
  125. end
  126.  
  127.  
  128. function ENT:Launch()
  129. for k, v in pairs(ents.FindInSphere(self:GetAttachment(self:LookupAttachment("bottom")).Pos, 5)) do
  130. if v!=self && v:GetPhysicsObject():IsValid() && (string.StartWith(v:GetClass(), "gf2_mortars_shell_big_")==true) then
  131. local phys = v:GetPhysicsObject()
  132. phys:AddVelocity(self:GetUp()*3500)
  133. phys:AddAngleVelocity(phys:GetAngleVelocity()*-1)
  134.  
  135. phys:AddAngleVelocity(Vector(0,0,1555))
  136.  
  137. ParticleEffectAttach("gf2_mortar_shell_airburst",PATTACH_ABSORIGIN_FOLLOW,v,1)
  138. ParticleEffectAttach("gf2_mortar_shell_trail_circularsparkles_white",PATTACH_ABSORIGIN_FOLLOW,v,1)
  139. timer.Simple(5, function()
  140. if v:IsValid()==true then
  141. v:Explode()
  142. end
  143. end)
  144.  
  145.  
  146. local sound = table.Random({"garrys_fireworks_2/fireworks/launch/mortar_launch.mp3","garrys_fireworks_2/fireworks/launch/mortar_launch_2.mp3"})
  147. self:EmitSound(sound, 100, math.random(70,150))
  148.  
  149. ParticleEffect( "gf2_battery_shot_effect", self:GetAttachment(self:LookupAttachment("top")).Pos, self:GetAngles(), nil )
  150.  
  151. end
  152. end
  153.  
  154.  
  155.  
  156. end
  157.  
  158. function ENT:Use( activator, caller )
  159. if (SERVER) then
  160. if self:CanLaunch()==true then
  161. self:Launch()
  162. end
  163. end
  164. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement