Skip to content

Commit a5abad0

Browse files
committed
Implement unhook functionality and pie menu integration for Grapple Gun
Adds pie menu unhook, refines grapple gun release Introduces an "Unhook" option to the grapple gun's pie menu for easier disengagement. Improves grapple release controls: - Reload key (R) now only unhooks if the player is currently holding the grapple gun. - Double-tapping crouch now only unhooks if the player is *not* holding the grapple gun, preventing accidental release when intending to crouch or manually control the rope. Also includes a minor typo correction in the grapple logic.
1 parent 394855b commit a5abad0

File tree

5 files changed

+63
-15
lines changed

5 files changed

+63
-15
lines changed

Data/Base.rte/Devices/Tools/GrappleGun/Grapple.lua

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@ function Update(self)
8989
local mode = self.parentGun:GetNumberValue("GrappleMode");
9090

9191
if mode ~= 0 then
92-
self.pieSelection = mode;
93-
self.parentGun:RemoveNumberValue("GrappleMode");
92+
if mode == 3 then -- Unhook via Pie Menu
93+
self.ToDelete = true;
94+
if self.parentGun then -- Corrected 'sif' to 'if'
95+
self.parentGun:RemoveNumberValue("GrappleMode");
96+
end
97+
else
98+
self.pieSelection = mode;
99+
self.parentGun:RemoveNumberValue("GrappleMode");
100+
end
94101
end
95102

96103
if self.parentGun.FiredFrame then
@@ -114,7 +121,10 @@ function Update(self)
114121
if (self.parentGun and self.parentGun.ID ~= rte.NoMOID) and (self.parentGun:GetRootParent().ID == self.parent.ID) then
115122
if self.parent:IsPlayerControlled() then
116123
if controller:IsState(Controller.WEAPON_RELOAD) then
117-
self.ToDelete = true;
124+
-- Only unhook with R if holding the Grapple Gun
125+
if self.parent.EquippedItem and self.parentGun and self.parent.EquippedItem.ID == self.parentGun.ID then
126+
self.ToDelete = true;
127+
end
118128
end
119129
if self.parentGun.Magazine then
120130
self.parentGun.Magazine.RoundCount = 0;
@@ -434,18 +444,30 @@ function Update(self)
434444

435445
-- Double tapping crouch retrieves the hook
436446
if controller and controller:IsState(Controller.BODY_PRONE) then
437-
self.pieSelection = 0;
438-
if self.canTap == true then
439-
controller:SetState(Controller.BODY_PRONE, false);
440-
self.climb = 0;
441-
if self.parentGun ~= nil and self.parentGun.ID ~= rte.NoMOID then
442-
self.parentGun:RemoveNumberValue("GrappleMode");
443-
end
447+
-- Check if the player is currently holding the grappling gun
448+
local isHoldingGrappleGun = false;
449+
if self.parent and self.parent.EquippedItem and self.parentGun and self.parent.EquippedItem.ID == self.parentGun.ID then
450+
isHoldingGrappleGun = true;
451+
end
444452

445-
self.tapTimer:Reset();
446-
self.didTap = true;
447-
self.canTap = false;
448-
self.tapCounter = self.tapCounter + 1;
453+
if not isHoldingGrappleGun then -- Only process tap for unhook if NOT holding grapple gun
454+
self.pieSelection = 0;
455+
if self.canTap == true then
456+
controller:SetState(Controller.BODY_PRONE, false);
457+
self.climb = 0;
458+
if self.parentGun ~= nil and self.parentGun.ID ~= rte.NoMOID then
459+
self.parentGun:RemoveNumberValue("GrappleMode");
460+
end
461+
462+
self.tapTimer:Reset();
463+
self.didTap = true;
464+
self.canTap = false;
465+
self.tapCounter = self.tapCounter + 1;
466+
end
467+
else
468+
-- If holding the gun, crouch might be for manual rope control.
469+
-- Ensure canTap is true so that normal crouch isn't blocked by this tap logic.
470+
self.canTap = true;
449471
end
450472
else
451473
self.canTap = true;
@@ -455,7 +477,16 @@ function Update(self)
455477
self.tapCounter = 0;
456478
else
457479
if self.tapCounter >= self.tapAmount then
458-
self.ToDelete = true;
480+
local isHoldingGrappleGun = false;
481+
if self.parent and self.parent.EquippedItem and self.parentGun and self.parent.EquippedItem.ID == self.parentGun.ID then
482+
isHoldingGrappleGun = true;
483+
end
484+
485+
if not isHoldingGrappleGun then -- Only unhook via double tap if NOT holding grapple gun
486+
self.ToDelete = true;
487+
else
488+
self.tapCounter = 0; -- If holding gun, reset counter to prevent unhook
489+
end
459490
end
460491
end
461492

Data/Base.rte/Devices/Tools/GrappleGun/GrappleGun.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@ AddDevice = HDFirearm
256256
CopyOf = Hand Open
257257
ScriptPath = Base.rte/Devices/Shared/Scripts/ToggleDualWield.lua
258258
FunctionName = ToggleDualWield
259+
AddPieSlice = PieSlice
260+
Description = Unhook
261+
Direction = Right
262+
Icon = Icon
263+
PresetName = Grapple Gun Unhook
264+
FrameCount = 2
265+
BitmapFile = ContentFile
266+
FilePath = Base.rte/Devices/Tools/GrappleGun/PieIcons/Unhook.png
267+
ScriptPath = Base.rte/Devices/Tools/GrappleGun/Pie.lua
268+
FunctionName = GrapplePieUnhook
259269
AddGib = Gib
260270
GibParticle = MOPixel
261271
CopyOf = Spark Yellow 1

Data/Base.rte/Devices/Tools/GrappleGun/Pie.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@ function GrapplePieExtend(pieMenuOwner, pieMenu, pieSlice)
1010
if gun then
1111
ToMOSRotating(gun):SetNumberValue("GrappleMode", 2);
1212
end
13+
end
14+
15+
function GrapplePieUnhook(pieMenuOwner, pieMenu, pieSlice)
16+
local gun = pieMenuOwner.EquippedItem;
17+
if gun then
18+
ToMOSRotating(gun):SetNumberValue("GrappleMode", 3); -- 3 will signify Unhook
19+
end
1320
end
175 Bytes
Loading
175 Bytes
Loading

0 commit comments

Comments
 (0)