Skip to content

Commit

Permalink
Stop monsters from being able to step into the lower part of solid pu…
Browse files Browse the repository at this point in the history
…shers (fixing bug from content-overridees feature).
  • Loading branch information
Shpoike committed Mar 6, 2021
1 parent 4dd8762 commit 963bc2e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion quakespasm/Quake/sv_phys.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ void SV_PushMove (edict_t *pusher, float movetime)
// see if the ent's bbox is inside the pusher's final position
if (pusher->v.skin < 0)
{ //a more precise check...
if (!SV_ClipMoveToEntity (pusher, check->v.origin, check->v.mins, check->v.maxs, check->v.origin).startsolid)
if (!SV_ClipMoveToEntity (pusher, check->v.origin, check->v.mins, check->v.maxs, check->v.origin, CONTENTMASK_ANYSOLID).startsolid)
continue;
}
else
Expand Down
37 changes: 24 additions & 13 deletions quakespasm/Quake/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ Handles selection or creation of a clipping hull, and offseting (and
eventually rotation) of the end points
==================
*/
trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end)
trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, unsigned int hitcontents)
{
trace_t trace;
vec3_t offset;
Expand Down Expand Up @@ -928,14 +928,24 @@ static void SV_ClipToLinks ( areanode_t *node, moveclip_t *clip )
continue; // don't clip against owner
}

if ((int)touch->v.flags & FL_MONSTER)
trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end);
if (touch->v.skin < 0)
{
if (!(clip->hitcontents & (1<<-(int)touch->v.skin)))
continue; //not solid, don't bother trying to clip.
if ((int)touch->v.flags & FL_MONSTER)
trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end, ~(1<<-CONTENTS_EMPTY));
else
trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end, ~(1<<-CONTENTS_EMPTY));
if (trace.contents != CONTENTS_EMPTY)
trace.contents = touch->v.skin;
}
else
trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end);
if (trace.contents == CONTENTS_SOLID && touch->v.skin < 0)
trace.contents = touch->v.skin;
if (!((1<<(-trace.contents)) & clip->hitcontents))
continue;
{
if ((int)touch->v.flags & FL_MONSTER)
trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end, clip->hitcontents);
else
trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end, clip->hitcontents);
}

if (trace.allsolid || trace.startsolid ||
trace.fraction < clip->trace.fraction)
Expand Down Expand Up @@ -1154,19 +1164,20 @@ trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, e

memset ( &clip, 0, sizeof ( moveclip_t ) );

if (type & MOVE_HITALLCONTENTS)
clip.hitcontents = ~0u;
else
clip.hitcontents = CONTENTMASK_ANYSOLID;

// clip to world
clip.trace = SV_ClipMoveToEntity ( qcvm->edicts, start, mins, maxs, end );
clip.trace = SV_ClipMoveToEntity ( qcvm->edicts, start, mins, maxs, end, clip.hitcontents );

clip.start = start;
clip.end = end;
clip.mins = mins;
clip.maxs = maxs;
clip.type = type&3;
clip.passedict = passedict;
if (type & MOVE_HITALLCONTENTS)
clip.hitcontents = ~0u;
else
clip.hitcontents = (1<<(-CONTENTS_SOLID)) | (1<<(-CONTENTS_CLIP));

if (type == MOVE_MISSILE)
{
Expand Down
4 changes: 3 additions & 1 deletion quakespasm/Quake/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ int SV_TruePointContents (vec3_t p);

edict_t *SV_TestEntityPosition (edict_t *ent);

trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
#define CONTENTMASK(c) (1u<<(-CONTENTS_##c))
#define CONTENTMASK_ANYSOLID (CONTENTMASK(SOLID) | CONTENTMASK(CLIP))
trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, unsigned int hitcontents);
trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, edict_t *passedict);
// mins and maxs are reletive

Expand Down

0 comments on commit 963bc2e

Please sign in to comment.