mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-28 04:51:42 +00:00
Rudimentary item usage code
This commit is contained in:
parent
102aca3ab4
commit
774c85d660
4 changed files with 79 additions and 12 deletions
|
|
@ -347,6 +347,8 @@ typedef enum
|
||||||
k_killfield, // How long have you been in the kill field, stay in too long and lose a bumper
|
k_killfield, // How long have you been in the kill field, stay in too long and lose a bumper
|
||||||
k_wrongway, // Display WRONG WAY on screen
|
k_wrongway, // Display WRONG WAY on screen
|
||||||
|
|
||||||
|
k_botitemdelay,
|
||||||
|
|
||||||
NUMKARTSTUFF
|
NUMKARTSTUFF
|
||||||
} kartstufftype_t;
|
} kartstufftype_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8594,7 +8594,9 @@ static const char *const KARTSTUFF_LIST[] = {
|
||||||
"SPRINGSTARS",
|
"SPRINGSTARS",
|
||||||
"SPRINGCOLOR",
|
"SPRINGCOLOR",
|
||||||
"KILLFIELD",
|
"KILLFIELD",
|
||||||
"WRONGWAY"
|
"WRONGWAY",
|
||||||
|
|
||||||
|
"BOTITEMDELAY"
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
36
src/k_bot.c
36
src/k_bot.c
|
|
@ -21,6 +21,7 @@
|
||||||
#include "d_net.h" // nodetoplayer
|
#include "d_net.h" // nodetoplayer
|
||||||
#include "k_kart.h"
|
#include "k_kart.h"
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
|
#include "i_system.h"
|
||||||
|
|
||||||
void K_AddBots(SINT8 numbots)
|
void K_AddBots(SINT8 numbots)
|
||||||
{
|
{
|
||||||
|
|
@ -174,6 +175,10 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
||||||
if (!player->mo)
|
if (!player->mo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
cmd->forwardmove = 0;
|
||||||
|
cmd->driftturn = 0;
|
||||||
|
cmd->buttons = 0;
|
||||||
|
|
||||||
if (player->playerstate == PST_DEAD)
|
if (player->playerstate == PST_DEAD)
|
||||||
{
|
{
|
||||||
cmd->buttons |= BT_ACCELERATE;
|
cmd->buttons |= BT_ACCELERATE;
|
||||||
|
|
@ -188,7 +193,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
||||||
|
|
||||||
if (leveltime <= starttime)
|
if (leveltime <= starttime)
|
||||||
{
|
{
|
||||||
if (leveltime >= starttime-50)
|
if (leveltime >= starttime-35)
|
||||||
cmd->buttons |= BT_ACCELERATE;
|
cmd->buttons |= BT_ACCELERATE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -268,5 +273,34 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
||||||
|
|
||||||
Z_Free(predict);
|
Z_Free(predict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player->kartstuff[k_userings] == 1 && !player->exiting)
|
||||||
|
{
|
||||||
|
if (player->kartstuff[k_rings] > 10)
|
||||||
|
cmd->buttons |= BT_ATTACK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (player->kartstuff[k_botitemdelay])
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (player->kartstuff[k_itemtype])
|
||||||
|
{
|
||||||
|
case KITEM_SNEAKER:
|
||||||
|
if (player->kartstuff[k_offroad] || K_GetWaypointIsShortcut(player->nextwaypoint) == true)
|
||||||
|
cmd->buttons |= BT_ATTACK;
|
||||||
|
break;
|
||||||
|
case KITEM_INVINCIBILITY:
|
||||||
|
case KITEM_SPB:
|
||||||
|
case KITEM_GROW:
|
||||||
|
case KITEM_SHRINK:
|
||||||
|
case KITEM_HYUDORO:
|
||||||
|
case KITEM_SUPERRING:
|
||||||
|
cmd->buttons |= BT_ATTACK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
49
src/k_kart.c
49
src/k_kart.c
|
|
@ -762,6 +762,8 @@ static void K_KartGetItemResult(player_t *player, SINT8 getitem)
|
||||||
if (getitem == KITEM_HYUDORO) // Hyudoro cooldown
|
if (getitem == KITEM_HYUDORO) // Hyudoro cooldown
|
||||||
hyubgone = 5*TICRATE;
|
hyubgone = 5*TICRATE;
|
||||||
|
|
||||||
|
player->kartstuff[k_botitemdelay] = TICRATE;
|
||||||
|
|
||||||
switch (getitem)
|
switch (getitem)
|
||||||
{
|
{
|
||||||
// Special roulettes first, then the generic ones are handled by default
|
// Special roulettes first, then the generic ones are handled by default
|
||||||
|
|
@ -810,7 +812,7 @@ static void K_KartGetItemResult(player_t *player, SINT8 getitem)
|
||||||
\return void
|
\return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush)
|
static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush, boolean bot)
|
||||||
{
|
{
|
||||||
INT32 newodds;
|
INT32 newodds;
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
@ -896,6 +898,27 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp
|
||||||
|
|
||||||
#define COOLDOWNONSTART (leveltime < (30*TICRATE)+starttime)
|
#define COOLDOWNONSTART (leveltime < (30*TICRATE)+starttime)
|
||||||
|
|
||||||
|
if (bot)
|
||||||
|
{
|
||||||
|
// TODO: Item use on bots should all be passed-in functions.
|
||||||
|
// Instead of manually inserting these, it should return 0
|
||||||
|
// for any items without an item use function supplied
|
||||||
|
|
||||||
|
switch (item)
|
||||||
|
{
|
||||||
|
case KITEM_SNEAKER:
|
||||||
|
case KITEM_INVINCIBILITY:
|
||||||
|
case KITEM_SPB:
|
||||||
|
case KITEM_GROW:
|
||||||
|
case KITEM_SHRINK:
|
||||||
|
case KITEM_HYUDORO:
|
||||||
|
case KITEM_SUPERRING:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case KITEM_ROCKETSNEAKER:
|
case KITEM_ROCKETSNEAKER:
|
||||||
|
|
@ -987,7 +1010,7 @@ static UINT8 K_FindUseodds(player_t *player, fixed_t mashed, UINT32 pdis, UINT8
|
||||||
|
|
||||||
for (j = 1; j < NUMKARTRESULTS; j++)
|
for (j = 1; j < NUMKARTRESULTS; j++)
|
||||||
{
|
{
|
||||||
if (K_KartGetItemOdds(i, j, mashed, spbrush) > 0)
|
if (K_KartGetItemOdds(i, j, mashed, spbrush, player->bot) > 0)
|
||||||
{
|
{
|
||||||
available = true;
|
available = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1275,7 +1298,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
|
||||||
useodds = K_FindUseodds(player, mashed, pdis, bestbumper, spbrush);
|
useodds = K_FindUseodds(player, mashed, pdis, bestbumper, spbrush);
|
||||||
|
|
||||||
for (i = 1; i < NUMKARTRESULTS; i++)
|
for (i = 1; i < NUMKARTRESULTS; i++)
|
||||||
spawnchance[i] = (totalspawnchance += K_KartGetItemOdds(useodds, i, mashed, spbrush));
|
spawnchance[i] = (totalspawnchance += K_KartGetItemOdds(useodds, i, mashed, spbrush, player->bot));
|
||||||
|
|
||||||
// Award the player whatever power is rolled
|
// Award the player whatever power is rolled
|
||||||
if (totalspawnchance > 0)
|
if (totalspawnchance > 0)
|
||||||
|
|
@ -2513,6 +2536,13 @@ void K_MomentumToFacing(player_t *player)
|
||||||
player->mo->momy = FixedMul(player->mo->momy - player->cmomy, player->mo->friction) + player->cmomy;
|
player->mo->momy = FixedMul(player->mo->momy - player->cmomy, player->mo->friction) + player->cmomy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean K_ApplyOffroad(player_t *player)
|
||||||
|
{
|
||||||
|
if (player->kartstuff[k_invincibilitytimer] || player->kartstuff[k_hyudorotimer] || EITHERSNEAKER(player))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// sets k_boostpower, k_speedboost, and k_accelboost to whatever we need it to be
|
// sets k_boostpower, k_speedboost, and k_accelboost to whatever we need it to be
|
||||||
static void K_GetKartBoostPower(player_t *player)
|
static void K_GetKartBoostPower(player_t *player)
|
||||||
{
|
{
|
||||||
|
|
@ -2527,8 +2557,7 @@ static void K_GetKartBoostPower(player_t *player)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Offroad is separate, it's difficult to factor it in with a variable value anyway.
|
// Offroad is separate, it's difficult to factor it in with a variable value anyway.
|
||||||
if (!(player->kartstuff[k_invincibilitytimer] || player->kartstuff[k_hyudorotimer] || EITHERSNEAKER(player))
|
if (K_ApplyOffroad(player) && player->kartstuff[k_offroad] >= 0)
|
||||||
&& player->kartstuff[k_offroad] >= 0)
|
|
||||||
boostpower = FixedDiv(boostpower, FixedMul(player->kartstuff[k_offroad], K_GetKartGameSpeedScalar(gamespeed)) + FRACUNIT);
|
boostpower = FixedDiv(boostpower, FixedMul(player->kartstuff[k_offroad], K_GetKartGameSpeedScalar(gamespeed)) + FRACUNIT);
|
||||||
|
|
||||||
if (player->kartstuff[k_bananadrag] > TICRATE)
|
if (player->kartstuff[k_bananadrag] > TICRATE)
|
||||||
|
|
@ -5985,6 +6014,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
|
||||||
player->powers[pw_flashing]--;
|
player->powers[pw_flashing]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player->kartstuff[k_botitemdelay])
|
||||||
|
player->kartstuff[k_botitemdelay]--;
|
||||||
|
|
||||||
if (player->kartstuff[k_spinouttimer])
|
if (player->kartstuff[k_spinouttimer])
|
||||||
{
|
{
|
||||||
if ((P_IsObjectOnGround(player->mo)
|
if ((P_IsObjectOnGround(player->mo)
|
||||||
|
|
@ -6866,10 +6898,7 @@ static void K_KartDrift(player_t *player, boolean onground)
|
||||||
|
|
||||||
// Disable drift-sparks until you're going fast enough
|
// Disable drift-sparks until you're going fast enough
|
||||||
if (player->kartstuff[k_getsparks] == 0
|
if (player->kartstuff[k_getsparks] == 0
|
||||||
|| (player->kartstuff[k_offroad]
|
|| (player->kartstuff[k_offroad] && K_ApplyOffroad(player)))
|
||||||
&& !player->kartstuff[k_invincibilitytimer]
|
|
||||||
&& !player->kartstuff[k_hyudorotimer]
|
|
||||||
&& !EITHERSNEAKER(player)))
|
|
||||||
driftadditive = 0;
|
driftadditive = 0;
|
||||||
|
|
||||||
// Inbetween minspeed and minspeed*2, it'll keep your previous drift-spark state.
|
// Inbetween minspeed and minspeed*2, it'll keep your previous drift-spark state.
|
||||||
|
|
@ -11056,7 +11085,7 @@ static void K_drawDistributionDebugger(void)
|
||||||
|
|
||||||
for (i = 1; i < NUMKARTRESULTS; i++)
|
for (i = 1; i < NUMKARTRESULTS; i++)
|
||||||
{
|
{
|
||||||
const INT32 itemodds = K_KartGetItemOdds(useodds, i, 0, spbrush);
|
const INT32 itemodds = K_KartGetItemOdds(useodds, i, 0, spbrush, stplyr->bot);
|
||||||
if (itemodds <= 0)
|
if (itemodds <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue