Пример #1
0
qboolean NPC_FaceEnemy( qboolean doPitch )
{
	if ( NPC == NULL )
		return qfalse;

	if ( NPC->enemy == NULL )
		return qfalse;

	return NPC_FaceEntity( NPC->enemy, doPitch );
}
Пример #2
0
void NPC_FlyToGoal( void )
{
	vec3_t	moveDir;

#if 0
	if ( NPCInfo->behaviorState == BS_FOLLOW_LEADER && NPC->client->leader )
	{
		NPC_GetFlyToLeader( moveDir );
	}
	else
#endif
	{
		NPC_GetFlyToGoal( moveDir );
	}

#if 1
#if 1
	if ( NPCInfo->behaviorState == BS_FOLLOW_LEADER && NPC->client->leader )	//hack ki pu
	{
		float dist = DistanceSquared( NPC->client->leader->r.currentOrigin, NPC->r.currentOrigin );
		float groundDist = G_GroundDistance( NPC );

		if ( dist < 9216 /*96*96*/ )
		{
			VectorInverse( moveDir );
		}
		else if ( dist < 25600 /*160*160*/ )
		{
			//on freine
			float speed = VectorLength( NPC->client->ps.velocity ) / 4.0f;
			if ( speed > NPCInfo->stats.acceleration )
				speed = NPCInfo->stats.acceleration;
			VectorNormalize2( NPC->client->ps.velocity, moveDir );
			VectorScale( moveDir, -speed, moveDir );
		}

		if ( groundDist < 64 )
			moveDir[2] += NPCInfo->stats.acceleration / 5.0f;
	}
#endif
	VectorAdd( NPC->client->ps.velocity, moveDir, NPC->client->ps.velocity );
	VectorCopy( moveDir, NPC->client->ps.moveDir );
	ucmd.forwardmove = ucmd.rightmove = ucmd.upmove = 0;
#else
	G_UcmdMoveForDir( NPC, &ucmd, moveDir );
#endif

	NPC_FaceEntity( NPCInfo->goalEntity, qtrue );
}
Пример #3
0
//added from SP
static qboolean NPC_Howler_Move( int randomJumpChance )
{
	if ( !TIMER_Done( NPC, "standing" ) )
	{//standing around
		return qfalse;
	}
	if ( NPC->client->ps.groundEntityNum == ENTITYNUM_NONE )
	{//in air, don't do anything
		return qfalse;
	}
	if ( (!NPC->enemy&&TIMER_Done( NPC, "running" )) || !TIMER_Done( NPC, "walking" ) )
	{
		ucmd.buttons |= BUTTON_WALKING;
	}
	if ( (!randomJumpChance||Q_irand( 0, randomJumpChance ))
		&& NPC_MoveToGoal( qtrue ) )
	{
		if ( VectorCompare( NPC->client->ps.moveDir, vec3_origin )
			|| !NPC->client->ps.speed )
		{//uh.... wtf?  Got there?
			if ( NPCInfo->goalEntity )
			{
				NPC_FaceEntity( NPCInfo->goalEntity, qfalse );
			}
			else
			{
				NPC_UpdateAngles( qfalse, qtrue );
			}
			return qtrue;
		}
		//TEMP: don't want to strafe
		VectorClear( NPC->client->ps.moveDir );
		ucmd.rightmove = 0.0f;
//		Com_Printf( "Howler moving %d\n",ucmd.forwardmove );
		//if backing up, go slow...
		if ( ucmd.forwardmove < 0.0f )
		{
			ucmd.buttons |= BUTTON_WALKING;
			//if ( NPC->client->ps.speed > NPCInfo->stats.walkSpeed )
			{//don't walk faster than I'm allowed to
				NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
			}
		}
		else
		{
			if ( (ucmd.buttons&BUTTON_WALKING) )
			{
				NPC->client->ps.speed = NPCInfo->stats.walkSpeed;
			}
			else
			{
				NPC->client->ps.speed = NPCInfo->stats.runSpeed;
			}
		}
		NPCInfo->lockedDesiredYaw = NPCInfo->desiredYaw = NPCInfo->lastPathAngles[YAW];
		NPC_UpdateAngles( qfalse, qtrue );
	}
	else if ( NPCInfo->goalEntity )
	{//couldn't get where we wanted to go, try to jump there
		NPC_FaceEntity( NPCInfo->goalEntity, qfalse );
		NPC_TryJump_Gent( NPCInfo->goalEntity, 400.0f, -256.0f );
	}
	return qtrue;
}