mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-22 02:00:11 +00:00
Expose K_GetItemRouletteDistance, K_FindUseodds and K_CreateAndShuffleItemReel to Lua
This commit is contained in:
parent
4694430292
commit
5a62e902a0
3 changed files with 64 additions and 9 deletions
|
|
@ -502,15 +502,7 @@ static UINT32 K_ScaleItemDistance(const player_t *player, UINT32 distance, UINT8
|
|||
/*--------------------------------------------------
|
||||
static UINT32 K_GetItemRouletteDistance(const player_t *player, UINT8 numPlayers)
|
||||
|
||||
Gets a player's distance used for the item
|
||||
roulette, including all scaling factors.
|
||||
|
||||
Input Arguments:-
|
||||
player - The player to get the distance of.
|
||||
numPlayers - Number of players in the game.
|
||||
|
||||
Return:-
|
||||
The player's finalized item distance.
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
UINT32 K_GetItemRouletteDistance(const player_t *player, UINT8 numPlayers)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -278,8 +278,38 @@ void K_KartItemRoulette(player_t *const player, ticcmd_t *cmd);
|
|||
|
||||
void K_KartGetItemResult(player_t *const player, kartitems_t getitem);
|
||||
|
||||
/*--------------------------------------------------
|
||||
static UINT32 K_GetItemRouletteDistance(const player_t *player, UINT8 numPlayers)
|
||||
|
||||
Gets a player's distance used for the item
|
||||
roulette, including all scaling factors.
|
||||
|
||||
Input Arguments:-
|
||||
player - The player to get the distance of.
|
||||
numPlayers - Number of players in the game.
|
||||
|
||||
Return:-
|
||||
The player's finalized item distance.
|
||||
--------------------------------------------------*/
|
||||
|
||||
UINT32 K_GetItemRouletteDistance(const player_t *player, UINT8 numPlayers);
|
||||
|
||||
/*--------------------------------------------------
|
||||
static UINT8 K_FindUseodds(const player_t *player, itemroulette_t *const roulette)
|
||||
|
||||
Gets which item bracket the player is in.
|
||||
This can be adjusted depending on which
|
||||
items being turned off.
|
||||
|
||||
Input Arguments:-
|
||||
player - The player the roulette is for.
|
||||
roulette - The item roulette data.
|
||||
|
||||
Return:-
|
||||
The item bracket the player is in, as an
|
||||
index to the array.
|
||||
--------------------------------------------------*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4320,6 +4320,36 @@ static int lib_kKartGetItemResult(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lib_kGetItemRouletteDistance(lua_State *L)
|
||||
{
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
UINT8 numPlayers = luaL_checkinteger(L, 2);
|
||||
INLEVEL
|
||||
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
|
||||
lua_pushinteger(L, K_GetItemRouletteDistance(player, numPlayers));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kCreateAndShuffleItemReel(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
itemroulette_t *itemRoulette = NULL;
|
||||
|
||||
getItemRouletteOrPlayerBasedOnFirstParam(L, &player, &itemRoulette);
|
||||
boolean freeplay = lua_optboolean(L, 2);
|
||||
|
||||
NOHUD
|
||||
INLEVEL
|
||||
if (!player && !itemRoulette)
|
||||
return LUA_ErrInvalid(L, "player_t/itemroulette_t");
|
||||
|
||||
K_CreateAndShuffleItemReel(player, itemRoulette, freeplay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lib_getTimeMicros(lua_State *L)
|
||||
{
|
||||
lua_pushinteger(L, I_GetPreciseTime() / (I_GetPrecisePrecision() / 1000000));
|
||||
|
|
@ -4622,6 +4652,9 @@ static luaL_Reg lib[] = {
|
|||
{"K_StartEggmanRoulette", lib_kStartEggmanRoulette},
|
||||
{"K_StopRoulette", lib_kStopRoulette},
|
||||
{"K_KartGetItemResult", lib_kKartGetItemResult},
|
||||
{"K_GetItemRouletteDistance", lib_kGetItemRouletteDistance},
|
||||
{"K_FindUseodds", lib_kFindUseodds},
|
||||
{"K_CreateAndShuffleItemReel", lib_kCreateAndShuffleItemReel},
|
||||
|
||||
// hu_stuff technically?
|
||||
{"HU_DoTitlecardCEcho", lib_startTitlecardCecho},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue