Weapon prediction changes. Needs more testing, but this will effectively handle all weapon-animation stuff client-side.

This commit is contained in:
Marco Cawthorne 2019-03-01 00:04:33 +01:00
parent e345e8b321
commit 5276d1f8cc
17 changed files with 54 additions and 33 deletions

View File

@ -183,6 +183,16 @@ void CSQC_UpdateView(float w, float h, float focus)
setproperty(VF_ANGLES, view_angles + pSeat->vPunchAngle);
setproperty(VF_DRAWWORLD, 1);
renderscene();
pl.w_attack_next -= clframetime;
pl.w_idle_next -= clframetime;
if (pl.w_attack_next <= 0) {
pl.w_attack_next = 0;
}
if (pl.w_idle_next <= 0) {
pl.w_idle_next = 0;
}
View_DropPunchAngle();
Fade_Update((int)video_mins[0],(int)video_mins[1], (int)w, (int)h);
@ -336,8 +346,6 @@ void CSQC_Input_Frame(void)
if (pSeat->iInputDuck == TRUE) {
input_buttons |= INPUT_BUTTON8;
}
Game_Input();
}
@ -601,6 +609,9 @@ void CSQC_WorldLoaded(void)
precache_pic("{bigshot3", TRUE);
precache_pic("{bigshot4", TRUE);
precache_pic("{bigshot5", TRUE);
precache_pic("{scorch1", TRUE);
precache_pic("{scorch2", TRUE);
precache_pic("{scorch3", TRUE);
}
/*

View File

@ -21,11 +21,6 @@ void Predict_PreFrame(player pl)
pl.netvelocity = pl.velocity;
pl.netflags = pl.flags;
#ifdef VALVE
pl.net_w_attack_next = pl.w_attack_next;
pl.net_w_idle_next = pl.w_idle_next;
#endif
//self.netpmove_flags = self.pmove_flags;
//we want to predict an exact copy of the data in the new packet
@ -64,11 +59,6 @@ void Predict_PostFrame(player pl)
pl.velocity = pl.netvelocity;
pl.flags = pl.netflags;
#ifdef VALVE
pl.w_attack_next = pl.net_w_attack_next;
pl.w_idle_next = pl.net_w_idle_next;
#endif
//self.pmove_flags = self.netpmove_flags;
setorigin(pl, pl.origin);
//self.pmove_frame = servercommandframe + 1;

View File

@ -40,7 +40,7 @@ void Player_ReadEntity(float flIsNew)
pl.a_ammo1 = readbyte();
pl.a_ammo2 = readbyte();
pl.a_ammo3 = readbyte();
pl.w_attack_next = readfloat();
pl.w_idle_next = readfloat();
//pl.w_attack_next = readfloat();
//pl.w_idle_next = readfloat();
setorigin( pl, pl.origin );
}

View File

@ -110,8 +110,6 @@ void Ammo_AutoFill(float fWeapon);
void Ammo_BuyPrimary(void);
void Ammo_BuySecondary(void);
void Input_Handle( void );
void Animation_PlayerTop( float fFrame );
void Animation_PlayerTopTemp( float fFrame, float fTime );

View File

@ -13,7 +13,7 @@ Input_Handle
Handles impulse and whatnot
=================
*/
void Input_Handle(void)
void Game_Input(void)
{
// Dead, specatator
if (self.health <= 0) {

View File

@ -16,6 +16,7 @@ void TraceAttack_FireBullets( int iShots, vector vPos, int iDamage);
void Damage_Radius( vector vOrigin, entity eAttacker, float fDamage, float fRadius, int iCheckClip );
void Damage_Apply( entity eTarget, entity eAttacker, float fDamage, vector vHitPos, int iSkipArmor );
void Client_TriggerCamera( entity eTarget, vector vPos, vector vEndPos, float fResetTime );
void Game_Input(void);
entity eActivator;

View File

@ -51,7 +51,6 @@ void PutClientInServer(void)
void PlayerPreThink(void)
{
Game_PlayerPreThink();
Input_Handle();
}
void PlayerPostThink(void)

View File

@ -28,6 +28,16 @@ void Game_PlayerPreThink(void)
}
void Game_PlayerPostThink(void)
{
player pl = (player)self;
pl.w_attack_next -= input_timelength;
pl.w_idle_next -= input_timelength;
if (pl.w_attack_next <= 0) {
pl.w_attack_next = 0;
}
if (pl.w_idle_next <= 0) {
pl.w_idle_next = 0;
}
self.SendFlags = 1;
}
void Game_RunClientCommand(void)

View File

@ -13,7 +13,7 @@ Input_Handle
Handles impulse and whatnot
=================
*/
void Input_Handle(void)
void Game_Input(void)
{
if (self.button0) {
Weapons_Primary();
@ -49,6 +49,15 @@ void Input_Handle(void)
Weapons_AddItem(pl, WEAPON_TRIPMINE);
Weapons_AddItem(pl, WEAPON_SNARK);
}
if (self.impulse == 102) {
// Respawn all the entities
for (entity a = world; (a = findfloat(a, gflags, GF_CANRESPAWN));) {
CBaseEntity caw = (CBaseEntity)a;
caw.Respawn();
}
bprint(PRINT_HIGH, "Respawning all map entities...\n");
}
}
self.impulse = 0;

View File

@ -111,8 +111,8 @@ float Player_SendEntity(entity ePEnt, float fChanged)
WriteByte(MSG_ENTITY, pl.a_ammo1);
WriteByte(MSG_ENTITY, pl.a_ammo2);
WriteByte(MSG_ENTITY, pl.a_ammo3);
WriteFloat(MSG_ENTITY, pl.w_attack_next);
WriteFloat(MSG_ENTITY, pl.w_idle_next);
//WriteFloat(MSG_ENTITY, pl.w_attack_next);
//WriteFloat(MSG_ENTITY, pl.w_idle_next);
return TRUE;
}

View File

@ -52,3 +52,15 @@ void Decals_PlaceBig(vector pos)
decal.nextthink = time /*+ 0.1f*/;
#endif
}
void Decals_PlaceScorch(vector pos)
{
#ifdef CSQC
// TODO
#else
entity decal = Decals_Next();
setorigin(decal, pos);
decal.texture = sprintf("{scorch%d", floor(random(1,3)));
decal.think = infodecal;
decal.nextthink = time /*+ 0.1f*/;
#endif
}

View File

@ -31,6 +31,7 @@ void Effect_CreateExplosion( vector vPos ) {
eExplosion.nextthink = time + 0.05f;
te_explosion( vPos );
Decals_PlaceScorch(vPos);
#endif
}

View File

@ -675,20 +675,10 @@ void PMove_Run(void)
if (input_buttons & INPUT_BUTTON5) {
input_movevalues *= 0.50;
}
player pl = (player)self;
pl.w_attack_next -= input_timelength;
pl.w_idle_next -= input_timelength;
if (pl.w_attack_next <= 0) {
pl.w_attack_next = 0;
}
if (pl.w_idle_next <= 0) {
pl.w_idle_next = 0;
}
#endif
Game_Input();
PMove_WaterMove();
if (self.waterlevel >= 2) {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.