mirror of
https://github.com/UberGames/ioef.git
synced 2024-11-27 22:42:09 +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,6 +1060,8 @@ qboolean CanDamage (gentity_t *targ, vec3_t origin) {
|
|||
vec3_t dest;
|
||||
trace_t tr;
|
||||
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
|
||||
// bmodels may have their origin is 0,0,0
|
||||
|
@ -1068,39 +1070,83 @@ qboolean CanDamage (gentity_t *targ, vec3_t origin) {
|
|||
|
||||
VectorCopy(midpoint, dest);
|
||||
trap_Trace(&tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
|
||||
|
||||
if (tr.fraction == 1.0 || tr.entityNum == targ->s.number)
|
||||
return qtrue;
|
||||
|
||||
// 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);
|
||||
dest[0] += 15.0;
|
||||
dest[1] += 15.0;
|
||||
dest[0] += offsetmaxs[0];
|
||||
dest[1] += offsetmaxs[1];
|
||||
dest[2] += offsetmaxs[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] += 15.0;
|
||||
dest[1] -= 15.0;
|
||||
dest[0] += offsetmaxs[0];
|
||||
dest[1] += offsetmins[1];
|
||||
dest[2] += offsetmaxs[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] -= 15.0;
|
||||
dest[1] += 15.0;
|
||||
dest[0] += offsetmins[0];
|
||||
dest[1] += offsetmaxs[1];
|
||||
dest[2] += offsetmaxs[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] -= 15.0;
|
||||
dest[1] -= 15.0;
|
||||
dest[0] += offsetmins[0];
|
||||
dest[1] += offsetmins[1];
|
||||
dest[2] += offsetmaxs[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] += 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue