Пример #1
0
/**
 * @brief Initialize the step_t data
 * @param[in] step The struct describing the move
 * @param[in] map Pointer to client or server side routing table (clMap, svMap)
 * @param[in] actorSize Give the field size of the actor (e.g. for 2x2 units) to check linked fields as well.
 * @param[in] crouchingState Whether the actor is currently crouching, 1 is yes, 0 is no.
 * @param[in] dir Direction vector index (see DIRECTIONS and dvecs)
 * @return false if dir is irrelevant or something went wrong
 */
static qboolean Grid_StepInit (step_t *step, const routing_t *map, const actorSizeEnum_t actorSize, const byte crouchingState, const int dir)
{
	step->map = map;
	/** @todo flier should return true if the actor can fly. */
	step->flier = qfalse; /**< This can be keyed into whether an actor can fly or not to allow flying */
	step->hasLadderToClimb = qfalse;
	step->hasLadderSupport = qfalse;
	step->actorSize = actorSize;
	/** @note This is the actor's height in QUANT units. */
	/** @todo actor_height is currently the fixed height of a 1x1 actor.  This needs to be adjusted
	 *  to the actor's actual height. */
	step->actorHeight = ModelCeilingToQuant((float)(crouchingState ? PLAYER_CROUCHING_HEIGHT : PLAYER_STANDING_HEIGHT)); /**< The actor's height */
	step->actorCrouchedHeight = ModelCeilingToQuant((float)(PLAYER_CROUCHING_HEIGHT));

	/* Ensure that dir is in bounds. */
	assert(dir >= 0 && dir < PATHFINDING_DIRECTIONS);

	/* IMPORTANT: only fliers can use directions higher than NON_FLYING_DIRECTIONS. */
	if (!step->flier && dir >= FLYING_DIRECTIONS) {
		return qfalse;
	}

	/* We cannot fly and crouch at the same time. This will also cause an actor to stand to fly. */
	if (crouchingState && dir >= FLYING_DIRECTIONS) {
		return qfalse;
	}

	return qtrue;
}
Пример #2
0
/**
 * @brief Initialize the other Step data
 * @return false if dir is irrelevant or something went wrong
 */
bool Step::init ()
{
	flier = false;
	hasLadderToClimb = false;
	hasLadderSupport = false;
	/** @note This is the actor's height in QUANT units. */
	/** @todo actor_height is currently the fixed height of a 1x1 actor.  This needs to be adjusted
	 *  to the actor's actual height. */
	actorHeight = ModelCeilingToQuant((float)(crouchingState ? PLAYER_CROUCHING_HEIGHT : PLAYER_STANDING_HEIGHT)); /**< The actor's height */
	actorCrouchedHeight = ModelCeilingToQuant((float)(PLAYER_CROUCHING_HEIGHT));

	/* Ensure that dir is in bounds. */
	assert(dir >= 0 && dir < PATHFINDING_DIRECTIONS);

	/* IMPORTANT: only fliers can use directions higher than NON_FLYING_DIRECTIONS. */
	if (!flier && dir >= FLYING_DIRECTIONS) {
		return false;
	}

	/* We cannot fly and crouch at the same time. This will also cause an actor to stand to fly. */
	if (crouchingState && dir >= FLYING_DIRECTIONS) {
		return false;
	}

	return true;
}
Пример #3
0
	static EConnectionState evaluateConnectionState (const routing_t routes[ACTOR_MAX_SIZE], const pos3_t pos,
			const int actorSize, const EDirection direction)
	{
		byte route = 0;
		byte stepup = 0;

		switch (direction) {
		case DIR_WEST:
			route = RT_CONN_NY(routes,actorSize,pos[0],pos[1],pos[2]);
			stepup = RT_STEPUP_NY(routes,actorSize,pos[0],pos[1],pos[2]);
			break;
		case DIR_NORTHWEST:
			route = RT_CONN_PX_NY(routes,actorSize,pos[0],pos[1],pos[2]);
			stepup = RT_STEPUP_PX_NY(routes,actorSize,pos[0],pos[1],pos[2]);
			break;
		case DIR_NORTH:
			route = RT_CONN_PX(routes,actorSize,pos[0],pos[1],pos[2]);
			stepup = RT_STEPUP_PX(routes,actorSize,pos[0],pos[1],pos[2]);
			break;
		case DIR_NORTHEAST:
			route = RT_CONN_PX_PY(routes,actorSize,pos[0],pos[1],pos[2]);
			stepup = RT_STEPUP_PX_PY(routes,actorSize,pos[0],pos[1],pos[2]);
			break;
		case DIR_EAST:
			route = RT_CONN_PY(routes,actorSize,pos[0],pos[1],pos[2]);
			stepup = RT_STEPUP_PY(routes,actorSize,pos[0],pos[1],pos[2]);
			break;
		case DIR_SOUTHEAST:
			route = RT_CONN_NX_PY(routes,actorSize,pos[0],pos[1],pos[2]);
			stepup = RT_STEPUP_NX_PY(routes,actorSize,pos[0],pos[1],pos[2]);
			break;
		case DIR_SOUTH:
			route = RT_CONN_NX(routes,actorSize,pos[0],pos[1],pos[2]);
			stepup = RT_STEPUP_NX(routes,actorSize,pos[0],pos[1],pos[2]);
			break;
		case DIR_SOUTHWEST:
			route = RT_CONN_NX_NY(routes,actorSize,pos[0],pos[1],pos[2]);
			stepup = RT_STEPUP_NX_NY(routes,actorSize,pos[0],pos[1],pos[2]);
			break;
		case MAX_DIRECTIONS:
			break;
		}

		if (stepup == PATHFINDING_NO_STEPUP)
			return CON_DISABLE;
		else if (route >= ModelCeilingToQuant(PLAYER_STANDING_HEIGHT))
			return CON_WALKABLE;
		else if (route >= ModelCeilingToQuant(PLAYER_CROUCHING_HEIGHT))
			return CON_CROUCHABLE;
		else
			return CON_DISABLE;
	}