From 920ea02401de9783433e8bdfe55e2d610109680d Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sun, 5 Apr 2009 10:48:21 +0000 Subject: [PATCH] Der dumme Stalker klebt nun wieder an der Decke --- src/g_local.h | 2 -- src/g_monster.c | 41 ++++++++++++++++++++++++++-------- src/g_phys.c | 10 ++++++++- src/g_spawn.c | 58 ++++++++++++++++++++++++++++++++++++++----------- src/g_utils.c | 6 +++++ src/m_move.c | 44 +++++++++++++++++++++++++++++-------- 6 files changed, 127 insertions(+), 34 deletions(-) diff --git a/src/g_local.h b/src/g_local.h index 2d5c8aa..460ae0f 100644 --- a/src/g_local.h +++ b/src/g_local.h @@ -1371,8 +1371,6 @@ struct edict_s //============= //ROGUE -#define ROGUE_GRAVITY 1 - #define SPHERE_DEFENDER 0x0001 #define SPHERE_HUNTER 0x0002 #define SPHERE_VENGEANCE 0x0004 diff --git a/src/g_monster.c b/src/g_monster.c index 208136e..923d536 100644 --- a/src/g_monster.c +++ b/src/g_monster.c @@ -162,25 +162,38 @@ void M_CheckGround (edict_t *ent) if (ent->flags & (FL_SWIM|FL_FLY)) return; - if (ent->velocity[2] > 100) + if ((ent->velocity[2] * ent->gravityVector[2]) < -100) // PGM { ent->groundentity = NULL; return; } -// if the hull point one-quarter unit down is solid the entity is on ground + // if the hull point one-quarter unit down is solid the entity is on ground point[0] = ent->s.origin[0]; point[1] = ent->s.origin[1]; - point[2] = ent->s.origin[2] - 0.25; + point[2] = ent->s.origin[2] + (0.25 * ent->gravityVector[2]); //PGM trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, point, ent, MASK_MONSTERSOLID); // check steepness - if ( trace.plane.normal[2] < 0.7 && !trace.startsolid) + //PGM + if ( ent->gravityVector[2] < 0) // normal gravity { - ent->groundentity = NULL; - return; + if ( trace.plane.normal[2] < 0.7 && !trace.startsolid) + { + ent->groundentity = NULL; + return; + } } + else // inverted gravity + { + if ( trace.plane.normal[2] > -0.7 && !trace.startsolid) + { + ent->groundentity = NULL; + return; + } + } +//PGM if (!trace.startsolid && !trace.allsolid) { @@ -324,9 +337,19 @@ void M_droptofloor (edict_t *ent) vec3_t end; trace_t trace; - ent->s.origin[2] += 1; - VectorCopy (ent->s.origin, end); - end[2] -= 256; + //PGM + if(ent->gravityVector[2] < 0) + { + ent->s.origin[2] += 1; + VectorCopy (ent->s.origin, end); + end[2] -= 256; + } + else + { + ent->s.origin[2] -= 1; + VectorCopy (ent->s.origin, end); + end[2] += 256; + } trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID); diff --git a/src/g_phys.c b/src/g_phys.c index 5cea4cd..df3af25 100644 --- a/src/g_phys.c +++ b/src/g_phys.c @@ -302,7 +302,15 @@ SV_AddGravity */ void SV_AddGravity (edict_t *ent) { - ent->velocity[2] -= ent->gravity * sv_gravity->value * FRAMETIME; + if(ent->gravityVector[2] > 0) + { + VectorMA(ent->velocity, + ent->gravity * sv_gravity->value * FRAMETIME, + ent->gravityVector, + ent->velocity); + } + else + ent->velocity[2] -= ent->gravity * sv_gravity->value * FRAMETIME; } /* diff --git a/src/g_spawn.c b/src/g_spawn.c index 53624ac..8edb180 100644 --- a/src/g_spawn.c +++ b/src/g_spawn.c @@ -347,6 +347,12 @@ void ED_CallSpawn (edict_t *ent) return; } + //PGM - do this before calling the spawn function so it can be overridden. + ent->gravityVector[0] = 0.0; + ent->gravityVector[1] = 0.0; + ent->gravityVector[2] = -1.0; + //PGM + // FIXME - PMM classnames hack if (!strcmp(ent->classname, "weapon_nailgun")) ent->classname = (FindItem("ETF Rifle"))->classname; @@ -757,6 +763,11 @@ void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint) ent->spawnflags &= ~(SPAWNFLAG_NOT_EASY|SPAWNFLAG_NOT_MEDIUM|SPAWNFLAG_NOT_HARD|SPAWNFLAG_NOT_COOP|SPAWNFLAG_NOT_DEATHMATCH); } + //PGM - do this before calling the spawn function so it can be overridden. + ent->gravityVector[0] = 0.0; + ent->gravityVector[1] = 0.0; + ent->gravityVector[2] = -1.0; + //PGM ED_CallSpawn (ent); ent->s.renderfx |= RF_IR_VISIBLE; //PGM @@ -1343,7 +1354,12 @@ qboolean CheckGroundSpawnPoint (vec3_t origin, vec3_t entMins, vec3_t entMaxs, f // first, do the easy flat check - start[2] = mins[2] - 1; + // + // FIXME - this will only handle 0,0,1 and 0,0,-1 gravity vectors + if(gravity > 0) + start[2] = maxs[2] + 1; + else + start[2] = mins[2] - 1; for (x=0 ; x<=1 ; x++) { for (y=0 ; y<=1 ; y++) @@ -1372,8 +1388,18 @@ realcheck: return false; mid = bottom = tr.endpos[2]; - stop[2] = start[2] - 2*STEPSIZE; - mid = bottom = tr.endpos[2] + entMins[2]; + if(gravity < 0) + { + start[2] = mins[2]; + stop[2] = start[2] - STEPSIZE - STEPSIZE; + mid = bottom = tr.endpos[2] + entMins[2]; + } + else + { + start[2] = maxs[2]; + stop[2] = start[2] + STEPSIZE + STEPSIZE; + mid = bottom = tr.endpos[2] - entMaxs[2]; + } for (x=0 ; x<=1 ; x++) for (y=0 ; y<=1 ; y++) @@ -1381,22 +1407,28 @@ realcheck: start[0] = stop[0] = x ? maxs[0] : mins[0]; start[1] = stop[1] = y ? maxs[1] : mins[1]; - /* - gi.WriteByte (svc_temp_entity); - gi.WriteByte (TE_DEBUGTRAIL); - gi.WritePosition (start); - gi.WritePosition (stop); - gi.multicast (start, MULTICAST_ALL); - */ tr = gi.trace (start, vec3_origin, vec3_origin, stop, NULL, MASK_MONSTERSOLID); //PGM - if (tr.fraction != 1.0 && tr.endpos[2] > bottom) - bottom = tr.endpos[2]; - if (tr.fraction == 1.0 || mid - tr.endpos[2] > STEPSIZE) + // FIXME - this will only handle 0,0,1 and 0,0,-1 gravity vectors + if(gravity > 0) + { + if (tr.fraction != 1.0 && tr.endpos[2] < bottom) + bottom = tr.endpos[2]; + if (tr.fraction == 1.0 || tr.endpos[2] - mid > STEPSIZE) { return false; } + } + else + { + if (tr.fraction != 1.0 && tr.endpos[2] > bottom) + bottom = tr.endpos[2]; + if (tr.fraction == 1.0 || mid - tr.endpos[2] > STEPSIZE) + { + return false; + } + } } return true; // we can land on it, it's ok diff --git a/src/g_utils.c b/src/g_utils.c index 77f75f6..dce3b9b 100644 --- a/src/g_utils.c +++ b/src/g_utils.c @@ -525,6 +525,12 @@ void G_InitEdict (edict_t *e) e->classname = "noclass"; e->gravity = 1.0; e->s.number = e - g_edicts; + + //PGM - do this before calling the spawn function so it can be overridden. + e->gravityVector[0] = 0.0; + e->gravityVector[1] = 0.0; + e->gravityVector[2] = -1.0; + //PGM } /* diff --git a/src/m_move.c b/src/m_move.c index d04823f..e3b683b 100644 --- a/src/m_move.c +++ b/src/m_move.c @@ -34,7 +34,10 @@ qboolean M_CheckBottom (edict_t *ent) // the corners must be within 16 of the midpoint //PGM + // FIXME - this will only handle 0,0,1 and 0,0,-1 gravity vectors start[2] = mins[2] - 1; + if(ent->gravityVector[2] > 0) + start[2] = maxs[2] + 1; //PGM for (x=0 ; x<=1 ; x++) @@ -61,7 +64,16 @@ realcheck: start[1] = stop[1] = (mins[1] + maxs[1])*0.5; //PGM - stop[2] = start[2] - 2*STEPSIZE; + if(ent->gravityVector[2] < 0) + { + start[2] = mins[2]; + stop[2] = start[2] - STEPSIZE - STEPSIZE; + } + else + { + start[2] = maxs[2]; + stop[2] = start[2] + STEPSIZE + STEPSIZE; + } //PGM trace = gi.trace (start, vec3_origin, vec3_origin, stop, ent, MASK_MONSTERSOLID); @@ -80,10 +92,21 @@ realcheck: trace = gi.trace (start, vec3_origin, vec3_origin, stop, ent, MASK_MONSTERSOLID); //PGM - if (trace.fraction != 1.0 && trace.endpos[2] > bottom) - bottom = trace.endpos[2]; - if (trace.fraction == 1.0 || mid - trace.endpos[2] > STEPSIZE) - return false; + // FIXME - this will only handle 0,0,1 and 0,0,-1 gravity vectors + if(ent->gravityVector[2] > 0) + { + if (trace.fraction != 1.0 && trace.endpos[2] < bottom) + bottom = trace.endpos[2]; + if (trace.fraction == 1.0 || trace.endpos[2] - mid > STEPSIZE) + return false; + } + else + { + if (trace.fraction != 1.0 && trace.endpos[2] > bottom) + bottom = trace.endpos[2]; + if (trace.fraction == 1.0 || mid - trace.endpos[2] > STEPSIZE) + return false; + } //PGM } @@ -291,9 +314,9 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) stepsize = 1; //PGM - neworg[2] += stepsize; - VectorCopy (neworg, end); - end[2] -= stepsize*2; + // trace from 1 stepsize gravityUp to 2 stepsize gravityDown. + VectorMA(neworg, -1 * stepsize, ent->gravityVector, neworg); + VectorMA(neworg, 2 * stepsize, ent->gravityVector, end); //PGM trace = gi.trace (neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID); @@ -316,7 +339,10 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink) //PGM test[0] = trace.endpos[0]; test[1] = trace.endpos[1]; - test[2] = trace.endpos[2] + ent->mins[2] + 1; + if(ent->gravityVector[2] > 0) + test[2] = trace.endpos[2] + ent->maxs[2] - 1; + else + test[2] = trace.endpos[2] + ent->mins[2] + 1; //PGM contents = gi.pointcontents(test);