- Backported VisibleToTeam and VisibleToPlayerClass from Skulltag with some modifications.

SVN r3290 (trunk)
This commit is contained in:
Braden Obrzut 2011-09-08 01:28:26 +00:00
parent bb1b825f24
commit c013e72caa
4 changed files with 58 additions and 1 deletions

View file

@ -763,6 +763,8 @@ public:
return bloodcls; return bloodcls;
} }
bool IsVisibleToPlayer() const;
// Calculate amount of missile damage // Calculate amount of missile damage
virtual int GetMissileDamage(int mask, int add); virtual int GetMissileDamage(int mask, int add);
@ -814,6 +816,13 @@ public:
DWORD flags4; // [RH] Even more flags! DWORD flags4; // [RH] Even more flags!
DWORD flags5; // OMG! We need another one. DWORD flags5; // OMG! We need another one.
DWORD flags6; // Shit! Where did all the flags go? DWORD flags6; // Shit! Where did all the flags go?
// [BB] If 0, everybody can see the actor, if > 0, only members of team (VisibleToTeam-1) can see it.
DWORD VisibleToTeam;
// [BB] If NAME_None, all players can see the actor, else only players whose playerclass name is VisibleToPlayerClass can see it.
FNameNoInit VisibleToPlayerClass;
int special1; // Special info int special1; // Special info
int special2; // Special info int special2; // Special info
int health; int health;

View file

@ -310,6 +310,7 @@ void AActor::Serialize (FArchive &arc)
<< smokecounter << smokecounter
<< BlockingMobj << BlockingMobj
<< BlockingLine << BlockingLine
<< VisibleToTeam // [BB]
<< pushfactor << pushfactor
<< Species << Species
<< Score; << Score;
@ -871,6 +872,34 @@ bool AActor::CheckLocalView (int playernum) const
return false; return false;
} }
//============================================================================
//
// AActor :: IsVisibleToPlayer
//
// Returns true if this actor should be seen by the console player.
//
//============================================================================
bool AActor::IsVisibleToPlayer() const
{
// [BB] Safety check. This should never be NULL. Nevertheless, we return true to leave the default ZDoom behavior unaltered.
if ( players[consoleplayer].camera == NULL )
return true;
if ( VisibleToTeam != 0 && teamplay &&
VisibleToTeam-1 != players[consoleplayer].userinfo.team )
return false;
const player_t* pPlayer = players[consoleplayer].camera->player;
if ( ( VisibleToPlayerClass != NAME_None )
&& pPlayer && pPlayer->mo && ( VisibleToPlayerClass != pPlayer->mo->GetClass()->TypeName ) )
return false;
// [BB] Passed all checks.
return true;
}
//============================================================================ //============================================================================
// //
// AActor :: ConversationAnimation // AActor :: ConversationAnimation

View file

@ -495,7 +495,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
// Don't waste time projecting sprites that are definitely not visible. // Don't waste time projecting sprites that are definitely not visible.
if (thing == NULL || if (thing == NULL ||
(thing->renderflags & RF_INVISIBLE) || (thing->renderflags & RF_INVISIBLE) ||
!thing->RenderStyle.IsVisible(thing->alpha)) !thing->RenderStyle.IsVisible(thing->alpha) ||
!thing->IsVisibleToPlayer())
{ {
return; return;
} }

View file

@ -1234,6 +1234,24 @@ DEFINE_PROPERTY(designatedteam, I, Actor)
defaults->DesignatedTeam = val; defaults->DesignatedTeam = val;
} }
//==========================================================================
// [BB]
//==========================================================================
DEFINE_PROPERTY(visibletoteam, I, Actor)
{
PROP_INT_PARM(i, 0);
defaults->VisibleToTeam=i+1;
}
//==========================================================================
// [BB]
//==========================================================================
DEFINE_PROPERTY(visibletoplayerclass, S, Actor)
{
PROP_STRING_PARM(n, 0);
defaults->VisibleToPlayerClass = n;
}
//========================================================================== //==========================================================================
// //
// Special inventory properties // Special inventory properties