Hi Rookie,
No, the script is old news, we've moved far from that script. We actually implemented it into the gamex wrapper and it worked with several people.
I know the players aren't rendered yet, but I also found that part of the rendering had to do with the bspvis, and since Aprop is currently working on the mapping maybe he can implement something with that.
For example in regards to the mapping. This may be unethical to do (I remember we talked about this earlier rookie), because basically it would require implementing the "hint" parameter throughout the map. It has some kind of parameter that blocks vis.
It was tested in a sample map, but it was unethical on stock maps because it would require massive amounts of calculations and would take forever to load and probably cause lag, but I don't know if there was an easier way to do it, aside from the above method I mentioned. Anyway here are some code samples from heiko's wrapper.
Code: Select all
static const char *tracepoints[] = {
"Bip01 Head",
"Bip01 Pelvis",
"Bip01 L UpperArm",
"Bip01 R UpperArm",
"Bip01 L ForeArm",
"Bip01 R ForeArm",
"Bip01 L Foot",
"Bip01 R Foot",
"Bip01 Neck",
"Bip01 Spine",
"Bip01 Spine1",
"Bip01 Spine2",
"Bip01 L Thigh",
"Bip01 R Thigh",
"Bip01 L Hand",
"Bip01 R Hand",
"Bip01 L Calf",
"Bip01 R Calf",
"Bip01 L Clavicle",
"Bip01 R Clavicle",
"Bip01 L Toe0",
"Bip01 R Toe0",
NULL
};
Code: Select all
static qboolean IsEntitySeenByEntity(gentity_t *gEntFrom, gentity_t* gEntTo) {
qboolean seen = qfalse;
//static vec3_t mins = { -10, -10, 0 };
//static vec3_t maxs = { 10, 10, 94 };
static vec3_t mins = { 0, 0, 0 };
static vec3_t maxs = { 0, 0, 0 };
Entity *entFrom = gEntFrom->entity;
Entity *entTo = gEntTo->entity;
int *weaponRef = NULL;
int index = 0;
int count = 2;
int playerCurrent = 0;
int targetCurrent = 0;
vec3_t playerOrigin;
vec3_t playerOriginBak;
vec3_t targetOrigin;
vec3_t targetOriginBak;
vec3_t vecToEnemy;
vec3_t vecView;
//these four are used for the offset point estimation
float oX;
float oY;
float m;
float normSqrt;
//This will be the current point we trace to.
orientation_t oTo;
//This is the viewer's eye.
//orientation_t oFrom;
//mEntityGetTag(gEntFrom->entity, (char *)"eyes bone", &oFrom);
//Now trace the eye position to "well" defined points of the
//we take the vViewPos instead of the eye bone pos, because the view pos is most likely not solid
VectorCopy(((Player *)gEntFrom->entity)->vViewPos, playerOrigin);
//fprintf(stderr, "tracing from eye: %f %f %f\n", playerOrigin[0], playerOrigin[1], playerOrigin[2]);
//trace from the player to the target including movement prediction for both
for (playerCurrent = 0; !seen && playerCurrent < count; playerCurrent++) {
if (gameImport.pointcontents(playerOrigin, 0) != 0) {
fprintf(stderr, "gameImport.pointcontents(playerOrigin, 0): %f\n", gameImport.pointcontents(playerOrigin, 0));
goto newPos;
}
//backup the original value prior to modifying it for the eyes
//VectorCopy(playerOrigin, playerOriginBak);
VectorCopy(gEntFrom->client->ps.viewangles, vecView);
//convert to forward vector
vecView[2] = vecView[0] * M_PI * 2 / 360;
vecView[1] = vecView[1] * M_PI * 2 / 360;
vecView[0] = cos(vecView[2]) * cos(vecView[1]);
vecView[1] = cos(vecView[2]) * sin(vecView[1]);
vecView[2] = 0.0;
//VectorScalarMult(vecView, 30.0, vecToEnemy);
//VectorSub(playerOrigin, vecToEnemy, vecToEnemy);
VectorSub(gEntTo->s.origin, playerOrigin, vecToEnemy);
//VectorSub(gEntTo->s.origin, vecToEnemy, vecToEnemy);
vecToEnemy[2] = 0.0;
VectorNormalize(vecView, vecView);
VectorNormalize(vecToEnemy, vecToEnemy);
//fprintf(stderr, "VectorScalarProduct((%f, %f), (%f, %f)): %f\n", vecToEnemy[0], vecToEnemy[1], vecView[0], vecView[1], VectorScalarProduct(vecToEnemy, vecView));
//behind us, save the trace
if (VectorScalarProduct(vecToEnemy, vecView) < 0.4) {
goto newPos;
}
//skip solid start points
#warning FIXME
if (true || gameImport.pointcontents(playerOrigin, 0) == 0) {
while (!seen && index < MAX_TRACEPOINTS) {
//orient = gameImport.TIKI_OrientationInternal(tiki, gEntTo->client->ps.clientNum, gameImport.Tag_NumForName(tiki, "Bip01 Head"), 1.0);
//orient = gameExportBackup.TIKI_Orientation(gEntTo, index);
//normal bip01 tag
if (tracepoints[index]) {
mEntityGetTag(gEntTo->entity, (char *)tracepoints[index], &oTo);
VectorCopy(oTo.origin, targetOrigin);
}
//some other tracepoints
else {
//Sentient::acitveWeaponList[x] is a SafePtr<Weapon>...
weaponRef = (int *)((SafePtr_s*) &((Sentient *)entTo)->activeWeaponList[0])->ptr;
//try the other 'hand'... this happens on nade secondary fire. i dunno why and how...
if (!weaponRef) {
weaponRef = (int *)((SafePtr_s*) &((Sentient *)entTo)->activeWeaponList[1])->ptr;
}
if (weaponRef) {
mWeaponGetMuzzlePosition(weaponRef, targetOrigin, NULL, NULL, NULL, NULL);
}
}
//backup the exact point
VectorCopy(targetOrigin, targetOriginBak);
//loop over all the possible offsets and calculate the destination origin
for (int curOffset = offsetFirst; !seen && curOffset < offsetLast; curOffset++) {
switch(curOffset) {
//the exact point
case offsetNone:
break;
case offsetLeft:
oX = targetOrigin[0] - playerOrigin[0];
if (oX == 0.0) {
targetOrigin[1] = targetOrigin[1] + ADDITIONAL_TRACE_OFFSET;
break;
}
oY = targetOrigin[1] - playerOrigin[1];
if (oY == 0.0) {
targetOrigin[0] = targetOrigin[0] + ADDITIONAL_TRACE_OFFSET;
break;
}
m = -1.0 / (oY / oX);
normSqrt = sqrt(m * m + 2);
targetOrigin[0] = targetOrigin[0] + (1 / normSqrt) * ADDITIONAL_TRACE_OFFSET;
targetOrigin[1] = targetOrigin[1] + (m / normSqrt) * ADDITIONAL_TRACE_OFFSET;
break;
case offsetRight:
oX = targetOrigin[0] - playerOrigin[0];
if (oX == 0.0) {
targetOrigin[1] = targetOrigin[1] - ADDITIONAL_TRACE_OFFSET;
break;
}
oY = targetOrigin[1] - playerOrigin[1];
if (oY == 0.0) {
targetOrigin[0] = targetOrigin[0] - ADDITIONAL_TRACE_OFFSET;
break;
}
m = -1.0 / (oY / oX);
normSqrt = sqrt(m * m + 2);
targetOrigin[0] = targetOrigin[0] - (1 / normSqrt) * ADDITIONAL_TRACE_OFFSET;
targetOrigin[1] = targetOrigin[1] - (m / normSqrt) * ADDITIONAL_TRACE_OFFSET;
break;
case offsetUp:
targetOrigin[2] += ADDITIONAL_TRACE_OFFSET;
break;
case offsetDown:
targetOrigin[2] -= ADDITIONAL_TRACE_OFFSET;
break;
default:
assert(0);
}
//trace to the calculated position for different movement points
for (targetCurrent = 0; !seen && targetCurrent < count; targetCurrent++) {
//solid endpoints are skipped
if (gameImport.pointcontents(targetOrigin, 0) == 0) {
//fprintf(stderr, "to point: %f %f %f\n", targetOrigin[0], targetOrigin[1], targetOrigin[2]);
seen |= gameImport.SightTrace(playerOrigin, mins, maxs, targetOrigin, 0, 0, CONTENTS_SOLID, qfalse);
//if (seen) {
// fprintf(stderr, "first saw: %s: %f %f %f\n", tracepoints[index], targetOrigin[0], targetOrigin[1], targetOrigin[2]);
//}
}
//if we did not get to the point try to trace points with respect to movement
if (!seen && count > 1) {
if (entTo->velocity[0] != 0.0 || entTo->velocity[1] != 0.0 || entTo->velocity[2] != 0.0) {
//update the position to trace to in nths of frame time
VectorMA(targetOrigin, entTo->velocity, FRAME_TIME / (count - 1), targetOrigin);
}
//if the velocity is 0 there's no sense in tracing further movement points
else {
break;
}
}
}
//restore the exact point
VectorCopy(targetOriginBak, targetOrigin);
}
index++;
}
}
//VectorCopy(playerOriginBak, playerOrigin);
newPos:
if (!seen && count > 1) {
if (entFrom->velocity[0] != 0.0 || entFrom->velocity[1] != 0.0 || entFrom->velocity[2] != 0.0) {
//update the position to trace from in nths of frame time
VectorMA(playerOrigin, entFrom->velocity, FRAME_TIME / (count - 1), playerOrigin);
}
//if the velocity is 0 there's no sense in tracing further movement points
else {
break;
}
}
}
return seen;
}