/** * @brief Spawn a singleplayer 2x2 unit. */ static void G_Actor2x2Spawn (edict_t *ent) { /* set properties */ level.num_2x2spawnpoints[ent->team]++; ent->classname = "ugv"; ent->type = ET_ACTOR2x2SPAWN; ent->fieldSize = ACTOR_SIZE_2x2; /* Fall to ground */ if (ent->pos[2] >= PATHFINDING_HEIGHT) ent->pos[2] = PATHFINDING_HEIGHT - 1; ent->pos[2] = gi.GridFall(gi.routingMap, ent->fieldSize, ent->pos); if (ent->pos[2] >= PATHFINDING_HEIGHT) gi.DPrintf("G_Actor2x2Spawn: Warning: z level is out of bounds: %i\n", ent->pos[2]); G_EdictCalcOrigin(ent); /* link it for collision detection */ ent->dir = AngleToDir(ent->angle); assert(ent->dir < CORE_DIRECTIONS); ent->solid = SOLID_BBOX; /* Set bounding box. Maybe this is already set in one of the spawn functions? */ if (ent->maxs[0] == 0) VectorSet(ent->maxs, PLAYER2x2_WIDTH, PLAYER2x2_WIDTH, PLAYER_STAND); if (ent->mins[0] == 0) VectorSet(ent->mins, -PLAYER2x2_WIDTH, -PLAYER2x2_WIDTH, PLAYER_MIN); }
/** * @brief Spawn a singleplayer 2x2 unit. */ static void G_Actor2x2Spawn (Edict* ent) { /* set properties */ level.num_2x2spawnpoints[ent->team]++; ent->classname = "ugv"; ent->type = ET_ACTOR2x2SPAWN; ent->fieldSize = ACTOR_SIZE_2x2; /* Spawning has already calculated the pos from the origin ( = center of the cell). Perfect for normal size actors. * For 2x2 actors, the origin(of the info_ box) is in the middle of the four cells. Using VecToPos on that origin * results in the upper right cell being the pos of the actor. But we want the lower left cell to be the pos of the * 2x2 actor because routing and pathfinding rely on that. So compensate for that. */ ent->pos[0]--; ent->pos[1]--; /* Fall to ground */ if (ent->pos[2] >= PATHFINDING_HEIGHT) ent->pos[2] = PATHFINDING_HEIGHT - 1; ent->pos[2] = gi.GridFall(ent->fieldSize, ent->pos); if (ent->pos[2] >= PATHFINDING_HEIGHT) gi.DPrintf("G_Actor2x2Spawn: Warning: z level is out of bounds: %i\n", ent->pos[2]); G_EdictCalcOrigin(ent); /* link it for collision detection */ ent->dir = AngleToDir(ent->angle); assert(ent->dir < CORE_DIRECTIONS); ent->solid = SOLID_BBOX; /* Set bounding box. Maybe this is already set in one of the spawn functions? */ if (ent->maxs[0] == 0) VectorSet(ent->maxs, PLAYER2x2_WIDTH, PLAYER2x2_WIDTH, PLAYER_STAND); if (ent->mins[0] == 0) VectorSet(ent->mins, -PLAYER2x2_WIDTH, -PLAYER2x2_WIDTH, PLAYER_MIN); }
static byte G_GetImpactDirection(const Edict* const target, const vec3_t impact) { vec3_t vec1, vec2; VectorSubtract(impact, target->origin, vec1); vec1[2] = 0; VectorNormalize(vec1); VectorCopy(dvecs[target->dir], vec2); VectorNormalize(vec2); return AngleToDir(VectorAngleBetween(vec2, vec1) * todeg); }
void G_InitCamera (Edict* ent, camera_type_t cameraType, float angle, bool rotate) { switch (cameraType) { CAMERAMODEL(CAMERA_MOBILE, 0); CAMERAMODEL(CAMERA_STATIONARY, 1); default: gi.DPrintf("unknown camera type given: %i\n", cameraType); G_FreeEdict(ent); return; } AABB modelAabb; if (gi.LoadModelAABB(ent->model, 0, modelAabb)) { ent->entBox.set(modelAabb); ent->camera.cameraType = cameraType; ent->camera.rotate = rotate; ent->classname = "misc_camera"; ent->type = ET_CAMERA; ent->solid = SOLID_BBOX; ent->flags |= FL_DESTROYABLE; ent->material = MAT_ELECTRICAL; ent->fieldSize = ACTOR_SIZE_NORMAL; ent->destroy = Destroy_Camera; ent->use = G_CameraUse; ent->dir = AngleToDir(angle); /* Set the position of the entity */ VecToPos(ent->origin, ent->pos); gi.LinkEdict(ent); } else { gi.DPrintf("Could not get bounding box for model '%s'\n", ent->model); G_FreeEdict(ent); } }
//================================================================================================= Direction GetLocationDir(const Vec2& from, const Vec2& to) { return AngleToDir(Vec2::LookAtAngle(from, to)); }