Refactor odds and move them to their own file

* Race odds now use 16 tiers and are intended to be balanced around 16 players
* DISTVAR has been increased to 2048 to match the new tier capacity
* Race odds now use a max-75 scale, with the x4 multiplier in calcs being used only in a battle odds context
This commit is contained in:
Anonimus 2025-09-10 15:58:11 -04:00
parent 5082c343c8
commit a8dc5774e2
13 changed files with 1685 additions and 1501 deletions

View file

@ -128,6 +128,7 @@ k_bot.cpp
k_botitem.cpp
k_botsearch.cpp
k_cluster.cpp
k_odds.cpp
k_grandprix.c
k_boss.c
k_hud.c

View file

@ -89,8 +89,8 @@
#define ASSET_HASH_TEXTURES_KART 0xb4211b2f32b6a291
#define ASSET_HASH_CHARS_KART 0x1e68a3e01aa5c68b
#define ASSET_HASH_MAPS_KART 0x38558ed00da41ce9
#define ASSET_HASH_MAIN_PK3 0xd9cf115699dc58c4
#define ASSET_HASH_MAPPATCH_PK3 0xf1c7678ded3a2d1b
#define ASSET_HASH_MAIN_PK3 0xb706e22cf2696294
#define ASSET_HASH_MAPPATCH_PK3 0x01ca675676c950a1
#define ASSET_HASH_BONUSCHARS_KART 0x60e6f13d822a7461
#ifdef USE_PATCH_FILE
#define ASSET_HASH_PATCH_PK3 0x0000000000000000

View file

@ -29,6 +29,7 @@
#include "m_random.h"
#include "r_things.h" // numskins
#include "m_easing.h"
#include "k_odds.hpp"
// Looks for players around the bot, and presses the item button
// if there is one in range.

View file

@ -7,6 +7,7 @@
#include "doomtype.h"
#include "p_mobj.h"
#include "k_kart.h"
#include "k_odds.hpp"
#include "p_local.h"
#include "s_sound.h"
#include "r_main.h" // R_PointToAngle2, R_PointToDist2

View file

@ -17,6 +17,7 @@
#include "k_boss.h"
#include "k_color.h"
#include "k_director.h"
#include "k_odds.hpp"
#include "p_mobj.h"
#include "screen.h"
#include "doomtype.h"

File diff suppressed because it is too large Load diff

View file

@ -68,9 +68,6 @@ extern boolean clusterplayer[MAXPLAYERS];
extern UINT32 clusterid; // ID of the "cluster player", the one closest to the cluster point.
extern vector3_t clusterpoint, clusterdtf;
// :)
#define MAXODDS 8
// Bubble Shield's maximum health
#define MAXBUBBLEHEALTH 6
@ -189,19 +186,6 @@ UINT32 K_GetPlayerDontDrawFlag(player_t *player);
boolean K_IsPlayerLosing(player_t *player);
fixed_t K_GetKartGameSpeedScalar(SINT8 value);
extern consvar_t *KartItemCVars[NUMKARTRESULTS-1];
UINT8 K_FindUseodds(const player_t *player, fixed_t mashed, UINT32 pdis, UINT8 bestbumper, boolean spbrush);
INT32 K_FindLegacyUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT32 bestbumper, boolean spbrush, boolean dontforcespb);
fixed_t K_ItemOddsScale(UINT8 numPlayers, boolean spbrush);
UINT32 K_ScaleItemDistance(UINT32 distance, UINT8 numPlayers, boolean spbrush);
INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, UINT32 ourDist, UINT32 clusterDist, fixed_t mashed, boolean spbrush, boolean bot, boolean rival);
INT32 K_KartGetLegacyItemOdds(UINT8 pos, SINT8 item, fixed_t clusterDist, fixed_t mashed, boolean spbrush);
INT32 K_GetRollingRouletteItem(player_t *player);
INT32 K_GetShieldFromPlayer(player_t *player);
INT32 K_GetShieldFromItem(INT32 item);
SINT8 K_ItemResultToType(SINT8 getitem);
UINT8 K_ItemResultToAmount(SINT8 getitem);
fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against);
boolean K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid);
void K_KartPainEnergyFling(player_t *player);

1623
src/k_odds.cpp Normal file

File diff suppressed because it is too large Load diff

50
src/k_odds.hpp Normal file
View file

@ -0,0 +1,50 @@
// BLANKART
//-----------------------------------------------------------------------------
// Copyright (C) 2018-2025 by Kart Krew.
// Copyright (C) 2025 by "Anonimus".
// Copyright (C) 2025 Blankart Team.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file k_odds.hpp
/// \brief Kart item odds systems.
#ifndef __K_ODDS__
#define __K_ODDS__
#include "command.h" // Need for player_t
#include "doomdef.h"
#include "doomtype.h"
#include "d_player.h" // Need for player_t
#include "d_ticcmd.h"
#include "m_fixed.h"
#ifdef __cplusplus
extern "C" {
#endif
// Max odds count
#define MAXODDS 16
extern consvar_t *KartItemCVars[NUMKARTRESULTS-1];
UINT8 K_FindUseodds(const player_t *player, fixed_t mashed, UINT32 pdis, UINT8 bestbumper, boolean spbrush);
INT32 K_FindLegacyUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT32 bestbumper, boolean spbrush, boolean dontforcespb);
fixed_t K_ItemOddsScale(UINT8 numPlayers, boolean spbrush);
UINT32 K_ScaleItemDistance(UINT32 distance, UINT8 numPlayers, boolean spbrush);
INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, UINT32 ourDist, UINT32 clusterDist, fixed_t mashed, boolean spbrush, boolean bot, boolean rival);
INT32 K_KartGetLegacyItemOdds(UINT8 pos, SINT8 item, fixed_t clusterDist, fixed_t mashed, boolean spbrush);
INT32 K_GetRollingRouletteItem(player_t *player);
INT32 K_GetShieldFromPlayer(player_t *player);
INT32 K_GetShieldFromItem(INT32 item);
SINT8 K_ItemResultToType(SINT8 getitem);
UINT8 K_ItemResultToAmount(SINT8 getitem);
void K_KartItemRoulette(player_t *player, ticcmd_t *cmd);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __K_ODDS__

View file

@ -66,7 +66,8 @@
#include "st_stuff.h"
#include "i_sound.h"
#include "k_hud.h" // SRB2kart
#include "k_kart.h" // KartItemCVars
#include "k_kart.h"
#include "k_odds.hpp" // KartItemCVars
#include "k_pwrlv.h"
#include "k_stats.h" // SRB2kart
#include "d_player.h" // KITEM_ constants

View file

@ -39,6 +39,7 @@
#include "k_boss.h"
#include "p_spec.h"
#include "k_objects.h"
#include "k_odds.hpp"
#include "acs/interface.h"
// CTF player names

View file

@ -50,6 +50,7 @@
#include "k_terrain.h"
#include "k_collide.h"
#include "k_objects.h"
#include "k_odds.hpp"
// BlanKart
#include "blan/b_soc.h"

View file

@ -61,6 +61,7 @@
#include "k_terrain.h" // K_SpawnSplashForMobj
#include "k_color.h"
#include "k_follower.h"
#include "k_odds.hpp"
#include "g_party.h"
#include "acs/interface.h"