Advanced Towing - Change into seperate Functions#446
Closed
Andx667 wants to merge 23 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors Advanced Towing into separate functions, centralizes shared helpers/macros, and wires initialization via XEH to be more modular.
- Extracts monolithic logic into discrete fnc_* files and adds PREP bindings.
- Introduces shared macros (surface finding, cargo retrieval) in script_component.hpp.
- Replaces initAdvancedTowing with init + install flow and action handlers.
Reviewed Changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| addons/advancedtowing/script_component.hpp | Adds macros for surface detection and cargo retrieval to support refactored functions. |
| addons/advancedtowing/functions/fnc_takeTowRopesActionCheck.sqf | Action condition wrapper to check if the player can take tow ropes. |
| addons/advancedtowing/functions/fnc_takeTowRopesAction.sqf | Action handler to take tow ropes from a vehicle. |
| addons/advancedtowing/functions/fnc_takeTowRopes.sqf | Core logic to spawn rope on a vehicle and hand off to pickup. |
| addons/advancedtowing/functions/fnc_simulateTowingSpeed.sqf | Periodic towing speed simulation adjusting max speed based on mass. |
| addons/advancedtowing/functions/fnc_simulateTowing.sqf | Physics-like towing simulation updating cargo position and orientation. |
| addons/advancedtowing/functions/fnc_putAwayTowRopesActionCheck.sqf | Action condition to put away tow ropes. |
| addons/advancedtowing/functions/fnc_putAwayTowRopesAction.sqf | Action handler to put away tow ropes. |
| addons/advancedtowing/functions/fnc_putAwayTowRopes.sqf | Core logic to destroy ropes and clean variables. |
| addons/advancedtowing/functions/fnc_pickupTowRopesActionCheck.sqf | Action condition to pick up tow ropes. |
| addons/advancedtowing/functions/fnc_pickupTowRopesAction.sqf | Action handler to pick up tow ropes from nearby vehicles. |
| addons/advancedtowing/functions/fnc_pickupTowRopes.sqf | Core logic to attach rope ends to a hidden helper attached to the player. |
| addons/advancedtowing/functions/fnc_isSupportedVehicle.sqf | Checks if a vehicle class is supported for towing. |
| addons/advancedtowing/functions/fnc_isSupportedCargo.sqf | Checks tow compatibility between vehicle and cargo. |
| addons/advancedtowing/functions/fnc_install.sqf | One-time initialization guard for installing Advanced Towing. |
| addons/advancedtowing/functions/fnc_initAdvancedTowing.sqf | Removes legacy monolithic implementation. |
| addons/advancedtowing/functions/fnc_init.sqf | New init loop to register actions and scan nearby vehicles; server install entry point. |
| addons/advancedtowing/functions/fnc_getHitchPoints.sqf | Computes front/rear hitch points from corner points. |
| addons/advancedtowing/functions/fnc_getCornerPoints.sqf | Computes approximate bounding corners based on bounding box and CoM. |
| addons/advancedtowing/functions/fnc_findNearbyTowVehicles.sqf | Finds nearby vehicles with rope ends in reach. |
| addons/advancedtowing/functions/fnc_dropTowRopesActionCheck.sqf | Action condition to drop tow ropes. |
| addons/advancedtowing/functions/fnc_dropTowRopesAction.sqf | Action handler to drop tow ropes. |
| addons/advancedtowing/functions/fnc_dropTowRopes.sqf | Core logic to detach and delete the pickup helper and clear vars. |
| addons/advancedtowing/functions/fnc_customSetOwner.sqf | Server-side setOwner wrapper. |
| addons/advancedtowing/functions/fnc_customRemoteExecServer.sqf | Server remoteExec utility. |
| addons/advancedtowing/functions/fnc_customRemoteExec.sqf | RemoteExec utility for client/target. |
| addons/advancedtowing/functions/fnc_customHint.sqf | Simplified hint wrapper. |
| addons/advancedtowing/functions/fnc_customHideObjectGlobal.sqf | Server-side hideObjectGlobal helper. |
| addons/advancedtowing/functions/fnc_canTakeTowRopes.sqf | Check if tow ropes can be taken from a vehicle. |
| addons/advancedtowing/functions/fnc_canPutAwayTowRopes.sqf | Check if tow ropes can be put away on a vehicle. |
| addons/advancedtowing/functions/fnc_canPickupTowRopes.sqf | Check if tow ropes can be picked up from nearby vehicles. |
| addons/advancedtowing/functions/fnc_canDropTowRopes.sqf | Check if the player can drop carried ropes. |
| addons/advancedtowing/functions/fnc_canAttachTowRopes.sqf | Check if selected cargo can be attached to vehicle ropes. |
| addons/advancedtowing/functions/fnc_attachTowRopesActionCheck.sqf | Action condition for attach-to-ropes. |
| addons/advancedtowing/functions/fnc_attachTowRopesAction.sqf | Action handler to attach cargo to ropes. |
| addons/advancedtowing/functions/fnc_attachTowRopes.sqf | Core logic to attach ropes to cargo and start simulate loop. |
| addons/advancedtowing/functions/fnc_addPlayerTowActions.sqf | Registers player actions with conditions. |
| addons/advancedtowing/XEH_postInit.sqf | Switches to calling new init function. |
| addons/advancedtowing/XEH_PREP.hpp | Registers all new functions for preInit compilation. |
Comments suppressed due to low confidence (2)
addons/advancedtowing/functions/fnc_pickupTowRopesAction.sqf:1
- References to legacy SA_* APIs remain. Replace SA_Can_Pickup_Tow_Ropes with FUNC(canPickupTowRopes), and SA_RemoteExec with FUNC(customRemoteExec) to use the new helpers.
#include "..\script_component.hpp"
addons/advancedtowing/functions/fnc_attachTowRopes.sqf:1
-
- QGVAR key mismatch on line 20: use QGVAR(Ropes_Vehicle) to match other code. - The hitch selection is immediately overridden on line 43, forcing the front hitch; remove line 43 to respect the computed hitch. - The remoteExec wrapper needs a quoted function name: use [["The tow ropes are too short. Move vehicle closer.", false], QFUNC(customHint), _player] call FUNC(customRemoteExec); - setVariable must use the same key SA_Get_Cargo expects; replace [GVAR(Cargo), _cargo, true] with ["SA_Cargo", _cargo, true]. - Declare _helper as private to avoid scope leaks: private _helper = "Land_Can_V2_F" createVehicle position _cargo;
#include "..\script_component.hpp"
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PULL REQUEST
When merged this pull request will:
ToDo:
IMPORTANT
Component - Add|Fix|Improve|Change|Remove {changes}.