@@ -20,10 +20,10 @@ function Create(self)
20
20
-- self.initializationOk = true -- This flag is effectively replaced by checking self.actionMode == 0 in Update.
21
21
22
22
-- Core grapple properties
23
- self .fireVel = 30 -- Initial velocity of the hook. Overwrites .ini FireVel.
24
- self .hookRadius = 50 -- Reduced from 360 for more precise parent finding
23
+ self .fireVel = 40 -- Initial velocity of the hook. Overwrites .ini FireVel.
24
+ self .hookRadius = 360 -- Reduced from 360 for more precise parent finding
25
25
26
- self .maxLineLength = 600 -- Maximum allowed length of the rope.
26
+ self .maxLineLength = 1000 -- Maximum allowed length of the rope.
27
27
self .maxShootDistance = self .maxLineLength * 0.95 -- Hook will detach if it travels further than this before sticking.
28
28
self .setLineLength = 0 -- Target length set by input/logic.
29
29
self .lineStrength = 10000 -- Force threshold for breaking (effectively unbreakable).
@@ -82,6 +82,17 @@ function Create(self)
82
82
-- Parent gun, parent actor, and related properties (Vel, anchor points, parentRadius)
83
83
-- will be determined and set in the first Update call.
84
84
-- No self.ToDelete = true will be set in Create.
85
+
86
+ -- Add these new flags:
87
+ self .shouldUnhook = false -- Flag set by gun to signal unhook
88
+ -- self.reloadKeyPressed = false -- Track R key state to prevent spam
89
+
90
+ -- Keep only the tap detection variables:
91
+ self .tapCounter = 0
92
+ self .canTap = false
93
+ self .tapTime = 150
94
+ self .tapAmount = 2
95
+ self .tapTimer = Timer ()
85
96
end
86
97
87
98
function Update (self )
@@ -186,29 +197,6 @@ function Update(self)
186
197
return
187
198
end
188
199
189
- local controller = parentActor :GetController ()
190
- if not controller then
191
- self .ToDelete = true
192
- return
193
- end
194
- local player = controller .Player or 0
195
-
196
- -- Handle pie menu modes
197
- if self .parentGun then
198
- local mode = self .parentGun :GetNumberValue (" GrappleMode" )
199
- if mode ~= 0 then
200
- if mode == 3 then -- Unhook via Pie Menu
201
- self .ToDelete = true
202
- if self .parentGun then
203
- self .parentGun :RemoveNumberValue (" GrappleMode" )
204
- end
205
- else
206
- self .pieSelection = mode
207
- self .parentGun :RemoveNumberValue (" GrappleMode" )
208
- end
209
- end
210
- end
211
-
212
200
-- Standard update flags
213
201
self .ToSettle = false -- Grapple claw should not settle
214
202
@@ -357,34 +345,37 @@ function Update(self)
357
345
-- Player-specific controls and unhooking mechanisms
358
346
if IsAHuman (parentActor ) or IsACrab (parentActor ) then
359
347
if parentActor :IsPlayerControlled () then
360
- -- R key unhooking functionality
361
- local isHoldingGrapple = false
362
-
363
- -- Check if holding grapple in main hand
364
- if self .parent .EquippedItem and self .parentGun and self .parent .EquippedItem .ID == self .parentGun .ID then
365
- isHoldingGrapple = true
366
- end
367
-
368
- -- Check if holding grapple in off-hand
369
- local isHoldingInBG = self .parent .EquippedBGItem and self .parentGun and
370
- self .parent .EquippedBGItem .ID == self .parentGun .ID
371
-
372
- -- If reload key pressed while holding grapple gun, unhook
373
- if controller :IsState (Controller .WEAPON_RELOAD ) and (isHoldingGrapple or isHoldingInBG ) then
374
- print (" R key unhook triggered!" ) -- Debug message
375
- self .ToDelete = true
376
- return -- Exit immediately to prevent other checks
377
- end
378
-
379
- -- Unhook with double-tap crouch (ONLY when NOT holding the gun)
380
- if not isHoldingGrapple and not isHoldingInBG then
348
+ local controller = self .parent :GetController ()
349
+ if controller then
350
+ -- ONLY use RopeInputController for all input handling
351
+
352
+ -- 1. R key to unhook (when holding gun)
353
+ if RopeInputController .handleReloadKeyUnhook (self , controller ) then
354
+ print (" Unhooking via R key!" )
355
+ self .ToDelete = true
356
+ return
357
+ end
358
+
359
+ -- 2. Double crouch-tap to unhook (when NOT holding gun)
381
360
if RopeInputController .handleTapDetection (self , controller ) then
382
- print (" Double-tap unhook triggered!" ) -- Debug message
361
+ print (" Unhooking via double crouch!" )
362
+ self .ToDelete = true
363
+ return
364
+ end
365
+
366
+ -- 3. Pie menu unhook
367
+ if RopeInputController .handlePieMenuSelection (self ) then
368
+ print (" Unhooking via pie menu!" )
383
369
self .ToDelete = true
384
- return -- Exit immediately
370
+ return
385
371
end
372
+
373
+ -- 4. Other rope controls
374
+ RopeInputController .handleRopePulling (self )
375
+ RopeInputController .handleAutoRetraction (self , false )
386
376
end
387
377
end
378
+
388
379
-- Gun stance offset when holding the gun
389
380
if self .parentGun and self .parentGun .RootID == parentActor .ID then
390
381
if MovableMan :IsParticle (self .parentGun .Magazine ) then -- Check if Magazine is a particle
@@ -394,27 +385,7 @@ function Update(self)
394
385
self .parentGun .StanceOffset = Vector (self .lineLength , 0 ):RadRotate (offsetAngle )
395
386
end
396
387
end
397
-
398
- -- Delegate all input handling to RopeInputController
399
- -- 1. Pie menu selection (unhook, retract, extend)
400
- if RopeInputController .handlePieMenuSelection (self ) then
401
- self .ToDelete = true
402
- if self .parentGun then self .parentGun :RemoveNumberValue (" GrappleMode" ) end
403
- return
404
- end
405
- -- 2. R key (reload) to unhook
406
- if RopeInputController .handleReloadKeyUnhook (self , controller ) then
407
- self .ToDelete = true
408
- return
409
- end
410
- -- 3. Double-tap crouch to unhook (only if not holding gun)
411
- if RopeInputController .handleTapDetection (self , controller ) then
412
- self .ToDelete = true
413
- return
414
- end
415
- -- 4. Mousewheel and directional controls for rope length
416
- RopeInputController .handleRopePulling (self )
417
-
388
+
418
389
-- Render the rope
419
390
RopeRenderer .drawRope (self , player )
420
391
0 commit comments