replication
{
reliable if( Role < ROLE_Authority )
PossessZed;
reliable if( Role==ROLE_Authority )
ClientDeathMessage;
}
state Spectating
{
function BeginState()
{
Super.BeginState();
if( VSGame(Level.Game)!=None && VSGame(Level.Game).ShouldGoHunt() && !PlayerReplicationInfo.bOnlySpectator )
GoToState('PreySpec');
}
}
state PreySpec extends BaseSpectating
{
ignores SwitchWeapon, RestartLevel, ClientRestart, Suicide, ThrowWeapon, NotifyPhysicsVolumeChange, NotifyHeadVolumeChange;
function PossessZed()
{
local Pawn P;
local vector HL,HN;
local bool bWasSpec;
if( NextPossessTimer>Level.TimeSeconds )
return;
NextPossessTimer = Level.TimeSeconds+0.4f;
foreach TraceActors(Class'Pawn',P,HL,HN,Location+vector(Rotation)*1000.f,Location)
{
log("P (Pawn) was"@P);
if( P!=None && P.Health>0 )
{
if( Monster(P)!=None )
VSGame(Level.Game).PlayerPossess(Self,Monster(P));
else if( KFHumanPawn(P)!=None )
{
log("I tried to set my ViewTarget");
bWasSpec = !bBehindView && ViewTarget != Pawn && ViewTarget != self;
SetViewTarget(KFHumanPawn(P));
ViewTargetChanged();
ClientSetViewTarget(KFHumanPawn(P));
if ( ViewTarget == self || bWasSpec )
bBehindView = false;
else
bBehindView = true; //bChaseCam;
ClientSetBehindView(bBehindView);
}
}
return;
}
ClientMessage("Can't possess: You must aim at the specimen to possess.");
}
exec function Fire( optional float F )
{
if( NextPossessTimer<Level.TimeSeconds )
{
PossessZed();
NextPossessTimer = Level.TimeSeconds+0.5f;
}
}
exec function AltFire( optional float F )
{
if( ViewTarget != self )
ServerViewSelf();
}
function Timer()
{
bFrozen = false;
}
function BeginState()
{
if ( Pawn != None )
{
SetLocation(Pawn.Location);
UnPossess();
}
bCollideWorld = true;
CameraDist = Default.CameraDist;
}
function EndState()
{
PlayerReplicationInfo.bIsSpectator = false;
bCollideWorld = false;
}
function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
{
bBehindView = false;
if( ViewTarget!=Self )
SetViewTarget(Self);
Acceleration = NewAccel;
MoveSmooth(SpectateSpeed * Normal(Acceleration) * DeltaTime);
}
}