mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Expose K_ScaleItemDistance and K_ItemOddsScale to Lua
This commit is contained in:
parent
501c85a7b1
commit
bf278f4fcc
3 changed files with 55 additions and 19 deletions
|
|
@ -399,17 +399,9 @@ botItemPriority_e K_GetBotItemPriority(kartitems_t result)
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
static fixed_t K_ItemOddsScale(UINT8 playerCount)
|
static fixed_t K_ItemOddsScale(UINT8 playerCount)
|
||||||
|
|
||||||
A multiplier for odds and distances to scale
|
See header file for description.
|
||||||
them with the player count.
|
|
||||||
|
|
||||||
Input Arguments:-
|
|
||||||
playerCount - Number of players in the game.
|
|
||||||
|
|
||||||
Return:-
|
|
||||||
Fixed point number, to multiply odds or
|
|
||||||
distances by.
|
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
static fixed_t K_ItemOddsScale(UINT8 playerCount)
|
fixed_t K_ItemOddsScale(UINT8 playerCount)
|
||||||
{
|
{
|
||||||
const UINT8 basePlayer = 8; // The player count we design most of the game around.
|
const UINT8 basePlayer = 8; // The player count we design most of the game around.
|
||||||
fixed_t playerScaling = 0;
|
fixed_t playerScaling = 0;
|
||||||
|
|
@ -462,7 +454,7 @@ static UINT32 K_UndoMapScaling(UINT32 distance)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
static UINT32 K_ScaleItemDistance(UINT32 distance, UINT8 numPlayers)
|
UINT32 K_ScaleItemDistance(UINT32 distance, UINT8 numPlayers)
|
||||||
|
|
||||||
Adjust item distance for lobby-size scaling
|
Adjust item distance for lobby-size scaling
|
||||||
as well as Frantic Items.
|
as well as Frantic Items.
|
||||||
|
|
@ -475,10 +467,8 @@ static UINT32 K_UndoMapScaling(UINT32 distance)
|
||||||
Return:-
|
Return:-
|
||||||
New distance after scaling.
|
New distance after scaling.
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
static UINT32 K_ScaleItemDistance(const player_t *player, UINT32 distance, UINT8 numPlayers)
|
UINT32 K_ScaleItemDistance(INT32 distance, UINT8 numPlayers)
|
||||||
{
|
{
|
||||||
(void)player;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (franticitems == true)
|
if (franticitems == true)
|
||||||
{
|
{
|
||||||
|
|
@ -493,9 +483,6 @@ static UINT32 K_ScaleItemDistance(const player_t *player, UINT32 distance, UINT8
|
||||||
FRACUNIT + (K_ItemOddsScale(numPlayers) / 2)
|
FRACUNIT + (K_ItemOddsScale(numPlayers) / 2)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Distance is reduced based on the player's gradingfactor
|
|
||||||
// distance = FixedMul(distance, player->gradingfactor);
|
|
||||||
|
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -554,7 +541,7 @@ UINT32 K_GetItemRouletteDistance(const player_t *player, UINT8 numPlayers)
|
||||||
}
|
}
|
||||||
|
|
||||||
pdis = K_UndoMapScaling(pdis);
|
pdis = K_UndoMapScaling(pdis);
|
||||||
pdis = K_ScaleItemDistance(player, pdis, numPlayers);
|
pdis = K_ScaleItemDistance(pdis, numPlayers);
|
||||||
|
|
||||||
if (player->bot && (player->botvars.rival || cv_levelskull.value))
|
if (player->bot && (player->botvars.rival || cv_levelskull.value))
|
||||||
{
|
{
|
||||||
|
|
@ -830,7 +817,7 @@ static void K_InitRoulette(itemroulette_t *const roulette)
|
||||||
&& roulette->secondDist > roulette->firstDist)
|
&& roulette->secondDist > roulette->firstDist)
|
||||||
{
|
{
|
||||||
roulette->secondToFirst = roulette->secondDist - roulette->firstDist;
|
roulette->secondToFirst = roulette->secondDist - roulette->firstDist;
|
||||||
roulette->secondToFirst = K_ScaleItemDistance(&players[i], roulette->secondToFirst, 16 - roulette->playing); // Reversed scaling
|
roulette->secondToFirst = K_ScaleItemDistance(roulette->secondToFirst, 16 - roulette->playing); // Reversed scaling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,38 @@ boolean K_ItemSingularity(kartitems_t item);
|
||||||
|
|
||||||
botItemPriority_e K_GetBotItemPriority(kartitems_t result);
|
botItemPriority_e K_GetBotItemPriority(kartitems_t result);
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
fixed_t K_ItemOddsScale(UINT8 playerCount)
|
||||||
|
|
||||||
|
A multiplier for odds and distances to scale
|
||||||
|
them with the player count.
|
||||||
|
|
||||||
|
Input Arguments:-
|
||||||
|
playerCount - Number of players in the game.
|
||||||
|
|
||||||
|
Return:-
|
||||||
|
Fixed point number, to multiply odds or
|
||||||
|
distances by.
|
||||||
|
--------------------------------------------------*/
|
||||||
|
|
||||||
|
fixed_t K_ItemOddsScale(UINT8 playerCount);
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
UINT32 K_ScaleItemDistance(UINT32 distance, UINT8 numPlayers)
|
||||||
|
|
||||||
|
Adjust item distance for lobby-size scaling
|
||||||
|
as well as Frantic Items.
|
||||||
|
|
||||||
|
Input Arguments:-
|
||||||
|
distance - Original distance.
|
||||||
|
numPlayers - Number of players in the game.
|
||||||
|
|
||||||
|
Return:-
|
||||||
|
New distance after scaling.
|
||||||
|
--------------------------------------------------*/
|
||||||
|
|
||||||
|
UINT32 K_ScaleItemDistance(INT32 distance, UINT8 numPlayers);
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
void K_PushToRouletteItemList(itemroulette_t *const roulette, INT32 item)
|
void K_PushToRouletteItemList(itemroulette_t *const roulette, INT32 item)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4411,6 +4411,21 @@ static int lib_kCalculateRouletteSpeed(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lib_kScaleItemDistance(lua_State *L)
|
||||||
|
{
|
||||||
|
UINT32 distance = luaL_checkinteger(L, 1);
|
||||||
|
UINT8 numPlayers = luaL_checkinteger(L, 2);
|
||||||
|
lua_pushfixed(L, K_ScaleItemDistance(distance, numPlayers));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lib_kItemOddsScale(lua_State *L)
|
||||||
|
{
|
||||||
|
UINT8 playerCount = luaL_checkinteger(L, 1);
|
||||||
|
lua_pushfixed(L, K_ItemOddsScale(playerCount));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int lib_kWipeItemsInReel(lua_State *L)
|
static int lib_kWipeItemsInReel(lua_State *L)
|
||||||
{
|
{
|
||||||
player_t *player = NULL;
|
player_t *player = NULL;
|
||||||
|
|
@ -4864,6 +4879,8 @@ static luaL_Reg lib[] = {
|
||||||
{"K_GetRouletteOffset", lib_kGetRouletteOffset},
|
{"K_GetRouletteOffset", lib_kGetRouletteOffset},
|
||||||
{"K_GetSlotOffset", lib_kGetSlotOffset},
|
{"K_GetSlotOffset", lib_kGetSlotOffset},
|
||||||
{"K_CalculateRouletteSpeed", lib_kCalculateRouletteSpeed},
|
{"K_CalculateRouletteSpeed", lib_kCalculateRouletteSpeed},
|
||||||
|
{"K_ScaleItemDistance", lib_kScaleItemDistance},
|
||||||
|
{"K_ItemOddsScale", lib_kItemOddsScale},
|
||||||
// These are not real functions in k_roulette, but they allow
|
// These are not real functions in k_roulette, but they allow
|
||||||
// encapsulation on how the scripter interacts with the item reel.
|
// encapsulation on how the scripter interacts with the item reel.
|
||||||
{"K_WipeItemsInReel", lib_kWipeItemsInReel},
|
{"K_WipeItemsInReel", lib_kWipeItemsInReel},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue