1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
if SERVER then
AddCSLuaFile("shared.lua")
end
if CLIENT then
SWEP.ViewModelFOV = 55
SWEP.ViewModelFlip = false
SWEP.PrintName = "SPAS-12"
SWEP.IconLetter = "k"
SWEP.Slot = 3
SWEP.Slotpos = 3
end
SWEP.HoldType = "shotgun"
SWEP.Base = "rad_base"
SWEP.UseHands = true
SWEP.UseShellSounds = false
SWEP.ViewModel = "models/weapons/c_shotgun.mdl"
SWEP.WorldModel = "models/weapons/w_shotgun.mdl"
//SWEP.SprintPos = Vector(-0.6026, -2.715, 0.0137)
//SWEP.SprintAng = Vector(-3.4815, -21.9362, 0.0001)
SWEP.SprintPos = Vector (1.4752, 0.0296, -3.577)
SWEP.SprintAng = Vector (5.8948, 20.2814, 0)
SWEP.IsSniper = false
SWEP.AmmoType = "Buckshot"
SWEP.Primary.Sound = Sound( "Weapon_Shotgun.Double" )
SWEP.Primary.Pump = Sound( "Weapon_Shotgun.Special1" )
SWEP.Primary.ReloadSound = Sound( "Weapon_Shotgun.Reload" )
SWEP.Primary.Recoil = 9.5
SWEP.Primary.Damage = 30
SWEP.Primary.NumShots = 8
SWEP.Primary.Cone = 0.080
SWEP.Primary.Delay = 0.500
SWEP.Primary.ClipSize = 8
SWEP.Primary.Automatic = false
function SWEP:Deploy()
self.Weapon:SetNWBool( "Reloading", false )
self.Weapon:SetVar( "PumpTime", 0 )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.3 )
if SERVER then
self.Weapon:SetZoomMode( 1 )
end
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
return true
end
function SWEP:CanPrimaryAttack()
if self.HolsterMode or self.LastRunFrame > CurTime() then return false end
if self.Owner:GetNWInt( "Ammo"..self.AmmoType, 0 ) < 1 then
self.Weapon:EmitSound( self.Primary.Empty )
return false
end
if self.Weapon:GetNWBool( "Reloading", false ) then
self.Weapon:SetNWBool( "Reloading", false )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
self.Weapon:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
return false
end
if self.Weapon:Clip1() <= 0 and not self.Weapon:GetNWBool( "Reloading", false ) then
self.Weapon:SetNWBool( "Reloading", true )
self.Weapon:SetVar( "ReloadTimer", CurTime() + 0.5 )
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
//self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
return false
end
return true
end
function SWEP:ShootEffects()
if IsFirstTimePredicted() then
self.Owner:ViewPunch( Angle( math.Rand( -0.2, -0.1 ) * self.Primary.Recoil, math.Rand( -0.05, 0.05 ) * self.Primary.Recoil, 0 ) )
end
self.Owner:MuzzleFlash()
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
if self.UseShellSounds then
local pitch = self.Pitches[ self.AmmoType ] + math.random( -3, 3 )
local tbl = self.BuckshotShellSounds
local pos = self.Owner:GetPos()
timer.Simple( math.Rand( self.MinShellDelay, self.MaxShellDelay ), function() sound.Play( table.Random( tbl ), pos, 50, pitch ) end )
end
end
function SWEP:PrimaryAttack()
if not self.Weapon:CanPrimaryAttack() then
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
return
end
self.Weapon:SetVar( "PumpTime", CurTime() + 0.5 )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:EmitSound( self.Primary.Sound, 100, math.random(95,105) )
self.Weapon:ShootBullets( self.Primary.Damage, self.Primary.NumShots, self.Primary.Cone, self.Weapon:GetZoomMode() )
self.Weapon:TakePrimaryAmmo( 1 )
self.Weapon:ShootEffects()
if SERVER then
self.Owner:AddAmmo( self.AmmoType, -1 )
end
end
function SWEP:Reload()
if self.Weapon:Clip1() == self.Primary.ClipSize or self.Weapon:Clip1() > self.Owner:GetNWInt( "Ammo" .. self.AmmoType, 0 ) or self.HolsterMode or self.ReloadTime then return end
if self.Weapon:Clip1() < self.Primary.ClipSize then
self.Weapon:SetNWBool( "Reloading", true )
self.Weapon:SetVar( "ReloadTimer", CurTime() + 0.5 )
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
//self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
end
end
function SWEP:PumpIt()
self.Weapon:SetNWBool( "Reloading", false )
self.Weapon:SendWeaponAnim( ACT_SHOTGUN_PUMP )
self.Weapon:EmitSound( self.Primary.Pump )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end
function SWEP:Think()
if self.Owner:KeyDown( IN_WALK ) and self.HolsterTime < CurTime() then
self.HolsterTime = CurTime() + 2
self.HolsterMode = !self.HolsterMode
--[[if self.HolsterMode then
self.Owner:SetLuaAnimation( self.HoldType )
else
self.Owner:StopAllLuaAnimations( 0.5 )
end]]
end
if self.Weapon:GetVar( "PumpTime", 0 ) != 0 and self.Weapon:GetVar( "PumpTime", 0 ) < CurTime() then
self.Weapon:SetVar( "PumpTime", 0 )
self.Weapon:PumpIt()
end
if self.Weapon:GetNWBool( "Reloading", false ) then
if self.Weapon:GetVar( "ReloadTimer", 0 ) < CurTime() then
// Finsished reload
if self.Weapon:Clip1() >= self.Primary.ClipSize then
self.Weapon:SetNWBool( "Reloading", false )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
self.Weapon:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
return
end
// Next cycle
self.Weapon:SetVar( "ReloadTimer", CurTime() + 0.75 )
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
// Add ammo
self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
// Sound
self.Weapon:EmitSound( self.Primary.ReloadSound, 100, math.random(90,110) )
end
end
if self.Owner:GetVelocity():Length() > 0 then
if self.Owner:KeyDown( IN_SPEED ) and self.Owner:GetNWFloat( "Weight", 0 ) < 50 then
self.LastRunFrame = CurTime() + 0.3
end
end
end
function SWEP:ShootBullets( damage, numbullets, aimcone, zoommode )
if SERVER then
self.Owner:AddStat( "Bullets", 1 )
end
local scale = aimcone
if self.Owner:KeyDown( IN_FORWARD ) or self.Owner:KeyDown( IN_BACK ) or self.Owner:KeyDown( IN_MOVELEFT ) or self.Owner:KeyDown( IN_MOVERIGHT ) then
scale = aimcone * 1.75
elseif self.Owner:KeyDown( IN_DUCK ) or self.Owner:KeyDown( IN_WALK ) then
scale = math.Clamp( aimcone / 1.25, 0, 10 )
end
local tracer = 1
if ( zoommode or 1 ) > 1 then
tracer = 0
end
local bullet = {}
bullet.Num = numbullets
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( scale, scale, 0 )
bullet.Tracer = 0
bullet.Force = damage * 2
bullet.Damage = damage
bullet.AmmoType = "Pistol"
bullet.TracerName = tracername
bullet.Callback = function ( attacker, tr, dmginfo )
dmginfo:ScaleDamage( self:GetDamageFalloffScale( tr.HitPos:Distance( self.Owner:GetShootPos() ) ) )
if tr.Entity.NextBot then
tr.Entity:OnLimbHit( tr.HitGroup, dmginfo )
end
if math.random(1,6) == 1 then
self.Weapon:BulletPenetration( attacker, tr, dmginfo, 0 )
end
end
self.Owner:FireBullets( bullet )
end
function SWEP:DrawHUD()
if self.Weapon:ShouldNotDraw() then return end
local x = ScrW() * 0.5
local y = ScrH() * 0.5
local scalebywidth = ( ScrW() / 1024 ) * 10
local scale = self.Primary.Cone
if self.Owner:KeyDown( IN_FORWARD ) or self.Owner:KeyDown( IN_BACK ) or self.Owner:KeyDown( IN_MOVELEFT ) or self.Owner:KeyDown( IN_MOVERIGHT ) then
scale = self.Primary.Cone * 1.75
elseif self.Owner:KeyDown( IN_DUCK ) or self.Owner:KeyDown( IN_WALK ) then
scale = math.Clamp( self.Primary.Cone / 1.25, 0, 10 )
end
scale = scale * scalebywidth
local dist = math.abs( self.CrosshairScale - scale )
self.CrosshairScale = math.Approach( self.CrosshairScale, scale, FrameTime() * 2 + dist * 0.05 )
local gap = 40 * self.CrosshairScale
local length = gap + self.CrossLength:GetInt()
surface.SetDrawColor( self.CrossRed:GetInt(), self.CrossGreen:GetInt(), self.CrossBlue:GetInt(), self.CrossAlpha:GetInt() )
surface.DrawLine( x - length, y, x - gap, y )
surface.DrawLine( x + length, y, x + gap, y )
surface.DrawLine( x, y - length, x, y - gap )
surface.DrawLine( x, y + length, x, y + gap )
end
|