Skip to content

Commit

Permalink
Doom|Heretic: Added "game-monsters-floatoverblocking" (default: 0)
Browse files Browse the repository at this point in the history
A new compatibility option that allows floating monsters to attempt floating
over things that come in their way. As a side-effect, also prevents the floating
monsters from getting stuck in an object when descending during
MF_SKULLFLY.

Todo for later: Investigate why MF_SKULLFLY allows monsters to end up
in invalid positions.
  • Loading branch information
skyjake committed Apr 19, 2012
1 parent 4d34505 commit 1ec0264
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 12 deletions.
5 changes: 5 additions & 0 deletions doomsday/engine/data/cphelp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1182,9 +1182,14 @@ desc = 1=Default to fullscreen.
[vid-bpp]
desc = Default color depth (bits per pixel), 16 or 32.


#
# CONSOLE VARIABLES: libcommon
# @todo Move these to a 'commonhelp.txt' under plugins/common/data.
#

[game-pause-focuslost]
desc = Pause the game when game window loses focus.

[game-monsters-floatoverblocking]
desc = 1=Allow floating monsters to attempt floating over blocking things (avoids getting stuck).
11 changes: 11 additions & 0 deletions doomsday/plugins/common/src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,17 @@ int PIT_CheckThing(mobj_t* thing, void* data)
return false;
}
}
else if(!tmThing->player && solid)
{
// A non-player object is contacting a solid object.
if(cfg.allowMonsterFloatOverBlocking && (tmThing->flags & MF_FLOAT))
{
float top = thing->pos[VZ] + thing->height;
tmThing->onMobj = thing;
tmFloorZ = MAX_OF(tmFloorZ, top);
return false;
}
}
#endif

