mirror of
https://github.com/UberGames/ioef.git
synced 2024-11-24 05:01:40 +00:00
Adds Z checking to CanDamage function.
This commit is contained in:
parent
ac621642ac
commit
2147f2b7c2
1 changed files with 65 additions and 19 deletions
|
@ -1060,47 +1060,93 @@ qboolean CanDamage (gentity_t *targ, vec3_t origin) {
|
||||||
vec3_t dest;
|
vec3_t dest;
|
||||||
trace_t tr;
|
trace_t tr;
|
||||||
vec3_t midpoint;
|
vec3_t midpoint;
|
||||||
|
vec3_t offsetmins = {-15, -15, -15};
|
||||||
|
vec3_t offsetmaxs = {15, 15, 15};
|
||||||
|
|
||||||
// use the midpoint of the bounds instead of the origin, because
|
// use the midpoint of the bounds instead of the origin, because
|
||||||
// bmodels may have their origin is 0,0,0
|
// bmodels may have their origin is 0,0,0
|
||||||
VectorAdd (targ->r.absmin, targ->r.absmax, midpoint);
|
VectorAdd (targ->r.absmin, targ->r.absmax, midpoint);
|
||||||
VectorScale (midpoint, 0.5, midpoint);
|
VectorScale (midpoint, 0.5, midpoint);
|
||||||
|
|
||||||
VectorCopy (midpoint, dest);
|
VectorCopy(midpoint, dest);
|
||||||
trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
if (tr.fraction == 1.0 || tr.entityNum == targ->s.number)
|
if (tr.fraction == 1.0 || tr.entityNum == targ->s.number)
|
||||||
return qtrue;
|
return qtrue;
|
||||||
|
|
||||||
// this should probably check in the plane of projection,
|
// this should probably check in the plane of projection,
|
||||||
// rather than in world coordinate, and also include Z
|
// rather than in world coordinate
|
||||||
VectorCopy (midpoint, dest);
|
VectorCopy(midpoint, dest);
|
||||||
dest[0] += 15.0;
|
dest[0] += offsetmaxs[0];
|
||||||
dest[1] += 15.0;
|
dest[1] += offsetmaxs[1];
|
||||||
trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
dest[2] += offsetmaxs[2];
|
||||||
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
if (tr.fraction == 1.0)
|
if (tr.fraction == 1.0)
|
||||||
return qtrue;
|
return qtrue;
|
||||||
|
|
||||||
VectorCopy (midpoint, dest);
|
VectorCopy(midpoint, dest);
|
||||||
dest[0] += 15.0;
|
dest[0] += offsetmaxs[0];
|
||||||
dest[1] -= 15.0;
|
dest[1] += offsetmins[1];
|
||||||
trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
dest[2] += offsetmaxs[2];
|
||||||
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
if (tr.fraction == 1.0)
|
if (tr.fraction == 1.0)
|
||||||
return qtrue;
|
return qtrue;
|
||||||
|
|
||||||
VectorCopy (midpoint, dest);
|
VectorCopy(midpoint, dest);
|
||||||
dest[0] -= 15.0;
|
dest[0] += offsetmins[0];
|
||||||
dest[1] += 15.0;
|
dest[1] += offsetmaxs[1];
|
||||||
trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
dest[2] += offsetmaxs[2];
|
||||||
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
if (tr.fraction == 1.0)
|
if (tr.fraction == 1.0)
|
||||||
return qtrue;
|
return qtrue;
|
||||||
|
|
||||||
VectorCopy (midpoint, dest);
|
VectorCopy(midpoint, dest);
|
||||||
dest[0] -= 15.0;
|
dest[0] += offsetmins[0];
|
||||||
dest[1] -= 15.0;
|
dest[1] += offsetmins[1];
|
||||||
trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
dest[2] += offsetmaxs[2];
|
||||||
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
if (tr.fraction == 1.0)
|
if (tr.fraction == 1.0)
|
||||||
return qtrue;
|
return qtrue;
|
||||||
|
|
||||||
|
VectorCopy(midpoint, dest);
|
||||||
|
dest[0] += offsetmaxs[0];
|
||||||
|
dest[1] += offsetmaxs[1];
|
||||||
|
dest[2] += offsetmins[2];
|
||||||
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
|
if (tr.fraction == 1.0)
|
||||||
|
return qtrue;
|
||||||
|
|
||||||
|
VectorCopy(midpoint, dest);
|
||||||
|
dest[0] += offsetmaxs[0];
|
||||||
|
dest[1] += offsetmins[1];
|
||||||
|
dest[2] += offsetmins[2];
|
||||||
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
|
if (tr.fraction == 1.0)
|
||||||
|
return qtrue;
|
||||||
|
|
||||||
|
VectorCopy(midpoint, dest);
|
||||||
|
dest[0] += offsetmins[0];
|
||||||
|
dest[1] += offsetmaxs[1];
|
||||||
|
dest[2] += offsetmins[2];
|
||||||
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
|
if (tr.fraction == 1.0)
|
||||||
|
return qtrue;
|
||||||
|
|
||||||
|
VectorCopy(midpoint, dest);
|
||||||
|
dest[0] += offsetmins[0];
|
||||||
|
dest[1] += offsetmins[2];
|
||||||
|
dest[2] += offsetmins[2];
|
||||||
|
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||||
|
|
||||||
|
if (tr.fraction == 1.0)
|
||||||
|
return qtrue;
|
||||||
|
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue