* Set player->outofcoop to false if it's not a coop gametype.

* Expose player->outofcoop to Lua.
This commit is contained in:
toasterbabe 2017-07-04 14:58:58 +01:00
parent f809923f69
commit 1a7a0662ba
2 changed files with 30 additions and 22 deletions

View file

@ -320,6 +320,8 @@ static int player_get(lua_State *L)
lua_pushangle(L, plr->awayviewaiming); lua_pushangle(L, plr->awayviewaiming);
else if (fastcmp(field,"spectator")) else if (fastcmp(field,"spectator"))
lua_pushboolean(L, plr->spectator); lua_pushboolean(L, plr->spectator);
else if (fastcmp(field,"outofcoop"))
lua_pushboolean(L, plr->outofcoop);
else if (fastcmp(field,"bot")) else if (fastcmp(field,"bot"))
lua_pushinteger(L, plr->bot); lua_pushinteger(L, plr->bot);
else if (fastcmp(field,"jointime")) else if (fastcmp(field,"jointime"))
@ -597,6 +599,8 @@ static int player_set(lua_State *L)
plr->awayviewaiming = luaL_checkangle(L, 3); plr->awayviewaiming = luaL_checkangle(L, 3);
else if (fastcmp(field,"spectator")) else if (fastcmp(field,"spectator"))
plr->spectator = lua_toboolean(L, 3); plr->spectator = lua_toboolean(L, 3);
else if (fastcmp(field,"outofcoop"))
plr->outofcoop = lua_toboolean(L, 3);
else if (fastcmp(field,"bot")) else if (fastcmp(field,"bot"))
return NOSET; return NOSET;
else if (fastcmp(field,"jointime")) else if (fastcmp(field,"jointime"))

View file

@ -9106,33 +9106,37 @@ void P_SpawnPlayer(INT32 playernum)
|| (cv_coopstarposts.value == 2 && (p->jointime < 1 || p->outofcoop)))) // late join or die in new coop || (cv_coopstarposts.value == 2 && (p->jointime < 1 || p->outofcoop)))) // late join or die in new coop
|| (((cv_cooplives.value == 1) || !P_GetLives(p)) && p->lives <= 0))); // game over and can't redistribute lives || (((cv_cooplives.value == 1) || !P_GetLives(p)) && p->lives <= 0))); // game over and can't redistribute lives
} }
else if (netgame && p->jointime < 1) else
p->spectator = true;
else if (multiplayer && !netgame)
{ {
// If you're in a team game and you don't have a team assigned yet... p->outofcoop = false;
if (G_GametypeHasTeams() && p->ctfteam == 0) if (netgame && p->jointime < 1)
{
changeteam_union NetPacket;
UINT16 usvalue;
NetPacket.value.l = NetPacket.value.b = 0;
// Spawn as a spectator,
// yes even in splitscreen mode
p->spectator = true; p->spectator = true;
if (playernum&1) p->skincolor = skincolor_redteam; else if (multiplayer && !netgame)
else p->skincolor = skincolor_blueteam; {
// If you're in a team game and you don't have a team assigned yet...
if (G_GametypeHasTeams() && p->ctfteam == 0)
{
changeteam_union NetPacket;
UINT16 usvalue;
NetPacket.value.l = NetPacket.value.b = 0;
// but immediately send a team change packet. // Spawn as a spectator,
NetPacket.packet.playernum = playernum; // yes even in splitscreen mode
NetPacket.packet.verification = true; p->spectator = true;
NetPacket.packet.newteam = !(playernum&1) + 1; if (playernum&1) p->skincolor = skincolor_redteam;
else p->skincolor = skincolor_blueteam;
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); // but immediately send a team change packet.
SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); NetPacket.packet.playernum = playernum;
NetPacket.packet.verification = true;
NetPacket.packet.newteam = !(playernum&1) + 1;
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
else // Otherwise, never spectator.
p->spectator = false;
} }
else // Otherwise, never spectator.
p->spectator = false;
} }
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())