diff --git a/src/blan/b_soc.h b/src/blan/b_soc.h index 9fb62cc68..0c8604e75 100644 --- a/src/blan/b_soc.h +++ b/src/blan/b_soc.h @@ -19,6 +19,8 @@ extern "C" { boolean B_UseWallTransfer(void); boolean B_UseTerrainDef(void); +boolean B_TrackComplexity(void); +fixed_t K_TrackModifierMax(void); #ifdef __cplusplus } // extern "C" diff --git a/src/blan/internal/b_soc.c b/src/blan/internal/b_soc.c index 86bbbf37f..7adc65450 100644 --- a/src/blan/internal/b_soc.c +++ b/src/blan/internal/b_soc.c @@ -47,3 +47,28 @@ boolean B_UseTerrainDef(void) return value; } + +// Give each map a custom track complexity +INT32 B_TrackComplexity(void) +{ + const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; + const INT32 defaultvalue = atoi(cv_kartbot_basetrackcomplexity.defaultvalue); + const INT32 mapvalue = mapheader->base_track_complexity; + + if (cv_kartbot_basetrackcomplexity.value != defaultvalue || mapvalue == INT32_MAX) + return cv_kartbot_basetrackcomplexity.value; + + return mapvalue; +} + +fixed_t K_TrackModifierMax(void) +{ + const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; + const fixed_t defaultvalue = FloatToFixed(atof(cv_kartbot_modifiermax.defaultvalue)); + const fixed_t mapvalue = mapheader->track_modifier_max; + + if (cv_kartbot_modifiermax.value != defaultvalue || mapvalue == INT32_MAX) + return cv_kartbot_modifiermax.value; + + return mapvalue; +} diff --git a/src/deh_soc.c b/src/deh_soc.c index c37e77778..6ca47041c 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1416,6 +1416,10 @@ void readlevelheader(MYFILE *f, char * name) mapheaderinfo[num]->encorepal = (UINT16)i; else if (fastcmp(word, "NUMLAPS")) mapheaderinfo[num]->numlaps = (UINT8)i; + else if (fastcmp(word, "BASETRACKCOMPLEXITY")) + mapheaderinfo[num]->base_track_complexity = i; + else if (fastcmp(word, "TRACKMODIFIERMAX")) + mapheaderinfo[num]->track_modifier_max = FloatToFixed(atof(word2)); else if (fastcmp(word, "LAPSPERSECTION")) mapheaderinfo[num]->lapspersection = max((UINT8)i, 1u); else if (fastcmp(word, "UNLOCKABLE")) diff --git a/src/doomstat.h b/src/doomstat.h index 707135c26..1d2e0d785 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -443,6 +443,8 @@ struct mapheader_t // BlanKart boolean use_walltransfer; ///< Whether to use RR style wall transfering or not boolean use_terrain; ///< Whether to use gameplay affecting Terrain effects or not (leaves visuals alone) + INT32 base_track_complexity; ///< Decides what the base track compexity for the current map is. + fixed_t track_modifier_max; ///< Decides what the modifier max for the current map is. }; diff --git a/src/k_bot.cpp b/src/k_bot.cpp index e7feb6792..8f568205f 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -41,6 +41,7 @@ #include "discord.h" // DRPC_UpdatePresence #endif #include "i_net.h" // doomcom +#include "blan/b_soc.h" consvar_t cv_forcebots = CVAR_INIT ("kartforcebots", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL); consvar_t cv_botcontrol = CVAR_INIT ("kartbotcontrol", "On", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL); @@ -510,7 +511,7 @@ const botcontroller_t *K_GetBotController(mobj_t *mobj) fixed_t K_BotMapModifier(void) { constexpr INT32 complexity_scale = 10000; - fixed_t modifier_max = cv_kartbot_modifiermax.value; + fixed_t modifier_max = K_TrackModifierMax(); if (K_CanChangeRules() == false) { diff --git a/src/k_waypoint.cpp b/src/k_waypoint.cpp index d8d605e5c..83a0096f9 100644 --- a/src/k_waypoint.cpp +++ b/src/k_waypoint.cpp @@ -21,6 +21,7 @@ #include "g_game.h" #include "p_slopes.h" #include "k_kart.h" +#include "blan/b_soc.h" #include "cxxutil.hpp" @@ -45,7 +46,8 @@ static waypoint_t *startingwaypoint = NULL; static UINT32 circuitlength = 0U; -#define BASE_TRACK_COMPLEXITY (cv_kartbot_basetrackcomplexity.value) // Arbritrary, vibes-based value +// Defaults to arbritrary, vibes-based value other wise uses maps specified value instead. +#define BASE_TRACK_COMPLEXITY (B_TrackComplexity()) static INT32 trackcomplexity = 0; static size_t numwaypoints = 0U; diff --git a/src/p_setup.c b/src/p_setup.c index 7c9532122..127891d12 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -432,6 +432,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 num) mapheaderinfo[num]->palette = UINT16_MAX; mapheaderinfo[num]->encorepal = UINT16_MAX; mapheaderinfo[num]->numlaps = NUMLAPS_DEFAULT; + mapheaderinfo[num]->base_track_complexity = INT32_MAX; + mapheaderinfo[num]->track_modifier_max = INT32_MAX; mapheaderinfo[num]->lapspersection = 1; mapheaderinfo[num]->unlockrequired = -1; mapheaderinfo[num]->levelselect = 0;