return solid;
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/include/d_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ typedef struct jdoom_config_s {
float hudTimer; // Number of seconds until the hud/statusbar auto-hides.
byte hudUnHide[NUMHUDUNHIDEEVENTS]; // when the hud/statusbar unhides.
byte moveCheckZ; // if true, mobjs can move over/under each other.
byte allowMonsterFloatOverBlocking; // if true, floating mobjs are allowed to climb over mobjs blocking the way.
byte weaponAutoSwitch;
byte noWeaponAutoSwitchIfFiring;
byte ammoAutoSwitch;
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/src/d_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ cvartemplate_t gameCVars[] = {
{"game-player-wallrun-northonly", 0, CVT_BYTE, &cfg.wallRunNorthOnly, 0, 1},
{"game-objects-falloff", 0, CVT_BYTE, &cfg.fallOff, 0, 1},
{"game-zclip", 0, CVT_BYTE, &cfg.moveCheckZ, 0, 1},
{"game-monsters-floatoverblocking", 0, CVT_BYTE, &cfg.allowMonsterFloatOverBlocking, 0, 1},
{"game-corpse-sliding", 0, CVT_BYTE, &cfg.slidingCorpses, 0, 1},

// Game state
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom64/include/d_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ typedef struct jdoom64_config_s {
float hudTimer; // Number of seconds until the hud auto-hides.
byte hudUnHide[NUMHUDUNHIDEEVENTS]; // When the hud unhides.
byte moveCheckZ; // If true, mobjs can move over/under each other.
byte allowMonsterFloatOverBlocking; // if true, floating mobjs are allowed to climb over mobjs blocking the way.
byte weaponAutoSwitch;
byte noWeaponAutoSwitchIfFiring;
byte weaponCycleSequential; // if true multiple next/prev weapon impulses can be chained to allow the user to "count-click-switch".
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom64/src/d_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ cvartemplate_t gameCVars[] = {
{"game-objects-falloff", 0, CVT_BYTE, &cfg.fallOff, 0, 1},
{"game-zclip", 0, CVT_BYTE, &cfg.moveCheckZ, 0, 1},
{"game-corpse-sliding", 0, CVT_BYTE, &cfg.slidingCorpses, 0, 1},
{"game-monsters-floatoverblocking", 0, CVT_BYTE, &cfg.allowMonsterFloatOverBlocking, 0, 1},

// Game state
{"game-fastmonsters", 0, CVT_BYTE, &fastParm, 0, 1},
Expand Down
6 changes: 1 addition & 5 deletions doomsday/plugins/jheretic/include/h_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ typedef struct jheretic_config_s {
float hudTimer; // Number of seconds until the hud/statusbar auto-hides.
byte hudUnHide[NUMHUDUNHIDEEVENTS]; // when the hud/statusbar unhides.
byte moveCheckZ; // if true, mobjs can move over/under each other.
byte allowMonsterFloatOverBlocking; // if true, floating mobjs are allowed to climb over mobjs blocking the way.
byte weaponAutoSwitch;
byte noWeaponAutoSwitchIfFiring;
byte ammoAutoSwitch;
Expand All @@ -138,11 +139,6 @@ typedef struct jheretic_config_s {
byte noTeamDamage;
byte respawnMonstersNightmare;






float statusbarScale;
float statusbarOpacity;
float statusbarCounterAlpha;
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jheretic/src/h_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ cvartemplate_t gameCVars[] = {
{"game-player-wallrun-northonly", 0, CVT_BYTE, &cfg.wallRunNorthOnly, 0, 1},
{"game-objects-falloff", 0, CVT_BYTE, &cfg.fallOff, 0, 1},
{"game-zclip", 0, CVT_BYTE, &cfg.moveCheckZ, 0, 1},
{"game-monsters-floatoverblocking", 0, CVT_BYTE, &cfg.allowMonsterFloatOverBlocking, 0, 1},
{"game-corpse-sliding", 0, CVT_BYTE, &cfg.slidingCorpses, 0, 1},
{"server-game-maulotaur-fixfloorfire", 0, CVT_BYTE, &cfg.fixFloorFire, 0, 1},
{"server-game-plane-fixmaterialscroll", 0, CVT_BYTE, &cfg.fixPlaneScrollMaterialsEastOnly, 0, 1},
Expand Down
41 changes: 34 additions & 7 deletions doomsday/plugins/jheretic/src/p_mobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ void P_MobjMoveXY(mobj_t* mo)
if(FEQUAL(mom[MX], 0) && FEQUAL(mom[MY], 0))
{
if(mo->flags & MF_SKULLFLY)
{ // A flying mobj slammed into something.
{
// A flying mobj slammed into something.
mo->flags &= ~MF_SKULLFLY;
mo->mom[MX] = mo->mom[MY] = mo->mom[MZ] = 0;
P_MobjChangeState(mo, P_GetState(mo->type, SN_SEE));
Expand Down Expand Up @@ -492,15 +493,17 @@ void P_MobjMoveZ(mobj_t *mo)
// Float down towards target if too close.
if(!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT))
{
float oldZ = mo->pos[VZ];

dist = P_ApproxDistance(mo->pos[VX] - mo->target->pos[VX],
mo->pos[VY] - mo->target->pos[VY]);

delta = (mo->target->pos[VZ] + mo->target->height /2) -
(mo->pos[VZ] + mo->height /2);
delta = (mo->target->pos[VZ] + mo->target->height / 2) - (mo->pos[VZ] + mo->height / 2);

if(dist < mo->radius + mo->target->radius &&
fabs(delta) < mo->height + mo->target->height)
{ // Don't go INTO the target.
fabs(delta) < mo->height + mo->target->height)
{
// Don't go INTO the target.
delta = 0;
}

Expand All @@ -513,6 +516,31 @@ void P_MobjMoveZ(mobj_t *mo)
{
mo->pos[VZ] += FLOATSPEED;
P_MobjSetSRVOZ(mo, FLOATSPEED);
}
if(delta)
{
// Where did we end up?
if(!P_CheckPosition3fv(mo, mo->pos))
{
// Not a valid position; undo the move.
mo->pos[VZ] = oldZ;
P_MobjSetSRVOZ(mo, 0);
}
}
}
}

if(cfg.allowMonsterFloatOverBlocking && (mo->flags & MF_FLOAT) && !mo->player && !(mo->flags & MF_SKULLFLY))
{
if(!P_CheckPosition3fv(mo, mo->pos))
{
#ifdef _DEBUG
Con_Message("Floating thing %i has gotten stuck! onmobj=%i z=%f flz=%f tmfz=%f\n",
mo->thinker.id, mo->onMobj? mo->onMobj->thinker.id : 0, mo->pos[VZ], mo->floorZ, tmFloorZ);
#endif
if(mo->pos[VZ] < tmFloorZ)
{
mo->pos[VZ] = mo->floorZ = tmFloorZ;
}
}
}
Expand Down Expand Up @@ -827,8 +855,7 @@ void P_MobjThinker(mobj_t *mobj)
P_UpdateHealthBits(mobj);

// Handle X and Y momentums.
if(!FEQUAL(mobj->mom[MX], 0) || !FEQUAL(mobj->mom[MY], 0) ||
(mobj->flags & MF_SKULLFLY))
if(!FEQUAL(mobj->mom[MX], 0) || !FEQUAL(mobj->mom[MY], 0) || (mobj->flags & MF_SKULLFLY))
{
P_MobjMoveXY(mobj);

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jhexen/include/x_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ typedef struct {
byte weaponAutoSwitch;
byte noWeaponAutoSwitchIfFiring;
byte ammoAutoSwitch;
byte allowMonsterFloatOverBlocking; // if true, floating mobjs are allowed to climb over mobjs blocking the way.
byte weaponCycleSequential; // if true multiple next/prev weapon impulses can be chained to allow the user to "count-click-switch".
int weaponOrder[NUM_WEAPON_TYPES];
byte weaponNextMode; // if true use the weaponOrder for next/previous.
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jhexen/src/hconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ cvartemplate_t gameCVars[] = {

// Compatibility options
{"game-icecorpse", 0, CVT_INT, &cfg.translucentIceCorpse, 0, 1},
//{"game-monsters-floatoverblocking", 0, CVT_BYTE, &cfg.allowMonsterFloatOverBlocking, 0, 1},

// Game state
{"game-fastmonsters", 0, CVT_BYTE, &cfg.fastMonsters, 0, 1},
Expand Down

0 comments on commit 1ec0264

Please sign in to comment.