mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-21 18:32:08 +00:00
Merge branch 'addplayer-2021-7-15' into 'addplayer'
Addplayer 2021 7 15 See merge request STJr/SRB2!1585
This commit is contained in:
commit
1285ba9f35
7 changed files with 59 additions and 42 deletions
|
@ -559,6 +559,7 @@ typedef struct player_s
|
|||
|
||||
boolean spectator;
|
||||
boolean outofcoop;
|
||||
boolean removing;
|
||||
UINT8 bot;
|
||||
struct player_s *botleader;
|
||||
UINT16 lastbuttons;
|
||||
|
|
22
src/g_game.c
22
src/g_game.c
|
@ -1545,7 +1545,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
cmd->forwardmove = (SINT8)(cmd->forwardmove + forward);
|
||||
cmd->sidemove = (SINT8)(cmd->sidemove + side);
|
||||
|
||||
//Note: Majority of botstuffs are handled in G_Ticker now.
|
||||
// Note: Majority of botstuffs are handled in G_Ticker now.
|
||||
if (player->bot == BOT_2PHUMAN) //Player-controlled bot
|
||||
{
|
||||
G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver
|
||||
|
@ -2198,6 +2198,23 @@ void G_Ticker(boolean run)
|
|||
UINT32 i;
|
||||
INT32 buf;
|
||||
|
||||
// Bot players queued for removal
|
||||
for (i = MAXPLAYERS-1; i != UINT32_MAX; i--)
|
||||
{
|
||||
if (playeringame[i] && players[i].removing)
|
||||
{
|
||||
CL_RemovePlayer(i, i);
|
||||
if (netgame)
|
||||
{
|
||||
char kickmsg[256];
|
||||
|
||||
strcpy(kickmsg, M_GetText("\x82*Bot %s has been removed"));
|
||||
strcpy(kickmsg, va(kickmsg, player_names[i], i));
|
||||
HU_AddChatText(kickmsg, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// see also SCR_DisplayMarathonInfo
|
||||
if ((marathonmode & (MA_INIT|MA_INGAME)) == MA_INGAME && gamestate == GS_LEVEL)
|
||||
marathontime++;
|
||||
|
@ -2520,6 +2537,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
|
|||
tic_t quittime;
|
||||
boolean spectator;
|
||||
boolean outofcoop;
|
||||
boolean removing;
|
||||
INT16 bot;
|
||||
SINT8 pity;
|
||||
INT16 rings;
|
||||
|
@ -2536,6 +2554,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
|
|||
quittime = players[player].quittime;
|
||||
spectator = players[player].spectator;
|
||||
outofcoop = players[player].outofcoop;
|
||||
removing = players[player].removing;
|
||||
pflags = (players[player].pflags & (PF_FLIPCAM|PF_ANALOGMODE|PF_DIRECTIONCHAR|PF_AUTOBRAKE|PF_TAGIT|PF_GAMETYPEOVER));
|
||||
playerangleturn = players[player].angleturn;
|
||||
oldrelangleturn = players[player].oldrelangleturn;
|
||||
|
@ -2612,6 +2631,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
|
|||
p->quittime = quittime;
|
||||
p->spectator = spectator;
|
||||
p->outofcoop = outofcoop;
|
||||
p->removing = removing;
|
||||
p->angleturn = playerangleturn;
|
||||
p->oldrelangleturn = oldrelangleturn;
|
||||
|
||||
|
|
|
@ -3490,22 +3490,14 @@ static int lib_gRemovePlayer(lua_State *L)
|
|||
return luaL_error(L, "playernum %d out of range (0 - %d)", pnum, MAXPLAYERS-1);
|
||||
if (playeringame[pnum]) // Found player
|
||||
{
|
||||
if (players[pnum].bot != BOT_NONE) // Can't remove clients.
|
||||
if (players[pnum].bot == BOT_NONE) // Can't remove clients.
|
||||
return luaL_error(L, "G_RemovePlayer can only be used on players with a bot value other than BOT_NONE.");
|
||||
else
|
||||
{
|
||||
CL_RemovePlayer(pnum, pnum);
|
||||
if (netgame)
|
||||
{
|
||||
char kickmsg[256];
|
||||
|
||||
strcpy(kickmsg, M_GetText("\x82*Bot %s has been removed"));
|
||||
strcpy(kickmsg, va(kickmsg, player_names[pnum], pnum));
|
||||
HU_AddChatText(kickmsg, false);
|
||||
}
|
||||
players[pnum].removing = true;
|
||||
lua_pushboolean(L, true);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return luaL_error(L, "G_RemovePlayer can only be used on players with a bot value other than BOT_NONE.");
|
||||
}
|
||||
// Fell through. Invalid player
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
|
|
|
@ -151,7 +151,7 @@ boolean P_CanPickupItem(player_t *player, boolean weapon)
|
|||
if (!player->mo || player->mo->health <= 0)
|
||||
return false;
|
||||
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
{
|
||||
if (weapon)
|
||||
return false;
|
||||
|
@ -178,7 +178,7 @@ void P_DoNightsScore(player_t *player)
|
|||
return; // Don't do any fancy shit for failures.
|
||||
|
||||
dummymo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+player->mo->height/2, MT_NIGHTSCORE);
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
player = &players[consoleplayer];
|
||||
|
||||
if (G_IsSpecialStage(gamemap)) // Global link count? Maybe not a good idea...
|
||||
|
@ -630,7 +630,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
// ***************************** //
|
||||
// Special Stage Token
|
||||
case MT_TOKEN:
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
|
||||
P_AddPlayerScore(player, 1000);
|
||||
|
@ -670,7 +670,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
|
||||
// Emerald Hunt
|
||||
case MT_EMERHUNT:
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
|
||||
if (hunt1 == special)
|
||||
|
@ -701,7 +701,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
case MT_EMERALD5:
|
||||
case MT_EMERALD6:
|
||||
case MT_EMERALD7:
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
|
||||
if (special->threshold)
|
||||
|
@ -738,7 +738,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
// Secret emblem thingy
|
||||
case MT_EMBLEM:
|
||||
{
|
||||
if (demoplayback || (player->bot && player->bot != 3))
|
||||
if (demoplayback || (player->bot && player->bot != BOT_MPAI))
|
||||
return;
|
||||
emblemlocations[special->health-1].collected = true;
|
||||
|
||||
|
@ -751,7 +751,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
// CTF Flags
|
||||
case MT_REDFLAG:
|
||||
case MT_BLUEFLAG:
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
if (player->powers[pw_flashing] || player->tossdelay)
|
||||
return;
|
||||
|
@ -826,7 +826,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
{
|
||||
boolean spec = G_IsSpecialStage(gamemap);
|
||||
boolean cangiveemmy = false;
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
if (player->exiting)
|
||||
return;
|
||||
|
@ -1072,7 +1072,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
}
|
||||
return;
|
||||
case MT_EGGCAPSULE:
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
|
||||
// make sure everything is as it should be, THEN take rings from players in special stages
|
||||
|
@ -1164,7 +1164,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
}
|
||||
return;
|
||||
case MT_NIGHTSSUPERLOOP:
|
||||
if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
return;
|
||||
if (!G_IsSpecialStage(gamemap))
|
||||
player->powers[pw_nights_superloop] = (UINT16)special->info->speed;
|
||||
|
@ -1186,7 +1186,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
}
|
||||
break;
|
||||
case MT_NIGHTSDRILLREFILL:
|
||||
if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
return;
|
||||
if (!G_IsSpecialStage(gamemap))
|
||||
player->drillmeter = special->info->speed;
|
||||
|
@ -1208,7 +1208,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
}
|
||||
break;
|
||||
case MT_NIGHTSHELPER:
|
||||
if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
return;
|
||||
if (!G_IsSpecialStage(gamemap))
|
||||
{
|
||||
|
@ -1240,7 +1240,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
}
|
||||
break;
|
||||
case MT_NIGHTSEXTRATIME:
|
||||
if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
return;
|
||||
if (!G_IsSpecialStage(gamemap))
|
||||
{
|
||||
|
@ -1272,7 +1272,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
}
|
||||
break;
|
||||
case MT_NIGHTSLINKFREEZE:
|
||||
if ((player->bot && player->bot != 3) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
if ((player->bot && player->bot != BOT_MPAI) || !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
return;
|
||||
if (!G_IsSpecialStage(gamemap))
|
||||
{
|
||||
|
@ -1332,7 +1332,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE)
|
||||
players[i].drillmeter += TICRATE/2;
|
||||
}
|
||||
else if (player->bot && player->bot != 3)
|
||||
else if (player->bot && player->bot != BOT_MPAI)
|
||||
players[consoleplayer].drillmeter += TICRATE/2;
|
||||
else
|
||||
player->drillmeter += TICRATE/2;
|
||||
|
@ -1385,7 +1385,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
thinker_t *th;
|
||||
mobj_t *mo2;
|
||||
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
|
||||
// Initialize my junk
|
||||
|
@ -1423,7 +1423,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
return;
|
||||
}
|
||||
case MT_FIREFLOWER:
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
|
||||
S_StartSound(toucher, sfx_mario3);
|
||||
|
@ -1685,7 +1685,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
return; // Only go in the mouth
|
||||
|
||||
// Eaten by player!
|
||||
if ((!player->bot || player->bot == 3) && (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1))
|
||||
if ((!player->bot || player->bot == BOT_MPAI) && (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1))
|
||||
{
|
||||
player->powers[pw_underwater] = underwatertics + 1;
|
||||
P_RestoreMusic(player);
|
||||
|
@ -1696,7 +1696,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
|
||||
if (!player->climbing)
|
||||
{
|
||||
if (player->bot && player->bot != 3 && toucher->state-states != S_PLAY_GASP)
|
||||
if (player->bot && player->bot != BOT_MPAI && toucher->state-states != S_PLAY_GASP)
|
||||
S_StartSound(toucher, special->info->deathsound); // Force it to play a sound for bots
|
||||
P_SetPlayerMobjState(toucher, S_PLAY_GASP);
|
||||
P_ResetPlayer(player);
|
||||
|
@ -1704,7 +1704,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
|
||||
toucher->momx = toucher->momy = toucher->momz = 0;
|
||||
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
else
|
||||
break;
|
||||
|
@ -1736,7 +1736,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
return;
|
||||
|
||||
case MT_MINECARTSPAWNER:
|
||||
if (!player->bot && player->bot != 3 && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART && !(player->powers[pw_ignorelatch] & (1<<15)))
|
||||
if (!player->bot && player->bot != BOT_MPAI && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART && !(player->powers[pw_ignorelatch] & (1<<15)))
|
||||
{
|
||||
mobj_t *mcart = P_SpawnMobj(special->x, special->y, special->z, MT_MINECART);
|
||||
P_SetTarget(&mcart->target, toucher);
|
||||
|
@ -1789,7 +1789,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
|||
}
|
||||
return;
|
||||
default: // SOC or script pickup
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
P_SetTarget(&special->target, toucher);
|
||||
break;
|
||||
|
@ -1813,7 +1813,7 @@ void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost)
|
|||
mobj_t *toucher = player->mo;
|
||||
mobj_t *checkbase = snaptopost ? post : toucher;
|
||||
|
||||
if (player->bot && player->bot != 3)
|
||||
if (player->bot && player->bot != BOT_MPAI)
|
||||
return;
|
||||
// In circuit, player must have touched all previous starposts
|
||||
if (circuitmap
|
||||
|
@ -2555,7 +2555,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
|
|||
|
||||
if ((target->player->lives <= 1) && (netgame || multiplayer) && G_GametypeUsesCoopLives() && (cv_cooplives.value == 0))
|
||||
;
|
||||
else if ((!target->player->bot || target->player->bot == 3) && !target->player->spectator && (target->player->lives != INFLIVES)
|
||||
else if ((!target->player->bot || target->player->bot == BOT_MPAI) && !target->player->spectator && (target->player->lives != INFLIVES)
|
||||
&& G_GametypeUsesLives())
|
||||
{
|
||||
if (!(target->player->pflags & PF_FINISHED))
|
||||
|
@ -3475,7 +3475,7 @@ void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source)
|
|||
if (inflictor && inflictor->type == MT_LHRT)
|
||||
return;
|
||||
|
||||
if (player->powers[pw_shield] || (player->bot && player->bot != 3)) //If One-Hit Shield
|
||||
if (player->powers[pw_shield] || (player->bot && player->bot != BOT_MPAI)) //If One-Hit Shield
|
||||
{
|
||||
P_RemoveShield(player);
|
||||
S_StartSound(player->mo, sfx_shldls); // Ba-Dum! Shield loss.
|
||||
|
@ -3566,7 +3566,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
|||
return false;
|
||||
|
||||
// Make sure that boxes cannot be popped by enemies, red rings, etc.
|
||||
if (target->flags & MF_MONITOR && ((!source || !source->player || (source->player->bot && source->player->bot != 3))
|
||||
if (target->flags & MF_MONITOR && ((!source || !source->player || (source->player->bot && source->player->bot != BOT_MPAI))
|
||||
|| (inflictor && (inflictor->type == MT_REDRING || (inflictor->type >= MT_THROWNBOUNCE && inflictor->type <= MT_THROWNGRENADE)))))
|
||||
return false;
|
||||
}
|
||||
|
@ -3701,7 +3701,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
|||
}
|
||||
else if (LUA_HookMobjDamage(target, inflictor, source, damage, damagetype))
|
||||
return true;
|
||||
else if (player->powers[pw_shield] || (player->bot && player->bot != 3 && !ultimatemode)) //If One-Hit Shield
|
||||
else if (player->powers[pw_shield] || (player->bot && player->bot != BOT_MPAI && !ultimatemode)) //If One-Hit Shield
|
||||
{
|
||||
P_ShieldDamage(player, inflictor, source, damage, damagetype);
|
||||
damage = 0;
|
||||
|
|
|
@ -201,6 +201,7 @@ static void P_NetArchivePlayers(void)
|
|||
WRITEUINT8(save_p, players[i].botmem.lastBlocked);
|
||||
WRITEUINT8(save_p, players[i].botmem.catchup_tics);
|
||||
WRITEUINT8(save_p, players[i].botmem.thinkstate);
|
||||
WRITEUINT8(save_p, players[i].removing);
|
||||
|
||||
WRITEUINT8(save_p, players[i].blocked);
|
||||
WRITEUINT16(save_p, players[i].lastbuttons);
|
||||
|
@ -428,6 +429,7 @@ static void P_NetUnArchivePlayers(void)
|
|||
players[i].botmem.lastBlocked = READUINT8(save_p);
|
||||
players[i].botmem.catchup_tics = READUINT8(save_p);
|
||||
players[i].botmem.thinkstate = READUINT8(save_p);
|
||||
players[i].removing = READUINT8(save_p);
|
||||
|
||||
players[i].blocked = READUINT8(save_p);
|
||||
players[i].lastbuttons = READUINT16(save_p);
|
||||
|
|
|
@ -1188,6 +1188,7 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings)
|
|||
{
|
||||
if (!player)
|
||||
return;
|
||||
|
||||
if ((player->bot == BOT_2PAI || player->bot == BOT_2PHUMAN) && player->botleader)
|
||||
player = player->botleader;
|
||||
|
||||
|
@ -11623,7 +11624,7 @@ void P_PlayerThink(player_t *player)
|
|||
INT32 i;
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
{
|
||||
if (!playeringame[i] || players[i].spectator || players[i].bot == BOT_2PAI || players[i].bot == BOT_2PHUMAN)
|
||||
continue;
|
||||
if (players[i].lives <= 0)
|
||||
|
@ -12596,6 +12597,7 @@ void P_PlayerAfterThink(player_t *player)
|
|||
player->mo->momy = tails->momy;
|
||||
player->mo->momz = tails->momz;
|
||||
}
|
||||
|
||||
if (G_CoopGametype() && tails->player && tails->player->bot != BOT_2PAI)
|
||||
{
|
||||
player->mo->angle = tails->angle;
|
||||
|
|
|
@ -242,7 +242,7 @@ boolean R_SkinUsable(INT32 playernum, INT32 skinnum)
|
|||
// Force 3.
|
||||
return true;
|
||||
}
|
||||
if (players[playernum].bot)
|
||||
if (playernum != -1 && players[playernum].bot)
|
||||
{
|
||||
//Force 4.
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue