NSClientSpectator: add new method SpectatorDeathcam()
This commit is contained in:
parent
bd2705eed6
commit
3d32e75e88
4 changed files with 87 additions and 5 deletions
|
@ -280,8 +280,9 @@ NSView::UpdateView(void)
|
|||
}
|
||||
|
||||
/* put entities into the scene (and call their predraws */
|
||||
if (m_bDrawEntities)
|
||||
if (m_bDrawEntities) {
|
||||
addentities(MASK_ENGINE);
|
||||
}
|
||||
|
||||
/* after predraws we can act upon their new positions */
|
||||
if (cl) {
|
||||
|
@ -309,6 +310,29 @@ NSView::UpdateView(void)
|
|||
spec = (NSClientSpectator)m_viewTarget;
|
||||
|
||||
switch (spec.spec_mode) {
|
||||
case SPECMODE_DEATHCAM:
|
||||
vector deathAngle;
|
||||
vector vecEnd;
|
||||
c = findfloat(world, ::entnum, spec.spec_ent);
|
||||
vector vecStart = c.origin;
|
||||
float progression = time - spec.m_flLastSpecTargetChange;
|
||||
|
||||
vecStart[2] += 16;
|
||||
vecStart += (v_right * 4);
|
||||
|
||||
deathAngle[0] = bound(0, progression * 15.0f, 90.0f);
|
||||
deathAngle[1] = c.angles[1] + (progression * 22.5f);
|
||||
deathAngle[2] = 0.0f;
|
||||
|
||||
makevectors(deathAngle);
|
||||
|
||||
vecEnd = vecStart + (v_forward * -48) + [0,0,16] + (v_right * 4);
|
||||
traceline(vecStart, vecEnd, FALSE, m_viewTarget);
|
||||
|
||||
SetCameraOrigin(trace_endpos + (v_forward * 5));
|
||||
SetCameraAngle(deathAngle);
|
||||
SetClientAngle(deathAngle);
|
||||
break;
|
||||
case SPECMODE_LOCKEDCHASE:
|
||||
view_angles = [0, spec.v_angle[1], 0];
|
||||
case SPECMODE_THIRDPERSON:
|
||||
|
|
|
@ -568,6 +568,10 @@ NSClientPlayer::ReceiveEntity(float new, float flChanged)
|
|||
setsize(this, mins, maxs);
|
||||
|
||||
setorigin(this, origin);
|
||||
|
||||
if (flChanged & PLAYER_SPECTATE) {
|
||||
m_flLastSpecTargetChange = time;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -26,6 +26,7 @@ typedef enumflags
|
|||
|
||||
typedef enum
|
||||
{
|
||||
SPECMODE_DEATHCAM,
|
||||
SPECMODE_LOCKEDCHASE,
|
||||
SPECMODE_THIRDPERSON,
|
||||
SPECMODE_FREE,
|
||||
|
@ -36,6 +37,7 @@ typedef enum
|
|||
|
||||
#ifdef CLIENT
|
||||
string g_specmodes[] = {
|
||||
"Death Cam",
|
||||
"Locked Chase Cam",
|
||||
"Free Chase Cam",
|
||||
"Free Look",
|
||||
|
@ -66,6 +68,8 @@ private:
|
|||
PREDICTED_FLOAT(spec_ent)
|
||||
PREDICTED_FLOAT(spec_flags)
|
||||
NSClientSpectatorMode_t spec_mode; NSClientSpectatorMode_t spec_mode_net;
|
||||
float m_flDeathCam;
|
||||
float m_flLastSpecTargetChange;
|
||||
|
||||
vector spec_org;
|
||||
|
||||
|
@ -110,6 +114,8 @@ public:
|
|||
virtual void EvaluateEntity(void);
|
||||
virtual float SendEntity(entity,float);
|
||||
virtual void ServerInputFrame(void);
|
||||
|
||||
nonvirtual void SpectatorDeathcam(NSRenderableEntity, NSEntity, float);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -212,6 +212,10 @@ NSClientSpectator::ReceiveEntity(float new, float flChanged)
|
|||
READENTITY_BYTE(spec_flags, SPECFL_FLAGS)
|
||||
READENTITY_BYTE(movetype, SPECFL_TYPE)
|
||||
READENTITY_BYTE(solid, SPECFL_TYPE)
|
||||
|
||||
if (flChanged & SPECFL_TARGET) {
|
||||
m_flLastSpecTargetChange = time;
|
||||
}
|
||||
};
|
||||
|
||||
float
|
||||
|
@ -225,9 +229,23 @@ NSClientSpectator::predraw(void)
|
|||
void
|
||||
NSClientSpectator::InputNext(void)
|
||||
{
|
||||
if (spec_flags & SPECFLAG_BUTTON_RELEASED)
|
||||
if (m_flDeathCam > time)
|
||||
return;
|
||||
|
||||
if (spec_flags & SPECFLAG_BUTTON_RELEASED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (spec_mode == SPECMODE_DEATHCAM && m_flDeathCam < time) {
|
||||
spec_mode = SPECMODE_THIRDPERSON;
|
||||
InputNext();
|
||||
return;
|
||||
} else if (spec_mode == SPECMODE_FREE) {
|
||||
spec_mode = SPECMODE_THIRDPERSON;
|
||||
} else if (spec_mode == SPECMODE_FREEOVERVIEW) {
|
||||
spec_mode = SPECMODE_CHASEOVERVIEW;
|
||||
}
|
||||
|
||||
spec_flags |= SPECFLAG_BUTTON_RELEASED;
|
||||
|
||||
#if 0
|
||||
|
@ -288,9 +306,23 @@ NSClientSpectator::InputNext(void)
|
|||
void
|
||||
NSClientSpectator::InputPrevious(void)
|
||||
{
|
||||
if (spec_flags & SPECFLAG_BUTTON_RELEASED)
|
||||
if (m_flDeathCam > time)
|
||||
return;
|
||||
|
||||
if (spec_flags & SPECFLAG_BUTTON_RELEASED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (spec_mode == SPECMODE_DEATHCAM && m_flDeathCam < time) {
|
||||
spec_mode = SPECMODE_THIRDPERSON;
|
||||
InputNext();
|
||||
return;
|
||||
} else if (spec_mode == SPECMODE_FREE) {
|
||||
spec_mode = SPECMODE_THIRDPERSON;
|
||||
} else if (spec_mode == SPECMODE_FREEOVERVIEW) {
|
||||
spec_mode = SPECMODE_CHASEOVERVIEW;
|
||||
}
|
||||
|
||||
spec_flags |= SPECFLAG_BUTTON_RELEASED;
|
||||
|
||||
#if 0
|
||||
|
@ -354,8 +386,15 @@ NSClientSpectator::InputPrevious(void)
|
|||
void
|
||||
NSClientSpectator::InputMode(void)
|
||||
{
|
||||
if (spec_flags & SPECFLAG_BUTTON_RELEASED)
|
||||
if (spec_mode == SPECMODE_DEATHCAM && m_flDeathCam < time) {
|
||||
spec_mode = SPECMODE_THIRDPERSON;
|
||||
InputNext();
|
||||
return;
|
||||
}
|
||||
|
||||
if (spec_flags & SPECFLAG_BUTTON_RELEASED) {
|
||||
return;
|
||||
}
|
||||
|
||||
spec_flags |= SPECFLAG_BUTTON_RELEASED;
|
||||
|
||||
|
@ -422,7 +461,8 @@ NSClientSpectator::PreFrame(void)
|
|||
void
|
||||
NSClientSpectator::SpectatorTrackPlayer(void)
|
||||
{
|
||||
if (spec_mode == SPECMODE_THIRDPERSON
|
||||
if (spec_mode == SPECMODE_DEATHCAM
|
||||
|| spec_mode == SPECMODE_THIRDPERSON
|
||||
|| spec_mode == SPECMODE_FIRSTPERSON
|
||||
|| spec_mode == SPECMODE_CHASEOVERVIEW
|
||||
|| spec_mode == SPECMODE_LOCKEDCHASE ) {
|
||||
|
@ -466,6 +506,14 @@ NSClientSpectator::EvaluateEntity(void)
|
|||
EVALUATE_FIELD(movetype, SPECFL_TYPE)
|
||||
EVALUATE_FIELD(solid, SPECFL_TYPE)
|
||||
}
|
||||
|
||||
void
|
||||
NSClientSpectator::SpectatorDeathcam(NSRenderableEntity ourCorpse, NSEntity trackEntity, float waitTime)
|
||||
{
|
||||
spec_ent = num_for_edict(ourCorpse);
|
||||
spec_mode = SPECMODE_DEATHCAM;
|
||||
m_flDeathCam = time + waitTime;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue