From c3329b3e73c6af9f3b23567cb7216ceeee39392d Mon Sep 17 00:00:00 2001 From: Chris Dawalt Date: Sat, 31 Jul 2021 05:53:41 -0400 Subject: [PATCH] last timer var fix, no pain flash on death --- src/client/draw.qc | 6 +- src/client/game_event.qc | 17 ++--- src/client/hud_crosshair.qc | 14 +++- src/client/scoreboard.qc | 1 - src/server/gamerules_multiplayer.qc | 3 + src/shared/event_custom.h | 3 + src/shared/event_custom.qc | 105 ++++++++++++++++++---------- src/shared/event_enum.h | 7 +- src/shared/player.h | 20 +++--- src/shared/player.qc | 54 ++++++-------- src/shared/util.qc | 29 ++++---- src/shared/weapons.qc | 12 ++-- 12 files changed, 151 insertions(+), 120 deletions(-) diff --git a/src/client/draw.qc b/src/client/draw.qc index b0d064d..f8a5dfd 100644 --- a/src/client/draw.qc +++ b/src/client/draw.qc @@ -128,7 +128,11 @@ drawPainFlash(void) void ClientGame_DamageDraw(void){ - if (pSeat->m_flDamageAlpha <= 0.0) { + // No alpha, or dead? No pain drawing + if( + pSeat->m_flDamageAlpha <= 0.0 || + getplayerkeyfloat(pSeat->m_ePlayer.entnum - 1, "*dead") == 1 + ){ return; } diff --git a/src/client/game_event.qc b/src/client/game_event.qc index 250798a..989ba75 100644 --- a/src/client/game_event.qc +++ b/src/client/game_event.qc @@ -29,13 +29,6 @@ ClientGame_EventParse(float fHeader) switch (fHeader) { - case EVENT_TS::PLAYER_DEATH: - // Require a tiny amount of time and a mouse release before a respawn, so that dying - // with the mouse held down isn't enough to trigger a respawn request. - pSeatLocal->m_bNeedPrimaryRelease = TRUE; - pSeatLocal->m_flReleaseTime = time + 0.15; - break; - case EV_OBITUARY: Obituary_Parse(); break; @@ -127,7 +120,6 @@ ClientGame_EventParse(float fHeader) FX_Impact_Melee(iType3, vOrigin3, vNormal3); break; - case EV_CHAT: float fSender = readbyte(); float fTeam = readbyte(); @@ -167,7 +159,7 @@ ClientGame_EventParse(float fHeader) HUD_WeaponPickupNotify(w); break; case EVENT_TS::SPAWN: - //time to read the config to send in the weapons one-by-one. + // time to read the config to send in the weapons one-by-one. deployConfig(); // so that any choice of weapon, same as before or even nothing, will still @@ -181,6 +173,9 @@ ClientGame_EventParse(float fHeader) int resetInventory = readbyte(); EV_TS_resetPlayer(pl, resetInventory); break; + case EVENT_TS::PLAYER_DEATH: + EV_PlayerDeath(); + break; //case EVENT_TS::PLAY_INSERT_SHELL_SND: // EV_TS_PlayInsertShellSound(pl); // break; @@ -202,7 +197,9 @@ ClientGame_EventParse(float fHeader) SoundPitched_Receive(); break; /* - //can this even happen ...? + // can this even happen anymore? + // If a drop-weapon call can be signaled by the server, not shared with the client & server + // reaching a drop call independently, then yes. case EVENT_TS::DROP_WEAPON: EV_TS_playerDropWeapon(pl); break; diff --git a/src/client/hud_crosshair.qc b/src/client/hud_crosshair.qc index 56aab09..5484353 100644 --- a/src/client/hud_crosshair.qc +++ b/src/client/hud_crosshair.qc @@ -95,15 +95,23 @@ void HUD_DrawCrosshair(void) { drawLaserDots = 2; } - // Is this a condition that forbids drawing hte laser dot on the screen? + // Is this a condition that forbids drawing the laser dot on the screen? if( + /* !pl.isReloading && - !(pSeat->m_eViewModel.frame == gunRef.iAnim_Deploy_Index && pl.w_attack_next > 0) && + !( + pSeat->m_eViewModel.frame == gunRef.iAnim_Deploy_Index && + pl.w_attack_next > 0 + ) && !pl.lasersightUnlockTime + */ + + !(pl.isReloading || (pl.lasersightUnlockTime && pl.w_idle_next <= 0)) + ){ trackLaserDots = FALSE; // force them to the center on the screen. }else{ - // Track their positions on the ingame world. Weird, I know. + // Track their positions on the ingame world. Weird, I know. trackLaserDots = TRUE; } }//END OF lasersight check diff --git a/src/client/scoreboard.qc b/src/client/scoreboard.qc index 712866b..fbc84cb 100644 --- a/src/client/scoreboard.qc +++ b/src/client/scoreboard.qc @@ -78,7 +78,6 @@ Scores_DrawTeam(player pl, vector pos) temp = getplayerkeyvalue(i, "ping"); l = stringwidth(temp, FALSE, [20,20]); - //TAGGG - IMPORTANT! // I don't know if TS does this too, but its scoreboard screen looks a lot like Half-Life's // so keeping this for now? diff --git a/src/server/gamerules_multiplayer.qc b/src/server/gamerules_multiplayer.qc index 293a6b2..0d6b142 100644 --- a/src/server/gamerules_multiplayer.qc +++ b/src/server/gamerules_multiplayer.qc @@ -1071,6 +1071,9 @@ TSMultiplayerRules::PlayerSpawn(base_player pp) // for player/spectator entity-change reasons? setPlayerMoneyDefault(pl); + // I guess this state counts as "dead"? + forceinfokey(pl, "*dead", "1"); + // we don't belong to any team forceinfokey(pl, "*team", "0"); forceinfokey(pl, "*deaths", "0"); //ftos(pl.deaths)); diff --git a/src/shared/event_custom.h b/src/shared/event_custom.h index f4c897f..8d1c2ab 100644 --- a/src/shared/event_custom.h +++ b/src/shared/event_custom.h @@ -48,6 +48,9 @@ void TS_resetPlayer(player localPlayer, BOOLEAN resetInventory) void EV_TS_resetPlayer(player localPlayer, BOOLEAN resetInventory) #endif +#ifdef CLIENT +void EV_PlayerDeath(void) +#endif #ifdef CSQC diff --git a/src/shared/event_custom.qc b/src/shared/event_custom.qc index 8103229..29b4ff3 100644 --- a/src/shared/event_custom.qc +++ b/src/shared/event_custom.qc @@ -119,8 +119,8 @@ void TS_Weapon_Draw(player localPlayer, int weaponEquipped, BOOLEAN useAkimbo ) -//This will be serverside only. Clientside should never call this. -//TAGGG - TODO. Would making this shared be OK? Seems to have worked for grenades and throwing knives +// This will be serverside only. Clientside should never call this. +// TODO. Would making this shared be OK? Seems to have worked for grenades and throwing knives // on removing themselves on running out of ammo. // Just remember that spawning the actual entitiy won't be happening clientside in any form. #ifdef SSQC @@ -135,7 +135,7 @@ void TS_Weapon_Drop() { // in case vOnUnEquip alters the weapon equipped, like a grenade switching out. int currentWeaponMem = pl.inventoryEquippedIndex; - //TAGGG - like equipping a new weapon, we have to let the existing equipped + // like equipping a new weapon, we have to let the existing equipped // weapon know that it's about to be unequipped. if(currentWeaponMem != -1){ pl.dropWeapon(currentWeaponMem, FALSE); @@ -151,7 +151,7 @@ void TS_Weapon_Drop() { -//TAGGG - CRITICAL! TS_playerEquippedWeapon methods dummied out to stop conflicts with +// CRITICAL! TS_playerEquippedWeapon methods dummied out to stop conflicts with // the new Nuclide way void TS_playerEquippedWeapon_Shared(player localPlayer, int newWeaponEquipped, BOOLEAN useAkimbo){ @@ -213,7 +213,7 @@ void TS_playerEquippedWeapon(player localPlayer, int newWeaponEquipped, BOOLEAN #endif #ifdef SSQC -//that's it really serverside. +// that's it really serverside. int _TS_playerEquippedWeapon(player localPlayer, int newWeaponEquipped, BOOLEAN useAkimbo){ player pl = localPlayer; @@ -233,11 +233,11 @@ void TS_playerEquippedWeapon(player localPlayer, int newWeaponEquipped, BOOLEAN } -//This is a received call from the client. -//We do need to let the server update first, which then tells the client -//of the updated state. Even though the client initiated the call in this case. -//The server can initiate the call too. -//Either side can call "TS_playerEquippedWeapon" to get the orders right. +// This is a received call from the client. +// We do need to let the server update first, which then tells the client +// of the updated state. Even though the client initiated the call in this case. +// The server can initiate the call too. +// Either side can call "TS_playerEquippedWeapon" to get the orders right. void CSEv_TS_playerEquippedWeapon_ii(int newWeaponEquipped, BOOLEAN useAkimbo){ player pl = (player)self; @@ -251,8 +251,6 @@ void CSEv_TS_playerEquippedWeapon_ii(int newWeaponEquipped, BOOLEAN useAkimbo){ - - #ifdef SSQC //SERVER ONLY. Send a request to change the animation of the viewmodel directly. void TS_PlayInsertShellSound(player localPlayer){ @@ -279,6 +277,7 @@ void EV_TS_PlayInsertShellSound(player localPlayer){ + // The server may want to tell the client to reset its viewmodel. // DUMMIED - nevermind that for now, assuming the logic is called from server/client // individually like a lot of weapon's logic. @@ -292,15 +291,20 @@ void TS_resetViewModel(player localPlayer){ msg_entity = localPlayer; multicast( [0,0,0], MULTICAST_ONE ); */ + + // IDEA: + // I don't think resetting w_idle_next and w_next_attack here would be very + // helpful. Same for in EV_TS_resetViewModel. } #else //CLIENT void TS_resetViewModel(player localPlayer){ - localPlayer.lasersightUnlockTime = FALSE; //reset EV_TS_resetViewModel(); } void EV_TS_resetViewModel(void){ - pSeat->m_iLastWeapon = -1; //any weapon slot choice will refresh the view model. + player pl = (player)self; + pSeat->m_iLastWeapon = -1; // any weapon slot choice will refresh the view model. + pl.lasersightUnlockTime = FALSE; resetViewModel(); } #endif @@ -345,6 +349,24 @@ void EV_TS_resetPlayer(player localPlayer, BOOLEAN resetInventory){ #endif +#ifdef CLIENT +// Called by the GameRules, PlayerDeath, for the client to do something as soon as possible. +void EV_PlayerDeath(void){ + printfline("EV_PlayerDeath"); + // Require a tiny amount of time and a mouse release before a respawn, so that dying + // with the mouse held down isn't enough to trigger a respawn request. + pSeatLocal->m_bNeedPrimaryRelease = TRUE; + pSeatLocal->m_flReleaseTime = time + 0.15; + + // Unfortunately not as effective as it may look. + // On the player using "kill" in console, a CSQC_Parse_Damage call happens shortly after + // this PlayerDeath one, somehow. Stopping damage-drawing on the "*dead" key being 1 works. + pSeat->m_flDamageAlpha = 0; +} +#endif + + + @@ -360,7 +382,7 @@ void _TS_playerDropWeapon(player localPlayer){ } */ -//TAGGG - TODO. Do anything clientside here too, maybe? Unsure. +// TODO. Do anything clientside here too, maybe? Unsure. void TS_playerDropWeapon(void){ sendevent("TS_playerDropWeapon", ""); }//END OF TS_playerDropWeapon @@ -446,9 +468,9 @@ void _TS_playerChangeFiremode(void ) { weapondata_gun_t* basicPointer = (weapondata_gun_t*) pl.getEquippedWeaponData(); weapondata_gun_t basicRef = *(basicPointer); - // If the bitmask for available firemodes for this weapon is just a flat "0" (none specified?) - // OR our bitmask matches the current firemode exactly (only one bit present), there is no point - // in trying to switch firemodes. + // If the bitmask for available firemodes for this weapon is just a flat "0" (none + // specified?) OR our bitmask matches the current firemode exactly (only one bit present), + // there is no point in trying to switch firemodes. if(basicRef.iBitsFireModes == 0){ return; } @@ -605,7 +627,6 @@ void _TS_playerUseItems(void){ //sound(pl, CHAN_ITEM, "weapons/switch.wav", 1, ATTN_NONE, 100.0f, SOUNDFLAG_PLAYER_SHARED, 0); /* - //TAGGG // unicast demo . Why does the sound play clientside the first few times anyway? // It shouldn't ever, with the clientside-call here disabled. #ifdef CLIENT @@ -653,7 +674,7 @@ void TS_playerUsePowerup(void){ } -//TAGGG - TODO. +// TODO. // Applies the currently equipped player powerup if there is one. void _TS_playerUsePowerup(void){ player pl = (player)self; @@ -691,7 +712,8 @@ void TS_playerCallAlt1(void){ } -// middle mouse wheel? Use for some stunts, at least ones that don't necessarily involve being mid-air. +// middle mouse wheel? Use for some stunts, at least ones that don't necessarily involve being +// mid-air. // double-tapping space does that. I think? void _TS_playerCallAlt1( void ) { player pl = (player)self; @@ -747,7 +769,7 @@ void _TS_playerCallAlt2(void){ -////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////// //!!!! SERVER EVENTS ONLY BELOW HERE #ifdef SSQC @@ -781,8 +803,8 @@ void CSEv_TS_Debug_getAngle_(void ) { //NOTICE - these event methods are server-side only. // anything in the "#ifdef S..." something. I dunno. -// The client sends a variety of messages at one time to the server to see if the player can really afford what they are -// requesting. Secure... probably. +// The client sends a variety of messages at one time to the server to see if the player can really +// afford what they are requesting. Secure... probably. //TODO - PROTOTYPE THIS OR SET IT UP. whatever. @@ -799,7 +821,8 @@ void CSEv_PlayerBuyAmmo_TS_i( int iAmmoTypeID, int iAmmoAmount ) { if(iAmmoTypeID != -1){ ammodata_t ammoRef = *ary_ammoData[iAmmoTypeID]; - //iActualAmmoAmount must be between 0 and ammoRef.iMax, inclusive on both. If the player had 0 ammo to begin with. + // iActualAmmoAmount must be between 0 and ammoRef.iMax, inclusive on both. If the player had + // 0 ammo to begin with. if(pl.ary_ammoTotal[iAmmoTypeID] + iActualAmmoAmount > ammoRef.iMax){ iActualAmmoAmount = ammoRef.iMax - pl.ary_ammoTotal[iAmmoTypeID]; } @@ -858,9 +881,10 @@ void CSEv_PlayerBuyAmmo_TS_i( int iAmmoTypeID, int iAmmoAmount ) { -//This is used to signify that we're done sending weapon config over and want to pick a weapon to start equipped with. -//Order appears to be the highest slot number first, unless there is a weapon in slot 3 (small machine guns). -//Then it gets equipped instead. +// This is used to signify that we're done sending weapon config over and want to pick a weapon to +// start equipped with. +// Order appears to be the highest slot number first, unless there is a weapon in slot 3 (small +// machine guns). Then it gets equipped instead. void CSEv_PlayerBuyWeapon_TS_end_( void ) { player pl = (player)self; @@ -868,8 +892,9 @@ void CSEv_PlayerBuyWeapon_TS_end_( void ) { playerEquipIdeal(pl); } -//Support upgrades, akimbo, etc. Include ammo if necessary! -//ACTUALLY... ammo will be signaled for purchase separately. The client still determines how much ammo to buy though. +// Support upgrades, akimbo, etc. Include ammo if necessary! +// ACTUALLY... ammo will be signaled for purchase separately. The client still determines how much +// ammo to buy though. void CSEv_PlayerBuyWeapon_TS_ii( int iWeaponTypeID, int iBuyOpts ) { player pl = (player)self; printf("Buying weaponTypeID:%i\n", iWeaponTypeID); @@ -895,14 +920,18 @@ void CSEv_PlayerBuyWeaponThw_TS_iii( int iWeaponTypeID, int iBuyOpts, int iCount -//Goes through the available weapons and picks what would make sense to equip. -//TAGGG TODO - SUGGESTION. Don't equip a weapon automatically if it's out of ammo, + + +// Goes through the available weapons and picks what would make sense to equip. +// SUGGESTION. Don't equip a weapon automatically if it's out of ammo, // assuming we have an option that isn't out of ammo. -//TAGGG TODO MAJOR - check to see what place was previously selected, and then look to see where we can grab a new weapon if that changes things. -//That is, we have a few cases with special circumstances. -//If a singular version of an akimbo weapon was dropped, equip it's now singular version (1 of the two weapons left in inventory). -//I think that's it actually. -//nah, just check for that special case when dropping a weapon +// MAJOR - check to see what place was previously selected, and then look to see where we can grab +// a new weapon if that changes things. +// That is, we have a few cases with special circumstances. +// If a singular version of an akimbo weapon was dropped, equip it's now singular version (1 of the +// two weapons left in inventory). +// I think that's it actually. +// nah, just check for that special case when dropping a weapon void playerEquipIdeal(player localPlayer){ //go through all the players weapons. whichever has the highest slot number, except for 5, gets picked @@ -954,7 +983,7 @@ void playerEquipIdeal(player localPlayer){ // Throwing knives can use either version here though, but everything works with _shared. // Plus changes to what's serverside are sent to the client soon enough anyway, doing so here // seems unnecessary. - //TAGGG - TODO, CRITICAL. Check other places. + // TODO, CRITICAL. Check other places. // Could anywhere else benefit from TS_playerEquippedWeapon being changed to TS_playerEquippedWeapon_Shared ? TS_playerEquippedWeapon_Shared(pl, weaponDynamicID_toEquip, TRUE); diff --git a/src/shared/event_enum.h b/src/shared/event_enum.h index 3760769..5b70d32 100644 --- a/src/shared/event_enum.h +++ b/src/shared/event_enum.h @@ -1,17 +1,16 @@ +// Best to avoid choices redundant with those offered by Nuclide. +// Not sure if EXPLOSION and SHAKE are already provided. enum EVENT_TS{ SPAWN = EV_SEPARATOR, RESET_VIEW_MODEL, RESET_PLAYER, - // Is this in nuclide now? I don't think so, verify. - // Same for EXPLOSION / SHAKE below. DROP_WEAPON probably is if we use - // the nuclide way for that. PLAYER_DEATH, EFFECT_EXPLOSION, EFFECT_SHAKE, DROP_WEAPON, - //TAGGG - NEW. Like EV_IMPACT but to paint a decal only. + // NEW. Like EV_IMPACT but to paint a decal only. EV_PLACEDECAL, EV_IMPACT_MELEE, SOUNDPITCHED, diff --git a/src/shared/player.h b/src/shared/player.h index 80d8539..3ec246f 100644 --- a/src/shared/player.h +++ b/src/shared/player.h @@ -24,6 +24,11 @@ class player:base_player //TAGGG - TODO! Put the PREDICTED_INT/FLOAT/whatever stuff on what needs it. + // Determines if this player should be a fake-spectator with MoTD and buymenu (FALSE) + // or be a physical player that can equip weapons and interact with the world (TRUE). + // Jumping to fake-spectator on death will force this to FALSE too. + // Yet to be implemented. + BOOL spawned; #ifdef SSQC @@ -77,8 +82,6 @@ class player:base_player int recentLaserDistanceDisplay; - BOOL lasersightUnlockTime; - BOOL forceViewModelUpdate; // NOTICE - individual dynamic weapons have "forceBodygroup1Submodel". "prev_forceBodygroup1Submodel" is player-wide // (here) instead because we only need to keep track of changes in a weapon's forceBodygroup1Submodel while that weapon @@ -157,12 +160,7 @@ class player:base_player - // !!! shared for now, WAS clientside only! - //When can the viewmodel pick an idle animaition? Interrupted by anything else of course. Server need not apply. - float nextViewModelAnimationTime; - - //TODO - see how to handle saving / loadig these on the client's end. //Server probably dosen't need to store config stuff at all. #ifdef CSQC @@ -173,9 +171,13 @@ class player:base_player // Come to think of it this might bring up a lot of other questions. float clientTime_prev; - // When should the viewmodel anim switch to the frozen idle anim? - float nextViewModelFreezeIdleTime; + // IDEA: should lasersightUnlockTime be networked? No idea, + // same for w_freeze_idle_next. + BOOL lasersightUnlockTime; + // When should the viewmodel anim switch to the frozen idle anim? + float w_freeze_idle_next; + //In the weapon select menu, what is currently being highlighted & picked if fire is pressed? //Also used as a base for finding the "previous" or "next" weapon while mouse wheeling through int weaponSelectHighlightID; diff --git a/src/shared/player.qc b/src/shared/player.qc index bf61514..d769346 100644 --- a/src/shared/player.qc +++ b/src/shared/player.qc @@ -75,15 +75,10 @@ player::ReceiveEntity(float new, float fl) } float temp_flViewModelFrame; - float temp_nextViewModelAnimationTime; temp_flViewModelFrame = readfloat(); - temp_nextViewModelAnimationTime = readfloat(); - // If all of below is commented out, just keep this I guess? - nextViewModelAnimationTime = temp_nextViewModelAnimationTime; - // TODO - any more sophistication needed? laser-lock versions? custom idle delays? etc.? // do we need to do this here, I: forget, I don't think so @@ -101,13 +96,14 @@ player::ReceiveEntity(float new, float fl) // (Bad to assume that the plain variant was always the one called) printfline("***VIEWMODEL FRAME SYNC ISSUE CORRECTED: was:%d suggested:%d", pSeat->m_eViewModel.frame, temp_flViewModelFrame); - if(temp_nextViewModelAnimationTime <= 0 || temp_nextViewModelAnimationTime == 255){ - temp_nextViewModelAnimationTime = 1; // ??? - }else{ - temp_nextViewModelAnimationTime = temp_nextViewModelAnimationTime + time; - } + // NOTE - this var has been abandoned, Nuclide's w_idle_next is used instead. + //if(temp_nextViewModelAnimationTime <= 0 || temp_nextViewModelAnimationTime == 255){ + // temp_nextViewModelAnimationTime = 1; // ??? + //}else{ + // temp_nextViewModelAnimationTime = temp_nextViewModelAnimationTime + time; + //} - TS_Weapons_ViewAnimation(temp_flViewModelFrame, temp_nextViewModelAnimationTime); + TS_Weapons_ViewAnimation(temp_flViewModelFrame, w_idle_next); } */ @@ -535,11 +531,6 @@ player::SendEntity(entity ePEnt, float fChanged) } WriteFloat(MSG_ENTITY, flViewModelFrame); - if(nextViewModelAnimationTime == -1 || nextViewModelAnimationTime == 0 || nextViewModelAnimationTime < time){ - WriteFloat(MSG_ENTITY, -1); - }else{ - WriteFloat(MSG_ENTITY, nextViewModelAnimationTime - time); - } @@ -781,8 +772,7 @@ player::reset(BOOLEAN resetInventory){ // doing this in reset too to avoid a little glitch. weaponSelectHighlightID = -1; - nextViewModelAnimationTime = -1; - nextViewModelFreezeIdleTime = -1; + w_freeze_idle_next = -1; flOldZoom = 1; flCurrentZoom = 1; @@ -1217,19 +1207,12 @@ player::preThink(void){ // maybe rename this to "viewModelAnimationDuration" // and let "nextViewModelAnimationTime" be re-used if we ever support idle animations like HL does? // doubt that really though. - /* - if(nextViewModelAnimationTime != -1){ - printfline("nextViewModelAnimationTime?? %.2f", (nextViewModelAnimationTime - time)); - } - */ - if(nextViewModelAnimationTime != -1 && time >= nextViewModelAnimationTime){ - nextViewModelAnimationTime = -1; - lasersightUnlockTime = FALSE; //forget me. - } - // When a viewmodel's nextViewModelFreezeIdleTime has expired, force to the frozen idle frame. - if(nextViewModelFreezeIdleTime != -1 && time >= nextViewModelFreezeIdleTime){ - nextViewModelFreezeIdleTime = -1; + // When a viewmodel's w_freeze_idle_next has expired, force to the frozen idle frame. + if(w_freeze_idle_next == 0){ + w_freeze_idle_next = -1; + + if(inventoryEquippedIndex != -1){ dynaRef = ary_myWeapons[inventoryEquippedIndex]; @@ -1273,7 +1256,7 @@ player::preThink(void){ } }//END OF inventoryEquippedIndex - }//END OF nextViewModelFreezeIdleTime check + }//END OF w_freeze_idle_next check }//preThink @@ -1295,6 +1278,15 @@ player::postThink(void){ w_attack_next_nonet -= cltime_delta; if(w_attack_next_nonet < 0)w_attack_next_nonet = 0; */ + + // client-only, so it uses this. + // Why does this decrease way too fast if it uses input_timelength instead? + // Vars that are networked (see w_attack_akimbo_next in ts/src/shared/input.qc) + // don't appear to have that problem. + if(w_freeze_idle_next != -1){ + w_freeze_idle_next = max(0, w_freeze_idle_next - cltime_delta); + } + }//postThink #endif diff --git a/src/shared/util.qc b/src/shared/util.qc index 483b22a..c46837a 100644 --- a/src/shared/util.qc +++ b/src/shared/util.qc @@ -352,14 +352,13 @@ void TS_Weapons_ViewAnimation(int i, float fDuration) { //printfline("TS_Weapons_ViewAnimation: %i %.2f", i, fDuration); - player pl = (player)self; + + pl.w_idle_next = fDuration; #ifdef CLIENT TS_View_PlayAnimation(i, fDuration); #else pl.flViewModelFrame = i; -// NOT AN AMAZING IDEA. Quick for testing - pl.nextViewModelAnimationTime = time + fDuration; #endif pl.weapontime = 0.0f; } @@ -369,12 +368,12 @@ TS_Weapons_ViewAnimation_noLaserLock(int i, float fDuration) { //printfline("TS_Weapons_ViewAnimation_noLaserLock: %i %.2f", i, fDuration); player pl = (player)self; + + pl.w_idle_next = fDuration; #ifdef CLIENT TS_View_PlayAnimation_noLaserLock(i, fDuration); #else pl.flViewModelFrame = i; -// NOT AN AMAZING IDEA. Quick for testing - pl.nextViewModelAnimationTime = time + fDuration; #endif pl.weapontime = 0.0f; } @@ -385,12 +384,12 @@ TS_Weapons_ViewAnimation_EndIdle(int i, float fDuration) { //printfline("TS_Weapons_ViewAnimation_EndIdle: %i %.2f", i, fDuration); player pl = (player)self; + + pl.w_idle_next = fDuration; #ifdef CLIENT TS_View_PlayAnimation_EndIdle(i, fDuration); #else pl.flViewModelFrame = i; -// NOT AN AMAZING IDEA. Quick for testing - pl.nextViewModelAnimationTime = time + fDuration; #endif pl.weapontime = 0.0f; } @@ -400,12 +399,12 @@ TS_Weapons_ViewAnimation_EndIdle_custom(int i, float fDuration, float fIdleEndOf { //printfline("TS_Weapons_ViewAnimation_EndIdle_custom: %i %.2f %.2f", i, fDuration, fIdleEndOffset); player pl = (player)self; + + pl.w_idle_next = fDuration; #ifdef CLIENT TS_View_PlayAnimation_EndIdle_custom(i, fDuration, fIdleEndOffset); #else pl.flViewModelFrame = i; -// NOT AN AMAZING IDEA. Quick for testing - pl.nextViewModelAnimationTime = time + fDuration; #endif pl.weapontime = 0.0f; } @@ -439,9 +438,8 @@ TS_View_PlayAnimation(int iSequence, float fDuration){ //MODDD //viewModelFrameChangedRecently = 1; - pl.nextViewModelFreezeIdleTime = -1; //assume this? + pl.w_freeze_idle_next = -1; //assume this? pl.lasersightUnlockTime = FALSE; - pl.nextViewModelAnimationTime = time + fDuration; } void @@ -451,9 +449,8 @@ TS_View_PlayAnimation_noLaserLock(int iSequence, float fDuration){ pl.weapontime = 0.0f; SAVE_STATE(pl.weapontime); - pl.nextViewModelFreezeIdleTime = -1; //assume this? + pl.w_freeze_idle_next = -1; //assume this? pl.lasersightUnlockTime = TRUE; - pl.nextViewModelAnimationTime = time + fDuration; } @@ -466,9 +463,8 @@ TS_View_PlayAnimation_EndIdle(int iSequence, float fDuration){ // ?? Do we want to do this or not then pl.lasersightUnlockTime = FALSE; //reset - pl.nextViewModelAnimationTime = time + fDuration; // unspecified fIdleEndOffset time? default to 0 (exactly at animation end) - pl.nextViewModelFreezeIdleTime = pl.nextViewModelAnimationTime + 0 + getViewModelAnimExtraDuration(); + pl.w_freeze_idle_next = fDuration + 0 + getViewModelAnimExtraDuration(); } @@ -480,8 +476,7 @@ TS_View_PlayAnimation_EndIdle_custom(int iSequence, float fDuration, float fIdle SAVE_STATE(pl.weapontime); pl.lasersightUnlockTime = FALSE; //reset - pl.nextViewModelAnimationTime = time + fDuration; - pl.nextViewModelFreezeIdleTime = pl.nextViewModelAnimationTime + fIdleEndOffset + getViewModelAnimExtraDuration(); + pl.w_freeze_idle_next = fDuration + fIdleEndOffset + getViewModelAnimExtraDuration(); } #endif diff --git a/src/shared/weapons.qc b/src/shared/weapons.qc index 6a10110..5acb367 100644 --- a/src/shared/weapons.qc +++ b/src/shared/weapons.qc @@ -39,8 +39,8 @@ void weapon_base_setWholeAttackDelay(player localPlayer, float amount){ // I think this is a good idea, right? // or, is only for the client better? Turned out to be the case somewhere else... //#ifdef SERVER - //SAVE_STATE(localPlayer.w_attack_next); - //SAVE_STATE(localPlayer.w_attack_akimbo_next); + SAVE_STATE(localPlayer.w_attack_next); + SAVE_STATE(localPlayer.w_attack_akimbo_next); //#endif }//END OF weapon_base_setWholeAttackDelay @@ -50,7 +50,7 @@ void weapon_base_setLeftAttackDelay(player localPlayer, float amount){ localPlayer.w_attack_next = amount; // ??? - //SAVE_STATE(localPlayer.w_attack_next); + SAVE_STATE(localPlayer.w_attack_next); } // akimbo secondary delay only? @@ -58,7 +58,7 @@ void weapon_base_setRightAttackDelay(player localPlayer, float amount){ localPlayer.w_attack_akimbo_next = amount; - //SAVE_STATE(localPlayer.w_attack_akimbo_next); + SAVE_STATE(localPlayer.w_attack_akimbo_next); } @@ -71,7 +71,7 @@ void weapon_base_setLeftAttackDelay_AtLeast(player localPlayer, float amount){ if(localPlayer.w_attack_next <= amount){ localPlayer.w_attack_next = amount; - //SAVE_STATE(localPlayer.w_attack_next); + SAVE_STATE(localPlayer.w_attack_next); } } @@ -81,7 +81,7 @@ void weapon_base_setRightAttackDelay_AtLeast(player localPlayer, float amount){ if(localPlayer.w_attack_akimbo_next <= amount){ localPlayer.w_attack_akimbo_next = amount; - //SAVE_STATE(localPlayer.w_attack_akimbo_next); + SAVE_STATE(localPlayer.w_attack_akimbo_next); } }