1
- SWEP .PrintName = L (" handsWeaponName" )
1
+ SWEP .PrintName = L (" handsWeaponName" )
2
2
SWEP .Slot = 0
3
3
SWEP .SlotPos = 1
4
4
SWEP .DrawAmmo = false
@@ -29,17 +29,20 @@ SWEP.LowerAngles = Angle(0, 5, -14)
29
29
SWEP .LowerAngles2 = Angle (0 , 5 , - 19 )
30
30
SWEP .KnockViewPunchAngle = Angle (- 1.3 , 1.8 , 0 )
31
31
SWEP .FireWhenLowered = true
32
- SWEP .HoldType = " fist "
32
+ SWEP .HoldType = " normal "
33
33
SWEP .holdDistance = 64
34
34
SWEP .maxHoldDistance = 96
35
35
SWEP .maxHoldStress = 4000
36
36
ACT_VM_FISTS_DRAW = 2
37
37
ACT_VM_FISTS_HOLSTER = 1
38
+
38
39
function SWEP :Initialize ()
39
40
self :SetHoldType (self .HoldType )
40
41
self .lastHand = 0
41
42
self .maxHoldDistanceSquared = self .maxHoldDistance ^ 2
42
43
self .heldObjectAngle = Angle (angle_zero )
44
+ self .lastPunchTime = 0
45
+ self .isFistHold = false
43
46
end
44
47
45
48
function SWEP :Deploy ()
@@ -77,6 +80,11 @@ function SWEP:Think()
77
80
local viewModel = self :GetOwner ():GetViewModel ()
78
81
if IsValid (viewModel ) and self .NextAllowedPlayRateChange < CurTime () then viewModel :SetPlaybackRate (1 ) end
79
82
else
83
+ if self .isFistHold and (CurTime () - (self .lastPunchTime or 0 ) > 5 ) then
84
+ self :SetHoldType (" normal" )
85
+ self .isFistHold = false
86
+ end
87
+
80
88
if self :IsHoldingObject () then
81
89
local physics = self :GetHeldPhysicsObject ()
82
90
local bIsRagdoll = self .heldEntity :IsRagdoll ()
@@ -198,6 +206,8 @@ function SWEP:DropObject(bThrow)
198
206
end )
199
207
end
200
208
209
+ self :SetHoldType (" normal" )
210
+
201
211
self .heldEntity .ixHeldOwner = nil
202
212
self .heldEntity .ixCollisionGroup = nil
203
213
self .heldEntity = nil
@@ -227,13 +237,19 @@ end
227
237
228
238
function SWEP :PrimaryAttack ()
229
239
if not IsFirstTimePredicted () then return end
240
+
230
241
if SERVER and self :IsHoldingObject () then
231
242
self :DropObject (true )
232
243
return
233
244
end
234
245
235
- self :SetNextPrimaryFire (CurTime () + self .Primary .Delay )
246
+ if not self .isFistHold then
247
+ self :SetHoldType (" fist" )
248
+ self .isFistHold = true
249
+ end
250
+
236
251
if hook .Run (" CanPlayerThrowPunch" , self :GetOwner ()) == false then return end
252
+
237
253
local staminaUse = lia .config .get (" PunchStamina" )
238
254
if staminaUse > 0 then
239
255
local owner = self :GetOwner ()
@@ -243,19 +259,32 @@ function SWEP:PrimaryAttack()
243
259
if SERVER then owner :consumeStamina (staminaUse ) end
244
260
end
245
261
246
- if SERVER then self :GetOwner ():EmitSound (" npc/vort/claw_swing" .. math.random (1 , 2 ) .. " .wav" ) end
247
- self :DoPunchAnimation ()
248
- self :GetOwner ():SetAnimation (PLAYER_ATTACK1 )
249
- self :GetOwner ():ViewPunch (Angle (self .lastHand + 2 , self .lastHand + 5 , 0.125 ))
262
+ self :SetNextPrimaryFire (CurTime () + self .Primary .Delay )
263
+
264
+ if SERVER then
265
+ self :GetOwner ():EmitSound (" npc/vort/claw_swing" .. math.random (1 , 2 ) .. " .wav" )
266
+ end
267
+
268
+ -- I can't do it without timer, my bad :(
269
+ timer .Simple (0.1 , function ()
270
+ self :DoPunchAnimation ()
271
+ self :GetOwner ():SetAnimation (PLAYER_ATTACK1 )
272
+ self :GetOwner ():ViewPunch (Angle (self .lastHand + 2 , self .lastHand + 5 , 0.125 ))
273
+ end )
274
+
275
+ self .lastPunchTime = CurTime ()
276
+
250
277
timer .Simple (0.055 , function ()
251
278
if not IsValid (self ) or not IsValid (self :GetOwner ()) then return end
279
+
252
280
local damage = self .Primary .Damage
253
281
local context = {
254
282
damage = damage
255
283
}
256
284
257
285
local result = hook .Run (" GetPlayerPunchDamage" , self :GetOwner (), damage , context )
258
286
damage = result ~= nil and result or context .damage
287
+
259
288
self :GetOwner ():LagCompensation (true )
260
289
local startPos = self :GetOwner ():GetShootPos ()
261
290
local endPos = startPos + self :GetOwner ():GetAimVector () * 96
@@ -319,6 +348,7 @@ function SWEP:SecondaryAttack()
319
348
self :PickupObject (entity )
320
349
self :PlayPickupSound (trace .SurfaceProps )
321
350
self :SetNextSecondaryFire (CurTime () + self .Secondary .Delay )
351
+ self :SetHoldType (" pistol" )
322
352
end
323
353
end
324
354
end
0 commit comments