Bot library for Lua (botvars getter/setter, bot functions)
Summary
This branch exposes botvars_t
, botcontroller_t
and bot functions to Lua. It changes the following:
- Exposes the following variables:
-
botvars_t
as part ofplayer_t
(asbotvars
, get/noset):- get/set:
style
,difficulty
,diffincrease
,rival
,rubberband
,itemdelay
,itemconfirm
,turnconfirm
,spindashconfirm
,respawnconfirm
,roulettepriority
,roulettetimeout
- get:
valid
- get/set:
-
botcontroller_t
as part ofsector_t
(asbotcontroller
, get/noset):- get:
valid
,trick
,flags
,forceangle
- get:
-
- Exposes the following constants:
-
k_bot.h
constants:MAXBOTDIFFICULTY
,DIFFICULTBOT
,BOTTURNCONFIRM
,BOTSPINDASHCONFIRM
,BOTRESPAWNCONFIRM
andBOT_ITEM_DECISION_TIME
-
botStyle_e
:BOT_STYLE_NORMAL
,BOT_STYLE_STAY
andBOT_STYLE__MAX
-
botItemPriority_e
:BOT_ITEM_PR__FALLBACK
,BOT_ITEM_PR_NEUTRAL
,BOT_ITEM_PR_FRONTRUNNER
,BOT_ITEM_PR_SPEED
,BOT_ITEM_PR__OVERRIDES
,BOT_ITEM_PR_RINGDEBT
,BOT_ITEM_PR_POWER
,BOT_ITEM_PR_SPB
andBOT_ITEM_PR__MAX
-
textmapbotcontroller_t
:TMBOT_NORUBBERBAND
,TMBOT_NOCONTROL
,TMBOT_FORCEDIR
andTMBOT_FASTFALL
-
textmapbottrick_t
:TMBOTTR_NONE
,TMBOTTR_LEFT
,TMBOTTR_RIGHT
,TMBOTTR_UP
andTMBOTTR_DOWN
-
- Exposes the following functions:
boolean K_PlayerUsesBotMovement(player_t player)
boolean K_BotCanTakeCut(player_t player)
botcontroller_t K_GetBotController(mobj_t mobj)
fixed_t K_BotMapModifier()
fixed_t K_BotRubberband(player_t player)
fixed_t K_UpdateRubberband(player_t player)
fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy)
-
boolean, player_t K_AddBot(int/string skin, int difficulty, botStyle_e style)
(boolean indicates whether the bot was created successfully. If true, the second returned value will be the bot player_t, otherwise it is nil). void K_SetNameForBot(player_t player, string name)
- Creates the following Lua-only function:
void K_RemoveBot(player_t player)
- Creates the following hooks:
-
"PlayerUsesBotMovement"
:function(player_t player)
. Controls whether the given player will be using bot movement or not.return true
for forced bot movement,return false
to force remove bot movement. The podium sequence's bot movement cannot be overriden.player
is read-only. -
"BotJoin"
:function(player_t player)
. Triggers when a bot joins the game (GP, Match Race, Lua...), as well as when a bot gets replaced during GP.
-
- Fixes
botvars.style
not being part ofG_PlayerReborn
, as well as not being archived and unarchived before.
Testing
Testing environment: ringracers_botVarsLib.exe -console -skipintro -warp RR_TESTRUN +addfile botvars.lua
A script was used, botvars.lua, to test the following additions:
- It will print all exposed constants as described above.
- It includes a HUD hook that displays the values of all the
botvars_t
values, and if in a sector with a bot controller, then all of the applicablebotcontroller_t
values (fromK_GetBotController
), as well as the values fromK_PlayerUsesBotMovement
,K_BotCanTakeCut
,K_BotRubberband
andK_UpdateRubberband
. Can by controlled by thebotvarshuddebug
cvar. - It has a
MapLoad
that prints the complexity of the level usingK_BotMapModifier
- It has a command
addbot [skin] [difficulty] [style] [customname]
that allows to create a bot with the specified parameters, withcustomname
as an optional parameter. - It has a command
removebot [node]
that removes a bot by node. - It has a command
changebotname [node] [name]
to change a bot's name. - It has a command
lethargicplay
that enables bot movement on the toggling player. - It has a command
setbotvalue [node] [variable] [value]
to set a specific value on a bot's botvars variables. - It has a command
setallbotsvalue [variable] [value]
to set a value to a variable in all bots' botvars. - It has a console variable
v1finish
that disables bot movement on all players at the end of a race. (Note: it's likely just better to set the bot style toBOT_STYLE_STAY
here - this is just a demonstration of the "PlayerUsesBotMovement" hook).
Changelog
- Exposed the
botvars
member fromplayer_t
, as well as various functions related to bots. - Exposed the
botcontroller
member fromsector_t
(as well as being used as part ofK_GetBotController(mobj_t mobj)
) - Created new hook:
PlayerUsesBotMovement
:function(player_t player)
. Return true to force bot movement, return false to force disable bot movement. - Created new hook:
BotJoin
:function(player_t player)
. Triggers when a bot joins the game or gets replaced in Grand Prix. - Fixed a bot's style not being preserved between deaths, as well as not being saved before for netgames.
Edited by JugadorXEI