Advertisement
Guest User

smart p

a guest
Jan 21st, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.13 KB | None | 0 0
  1. if CLIENT then
  2. SWEP.WepSelectIcon = surface.GetTextureID( "ui/menu/items/weapon_smartpistol" )
  3. SWEP.DrawWeaponInfoBox = false
  4. SWEP.BounceWeaponIcon = false
  5. killicon.Add( "mp_weapon_smart_pistol", "ui/menu/items/weapon_smartpistol", Color( 0, 0, 0, 255 ) )
  6. end
  7.  
  8. SWEP.PrintName = "Smart Pistol MK5"
  9.  
  10. SWEP.Category = "Titanfall"
  11.  
  12. SWEP.Spawnable= true
  13. SWEP.AdminSpawnable= true
  14. SWEP.AdminOnly = true
  15.  
  16. SWEP.ViewModelFOV = 55
  17. SWEP.ViewModel = "models/weapons/p2011sp/ptpov_p2011sp.mdl"
  18. SWEP.WorldModel = "models/weapons/p2011sp/w_p2011sp.mdl"
  19. SWEP.ViewModelFlip = false
  20.  
  21. SWEP.SwayScale = 0.5
  22. SWEP.BobScale = 0.5
  23.  
  24. SWEP.AutoSwitchTo = false
  25. SWEP.AutoSwitchFrom = false
  26. SWEP.Weight = 15
  27.  
  28. SWEP.Slot = 2
  29. SWEP.SlotPos = 0
  30.  
  31. SWEP.UseHands = false
  32. SWEP.HoldType = "pistol"
  33. SWEP.FiresUnderwater = true
  34. SWEP.DrawCrosshair = false
  35. SWEP.DrawAmmo = true
  36. SWEP.CSMuzzleFlashes = true
  37. SWEP.Base = "weapon_base"
  38.  
  39. SWEP.Aim = 0
  40. SWEP.IronInTime = 0.25
  41. SWEP.IronOutTime = 0.2
  42. SWEP.DeployTime = 0.4
  43. SWEP.Sprint = 0
  44. SWEP.Lock = 0
  45. SWEP.BobTimer = CurTime()
  46. SWEP.Bob = 0
  47.  
  48. SWEP.Primary.Sound = Sound( "Weapon_SmartPistol.Single" )
  49. SWEP.Primary.ClipSize = 12
  50. SWEP.Primary.DefaultClip = 120
  51. SWEP.Primary.MaxAmmo = 108
  52. SWEP.Primary.Automatic = true
  53. SWEP.Primary.Ammo = "pistol"
  54. SWEP.Primary.Damage = 42
  55. SWEP.Primary.TakeAmmo = 1
  56. SWEP.Primary.Recoil = 1
  57. SWEP.Primary.RecoilView = 0.75
  58. SWEP.Primary.Spread = 0.8
  59. SWEP.Primary.NumberofShots = 1
  60. SWEP.Primary.Delay = 0.125
  61. SWEP.Primary.Force = 10
  62.  
  63. SWEP.Secondary.ClipSize = 0
  64. SWEP.Secondary.DefaultClip = 0
  65. SWEP.Secondary.Automatic = false
  66. SWEP.Secondary.Ammo = "none"
  67.  
  68. function SWEP:Initialize()
  69. self:SetWeaponHoldType( self.HoldType )
  70. end
  71.  
  72. function SWEP:DrawHUD()
  73. if CLIENT then
  74. local x, y
  75. if self.Owner == LocalPlayer() and self.Owner:ShouldDrawLocalPlayer() then
  76. local tr = util.GetPlayerTrace( self.Owner )
  77. local trace = util.TraceLine( tr )
  78. local coords = trace.HitPos:ToScreen()
  79. x, y = coords.x, coords.y
  80. else
  81. x, y = ScrW() / 2, ScrH() / 2
  82. end
  83. surface.SetTexture( surface.GetTextureID( "vgui/hud/weapons/smart_pistol_reticle" ) )
  84. surface.SetDrawColor( 255, 255, 255, 255 )
  85. surface.DrawTexturedRect( x - 128, y - 128, 256, 256 )
  86. end
  87. end
  88.  
  89. function SWEP:Deploy()
  90. self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
  91. self:SetNextPrimaryFire( CurTime() + self.DeployTime )
  92. self:SetNextSecondaryFire( CurTime() + self.DeployTime )
  93. self.Primary.Spread = 0.8
  94. self.Owner:SetFOV( 0, 0 )
  95. self.Aim = 0
  96. self.Sprint = 0
  97. self.Lock = 0
  98. self.BobTimer = CurTime()
  99. self.Bob = 0
  100. self.Owner:SetWalkSpeed( 200 )
  101. end
  102.  
  103. function SWEP:Holster()
  104. self.Primary.Spread = 0.8
  105. self.Owner:SetFOV( 0, 0 )
  106. self.Aim = 0
  107. self.Sprint = 0
  108. self.Lock = 0
  109. self.BobTimer = CurTime()
  110. self.Bob = 0
  111. self.Owner:SetWalkSpeed( 200 )
  112. return true
  113. end
  114.  
  115. function SWEP:PrimaryAttack()
  116. if self.Sprint == 1 then return end
  117. if self.Weapon:Clip1() <= 0 and self.Weapon:Ammo1() <= 0 and !( self.Owner:WaterLevel() == 3 ) then
  118. self.Weapon:EmitSound( "Default.ClipEmpty_Rifle" )
  119. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay * 2 )
  120. end
  121. if self.FiresUnderwater == false and self.Owner:WaterLevel() == 3 then
  122. self.Weapon:EmitSound( "Default.ClipEmpty_Rifle" )
  123. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay * 2 )
  124. end
  125. if self.Weapon:Clip1() <= 0 and self.Weapon:Ammo1() > 0 then
  126. self:Reload()
  127. end
  128. if self.Weapon:Clip1() <= 0 then return end
  129. if self.FiresUnderwater == false and self.Owner:WaterLevel() == 3 then return end
  130. self.Owner:LagCompensation( true )
  131. local tr = util.TraceLine( {
  132. start = self.Owner:GetShootPos(),
  133. endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 1000,
  134. filter = self.Owner,
  135. mask = MASK_SHOT_HULL,
  136. } )
  137. if !IsValid( tr.Entity ) then
  138. tr = util.TraceHull( {
  139. start = self.Owner:GetShootPos(),
  140. endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 1000,
  141. filter = self.Owner,
  142. mins = Vector( -32, -32, 0 ),
  143. maxs = Vector( 32, 32, 0 ),
  144. mask = MASK_SHOT_HULL,
  145. } )
  146. end
  147. if SERVER and IsValid( tr.Entity ) and ( tr.Entity:IsNPC() || tr.Entity:IsPlayer() || tr.Entity:Health() > 0 ) then
  148. local dmginfo = DamageInfo()
  149. local attacker = self.Owner
  150. if !IsValid( attacker ) then
  151. attacker = self
  152. end
  153. self.Owner:EmitSound( "Weapon_SmartPistol.Lock" )
  154. dmginfo:SetAttacker( attacker )
  155. dmginfo:SetInflictor( self )
  156. dmginfo:SetDamage( self.Primary.Damage )
  157. dmginfo:SetDamageForce( self.Owner:GetForward() * 10000 )
  158. dmginfo:SetDamage( self.Primary.Damage )
  159. tr.Entity:TakeDamageInfo( dmginfo )
  160. else
  161. local bullet = {}
  162. bullet.Num = self.Primary.NumberofShots
  163. bullet.Src = self.Owner:GetShootPos()
  164. bullet.Dir = self.Owner:GetAimVector()
  165. bullet.Spread = Vector( self.Primary.Spread * 0.1, self.Primary.Spread * 0.1, 0 )
  166. bullet.Tracer = 1
  167. bullet.Force = self.Primary.Force
  168. bullet.Damage = self.Primary.Damage
  169. bullet.AmmoType = self.Primary.Ammo
  170. self.Owner:FireBullets( bullet )
  171. end
  172. if SERVER and IsValid( tr.Entity ) and ( tr.Entity:IsNPC() || tr.Entity:IsPlayer() || tr.Entity:Health() > 0 ) then
  173. local phys = tr.Entity:GetPhysicsObject()
  174. if IsValid( phys ) then
  175. phys:ApplyForceOffset( self.Owner:GetAimVector() * 80 * phys:GetMass(), tr.HitPos )
  176. end
  177. end
  178. self.Owner:LagCompensation( false )
  179. self:EmitSound( self.Primary.Sound )
  180. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  181. self.Owner:MuzzleFlash()
  182. self.Owner:ViewPunchReset()
  183. self.Owner:ViewPunch( Angle( -1, 0, 0 ) * self.Primary.Recoil )
  184. self.Owner:SetEyeAngles( self.Owner:EyeAngles() + Angle( -1, math.random( -0.25, 0.25 ), 0 ) * self.Primary.RecoilView )
  185. self:TakePrimaryAmmo( self.Primary.TakeAmmo )
  186. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  187. self:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  188. if self.Aim == 0 then
  189. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  190. end
  191. if self.Aim == 1 then
  192. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_DEPLOYED )
  193. end
  194. end
  195.  
  196. function SWEP:SecondaryAttack()
  197. if self.Sprint == 1 then return end
  198. if self.Aim == 0 then
  199. self.Weapon:SendWeaponAnim( ACT_VM_DEPLOY )
  200. self:SetNextPrimaryFire( CurTime() + self.IronInTime )
  201. self:SetNextSecondaryFire( CurTime() + self.IronInTime )
  202. self.Primary.Spread = 0.05
  203. self.Owner:SetFOV( 75, 0.1 )
  204. self.Aim = 1
  205. self.Owner:SetWalkSpeed( 100 )
  206. else
  207. if self.Aim == 1 then
  208. self.Weapon:SendWeaponAnim( ACT_VM_UNDEPLOY )
  209. self:SetNextPrimaryFire( CurTime() + self.IronOutTime )
  210. self:SetNextSecondaryFire( CurTime() + self.IronOutTime )
  211. self.Primary.Spread = 0.8
  212. self.Owner:SetFOV( 0, 0.1 )
  213. self.Aim = 0
  214. self.Owner:SetWalkSpeed( 200 )
  215. end
  216. end
  217. end
  218.  
  219. function SWEP:Reload()
  220. if self.Sprint == 1 then return end
  221. if self.Weapon:Clip1() < self.Primary.ClipSize and self.Weapon:Ammo1() > 0 then
  222. if self.Weapon:Clip1() > 0 then
  223. self.Weapon:DefaultReload( ACT_VM_RELOAD )
  224. end
  225. if self.Weapon:Clip1() <= 0 then
  226. self.Weapon:DefaultReload( ACT_VM_RELOAD_EMPTY )
  227. end
  228. self.Primary.Spread = 0.8
  229. self.Owner:SetFOV( 0, 0.1 )
  230. self.Aim = 0
  231. self.Owner:SetWalkSpeed( 200 )
  232. end
  233. end
  234.  
  235. function SWEP:Think()
  236. local tr = util.TraceLine( {
  237. start = self.Owner:GetShootPos(),
  238. endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 1000,
  239. filter = self.Owner,
  240. mask = MASK_SHOT_HULL,
  241. } )
  242. if !IsValid( tr.Entity ) then
  243. tr = util.TraceHull( {
  244. start = self.Owner:GetShootPos(),
  245. endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 1000,
  246. filter = self.Owner,
  247. mins = Vector( -32, -32, 0 ),
  248. maxs = Vector( 32, 32, 0 ),
  249. mask = MASK_SHOT_HULL,
  250. } )
  251. end
  252. if self.Lock == 0 and IsValid( tr.Entity ) and ( tr.Entity:IsNPC() || tr.Entity:IsPlayer() || tr.Entity:Health() > 0 ) then
  253. self.Owner:EmitSound( "Weapon_SmartPistol.TargetLock" )
  254. self.Lock = 1
  255. end
  256. if self.Lock == 1 and !IsValid( tr.Entity ) then
  257. self.Lock = 0
  258. end
  259. if self.Weapon:Ammo1() > self.Primary.MaxAmmo then
  260. self.Owner:SetAmmo( self.Primary.MaxAmmo, self.Primary.Ammo )
  261. end
  262. if self.Sprint == 0 and self.Owner:KeyDown( IN_SPEED ) and ( self.Owner:KeyDown( IN_FORWARD ) || self.Owner:KeyDown( IN_BACK ) || self.Owner:KeyDown( IN_MOVELEFT ) || self.Owner:KeyDown( IN_MOVERIGHT ) ) then
  263. if SERVER then
  264. self.Weapon:SendWeaponAnim( ACT_VM_SPRINT_IDLE )
  265. end
  266. self.Primary.Spread = 0.8
  267. self.Owner:SetFOV( 0, 0.1 )
  268. self.Sprint = 1
  269. self.Aim = 0
  270. self.BobTimer = CurTime()
  271. self.Bob = 1
  272. self.Owner:SetWalkSpeed( 200 )
  273. end
  274. if self.Sprint == 1 and self.BobTimer <= CurTime() and self.Bob == 1 then
  275. self.Owner:ViewPunch( Angle( 0, 0, -0.5 ) )
  276. self.BobTimer = CurTime() + 0.3
  277. self.Bob = 2
  278. end
  279. if self.Sprint == 1 and self.BobTimer <= CurTime() and self.Bob == 2 then
  280. self.Owner:ViewPunch( Angle( 0, 0, 0.5 ) )
  281. self.BobTimer = CurTime() + 0.3
  282. self.Bob = 1
  283. end
  284. if self.Sprint == 1 and !self.Owner:KeyDown( IN_SPEED ) then
  285. if SERVER then
  286. self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
  287. end
  288. self:SetNextPrimaryFire( CurTime() + 0.2 )
  289. self:SetNextSecondaryFire( CurTime() + 0.2 )
  290. self.Sprint = 0
  291. self.BobTimer = CurTime()
  292. self.Bob = 0
  293. end
  294. if self.Sprint == 1 and !( self.Owner:KeyDown( IN_FORWARD ) || self.Owner:KeyDown( IN_BACK ) || self.Owner:KeyDown( IN_MOVELEFT ) || self.Owner:KeyDown( IN_MOVERIGHT ) ) then
  295. if SERVER then
  296. self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
  297. end
  298. self:SetNextPrimaryFire( CurTime() + 0.2 )
  299. self:SetNextSecondaryFire( CurTime() + 0.2 )
  300. self.Sprint = 0
  301. self.BobTimer = CurTime()
  302. self.Bob = 0
  303. end
  304. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement