Unscrew player animation and fix a bug involving botlib overriding

important playermethods on bot-clients with CBaseEntity ones.
This commit is contained in:
Marco Cawthorne 2021-01-06 15:54:17 +01:00
parent ae6f3ebdfb
commit 3662565879
12 changed files with 38 additions and 32 deletions

View file

@ -115,8 +115,6 @@ player::draw(void)
}
}
var float autocvar_standheight = 0;
var float autocvar_crouchheight = 0;
float
player::predraw(void)
{

View file

@ -49,7 +49,7 @@ Player_ReceiveEntity(float new)
float fl;
player pl = (player)self;
if (new == TRUE) {
if (new == TRUE || pl.classname != "player") {
spawnfunc_player();
pl.classname = "player";
pl.solid = SOLID_SLIDEBOX;

View file

@ -47,6 +47,12 @@ void ClientConnect(float csqc_active)
{
int playercount = 0;
#ifdef BOT_INCLUDED
if (clienttype(self) == CLIENTTYPE_BOT) {
spawnfunc_bot();
} else
#endif
/* make sure you never change the classname. ever. */
if (self.classname != "player") {
spawnfunc_player();
@ -148,12 +154,6 @@ void PutClientInServer(void)
{
g_grMode.PlayerSpawn((base_player)self);
#ifdef BOT_INCLUDED
if (clienttype(self) == CLIENTTYPE_BOT) {
spawnfunc_bot();
}
#endif
/* activate all game_playerspawn entities */
for (entity a = world; (a = find(a, ::targetname, "game_playerspawn"));) {
CBaseTrigger t = (CBaseTrigger)a;

View file

@ -19,6 +19,7 @@ void
Game_RunClientCommand(void)
{
Footsteps_Update();
Animation_PlayerUpdate();
PMove_Run();
}

View file

@ -114,8 +114,6 @@ HLGameRules::LevelNewParms(void)
void
HLGameRules::PlayerPostFrame(base_player pl)
{
Animation_PlayerUpdate();
if (autocvar_sv_playerkeepalive)
pl.SendFlags |= PLAYER_KEEPALIVE;

View file

@ -14,7 +14,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
float Weapons_GetAim(int);
void Weapons_PickupNotify(base_player pl, int w);
void Weapons_RefreshAmmo(base_player pl);
void Weapons_SwitchBest(base_player pl);

View file

@ -47,13 +47,12 @@ depending on what the player is doing
*/
void Animation_PlayerUpdate(void) {
self.basebone = cvar("spinebone"); // gettagindex(self, "Bip01 Spine");
#ifdef SERVER
if (self.baseframe_time < time) {
base_player pl = (base_player)self;
self.baseframe = Weapons_GetAim(pl.activeweapon);
self.baseframe_old = self.frame;
}
#endif
/* in order to appear jumping, we want to not be on ground,
* but also make sure we're not just going down a ramp */

View file

@ -1,9 +1,10 @@
#includelist
../../shared/cstrike/defs.h
../../shared/cstrike/flags.h
../../shared/cstrike/player.h
../../shared/valve/weapon_common.h
../../shared/cstrike/animations.h
../../shared/cstrike/animations.c
../../shared/cstrike/player.h
../../shared/cstrike/item_c4bomb.h
@ -17,7 +18,6 @@
../../shared/cstrike/fx_smokenade.c
../../shared/cstrike/weapons_cstrike.c
../../shared/valve/weapon_common.h
../../shared/cstrike/w_ak47.c
../../shared/cstrike/w_deagle.c
../../shared/cstrike/w_knife.c

View file

@ -14,18 +14,22 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
.float baselerpfrac;
.float lerpfrac;
.float frame_time;
.float frame_old;
.float fWasCrouching;
.float frame2time;
.float frame2;
.float baseframe2time;
.float baseframe1time;
.float baseframe2;
// For lerping, sigh
#ifdef CLIENT
.float frame_last;
.float baseframe_last;
#else
.float subblendfrac;
.float subblend2frac;
#endif
void Animation_Print(string sWow) {
#ifdef CLIENT
@ -35,6 +39,9 @@ void Animation_Print(string sWow) {
#endif
}
var int autocvar_bone_spinebone = 0;
var int autocvar_bone_baseframe = 0;
var int autocvar_bone_frame = 0;
/*
=================
Animation_PlayerUpdate
@ -43,10 +50,11 @@ Called every frame to update the animation sequences
depending on what the player is doing
=================
*/
void Animation_PlayerUpdate(void) {
self.basebone = gettagindex(self, "Bip01 Spine");
void
Animation_PlayerUpdate(void)
{
self.basebone = gettagindex(self, "Bip01 Spine1");
#ifdef SERVER
// TODO: Make this faster
if (self.frame_time < time) {
player pl = (player)self;
@ -77,9 +85,7 @@ void Animation_PlayerUpdate(void) {
self.baseframe = ANIM_RUN;
}
}
#endif
#ifdef CLIENT
// Lerp it down!
if (self.lerpfrac > 0) {
self.lerpfrac -= frametime * 5;
@ -124,7 +130,7 @@ void Animation_PlayerUpdate(void) {
}
self.subblend2frac = self.angles[0];
#endif
self.angles[0] = self.angles[2] = 0;
if (!(self.flags & FL_ONGROUND)) {
@ -138,7 +144,7 @@ void Animation_PlayerUpdate(void) {
self.fWasCrouching = (self.flags & FL_CROUCHING);
}
#ifdef SERVER
#ifndef CLIENT
// On the CSQC it's done in Player.c
self.subblendfrac =
self.subblend2frac = self.v_angle[0] / 90;
@ -152,15 +158,21 @@ Animation_PlayerTop
Changes the animation sequence for the upper body part
=================
*/
void Animation_PlayerTop(float fFrame) {
void
Animation_PlayerTop(float fFrame)
{
#ifndef CLIENT
self.frame = fFrame;
self.frame_old = fFrame;
#endif
}
void Animation_PlayerTopTemp(float fFrame, float fTime) {
void
Animation_PlayerTopTemp(float fFrame, float fTime)
{
#ifndef CLIENT
self.frame = fFrame;
self.frame_time = time + fTime;
#ifdef SERVER
self.SendFlags |= PLAYER_FRAME;
#endif
}

View file

@ -127,13 +127,13 @@ w_crowbar_primary(void)
Weapons_ViewAnimation(trace_fraction >= 1 ? CBAR_ATTACK3MISS:CBAR_ATTACK3HIT);
}
#ifdef SERVER
if (pl.flags & FL_CROUCHING) {
Animation_PlayerTopTemp(ANIM_SHOOTCROWBAR, 0.5f);
} else {
Animation_PlayerTopTemp(ANIM_CR_SHOOTCROWBAR, 0.42f);
}
#ifdef SERVER
Sound_Play(self, CHAN_WEAPON, "weapon_crowbar.miss");
if (trace_fraction >= 1.0) {

View file

@ -200,7 +200,6 @@ string Weapons_GetDeathmessage(int id)
return "";
}
#ifdef SERVER
float Weapons_GetAim(int id)
{
if (g_weapons[id].aimanim != __NULL__) {
@ -209,7 +208,6 @@ float Weapons_GetAim(int id)
return 0;
}
#endif
#ifdef CLIENT
void Weapons_HUDPic(int id, int s, vector pos, float a)

View file

@ -40,6 +40,7 @@ typedef struct
void(int, vector, float) hudpic;
} weapon_t;
float Weapons_GetAim(int);
void Weapons_Reload(void);
void Weapons_DrawCrosshair(void);
void Weapons_MakeVectors(void);