From db1f584c135b1526dac0a42676a1e6118739748c Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 16 Dec 2017 15:38:15 -0500 Subject: [PATCH] MobjScale setting for map headers Replacement for Oldbrak mode, lets you set any scale instead of only 1/2, also modified some of Kart's scale shenanigans to be compatible. Requested by Sev for Dimension Heist --- src/dehacked.c | 22 +++++++++++++++++----- src/doomstat.h | 13 +++++++------ src/k_kart.c | 16 ++++++++-------- src/lua_maplib.c | 4 ++++ src/p_mobj.c | 15 ++++++--------- src/p_setup.c | 5 +++++ 6 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 0372df6d..f829090a 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -990,13 +990,13 @@ static const struct { {"2D",TOL_2D}, {"MARIO",TOL_MARIO}, {"NIGHTS",TOL_NIGHTS}, - {"OLDBRAK",TOL_ERZ3}, + //{"OLDBRAK",TOL_ERZ3}, {"XMAS",TOL_XMAS}, {"CHRISTMAS",TOL_XMAS}, {"WINTER",TOL_XMAS}, - {"KART",TOL_KART}, // SRB2kart + //{"KART",TOL_KART}, // SRB2kart {NULL, 0} }; @@ -1253,9 +1253,20 @@ static void readlevelheader(MYFILE *f, INT32 num) } else if (fastcmp(word, "LEVELFLAGS")) - mapheaderinfo[num-1]->levelflags = (UINT8)i; + mapheaderinfo[num-1]->levelflags = get_number(word2); else if (fastcmp(word, "MENUFLAGS")) - mapheaderinfo[num-1]->menuflags = (UINT8)i; + mapheaderinfo[num-1]->menuflags = get_number(word2); + + // SRB2Kart + /*else if (fastcmp(word, "AUTOMAP")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->automap = true; + else + mapheaderinfo[num-1]->automap = false; + }*/ + else if (fastcmp(word, "MOBJSCALE")) + mapheaderinfo[num-1]->mobj_scale = get_number(word2); // Individual triggers for level flags, for ease of use (and 2.0 compatibility) else if (fastcmp(word, "SCRIPTISFILE")) @@ -7529,8 +7540,9 @@ struct { {"TOL_2D",TOL_2D}, {"TOL_MARIO",TOL_MARIO}, {"TOL_NIGHTS",TOL_NIGHTS}, - {"TOL_ERZ3",TOL_ERZ3}, + //{"TOL_ERZ3",TOL_ERZ3}, {"TOL_XMAS",TOL_XMAS}, + //{"TOL_KART",TOL_KART}, // Level flags {"LF_SCRIPTISFILE",LF_SCRIPTISFILE}, diff --git a/src/doomstat.h b/src/doomstat.h index 11560259..726e3e63 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -246,13 +246,14 @@ typedef struct UINT8 numGradedMares; ///< Internal. For grade support. nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful. + // SRB2kart + //boolean automap; ///< Displays a level's white map outline in modified games + fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 + // Lua stuff. // (This is not ifdeffed so the map header structure can stay identical, just in case.) UINT8 numCustomOptions; ///< Internal. For Lua custom value support. customoption_t *customopts; ///< Custom options. Allocated dynamically for space reasons. Be careful. - - // SRB2kart - boolean automap; ///< Displays a level's white map outline in modified games } mapheader_t; // level flags @@ -290,9 +291,9 @@ enum TypeOfLevel TOL_2D = 0x0100, ///< 2D TOL_MARIO = 0x0200, ///< Mario TOL_NIGHTS = 0x0400, ///< NiGHTS - TOL_ERZ3 = 0x0800, ///< ERZ3 - TOL_XMAS = 0x1000, ///< Christmas NiGHTS - TOL_KART = 0x4000 ///< Kart 32768 + //TOL_ERZ3 = 0x0800, ///< ERZ3 + TOL_XMAS = 0x1000 ///< Christmas NiGHTS + //TOL_KART = 0x4000 ///< Kart 32768 }; // Gametypes diff --git a/src/k_kart.c b/src/k_kart.c index f276b44c..e037caa8 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -308,7 +308,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartcc); CV_RegisterVar(&cv_kartballoons); CV_RegisterVar(&cv_kartfrantic); - CV_RegisterVar(&cv_kartcomeback); + CV_RegisterVar(&cv_kartcomeback); CV_RegisterVar(&cv_kartmirror); CV_RegisterVar(&cv_speedometer); CV_RegisterVar(&cv_collideminimum); @@ -1479,7 +1479,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_growshrinktimer] == 1 || player->kartstuff[k_growshrinktimer] == -1) { - player->mo->destscale = FRACUNIT; + player->mo->destscale = mapheaderinfo[gamemap-1]->mobj_scale; P_RestoreMusic(player); } @@ -3524,21 +3524,21 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->kartstuff[k_growshrinktimer] > ((itemtime + TICRATE*2) - 25)) { if (leveltime & 2) - player->mo->destscale = FRACUNIT*3/2; + player->mo->destscale = (mapheaderinfo[gamemap-1]->mobj_scale)*3/2; else - player->mo->destscale = FRACUNIT; + player->mo->destscale = (mapheaderinfo[gamemap-1]->mobj_scale); } else if (player->kartstuff[k_growshrinktimer] > 26 && player->kartstuff[k_growshrinktimer] <= ((itemtime + TICRATE*2) - 25)) - player->mo->destscale = FRACUNIT*3/2; + player->mo->destscale = (mapheaderinfo[gamemap-1]->mobj_scale)*3/2; // Megashroom - Back to normal... else if (player->kartstuff[k_growshrinktimer] > 1 && player->kartstuff[k_growshrinktimer] <= 26) { if (leveltime & 2) - player->mo->destscale = FRACUNIT; + player->mo->destscale = (mapheaderinfo[gamemap-1]->mobj_scale); else - player->mo->destscale = FRACUNIT*3/2; + player->mo->destscale = (mapheaderinfo[gamemap-1]->mobj_scale)*3/2; } if (player->kartstuff[k_growshrinktimer] == 26) S_StartSound(player->mo, sfx_mario8); @@ -3671,7 +3671,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->kartstuff[k_boostcharge] = 0; // Increase your size while charging your engine. if (leveltime < 150) - player->mo->destscale = FRACUNIT + (player->kartstuff[k_boostcharge]*655); + player->mo->destscale = (mapheaderinfo[gamemap-1]->mobj_scale) + (player->kartstuff[k_boostcharge]*655); // Determine the outcome of your charge. if (leveltime > 140 && player->kartstuff[k_boostcharge]) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 0a455a30..771dd0af 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1235,6 +1235,10 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->levelflags); else if (fastcmp(field,"menuflags")) lua_pushinteger(L, header->menuflags); + /*else if (fastcmp(field,"automap")) + lua_pushboolean(L, header->automap);*/ + else if (fastcmp(field,"mobj_scale")) + lua_pushfixed(L, header->mobj_scale); // TODO add support for reading numGradedMares and grades else { // Read custom vars now diff --git a/src/p_mobj.c b/src/p_mobj.c index 256e3993..98063a02 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6507,7 +6507,7 @@ void P_MobjThinker(mobj_t *mobj) } // Actor's distance from its Target, or Radius. - radius = FixedDiv(7, mobj->target->scale)*FRACUNIT; + radius = 7*mobj->target->scale; // Switch blue flames to red flames if (mobj->target->player && mobj->type == MT_DRIFT @@ -6532,8 +6532,7 @@ void P_MobjThinker(mobj_t *mobj) } // Shrink if the player shrunk too. - if (mobj->target->player) - mobj->scale = mobj->target->scale; + mobj->scale = mobj->target->scale; P_UnsetThingPosition(mobj); { @@ -8466,9 +8465,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->destscale = mobj->scale; mobj->scalespeed = FRACUNIT/12; - // TODO: Make this a special map header - if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) - mobj->destscale = FRACUNIT/2; + if (mapheaderinfo[gamemap-1] && mapheaderinfo[gamemap-1]->mobj_scale != FRACUNIT) //&& !(mobj->type == MT_BLACKEGGMAN) + mobj->destscale = mapheaderinfo[gamemap-1]->mobj_scale; // set subsector and/or block links P_SetThingPosition(mobj); @@ -8737,9 +8735,8 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) mobj->destscale = mobj->scale; mobj->scalespeed = FRACUNIT/12; - // TODO: Make this a special map header - if ((maptol & TOL_ERZ3) && !(mobj->type == MT_BLACKEGGMAN)) - mobj->destscale = FRACUNIT/2; + if (mapheaderinfo[gamemap-1] && mapheaderinfo[gamemap-1]->mobj_scale != FRACUNIT) //&& !(mobj->type == MT_BLACKEGGMAN) + mobj->destscale = mapheaderinfo[gamemap-1]->mobj_scale; // set subsector and/or block links P_SetThingPosition(mobj); diff --git a/src/p_setup.c b/src/p_setup.c index ff256703..39eadd08 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -227,6 +227,11 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->menuflags = 0; // TODO grades support for delfile (pfft yeah right) P_DeleteGrades(num); + // SRB2Kart + //DEH_WriteUndoline("AUTOMAP", va("%d", mapheaderinfo[num]->automap), UNDO_NONE); + //mapheaderinfo[num]->automap = false; + DEH_WriteUndoline("MOBJSCALE", va("%d", mapheaderinfo[num]->mobj_scale), UNDO_NONE); + mapheaderinfo[num]->mobj_scale = FRACUNIT; // an even further impossibility, delfile custom opts support mapheaderinfo[num]->customopts = NULL; mapheaderinfo[num]->numCustomOptions = 0;