Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfriendly coop #286

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/g_game.cpp
Expand Up @@ -1765,6 +1765,8 @@ void G_DoReborn (int playernum, bool freshbot)
}
else
{
bool isUnfriendly = players[playernum].mo && !(players[playernum].mo->flags & MF_FRIENDLY);

// respawn at the start
// first disassociate the corpse
if (players[playernum].mo)
Expand All @@ -1774,7 +1776,7 @@ void G_DoReborn (int playernum, bool freshbot)
}

// spawn at random spot if in deathmatch
if (deathmatch)
if (deathmatch || isUnfriendly)
{
G_DeathMatchSpawnPlayer (playernum);
return;
Expand Down
5 changes: 4 additions & 1 deletion src/p_enemy.cpp
Expand Up @@ -1883,6 +1883,9 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
if (!(player->mo->flags & MF_SHOOTABLE))
continue; // not shootable (observer or dead)

if (!((actor->flags ^ player->mo->flags) & MF_FRIENDLY))
continue; // same +MF_FRIENDLY, ignore

if (player->cheats & CF_NOTARGET)
continue; // no target

Expand Down Expand Up @@ -1982,7 +1985,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
targ = NULL;
}

if (targ && targ->player && (targ->player->cheats & CF_NOTARGET))
if (targ && targ->player && ((targ->player->cheats & CF_NOTARGET) || !(targ->flags & MF_FRIENDLY)))
{
return 0;
}
Expand Down
5 changes: 4 additions & 1 deletion src/p_mobj.cpp
Expand Up @@ -7204,7 +7204,7 @@ bool AActor::IsTeammate (AActor *other)
}
else if (!deathmatch && player && other->player)
{
return true;
return (!((flags ^ other->flags) & MF_FRIENDLY));
}
else if (teamplay)
{
Expand Down Expand Up @@ -7285,6 +7285,9 @@ bool AActor::IsFriend (AActor *other)
other->FriendPlayer == 0 ||
players[FriendPlayer-1].mo->IsTeammate(players[other->FriendPlayer-1].mo);
}
// [SP] If friendly flags match, then they are on the same team.
/*if (!((flags ^ other->flags) & MF_FRIENDLY))
return true;*/
return false;
}

Expand Down
16 changes: 16 additions & 0 deletions src/p_setup.cpp
Expand Up @@ -4103,6 +4103,22 @@ void P_SetupLevel (const char *lumpname, int position)
}
}

// [SP] move unfriendly players around
// horribly hacky - yes, this needs rewritten.
for (i = 0; i < MAXPLAYERS; ++i)
{
if (playeringame[i] && players[i].mo != NULL)
{
if (!(players[i].mo->flags & MF_FRIENDLY))
{
AActor * oldSpawn = players[i].mo;
G_DeathMatchSpawnPlayer (i);
oldSpawn->Destroy();
}
}
}


// Don't count monsters in end-of-level sectors if option is on
if (dmflags2 & DF2_NOCOUNTENDMONST)
{
Expand Down