Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the POV button in spectator mode #611

Closed
wants to merge 5 commits into from
Closed

Conversation

Khalmee
Copy link
Contributor

@Khalmee Khalmee commented Apr 7, 2023

Pressing the Middle Mouse Button while spectating switches POV from 3rd to 1st person, just like how it works in vanilla.

@x3Karma
Copy link
Contributor

x3Karma commented Apr 7, 2023

Looks good but I think it shouldn't need to be in a separate file, maybe modify cl_gamestate.nut would be fine.

global function SpectatorPovButtonFixInit

void function SpectatorPovButtonFixInit(){
RegisterButtonPressedCallback(MOUSE_MIDDLE, SwitchPov)
Copy link
Contributor

Choose a reason for hiding this comment

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

The button callback needs to be only registered when spectating

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Registering and deregistering it would be pain, especially because all of the possible combinations of spectating/respawning/joining a game/switching players etc., so unless I manage do find proper callbacks for that I'd leave it as it is, since it only does something when spectating

@ASpoonPlaysGames
Copy link
Contributor

Looks good but I think it shouldn't need to be in a separate file, maybe modify cl_gamestate.nut would be fine.

I think ideally we put it in the same file as the spectator UI? I don't see a reason why this needs to be specifically on the CLIENT vm

@F1F7Y F1F7Y added the waiting on changes by author Waiting on PR author to implement the suggested changes label Apr 20, 2023
Copy link
Contributor

@ASpoonPlaysGames ASpoonPlaysGames left a comment

Choose a reason for hiding this comment

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

Works now in testing for me, and I did a formatting and code pass, so LGTM
(since I have commits on this PR now, another reviewer would be appreciated)

@ASpoonPlaysGames
Copy link
Contributor

I think ideally we put it in the same file as the spectator UI? I don't see a reason why this needs to be specifically on the CLIENT vm

I now disagree with myself here, since this is more of a temp fix than a permanent solution (ideally we find the root cause of spec_mode not working in native) I think it would be better to not commit a vanilla file

@ASpoonPlaysGames ASpoonPlaysGames added needs testing Changes from the PR still need to be tested needs code review Changes from PR still need to be reviewed in code and removed waiting on changes by author Waiting on PR author to implement the suggested changes labels May 11, 2023
@ghost
Copy link

ghost commented Jun 24, 2023

I found out that this can be fixed on pure server-side, by adding 0.1s spectator replay delay while in third person spec mode
in mp/_spectator.gnut, line 167

if ( target.IsPlayer() )
{		
	try
	{
		player.SetObserverTarget( target )
		player.StartObserverMode( OBS_MODE_CHASE )
		player.SetSpecReplayDelay( 0.1 ) // at least 0.1s specReplayDelay is required for client to know that player is spectating, and they can send "spec_mode" client command
	}
	catch ( ex ) { }
}

the same file, in function ClientCommandCallback_spec_mode()

bool function ClientCommandCallback_spec_mode( entity player, array<string> args )
{
	// currently unsure how this actually gets called on client, works through console and has references in client.dll tho
	if ( player.GetObserverMode() == OBS_MODE_CHASE )
	{
		// set to first person spectate		
		player.SetSpecReplayDelay( FIRST_PERSON_SPECTATOR_DELAY )
		player.SetViewEntity( player.GetObserverTarget(), true )
		player.StartObserverMode( OBS_MODE_IN_EYE )
	}
	else if ( player.GetObserverMode() == OBS_MODE_IN_EYE )
	{	
		// set to third person spectate
		player.StartObserverMode( OBS_MODE_CHASE )
		player.SetSpecReplayDelay( 0.1 ) // at least 0.1s specReplayDelay is required for client to know that player is spectating, and they can send "spec_mode" client command
	}
	
	return true
}

@F1F7Y
Copy link
Member

F1F7Y commented Jul 9, 2023

I found out that this can be fixed on pure server-side, by adding 0.1s spectator replay delay while in third person spec mode in mp/_spectator.gnut, line 167

if ( target.IsPlayer() )
{		
	try
	{
		player.SetObserverTarget( target )
		player.StartObserverMode( OBS_MODE_CHASE )
		player.SetSpecReplayDelay( 0.1 ) // at least 0.1s specReplayDelay is required for client to know that player is spectating, and they can send "spec_mode" client command
	}
	catch ( ex ) { }
}

the same file, in function ClientCommandCallback_spec_mode()

bool function ClientCommandCallback_spec_mode( entity player, array<string> args )
{
	// currently unsure how this actually gets called on client, works through console and has references in client.dll tho
	if ( player.GetObserverMode() == OBS_MODE_CHASE )
	{
		// set to first person spectate		
		player.SetSpecReplayDelay( FIRST_PERSON_SPECTATOR_DELAY )
		player.SetViewEntity( player.GetObserverTarget(), true )
		player.StartObserverMode( OBS_MODE_IN_EYE )
	}
	else if ( player.GetObserverMode() == OBS_MODE_IN_EYE )
	{	
		// set to third person spectate
		player.StartObserverMode( OBS_MODE_CHASE )
		player.SetSpecReplayDelay( 0.1 ) // at least 0.1s specReplayDelay is required for client to know that player is spectating, and they can send "spec_mode" client command
	}
	
	return true
}

Recon you could do a small Pr with these changes ?

Copy link
Contributor

@ASpoonPlaysGames ASpoonPlaysGames left a comment

Choose a reason for hiding this comment

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

Would be cool if the above suggestions get implemented.

@ASpoonPlaysGames
Copy link
Contributor

@Khalmee is this PR stale?

@ASpoonPlaysGames ASpoonPlaysGames added the waiting on changes by author Waiting on PR author to implement the suggested changes label Aug 25, 2023
Copy link
Member

@GeckoEidechse GeckoEidechse left a comment

Choose a reason for hiding this comment

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

Superseded by #706

(will close once other one gets merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs code review Changes from PR still need to be reviewed in code needs testing Changes from the PR still need to be tested vanilla parity waiting on changes by author Waiting on PR author to implement the suggested changes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants