Пример #1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CObjectSentrygun::OnGoActive( void )
{
	/*
	CTFPlayer *pBuilder = GetBuilder();

	Assert( pBuilder );

	if ( !pBuilder )
		return;
	*/
	SetModel( SENTRY_MODEL_LEVEL_1 );

	m_iState.Set( SENTRY_STATE_SEARCHING );

	// Orient it
	QAngle angles = GetAbsAngles();

	m_vecCurAngles.y = UTIL_AngleMod( angles.y );
	m_iRightBound = UTIL_AngleMod( (int)angles.y - 50 );
	m_iLeftBound = UTIL_AngleMod( (int)angles.y + 50 );
	if ( m_iRightBound > m_iLeftBound )
	{
		m_iRightBound = m_iLeftBound;
		m_iLeftBound = UTIL_AngleMod( (int)angles.y - 50);
	}

	// Start it rotating
	m_vecGoalAngles.y = m_iRightBound;
	m_vecGoalAngles.x = m_vecCurAngles.x = 0;
	m_bTurningRight = true;

	EmitSound( "Building_Sentrygun.Built" );

	// if our eye pos is underwater, we're waterlevel 3, else 0
	bool bUnderwater = ( UTIL_PointContents( EyePosition() ) & MASK_WATER ) ? true : false;
	SetWaterLevel( ( bUnderwater ) ? 3 : 0 );	

	m_iAmmoShells = m_iMaxAmmoShells;

	// Init attachments for level 1 sentry gun
	m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE] = LookupAttachment( "muzzle" );
	m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE_ALT] = 0;
	m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_L] = 0;
	m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_R] = 0;

	BaseClass::OnGoActive();

}
Пример #2
0
/*
================
idPhysics_Monster::Evaluate
================
*/
bool idPhysics_Monster::Evaluate( int timeStepMSec, int endTimeMSec ) {
	if( timeStepMSec == 0 ) {
		// angua: time step can be zero when the AI comes back from being dormant
		return false;
	}
	idVec3 masterOrigin, oldOrigin;
	idMat3 masterAxis;
	float timeStep;
#ifdef MOD_WATERPHYSICS
	waterLevel = WATERLEVEL_NONE;		// MOD_WATERPHYSICS
	waterType = 0;						// MOD_WATERPHYSICS
#endif		// MOD_WATERPHYSICS
	timeStep = MS2SEC( timeStepMSec );
	moveResult = MM_OK;
	blockingEntity = NULL;
	oldOrigin = current.origin;
	// if bound to a master
	if( masterEntity ) {
		self->GetMasterPosition( masterOrigin, masterAxis );
		current.origin = masterOrigin + current.localOrigin * masterAxis;
		clipModel->Link( gameLocal.clip, self, 0, current.origin, clipModel->GetAxis() );
		current.velocity = ( current.origin - oldOrigin ) / timeStep;
		masterDeltaYaw = masterYaw;
		masterYaw = masterAxis[0].ToYaw();
		masterDeltaYaw = masterYaw - masterDeltaYaw;
		return true;
	}
	// if the monster is at rest
	if( current.atRest >= 0 ) {
		return false;
	}
	ActivateContactEntities();
	// move the monster velocity into the frame of a pusher
	current.velocity -= current.pushVelocity;
	clipModel->Unlink();
#ifdef MOD_WATERPHYSICS
	// check water level / type
	SetWaterLevel( true );		// MOD_WATERPHYSICS
#endif		// MOD_WATERPHYSICS
	// check if on the ground
	idPhysics_Monster::CheckGround( current );
	// if not on the ground or moving upwards
	float upspeed;
	if( gravityNormal != vec3_zero ) {
		upspeed = -( current.velocity * gravityNormal );
	} else {
		upspeed = current.velocity.z;
	}
	if( fly || ( !forceDeltaMove && ( !current.onGround || upspeed > 1.0f ) ) ) {
		if( upspeed < 0.0f ) {
			moveResult = MM_FALLING;
		} else {
			current.onGround = false;
			moveResult = MM_OK;
		}
		delta = current.velocity * timeStep;
		if( delta != vec3_origin ) {
			moveResult = idPhysics_Monster::SlideMove( current.origin, current.velocity, delta );
			delta.Zero();
		}
		if( !fly ) {
			current.velocity += gravityVector * timeStep;
		}
	} else {
		if( useVelocityMove ) {
			delta = current.velocity * timeStep;
		} else {
			current.velocity = delta / timeStep;
		}
		current.velocity -= ( current.velocity * gravityNormal ) * gravityNormal;
		if( delta == vec3_origin ) {
			Rest();
		} else {
			// try moving into the desired direction
			moveResult = idPhysics_Monster::StepMove( current.origin, current.velocity, delta );
			delta.Zero();
		}
	}
	clipModel->Link( gameLocal.clip, self, 0, current.origin, clipModel->GetAxis() );
	// get all the ground contacts
	EvaluateContacts();
	// move the monster velocity back into the world frame
	current.velocity += current.pushVelocity;
	current.pushVelocity.Zero();
	if( IsOutsideWorld() ) {
		gameLocal.Warning( "clip model outside world bounds for entity '%s' at (%s)", self->name.c_str(), current.origin.ToString( 0 ) );
		Rest();
	}
	return ( current.origin != oldOrigin );
}
Пример #3
0
	virtual void Init(const CParamNode& UNUSED(paramNode))
	{
		SetWaterLevel(entity_pos_t::FromInt(5));
	}