Esempio n. 1
0
/**
 * @brief Starts shooting with actor.
 * @param[in] self Pointer to the event structure that is currently executed
 * @param[in] msg The netchannel message
 * @sa CL_ActorShootHidden
 * @sa CL_ActorShoot
 * @sa CL_ActorDoShoot
 * @todo Improve detection of left- or right animation.
 * @sa EV_ACTOR_START_SHOOT
 */
void CL_ActorStartShoot (const eventRegister_t* self, dbuffer* msg)
{
	pos3_t from, target;
	int entnum;
	shoot_types_t shootType;

	NET_ReadFormat(msg, self->formatString, &entnum, &shootType, &from, &target);

	/* shooting actor */
	le_t* le = LE_Get(entnum);

	/* center view (if wanted) */
	if (!cls.isOurRound())
		CL_CheckCameraRoute(from, target);

	/* actor dependent stuff following */
	if (!le)
		/* it's OK, the actor is not visible */
		return;

	if (!LE_IsLivingActor(le) || LE_IsStunned(le)) {
		Com_Printf("CL_ActorStartShoot: LE (%i) not a living actor (type: %i)\n", entnum, le->type);
		return;
	}

	/* ET_ACTORHIDDEN actors don't have a model yet */
	if (le->type == ET_ACTORHIDDEN)
		return;

	/* Animate - we have to check if it is right or left weapon usage. */
	if (IS_SHOT_RIGHT(shootType)) {
		R_AnimChange(&le->as, le->model1, LE_GetAnim("move", le->right, le->left, le->state));
	} else if (IS_SHOT_LEFT(shootType)) {
		R_AnimChange(&le->as, le->model1, LE_GetAnim("move", le->left, le->right, le->state));
	} else if (!IS_SHOT_HEADGEAR(shootType)) {
		/* no animation for headgear (yet) */
		Com_Error(ERR_DROP, "CL_ActorStartShoot: Invalid shootType given (entnum: %i, shootType: %i).\n", shootType, entnum);
	}
}
Esempio n. 2
0
/**
 * @brief Center the camera on the local entity's origin
 * @param le The local entity which origin is used to center the camera
 * @sa CL_CenterView
 * @sa CL_ViewCenterAtGridPosition
 * @sa CL_CameraRoute
 */
void LE_CenterView (const le_t* le)
{
	if (!cl_centerview->integer)
		return;

	assert(le);
	if (le->team == cls.team) {
		const float minDistToMove = 4.0f * UNIT_SIZE;
		const float dist = Vector2Dist(cl.cam.origin, le->origin);
		if (dist < minDistToMove) {
			pos3_t currentCamPos;
			VecToPos(cl.cam.origin, currentCamPos);
			if (le->pos[2] != currentCamPos[2])
				Cvar_SetValue("cl_worldlevel", le->pos[2]);
			return;
		}

		VectorCopy(le->origin, cl.cam.origin);
	} else {
		pos3_t pos;
		VecToPos(cl.cam.origin, pos);
		CL_CheckCameraRoute(pos, le->pos);
	}
}