Skip to content

Conversation

@AdamTadeusz
Copy link
Contributor

@AdamTadeusz AdamTadeusz commented May 14, 2025

Description

The function in C_BaseAnimating that calls CNEOBaseCombatWeapon::ProcessMuzzleFlashEvent is supposed to exit early if the weapon isn't visible to the local player, but this doesn't work for weapons which are hidden to spectators in first person observer mode. This seems to be at least known about considering the check in C_BaseCombatWeapon::DrawModel, so adding the same check to CNEOBaseCombatWeapon::ProcessMuzzleFlashEvent to exit early.

When trying to figure out why third person muzzle flashes were being drawn at world origin as well (turned out to be a particle error), I figured out a way to emit a particle client side only thats much simpler (see how "vortigaunt_beam_charge" is being emitted). Since we don't need to pass anything to the one and only particle controller in ntr_muzzle_source since we're using an attachment point, it becomes a one liner.

I also noticed two problems with the first person muzzle flash.

  • When using viewmodel only rotation, the muzzle flash does not rotate with the viewmodel. This is contrary to what a player would expect, as a muzzle flash is generated in part by the shape of a muzzle device. If a muzzle device is rotated in relation to a camera, then the muzzle flash would rotate too. Adding the muzzle flash rotation onto the initial rotation instead of overwriting it fixes this.
  • The first person muzzle flash rotation wasn't working. I'm certain this worked in the past, probably an issue with the muzzle flash current angle not being set server side. Since this variable doesn't really need to be networked, only reset to 0 when changing weapons, I removed it from the send table and receive tables which fixes the problem. In the future I imagine both the view model and view model muzzle flash should should be entirely predicted client side, since we should be able to work out all the viewmodel properties from the current active weapon of the local player or target player, as soon as we work out how to work around the server changing our active weapon for us.

There was a problem discovered recently where the first person muzzle flash wouldn't move with the muzzle attachment. We're not actually attaching the muzzle flash to the view model, but instead changing the muzzle flash origin and angle to where the muzzle is each draw. I figured moving this code to CalcViewModelView instead so the position of the muzzle flash is updated right after the position of the viewmodel itself is updated, in roughly the same way as the position of the viewmodel, could solve this issue. If we still notice this problem we could also try actually setting the muzzle flash attachment point to the muzzle in a onNewModel function in the viewmodel.

@AdamTadeusz AdamTadeusz changed the title Hide third person muzzle flash for spectators in eye, simplify particle emission, fix first person muzzle flash not rotating, rotate muzzle flash with viewmodel roation Hide third person muzzle flash for spectators in eye, simplify particle emission, fix first person muzzle flash not rotating, rotate muzzle flash with viewmodel rotation, move setorigin and angles of muzzleflash to CalcViewModelView May 14, 2025
@AdamTadeusz AdamTadeusz requested a review from a team May 14, 2025 19:17
Copy link
Contributor

@brysondev brysondev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brysondev brysondev requested a review from a team May 15, 2025 03:52
DESTROYGIRL
DESTROYGIRL previously approved these changes May 27, 2025
@DESTROYGIRL DESTROYGIRL requested a review from a team May 27, 2025 21:27
@Rainyan Rainyan requested a review from DESTROYGIRL August 1, 2025 10:33
Copy link
Contributor

@sunzenshen sunzenshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a local branch, rebased on top of e80e9b0 and then observed bot matches in both first version view and 3rd person follow mode. I guess muzzle flashes look fine? But admittedly I didn't notice the problems mentioned in the PR description, so my observations might be unsophisticated.

@AdamTadeusz AdamTadeusz merged commit 4357d82 into NeotokyoRebuild:master Aug 19, 2025
7 checks passed
@AdamTadeusz AdamTadeusz deleted the 229_hideThirdPersonMuzzleFlashForSpectators branch August 19, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants