diff --git a/specs/udmf_zdoom.txt b/specs/udmf_zdoom.txt index 4fc57f856..a6d8acb5d 100644 --- a/specs/udmf_zdoom.txt +++ b/specs/udmf_zdoom.txt @@ -204,6 +204,8 @@ Note: All fields default to false unless mentioned otherwise. // Parameter is the conversation ID, 0 meaning none. countsecret = ; // Picking up this actor counts as a secret. arg0str = ; // Alternate string-based version of arg0 + gravity = ; // Set per-actor gravity. Positive values are multiplied with the class's property, + // negative values are used as their absolute. Default = 1.0. * Note about arg0str diff --git a/src/doomdata.h b/src/doomdata.h index eeff13e2e..46af9d6a4 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -342,6 +342,7 @@ struct FMapThing int special; int args[5]; int Conversation; + fixed_t gravity; void Serialize (FArchive &); }; diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 417343f21..f2fd7b0bf 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -698,6 +698,7 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, mapthings[count].SkillFilter = 0xffff; mapthings[count].flags = MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH; mapthings[count].special = 0; + mapthings[count].gravity = FRACUNIT; if (xsprites != NULL && sprites[i].lotag == 710) { // Blood ambient sound diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 3b11ec415..14607a682 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4712,6 +4712,10 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) mobj->SpawnPoint[2] = mthing->z; mobj->SpawnAngle = mthing->angle; mobj->SpawnFlags = mthing->flags; + if (mthing->gravity < 0) mobj->gravity = -mthing->gravity; + else if (mthing->gravity > 0) mobj->gravity = FixedMul(mobj->gravity, mthing->gravity); + else mobj->flags &= ~MF_NOGRAVITY; + P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); if (!(mobj->flags2 & MF2_ARGSDEFINED)) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 2535641a5..784e6946f 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1750,6 +1750,7 @@ void P_LoadThings (MapData * map) memset (&mti[i], 0, sizeof(mti[i])); + mti[i].gravity = FRACUNIT; mti[i].Conversation = 0; mti[i].SkillFilter = MakeSkill(flags); mti[i].ClassFilter = 0xffff; // Doom map format doesn't have class flags so spawn for all player classes @@ -1825,6 +1826,7 @@ void P_LoadThings2 (MapData * map) mti[i].ClassFilter = (mti[i].flags & MTF_CLASS_MASK) >> MTF_CLASS_SHIFT; mti[i].flags &= ~(MTF_SKILLMASK|MTF_CLASS_MASK); mti[i].Conversation = 0; + mti[i].gravity = FRACUNIT; } delete[] mtp; } diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 91e4c8565..6d935ba63 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -475,6 +475,7 @@ public: FString arg0str, arg1str; memset(th, 0, sizeof(*th)); + th->gravity = FRACUNIT; sc.MustGetToken('{'); while (!sc.CheckToken('}')) { @@ -515,6 +516,11 @@ public: th->special = CheckInt(key); break; + case NAME_Gravity: + CHECK_N(Zd | Zdt) + th->gravity = CheckFixed(key); + break; + case NAME_Arg0: case NAME_Arg1: case NAME_Arg2: