示例#1
0
static int G_FillDirectionTable (dvec_t *dvtab, size_t size, byte crouchingState, pos3_t pos)
{
    int dvec;
    int numdv = 0;
    while ((dvec = gi.MoveNext(level.pathingMap, pos, crouchingState))
            != ROUTING_UNREACHABLE) {
        const int oldZ = pos[2];
        /* dvec indicates the direction traveled to get to the new cell and the original cell height. */
        /* We are going backwards to the origin. */
        PosSubDV(pos, crouchingState, dvec);
        /* Replace the z portion of the DV value so we can get back to where we were. */
        dvtab[numdv++] = setDVz(dvec, oldZ);
        if (numdv >= size)
            break;
    }

    return numdv;
}
示例#2
0
/**
* @brief Return the needed TUs to walk to a given position
* @param ent Edict to calculate move length for
* @param path Pointer to pathing table
* @param to Position to walk to
* @param stored Use the stored mask (the cached move) of the routing data
* @return ROUTING_NOT_REACHABLE if the move isn't possible, length of move otherwise (TUs)
*/
byte G_ActorMoveLength (const edict_t *ent, const pathing_t *path, const pos3_t to, bool stored)
{
	byte crouchingState = G_IsCrouched(ent) ? 1 : 0;
	const int length = gi.MoveLength(path, to, crouchingState, stored);
	int dvec, numSteps = 0;
	pos3_t pos;

	if (!length || length == ROUTING_NOT_REACHABLE)
		return length;

	VectorCopy(to, pos);
	while ((dvec = gi.MoveNext(level.pathingMap, pos, crouchingState)) != ROUTING_UNREACHABLE) {
		++numSteps;
		PosSubDV(pos, crouchingState, dvec); /* We are going backwards to the origin. */
	}

	return std::min(ROUTING_NOT_REACHABLE, length + static_cast<int>(numSteps *
			G_ActorGetInjuryPenalty(ent, MODIFIER_MOVEMENT)));
}