mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-10 04:27:10 +03:00
Added badPlaceTeam
This commit is contained in:
parent
64a3b04181
commit
dc1be17b2a
2 changed files with 103 additions and 106 deletions
|
@ -492,6 +492,10 @@ void PathNode::ArchiveStatic(Archiver& arc)
|
||||||
|
|
||||||
if (arc.Loading()) {
|
if (arc.Loading()) {
|
||||||
Child[i].numBlockers = 0;
|
Child[i].numBlockers = 0;
|
||||||
|
|
||||||
|
for (int j = 0; j < ARRAY_LEN(Child[i].badPlaceTeam); j++) {
|
||||||
|
Child[i].badPlaceTeam[j] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1086,6 +1090,7 @@ PathNode *PathSearch::DebugNearestStartNode(float *pos, Entity *ent)
|
||||||
vec3_t deltas[128];
|
vec3_t deltas[128];
|
||||||
vec3_t start;
|
vec3_t start;
|
||||||
vec3_t end;
|
vec3_t end;
|
||||||
|
int node_count;
|
||||||
|
|
||||||
cell = GetNodesInCell(pos);
|
cell = GetNodesInCell(pos);
|
||||||
|
|
||||||
|
@ -1093,7 +1098,7 @@ PathNode *PathSearch::DebugNearestStartNode(float *pos, Entity *ent)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int node_count = NearestNodeSetup(pos, cell, nodes, deltas);
|
node_count = NearestNodeSetup(pos, cell, nodes, deltas);
|
||||||
|
|
||||||
if (!node_count) {
|
if (!node_count) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1108,13 +1113,16 @@ PathNode *PathSearch::DebugNearestStartNode(float *pos, Entity *ent)
|
||||||
VectorCopy(start, end);
|
VectorCopy(start, end);
|
||||||
VectorAdd(end, deltas[nodes[i]], end);
|
VectorAdd(end, deltas[nodes[i]], end);
|
||||||
|
|
||||||
Vector vStart = start;
|
|
||||||
Vector vMins = Vector(-15, -15, 0);
|
|
||||||
Vector vMaxs = Vector(15, 15, 62);
|
|
||||||
Vector vEnd = end;
|
|
||||||
|
|
||||||
if (G_SightTrace(
|
if (G_SightTrace(
|
||||||
vStart, vMins, vMaxs, vEnd, ent, NULL, MASK_TARGETPATH, qtrue, "PathSearch::DebugNearestStartNode"
|
start,
|
||||||
|
Vector(-15, -15, 0),
|
||||||
|
Vector(15, 15, 62),
|
||||||
|
end,
|
||||||
|
ent,
|
||||||
|
NULL,
|
||||||
|
MASK_TARGETPATH,
|
||||||
|
qtrue,
|
||||||
|
"PathSearch::DebugNearestStartNode"
|
||||||
)) {
|
)) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -1132,6 +1140,7 @@ PathNode *PathSearch::NearestStartNode(float *pos, SimpleActor *ent)
|
||||||
vec3_t deltas[128];
|
vec3_t deltas[128];
|
||||||
vec3_t start;
|
vec3_t start;
|
||||||
vec3_t end;
|
vec3_t end;
|
||||||
|
int node_count;
|
||||||
|
|
||||||
cell = GetNodesInCell(pos);
|
cell = GetNodesInCell(pos);
|
||||||
|
|
||||||
|
@ -1139,60 +1148,54 @@ PathNode *PathSearch::NearestStartNode(float *pos, SimpleActor *ent)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int node_count = NearestNodeSetup(pos, cell, nodes, deltas);
|
node_count = NearestNodeSetup(pos, cell, nodes, deltas);
|
||||||
int n = 0;
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
VectorCopy(pos, start);
|
VectorCopy(pos, start);
|
||||||
start[2] += 32.0f;
|
start[2] += 32.0f;
|
||||||
|
|
||||||
Vector vMins = Vector(-15, -15, 0);
|
|
||||||
Vector vMaxs = Vector(15, 15, 62);
|
|
||||||
|
|
||||||
for (i = 0; i < node_count; i++) {
|
for (i = 0; i < node_count; i++) {
|
||||||
node = pathnodes[cell->nodes[nodes[i]]];
|
node = pathnodes[cell->nodes[nodes[i]]];
|
||||||
|
|
||||||
VectorAdd(start, deltas[nodes[i]], end);
|
VectorAdd(start, deltas[nodes[i]], end);
|
||||||
|
|
||||||
Vector vStart = start;
|
|
||||||
Vector vEnd = end;
|
|
||||||
|
|
||||||
if (G_SightTrace(
|
if (G_SightTrace(
|
||||||
vStart,
|
start,
|
||||||
vMins,
|
Vector(-15, -15, 0),
|
||||||
vMaxs,
|
Vector(15, 15, 62),
|
||||||
vEnd,
|
end,
|
||||||
(gentity_t *)NULL,
|
ent,
|
||||||
(gentity_t *)NULL,
|
NULL,
|
||||||
1107437825, //FIXME: macro
|
MASK_PATHSOLID,
|
||||||
qtrue,
|
qtrue,
|
||||||
"PathSearch::NearestStartNode 1"
|
"PathSearch::NearestStartNode 1"
|
||||||
)) {
|
)) {
|
||||||
ent->m_NearestNode = node;
|
ent->m_NearestNode = node;
|
||||||
ent->m_vNearestNodePos = end;
|
VectorCopy(end, ent->m_vNearestNodePos);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ent->m_NearestNode
|
if (ent->m_NearestNode) {
|
||||||
&& (G_SightTrace(
|
if (G_SightTrace(
|
||||||
Vector(start),
|
start,
|
||||||
vMins,
|
Vector(-15, -15, 0),
|
||||||
vMaxs,
|
Vector(15, 15, 62),
|
||||||
ent->m_vNearestNodePos,
|
ent->m_vNearestNodePos,
|
||||||
ent->edict,
|
ent,
|
||||||
(gentity_t *)NULL,
|
NULL,
|
||||||
1073883393, //FIXME: macro
|
MASK_TARGETPATH,
|
||||||
qtrue,
|
qtrue,
|
||||||
"PathSearch::NearestStartNode 2"
|
"PathSearch::NearestStartNode 2"
|
||||||
)))
|
)) {
|
||||||
|| node_count <= 0) {
|
return ent->m_NearestNode;
|
||||||
node = ent->m_NearestNode;
|
}
|
||||||
} else {
|
|
||||||
node = pathnodes[cell->nodes[nodes[0]]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
if (node_count <= 0) {
|
||||||
|
return ent->m_NearestNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pathnodes[cell->nodes[nodes[0]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
PathNode *PathSearch::NearestEndNode(float *pos)
|
PathNode *PathSearch::NearestEndNode(float *pos)
|
||||||
|
@ -1204,6 +1207,7 @@ PathNode *PathSearch::NearestEndNode(float *pos)
|
||||||
vec3_t deltas[128];
|
vec3_t deltas[128];
|
||||||
vec3_t start;
|
vec3_t start;
|
||||||
vec3_t end;
|
vec3_t end;
|
||||||
|
int node_count;
|
||||||
|
|
||||||
cell = GetNodesInCell(pos);
|
cell = GetNodesInCell(pos);
|
||||||
|
|
||||||
|
@ -1211,9 +1215,7 @@ PathNode *PathSearch::NearestEndNode(float *pos)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int node_count = NearestNodeSetup(pos, cell, nodes, deltas);
|
node_count = NearestNodeSetup(pos, cell, nodes, deltas);
|
||||||
int n = 0;
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
if (!node_count) {
|
if (!node_count) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1227,18 +1229,13 @@ PathNode *PathSearch::NearestEndNode(float *pos)
|
||||||
|
|
||||||
VectorAdd(start, deltas[nodes[i]], end);
|
VectorAdd(start, deltas[nodes[i]], end);
|
||||||
|
|
||||||
Vector vStart = start;
|
|
||||||
Vector vMins = Vector(-15, -15, 0);
|
|
||||||
Vector vMaxs = Vector(15, 15, 62);
|
|
||||||
Vector vEnd = end;
|
|
||||||
|
|
||||||
if (G_SightTrace(
|
if (G_SightTrace(
|
||||||
vStart,
|
start,
|
||||||
vMins,
|
Vector(-15, -15, 0),
|
||||||
vMaxs,
|
Vector(15, 15, 62),
|
||||||
vEnd,
|
end,
|
||||||
(gentity_t *)NULL,
|
(Entity *)nullptr,
|
||||||
(gentity_t *)NULL,
|
(Entity *)nullptr,
|
||||||
MASK_TARGETPATH,
|
MASK_TARGETPATH,
|
||||||
qtrue,
|
qtrue,
|
||||||
"PathSearch::NearestEndNode"
|
"PathSearch::NearestEndNode"
|
||||||
|
@ -1872,8 +1869,8 @@ void PathSearch::UpdatePathwaysForBadPlace(const Vector& origin, float radius, i
|
||||||
pathway_t& pathway = node->Child[j - 1];
|
pathway_t& pathway = node->Child[j - 1];
|
||||||
if (PointToSegmentDistanceSquared(origin, pathway.pos1, pathway.pos2) < radiusSqr) {
|
if (PointToSegmentDistanceSquared(origin, pathway.pos1, pathway.pos2) < radiusSqr) {
|
||||||
for (k = 0; k < 2; k++) {
|
for (k = 0; k < 2; k++) {
|
||||||
if ((1 << i) & team) {
|
if ((1 << k) & team) {
|
||||||
pathway.numBlockers += dir;
|
pathway.badPlaceTeam[k] += dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2122,10 +2119,10 @@ int PathSearch::FindPath(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
total_dist = 1e+12;
|
total_dist = 1e+12f;
|
||||||
|
|
||||||
if (!maxPath) {
|
if (!maxPath) {
|
||||||
maxPath = 1e+12;
|
maxPath = 1e+12f;
|
||||||
}
|
}
|
||||||
|
|
||||||
findFrame++;
|
findFrame++;
|
||||||
|
@ -2194,8 +2191,7 @@ int PathSearch::FindPath(
|
||||||
|
|
||||||
if (prev) {
|
if (prev) {
|
||||||
prev->NextNode = next;
|
prev->NextNode = next;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
open = next;
|
open = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3038,7 +3034,7 @@ int PathSearch::NearestNodeSetup(vec3_t pos, MapCell *cell, int *nodes, vec3_t *
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->origin[2] > pos[2] + 94.0f) {
|
if (pos[2] + 94.0f < node->origin[2]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ public:
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
byte numBlockers;
|
byte numBlockers;
|
||||||
|
byte badPlaceTeam[2];
|
||||||
short int node;
|
short int node;
|
||||||
short int fallheight;
|
short int fallheight;
|
||||||
float dist;
|
float dist;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue