Beispiel #1
0
void NPC::MoveAction(void)
{
	if ((g_waypoint->g_waypointPointFlag[m_currentWaypointIndex] & WAYPOINT_LADDER &&
		GetDistance2D(pev->origin, g_waypoint->g_waypointPointOrigin[m_currentWaypointIndex]) <= 10.0f) ||
		(m_oldNavIndex != -1 && g_waypoint->g_waypointPointFlag[m_oldNavIndex] & WAYPOINT_LADDER &&
			GetDistance2D(pev->origin, g_waypoint->g_waypointPointOrigin[m_oldNavIndex]) <= 10.0f))
		pev->movetype = MOVETYPE_FLY;
	else
		pev->movetype = MOVETYPE_PUSHSTEP;

	float oldSpeed = pev->speed;
	pev->speed = m_moveSpeed;
	if (m_moveSpeed == 0.0f || !IsAlive (GetEntity ()))
	{
		if (!IsOnLadder(GetEntity()) && pev->solid != SOLID_NOT)
			DROP_TO_FLOOR(GetEntity());
		return;
	}

	if (IsOnLadder(GetEntity()) || pev->solid == SOLID_NOT)
	{
		pev->velocity = GetSpeedVector(pev->origin, m_destOrigin, pev->speed);

		if (pev->solid == SOLID_NOT)
			goto lastly;
	}
	else
	{
		Vector vecMove = m_destOrigin - pev->origin;
		Vector vecFwd, vecAng;
		VEC_TO_ANGLES(vecMove, vecAng);
		vecAng = Vector(0.0f, vecAng.y, 0.0f);
		UTIL_MakeVectorsPrivate(vecAng, vecFwd, null, null);

		pev->velocity.x = vecFwd.x * pev->speed;
		pev->velocity.y = vecFwd.y * pev->speed;
	}

	if (m_jumpAction)
	{
		pev->velocity.z = (270.0f * pev->gravity) + 32.0f; // client gravity 1 = 270.0f , and jump+duck + 32.0f
		m_jumpAction = false;
	}

	CheckStuck(oldSpeed);

	lastly:
	float speed = GetDistance2D(pev->velocity);
	if (speed > 10.0f || speed < -10.0f)
		g_npcAS |= ASC_MOVE;

	MakeVectors(pev->angles);
}
Beispiel #2
0
void NPC::FacePosition(void)
{
	Vector direction = m_lookAt;
	VEC_TO_ANGLES((m_lookAt - pev->origin), direction);
	direction.x *= -1.0f;

	direction.x = 360.0f / 65536.0f * (static_cast <int> ((direction.x + 180.0f) * (65536.0f / 360.0f)) & 65535) - 180.0f;
	direction.y = 360.0f / 65536.0f * (static_cast <int> ((direction.y + 180.0f) * (65536.0f / 360.0f)) & 65535) - 180.0f;
	direction.z = 0.0f;

	pev->angles = direction;
	pev->angles.x = 0.0f;
}
Beispiel #3
0
Vector UTIL_VecToAngles( const Vector &vec )
{
	Vector rgflVecOut;
	VEC_TO_ANGLES(vec, rgflVecOut);
	return rgflVecOut;
}
Beispiel #4
0
Vector UTIL_VecToAngles( const Vector &vec )
{
   float rgflVecOut[3];
   VEC_TO_ANGLES(vec, rgflVecOut);
   return Vector(rgflVecOut);
}