base_player: Add Death() method that'll let the client know when to render
the 'Deathcam'. Also add the mentioned UpdateDeathcam().
This commit is contained in:
parent
3882611087
commit
93124fa6de
7 changed files with 73 additions and 4 deletions
|
@ -407,6 +407,8 @@ CSQC_UpdateView(float w, float h, float focus)
|
|||
View_DrawViewModel();
|
||||
} else if (pl.health > 0) {
|
||||
View_DrawViewModel();
|
||||
} else if (getplayerkeyvalue(pl.entnum-1, "*dead") == "1") {
|
||||
pl.UpdateDeathcam();
|
||||
}
|
||||
|
||||
/* this is running whenever we're doing 'buildcubemaps' */
|
||||
|
|
|
@ -8,6 +8,7 @@ base_client:NSSurfacePropEntity
|
|||
virtual void(void) ClientInputFrame;
|
||||
|
||||
#ifdef CLIENT
|
||||
virtual void(void) UpdateDeathcam;
|
||||
virtual float(void) predraw;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -5,6 +5,16 @@ base_client::ClientInputFrame(void)
|
|||
}
|
||||
|
||||
#ifdef CLIENT
|
||||
void
|
||||
base_client::UpdateDeathcam(void)
|
||||
{
|
||||
/* death cam */
|
||||
view_angles[2] = 45.0f;
|
||||
setproperty(VF_ORIGIN, pSeat->m_vecPredictedOrigin);
|
||||
setproperty(VF_CL_VIEWANGLES, view_angles);
|
||||
setproperty(VF_ANGLES, view_angles);
|
||||
}
|
||||
|
||||
float
|
||||
base_client::predraw(void)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
float Math_LerpAngle(float fStart, float fEnd, float fAmount);
|
||||
float Math_Lerp(float fA, float fB, float fPercent);
|
||||
float Math_FixDelta(float fDelta);
|
||||
vector Math_FixDeltaVector(vector);
|
||||
vector Math_Reflect(vector v1, vector v2);
|
||||
vector Math_RandomVector(float flyup);
|
||||
vector Math_RotateAroundPivot(vector pos, vector pivot, float degr);
|
||||
vector Math_RotateAroundPivot(vector pos, vector pivot, float degr);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* lerping function that accounts for negative degrees */
|
||||
float
|
||||
Math_LerpAngle(float fStart, float fEnd, float fAmount)
|
||||
{
|
||||
|
@ -21,12 +22,15 @@ Math_LerpAngle(float fStart, float fEnd, float fAmount)
|
|||
return shortest_angle * fAmount;
|
||||
}
|
||||
|
||||
/* linear lerp function */
|
||||
float
|
||||
Math_Lerp(float fA, float fB, float fPercent)
|
||||
{
|
||||
return (fA * (1 - fPercent)) + (fB * fPercent);
|
||||
}
|
||||
|
||||
/* tries to make sure an angle value stays within certain constraints...
|
||||
* however it doesn't account for much larger discrepancies */
|
||||
float
|
||||
Math_FixDelta(float fDelta)
|
||||
{
|
||||
|
@ -35,15 +39,28 @@ Math_FixDelta(float fDelta)
|
|||
} else if (fDelta <= -180) {
|
||||
fDelta += 360;
|
||||
}
|
||||
|
||||
return fDelta;
|
||||
}
|
||||
|
||||
vector
|
||||
Math_FixDeltaVector(vector in)
|
||||
{
|
||||
in[0] = Math_FixDelta(in[0]);
|
||||
in[1] = Math_FixDelta(in[1]);
|
||||
in[2] = Math_FixDelta(in[2]);
|
||||
return in;
|
||||
}
|
||||
|
||||
/* takes an impact angle and a plane normal, returns a new trajectory */
|
||||
vector
|
||||
Math_Reflect(vector v1, vector v2)
|
||||
{
|
||||
return v1 - 2 * dotproduct(v1, v2) * v2;
|
||||
}
|
||||
|
||||
/* returns a random vector, if the first paramete is true it'll make
|
||||
* sure that vertical velocity is ALWAYS positive */
|
||||
vector
|
||||
Math_RandomVector(float fFlyUp)
|
||||
{
|
||||
|
@ -60,6 +77,7 @@ Math_RandomVector(float fFlyUp)
|
|||
return tmp * 2.0f;
|
||||
}
|
||||
|
||||
/* takes a position and a pivot point and rotates point by X degrees around the pivot (YAW) */
|
||||
vector
|
||||
Math_RotateAroundPivot(vector pos, vector pivot, float degr)
|
||||
{
|
||||
|
@ -67,4 +85,4 @@ Math_RotateAroundPivot(vector pos, vector pivot, float degr)
|
|||
new[0] = pivot[0] + (pos[0] - pivot[0]) * cos(degr) - (pos[1] - pivot[1]) * sin(degr);
|
||||
new[1] = pivot[1] + (pos[0] - pivot[0]) * sin(degr) + (pos[1] - pivot[1]) * cos(degr);
|
||||
return new;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ base_player:base_client
|
|||
virtual void(void) EvaluateEntity;
|
||||
virtual float(entity, float) SendEntity;
|
||||
|
||||
virtual void(void) Death;
|
||||
virtual void(void) MakePlayer;
|
||||
virtual void(void) MakeTempSpectator;
|
||||
#endif
|
||||
|
|
|
@ -361,7 +361,7 @@ base_player::Respawn(void)
|
|||
}
|
||||
|
||||
/*
|
||||
=================*
|
||||
=================
|
||||
base_player::MakeTempSpectator
|
||||
|
||||
This is what dead players in round matches become, or when we spawn
|
||||
|
@ -384,10 +384,45 @@ base_player::MakeTempSpectator(void)
|
|||
maxspeed = 250;
|
||||
takedamage = DAMAGE_NO;
|
||||
forceinfokey(this, "*spec", "2");
|
||||
forceinfokey(this, "*dead", "0");
|
||||
}
|
||||
|
||||
/*
|
||||
=================*
|
||||
=================
|
||||
base_player::MakeDead
|
||||
|
||||
Sets all the appropriate attributes to make sure we're dead
|
||||
=================
|
||||
*/
|
||||
void
|
||||
base_player::Death(void)
|
||||
{
|
||||
classname = "player";
|
||||
health = max_health = 0;
|
||||
armor = 0;
|
||||
g_items = 0;
|
||||
activeweapon = 0;
|
||||
effects = 0;
|
||||
alpha = 1.0f;
|
||||
SetModelindex(0);
|
||||
SetMovetype(MOVETYPE_NONE);
|
||||
SetSolid(SOLID_NOT);
|
||||
takedamage = DAMAGE_NO;
|
||||
forceinfokey(this, "*spec", "0");
|
||||
forceinfokey(this, "*dead", "1");
|
||||
viewzoom = 1.0;
|
||||
view_ofs = [0,0,0];
|
||||
vehicle = __NULL__;
|
||||
velocity = [0,0,0];
|
||||
gravity = __NULL__;
|
||||
customphysics = Empty;
|
||||
iBleeds = FALSE;
|
||||
forceinfokey(this, "*deaths", ftos(deaths));
|
||||
setsize(this, [0,0,0], [0,0,0]);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
base_player::MakeTempSpectator
|
||||
|
||||
This is what dead players in round matches become, or when we spawn
|
||||
|
@ -410,6 +445,7 @@ base_player::MakePlayer(void)
|
|||
movetype = MOVETYPE_WALK;
|
||||
takedamage = DAMAGE_YES;
|
||||
forceinfokey(this, "*spec", "0");
|
||||
forceinfokey(this, "*dead", "0");
|
||||
viewzoom = 1.0;
|
||||
vehicle = __NULL__;
|
||||
velocity = [0,0,0];
|
||||
|
|
Loading…
Reference in a new issue