Fix cone projectile aiming in third person (free aim and target lock)#7
Open
zspatter wants to merge 2 commits into
Open
Fix cone projectile aiming in third person (free aim and target lock)#7zspatter wants to merge 2 commits into
zspatter wants to merge 2 commits into
Conversation
Cone-type projectiles were never redirected during target lock: the GetLinearVelocity hook was not installed on ConeProjectile's vtable, and ProjectileAimSupport's form type switch fell through to free aim for them. Install the hook and map cones to the spell/missile aim type setting so predict and homing work for cone projectiles the same way they do for missiles.
The engine launches cone projectiles using the shooter's body pitch rather than the camera aim pitch. With the free camera active, the character's pitch is not synced to the camera (UpdateFacingCrosshair only transfers yaw), so player-fired cone projectiles miss the crosshair, with the error growing with distance. Missiles, arrows and beams are unaffected because their launch direction is derived from the camera. Re-aim cone projectiles along the camera-crosshair raycast at launch, using the same approach as the existing mounted aiming correction in InitProjectile. The arrow tilt-up angle is intentionally not applied since cones receive no engine side crosshair correction that would compensate for it.
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.
Addresses #6.
Two independent commits, intentionally kept separate so they can be cherry-picked individually:
1.
Support cone projectiles in target lock aim typesMinimal extension of the existing pattern: installs the
GetLinearVelocityhook onRE::VTABLE_ConeProjectile[0](cones have their own vtable, so the baseProjectilehook never fires for them) and mapsFormType::ProjectileConetouTargetLockMissileAimTypeinProjectileAimSupport. With this, predict and homing behave for cone projectiles the way they already do for missiles. No new settings and no MCM changes.2.
Aim player cone projectiles at the crosshair in third personFixes the free aim case. The engine derives the launch direction of player-fired missiles/arrows/beams from the camera, but cone projectiles launch with the shooter's body pitch. Since the free camera keeps camera pitch in
freeRotation.ywithout syncing the character's pitch (UpdateFacingCrosshairtransfers yaw only), cones miss the crosshair, with error growing with distance.The fix re-aims player-fired cone projectiles along the camera-crosshair raycast in
InitProjectile, reusing the exact approach (and constants) of the existing mounted aiming block, gated to: player shooter, cone form type,IsFreeCamera(), third person camera state, and either no target lock or lock with the free aim setting. Notes:f3PArrowTiltUpAngletilt from the mounted block is intentionally omitted: cones get no engine-side crosshair correction that would compensate for the tilt, so the exact ray direction is what should be flown.Testing status
Full disclosure: I authored this against the patterns already in the codebase and it compiles clean in CI, but I have not yet done an in-game runtime test of these builds. I did verify the diagnosis in-game extensively (cone spells miss high in third person free aim and target lock, are accurate in first person, and accurate with TDM removed - details in #6). Happy to run the CI artifact through in-game testing if you'd like that before considering this, or feel free to treat this PR as a reference implementation for #6 and rework it as you see fit.