Advertisement
Guest User

Untitled

a guest
Jun 30th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.70 KB | None | 0 0
  1. if ( SERVER ) then
  2. AddCSLuaFile()
  3.  
  4. CreateConVar( "rb655_force_downloads", "0", FCVAR_ARCHIVE )
  5.  
  6. if ( GetConVarNumber( "rb655_force_downloads" ) > 0 ) then
  7. resource.AddFile( "materials/entities/weapon_nyangun.png" )
  8.  
  9. resource.AddFile( "materials/nyan/selection.png" )
  10. resource.AddFile( "materials/nyan/cat.png" )
  11. resource.AddFile( "materials/nyan/cat_reversed.png" )
  12. resource.AddFile( "materials/nyan/cat.vmt" )
  13. resource.AddFile( "materials/nyan/killicon.vmt" )
  14. resource.AddFile( "materials/nyan/rainbow.vmt" )
  15.  
  16. resource.AddFile( "sound/weapons/nyan/nya1.wav" )
  17. resource.AddFile( "sound/weapons/nyan/nya2.wav" )
  18.  
  19. resource.AddFile( "sound/weapons/nyan/nyan_loop.wav" )
  20. resource.AddFile( "sound/weapons/nyan/nyab_beat.wav" )
  21. end
  22. end
  23.  
  24. if ( CLIENT ) then
  25. SWEP.Slot = 6
  26. SWEP.SlotPos = 6
  27.  
  28. killicon.Add( "weapon_nyangun", "nyan/killicon", color_white )
  29. SWEP.WepSelectIcon = Material( "nyan/selection.png" )
  30. SWEP.BounceWeaponIcon = false
  31. SWEP.DrawWeaponInfoBox = false
  32. end
  33. SWEP.HeadshotMultiplier = 3
  34. SWEP.Kind = WEAPON_EQUIP1
  35. SWEP.AutoSpawnable = false
  36. SWEP.CanBuy = { ROLE_TRAITOR }
  37. SWEP.InLoadoutFor = nil
  38. SWEP.LimitedStock = true
  39. SWEP.AllowDrop = true
  40. SWEP.ViewModelFlip = false
  41. SWEP.Base = "weapon_tttbase"
  42. SWEP.PrintName = "Nyan Gun"
  43. SWEP.Category = "Fun"
  44. SWEP.ViewModel = "models/weapons/c_smg1.mdl"
  45. SWEP.WorldModel = "models/weapons/w_smg1.mdl"
  46. SWEP.Spawnable = true
  47. SWEP.AdminSpawnable = true
  48. SWEP.AutoSwitchTo = false
  49. SWEP.AutoSwitchFrom = false
  50. SWEP.ViewModelFOV = 54
  51. SWEP.UseHands = false
  52. SWEP.HoldType = "smg"
  53. SWEP.Primary.ClipSize = 100
  54. SWEP.Primary.Delay = 0.1
  55. SWEP.Primary.DefaultClip = 100
  56. SWEP.Primary.Automatic = true
  57. SWEP.Primary.Ammo = ""
  58.  
  59. SWEP.Secondary.ClipSize = 10
  60. SWEP.Secondary.Delay = 0.5
  61. SWEP.Secondary.DefaultClip = 10
  62. SWEP.Secondary.Automatic = false
  63. SWEP.Secondary.Ammo = ""
  64.  
  65. if CLIENT then
  66. SWEP.Icon = "
  67.  
  68. SWEP.EquipMenuData = {
  69. type = "Weapon",
  70. desc = ""
  71. };
  72. end
  73.  
  74. function SWEP:Initialize()
  75. self:SetWeaponHoldType( self.HoldType )
  76. end
  77.  
  78. function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
  79. surface.SetDrawColor( 255, 255, 255, alpha )
  80. surface.SetMaterial( self.WepSelectIcon )
  81. surface.DrawTexturedRect( x + 10, y, 128, 128 )
  82. end
  83.  
  84. function SWEP:PrimaryAttack()
  85. if ( !self:CanPrimaryAttack() ) then return end
  86.  
  87. if (self.Owner:IsNPC()) then
  88. self:EmitSound( "weapons/nyan/nya" .. math.random( 1, 2 ) .. ".wav", 100, math.random( 60, 80 ) )
  89. else
  90. if ( self.LoopSound ) then
  91. self.LoopSound:ChangeVolume( 1, 0.1 )
  92. else
  93. self.LoopSound = CreateSound( self.Owner, Sound( "weapons/nyan/nyan_loop.wav" ) )
  94. if ( self.LoopSound ) then self.LoopSound:Play() end
  95. end
  96. if ( self.BeatSound ) then self.BeatSound:ChangeVolume( 0, 0.1 ) end
  97. end
  98.  
  99. local bullet = {}
  100. bullet.Num = 1
  101. bullet.Src = self.Owner:GetShootPos()
  102. bullet.Dir = self.Owner:GetAimVector()
  103. bullet.Spread = Vector( 0.01, 0.01, 0 )
  104. bullet.Tracer = 1
  105. bullet.Force = 5
  106. bullet.Damage = 16
  107. //bullet.AmmoType = "Ar2AltFire" -- For some extremely stupid reason this breaks the tracer effect
  108. bullet.TracerName = "rb655_nyan_tracer"
  109. self.Owner:FireBullets( bullet )
  110.  
  111. self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  112. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  113.  
  114. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  115. self:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  116. end
  117.  
  118. function SWEP:SecondaryAttack()
  119. if ( !self:CanSecondaryAttack() ) then return end
  120. self:EmitSound( "weapons/nyan/nya" .. math.random( 1, 2 ) .. ".wav", 100, math.random( 85, 100 ) )
  121.  
  122. local bullet = {}
  123. bullet.Num = 6
  124. bullet.Src = self.Owner:GetShootPos()
  125. bullet.Dir = self.Owner:GetAimVector()
  126. bullet.Spread = Vector( 0.10, 0.1, 0 )
  127. bullet.Tracer = 1
  128. bullet.Force = 10
  129. bullet.Damage = 6
  130. //bullet.AmmoType = "Ar2AltFire"
  131. bullet.TracerName = "rb655_nyan_tracer"
  132. self.Owner:FireBullets( bullet )
  133.  
  134. self:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
  135. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  136.  
  137. self:SetNextPrimaryFire( CurTime() + self.Secondary.Delay )
  138. self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
  139. end
  140.  
  141. function SWEP:Reload()
  142. if ( !self.Owner:KeyPressed( IN_RELOAD ) ) then return end
  143. if ( self:GetNextPrimaryFire() > CurTime() ) then return end
  144.  
  145. if ( SERVER ) then
  146. local ang = self.Owner:EyeAngles()
  147. local ent = ents.Create( "ent_nyan_bomb" )
  148. if ( IsValid( ent ) ) then
  149. ent:SetPos( self.Owner:GetShootPos() + ang:Forward() * 28 + ang:Right() * 24 - ang:Up() * 8 )
  150. ent:SetAngles( ang )
  151. ent:SetOwner( self.Owner )
  152. ent:Spawn()
  153. ent:Activate()
  154.  
  155. local phys = ent:GetPhysicsObject()
  156. if ( IsValid( phys ) ) then phys:Wake() phys:AddVelocity( ent:GetForward() * 1337 ) end
  157. end
  158. end
  159.  
  160. self:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
  161. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  162.  
  163. self:EmitSound( "weapons/nyan/nya" .. math.random( 1, 2 ) .. ".wav", 100, math.random( 60, 80 ) )
  164.  
  165. self:SetNextPrimaryFire( CurTime() + 1 )
  166. self:SetNextSecondaryFire( CurTime() + 1 )
  167. end
  168.  
  169. function SWEP:DoImpactEffect( trace, damageType )
  170. local effectdata = EffectData()
  171. effectdata:SetStart( trace.HitPos )
  172. effectdata:SetOrigin( trace.HitNormal + Vector( math.Rand( -0.5, 0.5 ), math.Rand( -0.5, 0.5 ), math.Rand( -0.5, 0.5 ) ) )
  173. util.Effect( "rb655_nyan_bounce", effectdata )
  174.  
  175. return true
  176. end
  177.  
  178. function SWEP:FireAnimationEvent( pos, ang, event )
  179. return true
  180. end
  181.  
  182. function SWEP:KillSounds()
  183. if ( self.BeatSound ) then self.BeatSound:Stop() self.BeatSound = nil end
  184. if ( self.LoopSound ) then self.LoopSound:Stop() self.LoopSound = nil end
  185. end
  186.  
  187. function SWEP:OnRemove()
  188. self:KillSounds()
  189. end
  190.  
  191. function SWEP:OnDrop()
  192. self:KillSounds()
  193. end
  194.  
  195. function SWEP:Deploy()
  196. self:SendWeaponAnim( ACT_VM_DRAW )
  197. self:SetNextPrimaryFire( CurTime() + self:SequenceDuration() )
  198.  
  199. if ( CLIENT ) then return true end
  200.  
  201. self.BeatSound = CreateSound( self.Owner, Sound( "weapons/nyan/nyan_beat.wav" ) )
  202. if ( self.BeatSound ) then self.BeatSound:Play() end
  203.  
  204. return true
  205. end
  206.  
  207. function SWEP:Holster()
  208. self:KillSounds()
  209. return true
  210. end
  211.  
  212. function SWEP:Think()
  213. if ( self.Owner:IsPlayer() && ( self.Owner:KeyReleased( IN_ATTACK ) || !self.Owner:KeyDown( IN_ATTACK ) ) ) then
  214. if ( self.LoopSound ) then self.LoopSound:ChangeVolume( 0, 0.1 ) end
  215. if ( self.BeatSound ) then self.BeatSound:ChangeVolume( 1, 0.1 ) end
  216. end
  217. end
  218.  
  219. if ( SERVER ) then return end
  220.  
  221. --------------------------------------------------------------------------------------
  222.  
  223. local EFFECT = {}
  224.  
  225. local Cat = Material( "nyan/cat" )
  226. local Rainbow = Material( "nyan/rainbow" )
  227.  
  228. function EFFECT:Init( data )
  229. self.StartPos = data:GetStart()
  230. self.Direction = data:GetOrigin()
  231.  
  232. self.Dist = math.random( 32, 64 )
  233. self.EndPos = self.StartPos + self.Direction * self.Dist
  234. self:SetRenderBoundsWS( self.StartPos, self.EndPos )
  235.  
  236. self.LifeTime = 1
  237. self.DieTime = CurTime() + self.LifeTime
  238. end
  239.  
  240. function EFFECT:Think()
  241. if ( CurTime() > self.DieTime ) then return false end
  242. return true
  243. end
  244.  
  245. function EFFECT:Render()
  246. local v1 = ( CurTime() - self.DieTime ) / self.LifeTime
  247. local v2 = ( self.DieTime - CurTime() ) / self.LifeTime
  248. local a = self.EndPos + self.Direction * math.min( v1 * self.Dist, 0 )
  249.  
  250. render.SetMaterial( Rainbow )
  251. render.DrawBeam( self.StartPos, a, v2 * 6, 0, self.StartPos:Distance( self.EndPos ) / 10, Color( 255, 255, 255, v2 * 255 ) )
  252. render.SetMaterial( Cat )
  253. render.DrawBeam( a + self.Direction * 8, a + self.Direction * -8, 16, 0, 1, Color( 255, 255, 255, math.min( ( v2 * 3 ) * 200, 255 ) ) )
  254. end
  255.  
  256.  
  257. effects.Register( EFFECT, "rb655_nyan_bounce" )
  258.  
  259. --------------------------------------------------------------------------------------
  260.  
  261. local EFFECT = {}
  262.  
  263. function EFFECT:Init( data )
  264. self.Position = data:GetStart()
  265. self.EndPos = data:GetOrigin()
  266. self.WeaponEnt = data:GetEntity()
  267. self.Attachment = data:GetAttachment()
  268. self.StartPos = self:GetTracerShootPos( self.Position, self.WeaponEnt, self.Attachment )
  269. self:SetRenderBoundsWS( self.StartPos, self.EndPos )
  270.  
  271. self.Dir = ( self.EndPos - self.StartPos ):GetNormalized()
  272. self.Dist = self.StartPos:Distance( self.EndPos )
  273.  
  274. self.LifeTime = 1 - ( 1 / self.Dist )
  275. self.DieTime = CurTime() + self.LifeTime
  276. end
  277.  
  278. function EFFECT:Think()
  279. if ( CurTime() > self.DieTime ) then return false end
  280. return true
  281. end
  282.  
  283. function EFFECT:Render()
  284. local v1 = ( CurTime() - self.DieTime ) / self.LifeTime
  285. local v2 = ( self.DieTime - CurTime() ) / self.LifeTime
  286. local a = self.EndPos - self.Dir * math.min( 1 - ( v1 * self.Dist ), self.Dist )
  287.  
  288. render.SetMaterial( Rainbow )
  289. render.DrawBeam( a, self.EndPos, v2 * 6, 0, self.Dist / 10, Color( 255, 255, 255, v2 * 255 ) )
  290. end
  291.  
  292. effects.Register( EFFECT, "rb655_nyan_tracer" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement