Exemple #1
0
/*
-----------------------------------------------------------------------------
 Function: 
 
 Parameters:
 
 Returns:
 
 Notes: 

-----------------------------------------------------------------------------
*/
PUBLIC void PL_Process( player_t *self, LevelData_t *lvl )
{	
	int n;

	self->madenoise = false;

	PL_ControlMovement( self, lvl );

	if( self->flags & PL_FLAG_ATTCK )
	{
		PL_PlayerAttack( self, Player.cmd.buttons & BUTTON_ATTACK );
	}
	else
	{
		if( Player.cmd.buttons & BUTTON_USE )
		{
			if(!(self->flags & PL_FLAG_REUSE) && PL_Use( self, lvl ) )
			{
				self->flags|=PL_FLAG_REUSE;
			}
		}
		else
		{
			self->flags &= ~PL_FLAG_REUSE;
		}

		if( Player.cmd.buttons & BUTTON_ATTACK )
		{
			self->flags |= PL_FLAG_ATTCK;
			
			//gsh
			if (self->previousweapon != WEAPON_KNIFE && self->previousweapon)
			{
				//self->weapon = self->previousweapon;
				PL_ChangeWeapon(self, self->previousweapon);
			}
			
			self->attackframe = 0;
			self->attackcount = attackinfo[ self->weapon ][ 0 ].tics;
			self->weaponframe = attackinfo[ self->weapon ][ 0 ].frame;
		}
		else if ( Player.cmd.buttons & BUTTON_ALTERNATE_ATTACK )   //gsh
		{
			self->flags |= PL_FLAG_ATTCK;
			
//			PL_ChangeWeapon(self, WEAPON_KNIFE);
			if (self->weapon != WEAPON_KNIFE)
			{
				self->previousweapon = self->weapon;
				self->weapon = WEAPON_KNIFE;
			}
			
			self->attackframe = 0;
			self->attackcount = attackinfo[ self->weapon ][ 0 ].tics;
			self->weaponframe = attackinfo[ self->weapon ][ 0 ].frame;
		}
		else if ( Player.cmd.buttons & BUTTON_CHANGE_WEAPON ) {
			self->pendingweapon=self->weapon;
			for( n = 0 ; n < 4; ++n )
			{
				if( ++self->weapon > WEAPON_CHAIN ) 
				{
					self->weapon = WEAPON_KNIFE;
				}
				
				if( PL_ChangeWeapon( self, self->weapon ) ) 
				{
					break;
				}
			}
			self->weapon = self->pendingweapon;
		}
		
	}
}
Exemple #2
0
/**
 * \brief Process player input every frame
 * \param[in] self Player
 * \param[in] lvl Level data structure
 */
PUBLIC void PL_Process( player_t *self, LevelData_t *lvl )
{
	int n;

	self->madenoise = false;

	PL_ControlMovement( self, lvl );

	if( self->flags & PL_FLAG_ATTCK )
	{
		PL_PlayerAttack( self, ClientState.cmd.buttons & BUTTON_ATTACK );
	}
	else
	{
		if( ClientState.cmd.buttons & BUTTON_USE )
		{
			if(!(self->flags & PL_FLAG_REUSE) && PL_Use( self, lvl ) )
			{
				self->flags|=PL_FLAG_REUSE;
			}
		}
		else
		{
			self->flags &= ~PL_FLAG_REUSE;
		}

		if( ClientState.cmd.buttons & BUTTON_ATTACK )
		{
			self->flags |= PL_FLAG_ATTCK;

			self->attackframe = 0;
			self->attackcount = attackinfo[ self->weapon ][ 0 ].tics;
			self->weaponframe = attackinfo[ self->weapon ][ 0 ].frame;
		}
	}

// process impulses
	switch( ClientState.cmd.impulse )
	{
		case 0:
			break; // no impulse

		case 1:
		case 2:
		case 3:
		case 4:
			PL_ChangeWeapon( self, ClientState.cmd.impulse - 1 );
			break;

		case 10: // next weapon /like in Quake/ FIXME: weapprev, weapnext
			self->pendingweapon=self->weapon;
			for( n = 0 ; n < 4; ++n )
			{
				if( ++self->weapon > WEAPON_GATLINGGUN )
				{
					self->weapon = WEAPON_KNIFE;
				}

				if( PL_ChangeWeapon( self, self->weapon ) )
				{
					break;
				}
			}
			self->weapon = self->pendingweapon;
			break;

		default:
			Com_Printf( "Unknown Impulse: %d\n", ClientState.cmd.impulse );
			break;
	}

}