Doesn't that code just check if the player has new angles? That's not really what I'm looking for... I tried several methods of yaw restriction, here they both are:
This one used arc length to determine a boundary: if( ent->curstate.iuser3 & FL2_USINGBIPOD ) { float flMin, flMax, flYawRads, flViewRads; if( yaw_angle == 0.0f ) yaw_angle = pparams->cl_viewangles[YAW]; // get the length of the possible yaw arc, total of 90 degrees of motion, so the length is M_PI/2 flYawRads = (yaw_angle * M_PI)/180; // length of their angles for subtraction and addition flMin = flYawRads - (M_PI/4); flMax = flYawRads + (M_PI/4); flViewRads = (pparams->cl_viewangles[YAW] * M_PI)/180; if( flViewRads < flMin ) pparams->cl_viewangles[YAW] = (flMin/M_PI)*180; else if( flViewRads > flMax ) pparams->cl_viewangles[YAW] = (flMax/M_PI)*180; // clamp to a certain pitch value if( pparams->cl_viewangles[PITCH] > 45 ) pparams->cl_viewangles[PITCH] = 45; else if( pparams->cl_viewangles[PITCH] < -20 ) pparams->cl_viewangles[PITCH] = -20; } else yaw_angle = 0.0f; yaw_angle is defined as a static float outside of the function (not in any function) Here's a method that uses strictly angles: if( ent->curstate.iuser3 & FL2_USINGBIPOD ) { float flMax, flMin; cl_entity_t *ent = gEngfuncs.GetLocalPlayer(); flMin = g_vecBipodAngles[YAW] - 45.0f; flMax = g_vecBipodAngles[YAW] + 45.0f; gEngfuncs.Con_Printf( ">> %f\n", g_vecBipodAngles[YAW]); if( flMax > 360 ) { float flDiff = flMax - 360; if( pparams->cl_viewangles[YAW] + flDiff > flMax ) pparams->cl_viewangles[YAW] = flMax; else if( pparams->cl_viewangles[YAW] < flMin ) pparams->cl_viewangles[YAW] = flMin; } else { if( pparams->cl_viewangles[YAW] > flMax ) pparams->cl_viewangles[YAW] = flMax; else if( pparams->cl_viewangles[YAW] < flMin ) pparams->cl_viewangles[YAW] = flMin; } gEngfuncs.Con_Printf( ">> %f - %f - %f\n", pparams->cl_viewangles[YAW], flMin, flMax ); // clamp to a certain pitch value if( pparams->cl_viewangles[PITCH] > 45 ) pparams->cl_viewangles[PITCH] = 45; else if( pparams->cl_viewangles[PITCH] < -20 ) pparams->cl_viewangles[PITCH] = -20; } Both of them don't work correctly.... The game throws a fit when a player puts the bipod down at an angle >= 270, because when they move past the 360 degree point, their angles get reset to zero, which meets the flMin condition, so the game throws the player back to the minimum, when they should be at a max. Both of these methods work when the angle of view is less than 270 and greater than 45 (it does the same thing at 45, but with the flMax condition). -Cale 'Mazor' Dunlap -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Rockefeller Sent: Tuesday, January 21, 2003 1:35 AM To: [EMAIL PROTECTED] Subject: [hlcoders] Re: Yaw restriction > I need to figure out a way to restrict the players' yaw movement to a > certain cone. I slaved over my keyboard for hours trying to figure it > out with no luck. I made a little progress, but there were large > problems which could really hinder gameplay. My starting point is when > the server sends the players' view angles to the client for calculation > via the delta.lst file. The values check out, and are correct, so they > don't get mutilated when they get sent through the delta file. These > angles are sent to a global array called g_vecBipodAngles, then I tried > setting some bounds checks in the V_CalcNormalRefdef function and I > still didn't get it to work properly. is there another way to do this? The best way is to check that i pm_shared.c. Here is some code i use in Project Timeless: if (...) { pmove->angles[YAW] = newangles ; #ifdef CLIENT_DLL if ( pmove->runfuncs ) { iHasNewViewAngles = true; VectorCopy (pmove->angles, vecNewViewAngles) } #endif } You can insert it where you want the pm-code to check the angles, for example in the case part of MOVETYPE_WALK in PM_PlayerMove(). Rockefeller _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders