- fixed: AActor::IsTeammate must consider monsters friendly to a specific player as members of the same team as the owning player. Such monsters cannot be made members of a designated team, though, because their association needs to change if the player changes teams.

This commit is contained in:
Christoph Oelckers 2014-10-25 14:59:30 +02:00
parent 2e1fa70cbf
commit d4c50b1662
3 changed files with 31 additions and 9 deletions

View file

@ -716,6 +716,9 @@ public:
// Transforms the actor into a finely-ground paste // Transforms the actor into a finely-ground paste
virtual bool Grind(bool items); virtual bool Grind(bool items);
// Get this actor's team
int GetTeam();
// Is the other actor on my team? // Is the other actor on my team?
bool IsTeammate (AActor *other); bool IsTeammate (AActor *other);

View file

@ -1592,7 +1592,7 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
} }
#endif #endif
// [SP] If you don't see any enemies in deathmatch, look for players (but only when friend to a specific player.) // [SP] If you don't see any enemies in deathmatch, look for players (but only when friend to a specific player.)
if (actor->FriendPlayer == 0 && (!teamplay || actor->DesignatedTeam == TEAM_NONE)) return result; if (actor->FriendPlayer == 0 && (!teamplay || actor->GetTeam() == TEAM_NONE)) return result;
if (result || !deathmatch) return true; if (result || !deathmatch) return true;

View file

@ -5855,22 +5855,41 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z,
return NULL; return NULL;
} }
int AActor::GetTeam()
{
if (player)
{
return player->userinfo.GetTeam();
}
int myTeam = DesignatedTeam;
// Check for monsters that belong to a player on the team but aren't part of the team themselves.
if (myTeam == TEAM_NONE && FriendPlayer != 0)
{
myTeam = players[FriendPlayer - 1].userinfo.GetTeam();
}
return myTeam;
}
bool AActor::IsTeammate (AActor *other) bool AActor::IsTeammate (AActor *other)
{ {
if (!other) if (!other)
{
return false; return false;
}
else if (!deathmatch && player && other->player) else if (!deathmatch && player && other->player)
return true;
int myTeam = DesignatedTeam;
int otherTeam = other->DesignatedTeam;
if (player)
myTeam = player->userinfo.GetTeam();
if (other->player)
otherTeam = other->player->userinfo.GetTeam();
if (teamplay && myTeam != TEAM_NONE && myTeam == otherTeam)
{ {
return true; return true;
} }
else if (teamplay)
{
int myTeam = GetTeam();
int otherTeam = other->GetTeam();
return (myTeam != TEAM_NONE && myTeam == otherTeam);
}
return false; return false;
} }