Locking player's viewangles

Locked
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Locking player's viewangles

Post by Eraser »

I'm having a bit of an odd problem. I implemented cutscenes in my EntityPlus mod and while this works well, the only problem is that if the player moves the mouse during the cutscene (or presses the view up/down/left/right buttons) the view of the player after the cutscene will be affected by the mouse movement/button presses.

I want the player to be unable to alter its own view angles during the cutscene so that the view after the cutscene has ended is identical to the view before the cutscene. Locking player movement works already, it's just the view angles that won't seem to stick.

Anyone know how I can achieve this? Current source can be found here.

I already have this bit of code in PM_UpdateViewAngles in bg_pmove.c, but it doesn't seem to help anything:

Code: Select all

if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION || ps->pm_type == PM_CUTSCENE ) {
	return;         // no view changes at all
}
During a cutscene, the player's pm_type is set to PM_CUTSCENE. This is how I tell if a player is currently in a cutscene or not.

I've also tried storing the player's viewangles in a temporary variable when the cutscene starts and then restore that when the cutscene has finished playing. This is done serverside (in the game project):

Code: Select all

VectorCopy(self->activator->orgAngles, self->activator->client->ps.viewangles);
But this doesn't seem to help either.

Anyone know how I can stop the player from giving input that changes the view angles?
themuffinman
Posts: 384
Joined: Fri Mar 05, 2010 5:29 pm

Re: Locking player's viewangles

Post by themuffinman »

I think what you want is...

pm->xyspeed = 0;

... although I haven't tested it myself. I just got that from scratching around in the Smoking Guns source for the duel camera intro in g_active.c

Edit:
Nevermind, this looks more relevant:

bg_public.h:

Code: Select all

#define SF_DU_INTRO		0x00020	// player is in intro mode, don't update the viewangles

bg_pmove.c (PM_UpdateViewAngles):

Code: Select all

	// if in duel intro mode, don't update viewangles
	if (ps->stats[STAT_FLAGS] & SF_DU_INTRO){

		// set the delta angle
		for (i=0 ; i<3 ; i++) {
			int		cmdAngle;

			cmdAngle = ANGLE2SHORT(pm->ps->viewangles[i]);
			pm->ps->delta_angles[i] = cmdAngle - pm->cmd.angles[i];
		}
		return;
	}

g_active.c (ClientThink_real):

Code: Select all

	// mouseangles can't be moved during camera move
	if(!du_nextroundstart && du_introend - DU_INTRO_DRAW >= level.time &&
		ent->client->sess.sessionTeam == TEAM_FREE) {
		pm.ps->stats[STAT_FLAGS] |= SF_DU_INTRO;
	} else {
		pm.ps->stats[STAT_FLAGS] &= ~SF_DU_INTRO;
	}
Which you'd obviously alter appropriately. You can get the source at http://sourceforge.net/projects/smokinguns/
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Re: Locking player's viewangles

Post by Eraser »

That bg_pmove.c code is exactly what I needed. Thanks a lot, it works perfectly!
Locked