From b8fd0a0f6ff77caf4998605d26f844445d702336 Mon Sep 17 00:00:00 2001 From: Chris Dawalt Date: Fri, 20 Aug 2021 20:20:35 -0400 Subject: [PATCH] scope zoom, stunt dot, ammo counters more responsive under net latency, HUD order more sensible, forced origin no longer default --- src/client/defs.h | 3 +- src/client/draw.h | 4 + src/client/draw.qc | 51 +++-- src/client/game_event.qc | 4 + src/client/hud.qc | 28 ++- src/client/hud_crosshair.qc | 5 +- src/client/progs.src | 1 + src/client/util.qc | 2 - src/client/view.qc | 32 ++- src/server/defs.h | 3 + src/server/gamerules_multiplayer.qc | 26 ++- src/server/progs.src | 10 +- src/shared/defs.h | 1 - src/shared/event_custom.h | 1 + src/shared/event_custom.qc | 114 +++++++--- src/shared/event_enum.h | 1 + src/shared/input.qc | 4 +- src/shared/player.h | 12 +- src/shared/player.qc | 196 +++++++++++++----- src/shared/util.h | 3 +- src/shared/util.qc | 11 +- src/shared/weapons.h | 13 +- src/shared/weapons.qc | 53 ++--- src/shared/weapons/weapon_ak47.qc | 31 ++- src/shared/weapons/weapon_akimbocolts.qc | 1 + src/shared/weapons/weapon_barrettm82.qc | 16 +- src/shared/weapons/weapon_benellim3.qc | 14 +- src/shared/weapons/weapon_beretta.qc | 1 + src/shared/weapons/weapon_beretta_akimbo.qc | 1 + src/shared/weapons/weapon_combatknife.qc | 3 +- src/shared/weapons/weapon_contenderg2.qc | 14 +- src/shared/weapons/weapon_deserteagle.qc | 14 +- src/shared/weapons/weapon_fiveseven.qc | 1 + src/shared/weapons/weapon_fiveseven_akimbo.qc | 1 + src/shared/weapons/weapon_glock18.qc | 1 + src/shared/weapons/weapon_glock20.qc | 1 + src/shared/weapons/weapon_hkpdw.qc | 14 +- src/shared/weapons/weapon_karate.qc | 3 +- src/shared/weapons/weapon_katana.qc | 5 +- src/shared/weapons/weapon_m16a4.qc | 16 +- src/shared/weapons/weapon_m4a1.qc | 15 +- src/shared/weapons/weapon_m60.qc | 1 + src/shared/weapons/weapon_m61grenade.qc | 4 +- src/shared/weapons/weapon_mac10.qc | 1 + src/shared/weapons/weapon_miniuzi.qc | 1 + src/shared/weapons/weapon_miniuzi_akimbo.qc | 1 + src/shared/weapons/weapon_mossberg500.qc | 1 + src/shared/weapons/weapon_mp5k.qc | 14 +- src/shared/weapons/weapon_mp5sd.qc | 14 +- src/shared/weapons/weapon_ragingbull.qc | 14 +- src/shared/weapons/weapon_rugermk1.qc | 1 + src/shared/weapons/weapon_sawedoff.qc | 1 + src/shared/weapons/weapon_sealknife.qc | 3 +- src/shared/weapons/weapon_skorpion.qc | 1 + src/shared/weapons/weapon_skorpion_akimbo.qc | 1 + src/shared/weapons/weapon_socommk23.qc | 1 + src/shared/weapons/weapon_socommk23_akimbo.qc | 1 + src/shared/weapons/weapon_spas12.qc | 1 + src/shared/weapons/weapon_steyraug.qc | 14 +- src/shared/weapons/weapon_steyrtmp.qc | 1 + src/shared/weapons/weapon_ump.qc | 14 +- src/shared/weapons/weapon_usas12.qc | 1 + 62 files changed, 569 insertions(+), 252 deletions(-) create mode 100644 src/client/draw.h diff --git a/src/client/defs.h b/src/client/defs.h index e918869..027efe6 100644 --- a/src/client/defs.h +++ b/src/client/defs.h @@ -29,8 +29,7 @@ vector g_hudres; /* // Do we need these? Note the similarly named "g_hud_color" already above! // Going to keep the latter two for compatability. -// Yes using old VGUI is kinda crappy but good for now. -vector vHUDColor; // Defined in HUD_Draw (HUD.c) +vector vHUDColor; */ vector g_UI_Color; diff --git a/src/client/draw.h b/src/client/draw.h new file mode 100644 index 0000000..323f824 --- /dev/null +++ b/src/client/draw.h @@ -0,0 +1,4 @@ + +void TS_HUD_DamageDraw(void); +void TS_HUD_drawPainArrows(void); +void TS_HUD_drawPainFlash(void); diff --git a/src/client/draw.qc b/src/client/draw.qc index 0c4236b..33dce72 100644 --- a/src/client/draw.qc +++ b/src/client/draw.qc @@ -27,19 +27,40 @@ extern var string g_damage_spr_l; extern var string g_damage_spr_r; -void drawPainArrows(void); -void drawPainFlash(void); -void Custom_DamageDraw(void); - - -// WARNING: don't try drawing any 2D things on screen here, they'll be rendered on top of -// and ultimately lost, at least I think that's how it goes +// WARNING: don't try drawing any 2D things on screen here, they'll be rendered +// over soon and ultimately lost, at least I think that's how it goes void ClientGame_PreDraw(void) { + player pl = (player)pSeat->m_ePlayer; + // TODO: may as well make TS_View_HandleZoom a player method at this point, + // do the state check inside player then + if(pl.iState == PLAYER_STATE::SPAWNED){ + TS_View_HandleZoom(); + } -} + + pl.viewzoom = pl.flZoomCurrent; + // PreDraw is called right after viewzoom is set by Nuclide, so this overrides + // it. That is fine. + // Although, the 'setproperty' line already happened by the time this + // method was reached, so these areas from Nuclide need to be redone. + //////////////////////////////////////////////////////////////////// + setproperty(VF_AFOV, cvar("fov") * pl.viewzoom); + + if (autocvar_zoom_sensitivity && pl.viewzoom < 1.0f) { + setsensitivityscaler(pl.viewzoom * autocvar_zoom_sensitivity); + } else { + setsensitivityscaler(pl.viewzoom); + } + + if (pl.viewzoom <= 0.0f) { + setsensitivityscaler(1.0f); + } + //////////////////////////////////////////////////////////////////// + +}//ClientGame_PreDraw // Happens right before the CSQC_RenderScene call seen in Nuclide's client/draw.qc. @@ -62,10 +83,6 @@ Custom_LatePreDraw(void) void ClientGame_PostDraw(void) { - // This is just the right place - occurs right beofre a HUD_Draw call so that the HUD - // is drawn on top of the potentially bright-red pain flash, rather than obscurred by it - Custom_DamageDraw(); - // To replicate what Nuclide does for the normal muzzle flash entity in frame-logic: // reduce the alpha every frame to quickly fade away entity m_eMuzzleflashAkimbo = pSeatLocal->m_eMuzzleflashAkimbo; @@ -83,7 +100,7 @@ ClientGame_PostDraw(void) // copied from Nuclide void -drawPainArrows(void) +TS_HUD_drawPainArrows(void) { vector center; vector rel_pos; @@ -133,7 +150,7 @@ drawPainArrows(void) // and now for the screen-wide pain flash. void -drawPainFlash(void) +TS_HUD_drawPainFlash(void) { //drawfill( video_mins, video_res, clrRed, VGUI_WINDOW_FGALPHA ); @@ -153,7 +170,7 @@ drawPainFlash(void) void -Custom_DamageDraw(void){ +TS_HUD_DamageDraw(void){ // No alpha, or dead? No pain drawing if( @@ -163,8 +180,8 @@ Custom_DamageDraw(void){ return; } - drawPainFlash(); - drawPainArrows(); + TS_HUD_drawPainFlash(); + TS_HUD_drawPainArrows(); // Nuclide's default had no modifier on clframetime ( * 1). pSeat->m_flDamageAlpha -= clframetime * 1.7; diff --git a/src/client/game_event.qc b/src/client/game_event.qc index d6d421d..3b94c9e 100644 --- a/src/client/game_event.qc +++ b/src/client/game_event.qc @@ -185,6 +185,10 @@ ClientGame_EventParse(float fHeader) case EVENT_TS::EQUIP_CALLBACK:{ EV_EquipCallback(); }break; + case EVENT_TS::TEST_CALLBACK:{ + int arg_mesageID = readint(); + EV_TestCallback(arg_mesageID); + }break; case EVENT_TS::SOUNDPITCHED:{ SoundPitched_Receive(); }break; diff --git a/src/client/hud.qc b/src/client/hud.qc index 5e6f7e4..7aedb67 100644 --- a/src/client/hud.qc +++ b/src/client/hud.qc @@ -76,21 +76,24 @@ HUD_Draw(void) g_hud_color = autocvar_con_color * (1 / 255); - /* little point in not drawing these, even if you don't have a suit */ - Weapons_DrawCrosshair(); - TS_HUD_DrawWeaponSelect(); - Obituary_Draw(); - Textmenu_Draw(); - //TAGGG - NEw ////////////////////////////////////////////////////////////// - // moved to shared/player.qc, clientside player::preThink + // moved to shared/player.qc //TS_View_HandleZoom(); //printfline("SCOPE LEVEL %.2f", pl.flZoomCurrent); if(pl.flZoomCurrent < 0.5){ //is this < 40/80 mag? yes. HUD_DrawScope(); + + // TS custom damage draw method. + // Done here to be drawn on top of the Scope. + TS_HUD_DamageDraw(); }else{ + + // Draw the crosshair over damage, rather not shade over important UI, but + // up to taste here + TS_HUD_DamageDraw(); + // We'll leave details like extra details for the lasersight and the // weight bars at a bare minimum (should be drawn at all times, oversight // in TS 2.1 that they're missing from melee views like with knives, @@ -99,6 +102,17 @@ HUD_Draw(void) } ////////////////////////////////////////////////////////////// + + + // Assuming that drawing these on top of the scope is a good idea. + // "Weapons_DrawCrosshair" is for tapping into the weapon's drawHUD methods, + // Nuclide methods in its weapons struct + Weapons_DrawCrosshair(); + TS_HUD_DrawWeaponSelect(); + Obituary_Draw(); + Textmenu_Draw(); + + //TAGGG - new ////////////////////////////////////////////////////////////// drawTimer(); diff --git a/src/client/hud_crosshair.qc b/src/client/hud_crosshair.qc index 6a38895..7e649ee 100644 --- a/src/client/hud_crosshair.qc +++ b/src/client/hud_crosshair.qc @@ -131,7 +131,10 @@ HUD_DrawCrosshair(void){ int thirdBelongingTo = 0; - float ratioNumber = getViewPitchRelativeRatio(pl.pitch); + // pl.pitch is only updated on server pings, might not be wise to use here, + // looks choppy with any kind of ping time + + float ratioNumber = getViewPitchRelativeRatio(view_angles.x); float newDegreeRad = (ratioNumber * (270 - 90) + 90) * (M_PI/180); //printfline("MY ANGLE? %.2f", (ratioNumber * (270 - 90) + 90) ); diff --git a/src/client/progs.src b/src/client/progs.src index 0e0e49d..6d62fcc 100644 --- a/src/client/progs.src +++ b/src/client/progs.src @@ -51,6 +51,7 @@ hud_weaponselect.h inventory_logic_draw.h view.h hud.h +draw.h // Yes, really, server/entity... We have a clientside rendering component to this. ../server/entity/ts_powerup.h diff --git a/src/client/util.qc b/src/client/util.qc index 6018537..f86ce19 100644 --- a/src/client/util.qc +++ b/src/client/util.qc @@ -111,8 +111,6 @@ drawSpriteNumber( // Convenience methods for drawing without any font-related struct, just some font's // load ID. Otherwise close to the engine-provided drawstring and drawtextfield // methods. "drawfont" is a global provided by the engine (fteextensions.qc). -// Compare with src/vgui/font.cpp's "Font_DrawText" and "Font_DrawField" which take a -// font struct. void Gfx_Text(vector vPos, string sText, vector vSize, vector vRGB, float flAlpha, float flDrawFlag, float flFont) { diff --git a/src/client/view.qc b/src/client/view.qc index f4692f9..08081a8 100644 --- a/src/client/view.qc +++ b/src/client/view.qc @@ -205,7 +205,8 @@ TS_View_ChangeViewModelPost(void) SAVE_STATE(pl.weapontime); //TAGGG - NEW VAR SAVE_STATE(pl.w_attack_akimbo_next); - SAVE_STATE(pl.flZoomTarget); + SAVE_STATE(pl.iZoomLevel); + //SAVE_STATE(pl.flZoomTarget); //TAGGG - also new line. It is a good idea to reset the event // on changing models, right? @@ -789,6 +790,10 @@ TS_View_ShowMuzzleflash(int index, int akimboChoice) } } + + +//var int oldZoomLevel = 0; + //TAGGG - loaned from The Wastes. void TS_View_HandleZoom(void) { @@ -808,15 +813,23 @@ void TS_View_HandleZoom(void) //printfline("WHATS GOING ON %.2f %.2f %.2f %.2f %.2f", pl.flZoomEnd, pl.flZoomTarget, pl.flZoomStart, pl.flZoomLerp, pl.flZoomCurrent); - //TAGGG - any references to STAT_VIEWZOOM are now garbage. - // Rely on pl.flZoomTarget instead, it's sent to the client every frame - // and should be handled serverside anyway. - // flZoomEnd is actually the "target" zoom we want to reach. - // flZoomStart is the zoom we started at, at the time of the change. - // flZoomLerp is how far along we are from oldZoom to currentZoom. - // flZoomCurrent is the actual zoom we are at this very moment. + //TAGGG - no other codebase refers to STAT_VIEWZOOM, best to replace anything + // involving that. + // in case of some unexpected change. + // TODO: this might have an issue if the player were to change weapons and end up + // on the same zoom level as a previous weapon, despite the two weapons having + // different target values (like 0.4 vs. 0.6) at their own zoom level #1's. + // A check for being a different equipped weapon type + // (pl.activeweapon vs. pl.activeweapon_zoomprev, set only by setZoomLevel) + // ought to work. But that would be a very strange case anyway + if(pl.iZoomLevel != pl.iZoomLevelPrev){ + pl.setZoomLevel(pl.iZoomLevel); + } + if (pl.flZoomEnd != pl.flZoomTarget ) { + //printfline("NEW ZOOM DETECTED: %.2f -> %.2f (zoomlev: %i)", pl.flZoomEnd, pl.flZoomTarget, pl.iZoomLevel); + // is setting flZoomStart to flZoomEnd or flZoomCurrent a better idea? // at flZoomEnd means, on changing before the current lerp has finished, it jumps to beginning // at the end point of the lerp in progress. But starting at flZoomCurrent might be smoother? @@ -834,6 +847,7 @@ void TS_View_HandleZoom(void) // 0.8 can be safe. // The Wastes default was 4. + // !!! clframetime, frametime, or input_timelength ? pl.flZoomLerp += clframetime * 5.7; if(pl.flZoomLerp >= 1.0){ @@ -848,7 +862,7 @@ void TS_View_HandleZoom(void) // Set this, since Nuclide will read it in and apply instantly. // So same effect without having to edit Nuclide, this pipes it over for it // to do the setproperty thing below to apply - pl.viewzoom = pl.flZoomCurrent; + //pl.viewzoom = pl.flZoomCurrent; ////setproperty(VF_AFOV, DEFAULT_FOV * pl.flZoomCurrent); ////setsensitivityscaler(pl.flZoomCurrent); diff --git a/src/server/defs.h b/src/server/defs.h index 6e633d5..6c5c30f 100644 --- a/src/server/defs.h +++ b/src/server/defs.h @@ -38,6 +38,9 @@ var int autocvar_mp_friendlyfire = FALSE; var int autocvar_fcs_swapteams = FALSE; /* Swaps spawnpoints */ var int autocvar_fcs_maxmoney = 99999; //TAGG - was 16000. +var int autocvar_debug_spawnpointforced = 0; + + //TAGGG - not used, don't know if the TS really supported denying weapon drop-ables. // Doesn't mean that can't be implemented anyway (check this CVar, and if on while about // to spawn a drop-able, deny the request and don't drop at all on player death) diff --git a/src/server/gamerules_multiplayer.qc b/src/server/gamerules_multiplayer.qc index 0e68e1b..a15d225 100644 --- a/src/server/gamerules_multiplayer.qc +++ b/src/server/gamerules_multiplayer.qc @@ -857,22 +857,32 @@ TSMultiplayerRules::PlayerRespawn(base_player pp, int fTeam) // If so whatever picks a spawn point should probably come with a spawn point to // put the player anyway, including droptofloor. + + if(autocvar_debug_spawnpointforced == 1){ + #ifdef TS_CUSTOM_SPAWN_ORIGIN - myOrigin = TS_CUSTOM_SPAWN_ORIGIN; + myOrigin = TS_CUSTOM_SPAWN_ORIGIN; #else - myOrigin = eSpawn.origin; + printfline("WARNING! debug_spawnpointforced set, but TS_CUSTOM_SPAWN_ORIGIN is not defined!"); + myOrigin = eSpawn.origin; #endif - - + #ifdef TS_CUSTOM_SPAWN_VANGLE - pl.angles = TS_CUSTOM_SPAWN_VANGLE; - pl.v_angle = TS_CUSTOM_SPAWN_VANGLE; + pl.angles = TS_CUSTOM_SPAWN_VANGLE; #else - pl.angles = eSpawn.angles; + printfline("WARNING! debug_spawnpointforced set, but TS_CUSTOM_SPAWN_VANGLE is not defined!"); + pl.angles = eSpawn.angles; +#endif + }else{ + + myOrigin = eSpawn.origin; + pl.angles = eSpawn.angles; + } + // Why do we have to do this now? No clue. // something about animation.h maybe? I Forget. pl.v_angle = pl.angles; -#endif + Client_FixAngle(pl, pl.angles); diff --git a/src/server/progs.src b/src/server/progs.src index cd2d6cd..a4cd72a 100644 --- a/src/server/progs.src +++ b/src/server/progs.src @@ -25,9 +25,12 @@ -// FORCE A SPAWN LOC. Sometimes easier for testing to have a constant set of spawn coords/angle. -// Use with the right start params to jump into the map at debug. +// FORCE A SPAWN LOC. Sometimes easier for testing to have a constant set of +// spawn coords/angle. +// Below intneded for TS Bikini unlesss otherwise noted. +// Only applies if CVar "debug_spawnpoints" is set +// I forget, only origins //#define TS_CUSTOM_SPAWN_ORIGIN '21 -1291 -380' //#define TS_CUSTOM_SPAWN_ORIGIN '-754 569 -380' @@ -39,8 +42,7 @@ //#define TS_CUSTOM_SPAWN_ORIGIN [93.1, -80.0, -380.0] //#define TS_CUSTOM_SPAWN_VANGLE [0.0, 90.0, 0.0] - -// ts_awaken: the ledge thingy. +// ts_awaken: the ledge //#define TS_CUSTOM_SPAWN_ORIGIN [12.4, -1350.6, -292.0] //#define TS_CUSTOM_SPAWN_VANGLE [-12.5, 0.5, 0.0] diff --git a/src/shared/defs.h b/src/shared/defs.h index eb736c2..36caab0 100644 --- a/src/shared/defs.h +++ b/src/shared/defs.h @@ -1,5 +1,4 @@ - enum TS_GameMode{ DEATHMATCH, TEAM_DEATHMATCH, diff --git a/src/shared/event_custom.h b/src/shared/event_custom.h index 93c52cd..a371a9c 100644 --- a/src/shared/event_custom.h +++ b/src/shared/event_custom.h @@ -12,6 +12,7 @@ void TS_playerEquippedWeapon_Shared(player pl, int newWeaponEquipped, BOOL useAk void _TS_playerEquippedWeapon(player pl, int newWeaponEquipped, BOOL useAkimbo); void TS_playerEquippedWeapon(player pl, int newWeaponEquipped, BOOL useAkimbo); void EV_EquipCallback(void); +void EV_TestCallback(int arg_messageID); #endif #ifdef SERVER void _TS_playerEquippedWeapon(player pl, int newWeaponEquipped, BOOL useAkimbo); diff --git a/src/shared/event_custom.qc b/src/shared/event_custom.qc index 150a427..ac14e84 100644 --- a/src/shared/event_custom.qc +++ b/src/shared/event_custom.qc @@ -188,27 +188,6 @@ TS_playerEquippedWeapon(player pl, int newWeaponEquipped, BOOL useAkimbo){ } -// EXPERIMENTAL. If the currently equipped weapon has been changed, reject -// messages received between the time I sent an order to change the current wepaon -// and the time it takes to get a response that the new weapon was seen by the server. -// This stops out-of-date calls coming in from reverting the zoom (or whatever other var) -// back to the old state. -// Or, example: -// Var A is networked (server sends updates to the client of its current value to keep it -// from going too far out of sync). -// var A starts at 30 both places. Say the ping is 500 milliseconds. -// Client sets var A to 12, sends a message to the server to have it changed too. -// But, during those 500 milliseconds to reach the server, messages sent from the server -// with the old A value (30), sent before the client sent the A-update to the server, reach -// the client and rever the value of A back to that 30. -// Only after the A-update of 12 reaches the server and the server updates the client back -// does that stop. -void -EV_EquipCallback(void){ - player pl = (player)self; - pl.equippedWeaponWaitingForCallback = FALSE; -} - #endif #ifdef SERVER // that's it really serverside. @@ -254,6 +233,89 @@ CSEv_TS_playerEquippedWeapon_ii(int newWeaponEquipped, BOOL useAkimbo){ + + + + +#ifdef SERVER + +void +CSEv_TS_Test_i(int arg){ + player pl = (player)self; + WriteByte( MSG_MULTICAST, SVC_CGAMEPACKET ); + WriteByte( MSG_MULTICAST, EVENT_TS::TEST_CALLBACK ); + WriteInt( MSG_MULTICAST, arg ); + msg_entity = pl; + multicast( [0,0,0], MULTICAST_ONE_R ); +} + +#else + + + +// begins from clientside! Manually call from wherever +// DUMMIED FOR NOW. If seriously used, the player needs a global counter +// that goes up with each call of this function (where globTemp is). +void TestCallback_Initiate(void){ + /* + globTemp = ((float)globTemp + 1); //% 255; // use a byte or not? + pl.equippedWeaponWaitingForCallback = TRUE; + pl.equippedWeaponWaitingForCallback_ID = globTemp; + pl.equippedWeaponWaitingForCallback_maxWaitTime = time + 0.8; + sendevent("TS_Test", "i", pl.equippedWeaponWaitingForCallback_ID); + */ +} + +// EXPERIMENTAL. If the currently equipped weapon has been changed, reject +// messages received between the time I sent an order to change the current wepaon +// and the time it takes to get a response that the new weapon was seen by the server. +// This stops out-of-date calls coming in from reverting the zoom (or whatever other var) +// back to the old state. +// Or, example: +// Var A is networked (server sends updates to the client of its current value to keep it +// from going too far out of sync). +// var A starts at 30 both places. Say the ping is 500 milliseconds. +// Client sets var A to 12, sends a message to the server to have it changed too. +// But, during those 500 milliseconds to reach the server, messages sent from the server +// with the old A value (30), sent before the client sent the A-update to the server, reach +// the client and rever the value of A back to that 30. +// Only after the A-update of 12 reaches the server and the server updates the client back +// does that stop. +void +EV_EquipCallback(void){ + player pl = (player)self; + pl.equippedWeaponWaitingForCallback = FALSE; +} +void +EV_TestCallback(int arg_messageID){ + player pl = (player)self; + + if(pl.equippedWeaponWaitingForCallback == FALSE){ + printfline("??? Not expecting a callback message!"); + } + + if(arg_messageID == pl.equippedWeaponWaitingForCallback_ID){ + printfline("EV_TestCallback: Received up to date message!"); + pl.equippedWeaponWaitingForCallback = FALSE; + }else{ + printfline("EV_TestCallback: Message out of date! Exp:%i Recv:%i", pl.equippedWeaponWaitingForCallback_ID, arg_messageID); + } +} + +#endif + + + + + + + + + + + + + // 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. @@ -518,10 +580,10 @@ _TS_playerChangeFiremode(void ) { //this power of 2 is a valid fireMode? pick it (*fireModeVar) = currentChoice; - #ifdef CLIENT +#ifdef CLIENT // effectively SAVE_STATE on whatever choice (*fireModeVar_net) = currentChoice; - #endif +#endif return; } @@ -595,9 +657,9 @@ _TS_playerUseItems(void){ #if defined(CLIENT_CMD_SAFEMODE) && defined(CLIENT) // Have a much simpler version instead - #ifdef CLIENT +#ifdef CLIENT localsound("weapons/switch.wav", CHAN_AUTO, 1.0f); - #endif +#endif return; #endif @@ -842,6 +904,8 @@ CSEv_TS_Debug_getAngle_(void ) { // Note that trying to exceed an ammo's max allowed ammount still caps at the ammmo's capacity. // And if the player can't afford the ammount, the next greatest ammount to use the remaining money // will be used instead. +// !!! PENDING REMOVAL. +// Nothing calls this, and it's the wrong name anyway (_i, should be _ii at the end I belive). void CSEv_PlayerBuyAmmo_TS_i( int iAmmoTypeID, int iAmmoAmount ) { player pl = (player)self; diff --git a/src/shared/event_enum.h b/src/shared/event_enum.h index 4a2fd93..57c5548 100644 --- a/src/shared/event_enum.h +++ b/src/shared/event_enum.h @@ -11,6 +11,7 @@ enum EVENT_TS{ //DROP_WEAPON, FX_TS_EXPLOSION_GRENADE, EQUIP_CALLBACK, + TEST_CALLBACK, SOUNDPITCHED, SOUNDPITCHED_CHANNEL, TEST, diff --git a/src/shared/input.qc b/src/shared/input.qc index 84e5a22..2d56a5b 100644 --- a/src/shared/input.qc +++ b/src/shared/input.qc @@ -136,9 +136,9 @@ Game_Input(void) if(pl.doFiremodeChange){ // so they say? - #ifdef CLIENT +#ifdef CLIENT //sendevent("TS_playerChangeFiremode", ""); - #endif +#endif int iOldFiremode = pl.ary_myWeapons[pl.inventoryEquippedIndex].iFireMode; _TS_playerChangeFiremode(); pl.doFiremodeChange = FALSE; diff --git a/src/shared/player.h b/src/shared/player.h index 486d260..56f0697 100644 --- a/src/shared/player.h +++ b/src/shared/player.h @@ -121,19 +121,26 @@ class player:base_player // Set this (or the setZoom method) to tap into the lerp system properly. // When noticed (client/view.qc), the current zoom value goes to flZoomStart and // flZoomTarget goes to flZoomEnd. The lerp goes from Start to End for a smooth transition. - PREDICTED_FLOAT(flZoomTarget); + // TODO - soon, no longer serverside, not even involved there anymore at all. + // This can still be on server and clientside, since determining it from iZoomLevel + // given a weapon is possible (ak47's zoom #1 is this, barrett's zoom #1 is that, etc.) + //PREDICTED_FLOAT(flZoomTarget); + float flZoomTarget; #ifdef CLIENT float flZoomEnd; float flZoomStart; float flZoomLerp; float flZoomCurrent; + float flZoomTarget; + float iZoomLevelPrev; // for clientside to detect a change #endif //////////////////////////////// #ifdef CLIENT BOOL equippedWeaponWaitingForCallback; + int equippedWeaponWaitingForCallback_ID; float equippedWeaponWaitingForCallback_maxWaitTime; @@ -484,8 +491,9 @@ class player:base_player virtual vector(vector vecInputAngles)View_approachAngleOffsetTarget; virtual void (void)updateTimers; - virtual void(float arg_theZoom) setZoom; + virtual void(int arg_iZoomLevel) setZoomLevel; virtual void(void) resetZoom; + virtual void(void) resetZoomSoft; virtual void(int arg_newIndex) setInventoryEquippedIndex; diff --git a/src/shared/player.qc b/src/shared/player.qc index 2a8b894..e2998b1 100644 --- a/src/shared/player.qc +++ b/src/shared/player.qc @@ -18,7 +18,7 @@ // little test //var float otherTimer = 0; -//#define FORCE_NETWORK_ALL_INVENTORY +#define FORCE_NETWORK_ALL_INVENTORY /* all potential SendFlags bits we can possibly send */ @@ -172,6 +172,12 @@ player::ReceiveEntity(float new, float fl) // printfline("WELL hey WHAT:%i new:%i", oldPlayerWeapEq, inventoryEquippedIndex); //} + + // TODO! Test surrounding with this + if(!equippedWeaponWaitingForCallback){ + + } + // important to keep pl.activeweapon in sync inventoryEquippedIndex = inventoryEquippedIndex_temp; //setInventoryEquippedIndex(inventoryEquippedIndex_temp); @@ -188,19 +194,25 @@ player::ReceiveEntity(float new, float fl) isReloading = readbyte(); isChangingIronsight = readbyte(); - //flZoomTarget = readfloat(); - float tempThing = readfloat(); - /* - if(tempThing != flZoomTarget){ - printfline("flZoomTarget change! %.2f - %.2f", flZoomTarget, tempThing); - } - */ - // That's a good thing, yes? - if(!equippedWeaponWaitingForCallback){ - flZoomTarget = tempThing; + + if(fl & PLAYER_UNUSED2){ + + //float flZoomTarget_temp = readfloat(); + //flZoomTarget = flZoomTarget_temp; + + + int iZoomLevel_temp = readbyte(); + if(iZoomLevel_temp != iZoomLevel){ + // printfline("!!! ZoomLevel change A. %i -> %i (%.2f)", iZoomLevel, iZoomLevel_temp, time); + } + + if(!equippedWeaponWaitingForCallback){ + iZoomLevel = iZoomLevel_temp; + } } - iZoomLevel = readbyte(); + + nextAkimboAttackPreference = readbyte(); akimboDualFireToleranceTime = readfloat(); grenadeFireIndex = readbyte() - 1; @@ -291,8 +303,10 @@ player::ReceiveEntity(float new, float fl) // TODO! Check for any change in ammo values like this: + // Or maybe not, looks like Weapons_AmmoUpdate isn't needed for FreeTS, HUD draw methods + // already use the current weapon's ammo valus per weapon on the HUD without it // if (fl & PLAYER_AMMO1 || fl & PLAYER_AMMO2 || fl & PLAYER_AMMO3) - Weapons_AmmoUpdate(this); + //Weapons_AmmoUpdate(this); setorigin(this, origin); @@ -348,9 +362,12 @@ so we can roll them back later. void player::PredictPreFrame(void) { + //printfline("---PREDIT PRE FRAME"); + /* the generic client attributes */ base_player::PredictPreFrame(); + // client's way of calling prethink preThink(); @@ -394,7 +411,7 @@ player::PredictPreFrame(void) SAVE_STATE(w_attack_akimbo_next); SAVE_STATE(isReloading); SAVE_STATE(isChangingIronsight); - SAVE_STATE(flZoomTarget); + //SAVE_STATE(flZoomTarget); SAVE_STATE(iZoomLevel); SAVE_STATE(nextAkimboAttackPreference); SAVE_STATE(akimboDualFireToleranceTime); @@ -450,6 +467,10 @@ player::PredictPreFrame(void) SAVE_STATE_ARY(ary_ammoTotal, i); } + // viewzoom must be set by the end of PrePredict or else it will not + // reach the Nuclide logic looking at it in time to be applied. + // No need here now I think? + //this.viewzoom = this.flZoomCurrent; } /* @@ -462,9 +483,21 @@ Where we roll back our values to the ones last sent/verified by the server. void player::PredictPostFrame(void) { + //printfline("---PREDIT POST FRAME"); + + + /* +#ifdef CLIENT + if(iState == PLAYER_STATE::SPAWNED){ + TS_View_HandleZoom(); + } +#endif + */ + /* the generic client attributes */ base_player::PredictPostFrame(); + // client's way of calling postthink postThink(); @@ -508,8 +541,17 @@ player::PredictPostFrame(void) ROLL_BACK(w_attack_akimbo_next); ROLL_BACK(isReloading); ROLL_BACK(isChangingIronsight); - ROLL_BACK(flZoomTarget); + //ROLL_BACK(flZoomTarget); + + /* + if(iZoomLevel != iZoomLevel_net){ + printfline("!!! ZoomLevel change B. %i -> %i (%.2f)", iZoomLevel, iZoomLevel_net, time); + } + */ ROLL_BACK(iZoomLevel); + + + ROLL_BACK(nextAkimboAttackPreference); ROLL_BACK(akimboDualFireToleranceTime); ROLL_BACK(grenadeFireIndex); @@ -567,6 +609,7 @@ player::PredictPostFrame(void) void player::EvaluateEntity(void) { + /* the generic client attributes */ base_player::EvaluateEntity(); @@ -699,7 +742,14 @@ player::EvaluateEntity(void) } - + // iZoomLevel or flZoomTarget ? + if( + //ATTR_CHANGED(flZoomTarget) + //|| + ATTR_CHANGED(iZoomLevel) + ){ + SendFlags |= PLAYER_UNUSED2; + } SAVE_STATE(anim_top); @@ -714,7 +764,7 @@ player::EvaluateEntity(void) SAVE_STATE(w_attack_akimbo_next); SAVE_STATE(isReloading); SAVE_STATE(isChangingIronsight); - SAVE_STATE(flZoomTarget); + //SAVE_STATE(flZoomTarget); SAVE_STATE(iZoomLevel); SAVE_STATE(nextAkimboAttackPreference); SAVE_STATE(akimboDualFireToleranceTime); @@ -883,8 +933,10 @@ player::SendEntity(entity ePEnt, float fChanged) WriteFloat(MSG_ENTITY, w_attack_akimbo_next ); WriteByte(MSG_ENTITY, isReloading ); WriteByte(MSG_ENTITY, isChangingIronsight ); - WriteFloat(MSG_ENTITY, flZoomTarget); - WriteByte(MSG_ENTITY, iZoomLevel); + if(fChanged & PLAYER_UNUSED2){ + //WriteFloat(MSG_ENTITY, flZoomTarget); + WriteByte(MSG_ENTITY, iZoomLevel); + } WriteByte(MSG_ENTITY, nextAkimboAttackPreference); WriteFloat(MSG_ENTITY, akimboDualFireToleranceTime); WriteByte(MSG_ENTITY, grenadeFireIndex + 1); @@ -1097,6 +1149,7 @@ player::reset(BOOL resetInventory){ // should this even make any assumptions about this? //iState = ?; + resetZoom(); #ifdef CLIENT @@ -1153,7 +1206,6 @@ player::reset(BOOL resetInventory){ doFiremodeChange = FALSE; //Grenade stuff - printfline("I set grenadeFireIndex to -1, D!"); grenadeFireIndex = -1; grenadeHeldDuration = -1; grenadeSpawnTime = -1; @@ -1250,6 +1302,8 @@ vector player::View_approachAngleOffsetTarget(vector vecInputAngles) { float frametimeUse; + + // is this wise? #ifdef CLIENT frametimeUse = clframetime; #else @@ -1287,7 +1341,7 @@ player::View_approachAngleOffsetTarget(vector vecInputAngles) // little test -var float input_timelengthSum = 0; +//var float input_timelengthSum = 0; // Count down my custom timers, called by ts/src/shared/input.qc, which is called // by Nuclide's PMove, same place that counts down w_attack_next. @@ -1316,7 +1370,6 @@ player::updateTimers(void){ } */ - fAccuracyKickbackStartCooldown = max(0, fAccuracyKickbackStartCooldown - input_timelength); if(fKarateStamina < 1.0){ @@ -1336,15 +1389,29 @@ player::updateTimers(void){ } }//kickbackStartCooldown check + }//updateTimers + void -player::setZoom(float arg_theZoom) -{ - //printfline("setZoom: %.2f", arg_theZoom); - flZoomTarget = arg_theZoom; +player::setZoomLevel(int arg_iZoomLevel){ + iZoomLevel = arg_iZoomLevel; + +#ifdef CLIENT + iZoomLevelPrev = iZoomLevel; +#endif + + weapondata_basic_t* myDat = getEquippedWeaponData(); + + if(myDat != NULL){ + if(myDat.funOnSetZoomLevel != NULL){ + myDat.funOnSetZoomLevel(this); + } + } + } + // forget any zoom-related settings instantly. // Unsure if a message should be sent to the client if called from the server, or assume the // calls coincide. @@ -1353,19 +1420,31 @@ player::resetZoom(void) { iZoomLevel = 0; viewzoom = 1.0f; - setZoom(1.0f); // sets flZoomTarget + flZoomTarget = 1.0f; #ifdef CLIENT // IMPORTANT! ZoomLerp under 0 tries to involve flZoomOld, set or not flZoomLerp = 1.0f; + /* SAVE_STATE(iZoomLevel); SAVE_STATE(viewzoom); - SAVE_STATE(flZoomTarget); + //SAVE_STATE(flZoomTarget); + */ flZoomEnd = 1.0f; flZoomCurrent = 1.0f; #endif } +// similar as above, but still go for the transition smoothness, +// not an instant change +void +player::resetZoomSoft(void) +{ + iZoomLevel = 0; + flZoomTarget = 1.0f; +} + + void player::setInventoryEquippedIndex(int arg_newIndex) { @@ -1454,6 +1533,8 @@ player::setInventoryEquippedIndex_Akimbo(int arg_newIndex, BOOL useAkimbo) // (force a sendoff, expect it area) + + #ifdef SERVER // Force a sendoff! SendFlags |= PLAYER_WEAPON; @@ -1592,6 +1673,8 @@ player::shotgunAddAmmoTime_setCooldownSetTime(void){ #ifdef SERVER +// (Comment may be out of date, verify if serverside postthink or setting think methods +// anywhere still has issues) // runs every frame server-side. postthink, oddly enough, does not. // Even cumulative 'frametime' readings do not at all add up to the real passage of time. // Looks like we have to do this with server calling our think instead... it's own frame @@ -1606,15 +1689,10 @@ player::shotgunAddAmmoTime_setCooldownSetTime(void){ void player::frameThink_fromServer(void){ - if(autocvar_sv_printoutspam == 1){ - printfline("My state: %d", iState); - printfline("STATUS: %d, %i", activeweapon, inventoryEquippedIndex); - } - // no, leave that to shared/input.qc //updateTimers(); - preThinkShared(); + //preThinkShared(); }// frameThink_fromServer @@ -1624,12 +1702,15 @@ player::frameThink_fromServer(void){ -#ifdef CLIENT +// preThink & postThink are supporter client and serverside. +// They're not built-in methods per entity nor called by Nuclide. +// For clientside, preThink/postThink are called by prediction pre/post methods. +// For serverside, gamerules "Player(Pre/Post)Frame" events call these for every +// player. +// An above comment says there were problems with serverside postthink, but unsure +// if that is still the case. -// Note that these pre/postThink's aren't game events, they're just called -// before/after prediction accordingly, and every single rendered frame. -// Unlike serverside preThink / postThink, which (I think?) are called independent of any -// logic frame-rate on the server. +#ifdef CLIENT void player::preThink(void){ weapondynamic_t dynaRef; @@ -1639,15 +1720,11 @@ player::preThink(void){ gFun_UI_EventGrabber_DebugMethod(); } - if(time >= equippedWeaponWaitingForCallback_maxWaitTime){ // stop then equippedWeaponWaitingForCallback = FALSE; } - // Called before rendering, so this is an acceptable place. - TS_View_HandleZoom(); - //callWeaponThink(); @@ -1714,8 +1791,6 @@ player::preThink(void){ }//preThink - - void player::postThink(void){ @@ -1742,23 +1817,24 @@ player::postThink(void){ } }//postThink -#endif +#endif // CLIENT -// preThink & postThink are serverside only. -// Now supported clientside as separate implementations (see above) -// we have other ways for handling logic clientside. #ifdef SERVER void player::preThink(void){ + if(autocvar_sv_printoutspam == 1){ + printfline("My state: %d", iState); + printfline("STATUS: %d, %i", activeweapon, inventoryEquippedIndex); + } + //self.angles += '0 0.3 0'; //self.v_angle = self.angles; - // TODO - for clientside, this would need to involve the "view_angles" global - // instead! Unsure if the macro GET_VIEW_ANGLES is good enough - v_angle = View_approachAngleOffsetTarget(v_angle); + preThinkShared(); + }// preThink @@ -1775,6 +1851,22 @@ player::postThink(void){ void player::preThinkShared(void){ + + + // TODO: make this view kickback properly predicted +#ifdef CLIENT + //printfline("So what is my view ang?? %.2f %.2f", view_angles[0], view_angles[1]); + // TODO - for clientside, this would need to involve the "view_angles" global + // instead! Unsure if the macro GET_VIEW_ANGLES is good enough + //v_angle = View_approachAngleOffsetTarget(v_angle); + //view_angles = View_approachAngleOffsetTarget(view_angles); +#else + //printfline("So what is my view ang?? %.2f %.2f", this.v_angle[0], this.v_angle[1]); + this.v_angle = View_approachAngleOffsetTarget(this.v_angle); +#endif + + + // little test //otherTimer += frametime; diff --git a/src/shared/util.h b/src/shared/util.h index d7b22cb..d377349 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -249,8 +249,9 @@ if (pl.inputSecondaryTapFrameCount == 0)\ // be aware of the player class player; +// extern? +const vector g_vZero = [0,0,0]; -extern const vector g_vZero; diff --git a/src/shared/util.qc b/src/shared/util.qc index 33bf227..f0d9f65 100644 --- a/src/shared/util.qc +++ b/src/shared/util.qc @@ -1,8 +1,5 @@ -//easy ref. -const vector g_vZero = [0,0,0]; - @@ -337,7 +334,7 @@ void entityRemoveRespawnFlag(CBaseEntity arg_this){ void TS_Weapons_ViewAnimation(int i, float fDuration) { - //printfline("TS_Weapons_ViewAnimation: %i %.2f", i, fDuration); + printfline("TS_Weapons_ViewAnimation: %i %.2f", i, fDuration); player pl = (player)self; pl.w_idle_next = fDuration; @@ -352,7 +349,7 @@ TS_Weapons_ViewAnimation(int i, float fDuration) void TS_Weapons_ViewAnimation_noLaserLock(int i, float fDuration) { - //printfline("TS_Weapons_ViewAnimation_noLaserLock: %i %.2f", i, fDuration); + printfline("TS_Weapons_ViewAnimation_noLaserLock: %i %.2f", i, fDuration); player pl = (player)self; pl.w_idle_next = fDuration; @@ -368,7 +365,7 @@ TS_Weapons_ViewAnimation_noLaserLock(int i, float fDuration) void TS_Weapons_ViewAnimation_EndIdle(int i, float fDuration) { - //printfline("TS_Weapons_ViewAnimation_EndIdle: %i %.2f", i, fDuration); + printfline("TS_Weapons_ViewAnimation_EndIdle: %i %.2f", i, fDuration); player pl = (player)self; pl.w_idle_next = fDuration; @@ -383,7 +380,7 @@ TS_Weapons_ViewAnimation_EndIdle(int i, float fDuration) void TS_Weapons_ViewAnimation_EndIdle_custom(int i, float fDuration, float fIdleEndOffset) { - //printfline("TS_Weapons_ViewAnimation_EndIdle_custom: %i %.2f %.2f", i, fDuration, fIdleEndOffset); + printfline("TS_Weapons_ViewAnimation_EndIdle_custom: %i %.2f %.2f", i, fDuration, fIdleEndOffset); player pl = (player)self; pl.w_idle_next = fDuration; diff --git a/src/shared/weapons.h b/src/shared/weapons.h index 5a4b91b..a25f4cb 100644 --- a/src/shared/weapons.h +++ b/src/shared/weapons.h @@ -443,10 +443,8 @@ typedef struct{ // bind "c" "+alt2" void(player pl, weapondynamic_t arg_thisWeapon) funOnColdCock; - // We'll handle firing animations (weapon recoil mainly) in their own methods. - // Little too much going on. Number of animations to cylce through (shoot1, shoot2)? - // separate batch for firing in semi-auto mode (sshoot1, sshoot2)? - // and new ones for ironsight firing sometimes? + // This event is for recently changing the zoom level on the player. + void(player pl) funOnSetZoomLevel; int iAnim_Idle_Index; @@ -512,7 +510,8 @@ typedef struct{ void(player pl, weapondynamic_t arg_thisWeapon) funOnThink; void(player pl, weapondynamic_t arg_thisWeapon) funOnColdCock; - + void(player pl) funOnSetZoomLevel; + int iAnim_Idle_Index; @@ -587,6 +586,7 @@ typedef struct{ void(player pl, weapondynamic_t arg_thisWeapon) funOnThink; void(player pl, weapondynamic_t arg_thisWeapon) funOnColdCock; + void(player pl) funOnSetZoomLevel; int iAnim_Idle_Index; @@ -651,6 +651,7 @@ typedef struct{ void(player pl, weapondynamic_t arg_thisWeapon) funOnThink; void(player pl, weapondynamic_t arg_thisWeapon) funOnColdCock; + void(player pl) funOnSetZoomLevel; int iAnim_Idle_Index; @@ -700,6 +701,7 @@ typedef struct{ void(player pl, weapondynamic_t arg_thisWeapon) funOnThink; void(player pl, weapondynamic_t arg_thisWeapon) funOnColdCock; + void(player pl) funOnSetZoomLevel; int iAnim_Idle_Index; @@ -778,7 +780,6 @@ typedef struct{ } weapondata_shotgun_extra_t; - //TODO. Is extern'ing these earlier possible? ammodata_t* ary_ammoData[AMMO_ID::LAST_ID]; #ifdef CLIENT diff --git a/src/shared/weapons.qc b/src/shared/weapons.qc index 252ef7f..64cd573 100644 --- a/src/shared/weapons.qc +++ b/src/shared/weapons.qc @@ -273,7 +273,6 @@ weapon_base_onPrimaryAttack_melee_fromCustomDirection( }// weapon_base_onPrimaryAttack_melee -// Apparently serverside-only? ok... void weapon_base_onAttack(player pl, weapondata_basic_t* basePRef, weapondynamic_t arg_thisWeapon, int attackTypeUsed) { @@ -294,7 +293,6 @@ void weapon_base_onAttack_multi(player pl, weapondata_basic_t* basePRef, weapondynamic_t arg_thisWeapon, int shellCount, int attackTypeUsed) { -#ifdef SERVER weapondata_gun_t baseRef = *((weapondata_gun_t*)basePRef); float randoAngFactor = randomInRange_f(0, 1); @@ -336,6 +334,7 @@ weapon_base_onAttack_multi(player pl, weapondata_basic_t* basePRef, weapondynami //float maxer = 1.00/128; +#ifdef SERVER //TAGGG - NOTE! // Nuclide does not support custom range as of now, nor how to tell how far penetration can go. // Old FreeTS did penetration distance by reducing range by 3 times as far as any solid object @@ -356,6 +355,7 @@ weapon_base_onAttack_multi(player pl, weapondata_basic_t* basePRef, weapondynami myPenetrationCount = 0; } TraceAttack_SetPenetrationPower(myPenetrationCount); +#endif //////////////////////////////////////////////////////////////////////////////////////////////// @@ -363,7 +363,9 @@ weapon_base_onAttack_multi(player pl, weapondata_basic_t* basePRef, weapondynami // like "WEAPON_ID::Glock18". Consider sending that as a parameter to be available here if(attackTypeUsed & BITS_AKIMBOCHOICE_LEFT){ //left +#ifdef SERVER TraceAttack_FireBullets(shellCount, (pl.origin + pl.view_ofs), baseRef.fAttackDamage, [acc, acc], (int)pl.activeweapon); +#endif arg_thisWeapon.iClipLeft -= 1; toGo = [-sin(finalAng), cos(finalAng), 0] * baseRef.firestats.fViewKickback * randomInRange_f(miner, maxer); pl.vViewAngleOffsetTarget += toGo; @@ -371,8 +373,9 @@ weapon_base_onAttack_multi(player pl, weapondata_basic_t* basePRef, weapondynami if(attackTypeUsed & BITS_AKIMBOCHOICE_RIGHT){ //right +#ifdef SERVER TraceAttack_FireBullets(shellCount, (pl.origin + pl.view_ofs), baseRef.fAttackDamage, [acc, acc], (int)pl.activeweapon); - +#endif arg_thisWeapon.iClipAkimboLeft -= 1; toGo = [-sin(finalAng), cos(finalAng), 0] * baseRef.firestats.fViewKickback * randomInRange_f(miner, maxer); pl.vViewAngleOffsetTarget += toGo; @@ -391,12 +394,9 @@ weapon_base_onAttack_multi(player pl, weapondata_basic_t* basePRef, weapondynami pl.fAccuracyKickback = 0.1; } - // TODO - third person. + + // TODO - third person. This is mad old isn't it //Animation_ShootWeapon( pl ); -#else - //CLIENTSIDE - -#endif }// weapon_base_onAttack @@ -498,8 +498,7 @@ weapon_shotgun_reload( } pl.isChangingIronsight = FALSE; - //pl.resetZoom(); - pl.setZoom(1.0f); + pl.resetZoomSoft(); pl.aryNextBurstShotTime_softLength = 0; pl.aryNextBurstShotTime_listenIndex = -1; @@ -1287,7 +1286,7 @@ weapon_akimbo_fullAttackChoice( */ } - \ + } return finalAkimboChoice; @@ -1366,8 +1365,7 @@ weapon_gun_Reload( } pl.isChangingIronsight = FALSE; - //pl.resetZoom(); - pl.setZoom(1.0f); + pl.resetZoomSoft(); pl.aryNextBurstShotTime_softLength = 0; pl.aryNextBurstShotTime_listenIndex = -1; pl.isReloading = TRUE; @@ -1410,8 +1408,7 @@ weapon_gun_Reload_CustomSequence( } pl.isChangingIronsight = FALSE; - //pl.resetZoom(); - pl.setZoom(1.0f); + pl.resetZoomSoft(); pl.aryNextBurstShotTime_softLength = 0; pl.aryNextBurstShotTime_listenIndex = -1; pl.isReloading = TRUE; @@ -1432,13 +1429,19 @@ weapon_ironsight_Reload( ){ weapondata_ironsight_t baseRef = *basePRef; + + /* + if (pl.w_attack_next > 0.0){ + return; + } + */ + if ( pl.isReloading || pl.isChangingIronsight){ //blocked return; } - //if ( self.fAttackFinished > time ) { - // return; - //} + + if(pl.ary_ammoTotal[baseRef.iAmmoDataID] <= 0){ //also no. Having no ammo in the pool to take from means no reloading. @@ -1451,19 +1454,19 @@ weapon_ironsight_Reload( } }else{ //akimbo, allows reloading for either being less than full - if(arg_thisWeapon.iClipLeft >= baseRef.iClipMax && arg_thisWeapon.iClipAkimboLeft >= baseRef.iClipMax){ + if(arg_thisWeapon.iClipLeft >= baseRef.iClipMax && arg_thisWeapon.iClipAkimboLeft >= baseRef.iClipMax){ return; //both full? don't reload! } } pl.isChangingIronsight = FALSE; - //pl.resetZoom(); - pl.setZoom(1.0f); + pl.resetZoomSoft(); pl.aryNextBurstShotTime_softLength = 0; pl.aryNextBurstShotTime_listenIndex = -1; pl.isReloading = TRUE; weapon_base_setWholeAttackDelay(pl, baseRef.fAnim_Reload_Duration); + //printfline("not ironsite rite %i", arg_thisWeapon.iIronSight); if(!arg_thisWeapon.iIronSight){ TS_Weapons_ViewAnimation(baseRef.iAnim_Reload_Index, baseRef.fAnim_Reload_Duration ); }else{ @@ -1644,6 +1647,8 @@ weapon_gun_onThink_burstFireLogic( }// weapon_gun_onThink + + void weapon_gun_onDrawHUD(player pl, weapondata_gun_t* basePRef, weapondynamic_t arg_thisWeapon) { @@ -2000,6 +2005,7 @@ weapondata_basic_t weapon_none = weapons_dummyfun, weapons_dummyfun, weapons_dummyfun, + NULL, 0, 0, 0.0f, @@ -2031,6 +2037,7 @@ weapondata_basic_t weapon_none_akimbo = weapons_dummyfun, weapons_dummyfun, weapons_dummyfun, + NULL, 0, 0, 0.0f, @@ -2049,9 +2056,7 @@ weapondata_basic_t weapon_none_akimbo = -//include after all weapons have been defined? (that is, compile weapon.c (here), then weapon-specific files, then a new file containing setupWeaponData) -//Or would it make sense to extern the structs here and keep this method in the same file? -// (compile weapon-specific files first, then weapon.c) + void setupWeaponData(void) { diff --git a/src/shared/weapons/weapon_ak47.qc b/src/shared/weapons/weapon_ak47.qc index 4e4d992..578f55b 100644 --- a/src/shared/weapons/weapon_ak47.qc +++ b/src/shared/weapons/weapon_ak47.qc @@ -24,6 +24,13 @@ void weapon_ak47_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_ak47_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_ak47_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.40f;break; + case 2:pl.flZoomTarget = 0.1625f;break; + } +} weapondata_ironsight_t weapon_ak47 = { @@ -38,6 +45,7 @@ weapondata_ironsight_t weapon_ak47 = weapon_ak47_onSecondaryAttackRelease, weapon_ak47_onThink, weapon_ak47_onColdCock, + weapon_ak47_onSetZoomLevel, weaponseq_ak47::idle, weaponseq_ak47::draw, 31.0f / 35.0f, @@ -171,6 +179,7 @@ w_ak47_primary(void) } + void w_ak47_secondary(void) { @@ -180,13 +189,20 @@ w_ak47_secondary(void) INPUT_SECONDARY_TAP_GATE if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ - // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 3; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.40f);break; - case 2:pl.setZoom(0.1625f);break; - } + + //int iZoomLevel_old = pl.iZoomLevel; + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 3; + //printfline("!!! ZoomLevel change MANUAL %i -> %i (%.2f) inputframe:%i", iZoomLevel_old, pl.iZoomLevel, time, input_sequence); + pl.setZoomLevel(newZoomLevel); + + // IDEA: have a var set by that EquipmentCallback thing instead that's networked, + // so: client: set "waitingForCallback" to FALSE. SendEvent("...") + // server: modify "waitingForCallback", set to TRUE. + // (because that var is networked, the client will see it when it updates). + // Or don't, that might be stupidly wasteful from being sent every frame when the + // sheer majority do not involve weapon changes. + + }else{ if(pl.w_attack_next > 0){ return; @@ -194,7 +210,6 @@ w_ak47_secondary(void) // no scope? we use ironsights then. weapon_ironsight_ToggleIronsight(pl, (weapondata_ironsight_t*)ary_weaponData[WEAPON_ID::AK47], arg_thisWeapon); } - } void diff --git a/src/shared/weapons/weapon_akimbocolts.qc b/src/shared/weapons/weapon_akimbocolts.qc index c79e787..f147454 100644 --- a/src/shared/weapons/weapon_akimbocolts.qc +++ b/src/shared/weapons/weapon_akimbocolts.qc @@ -39,6 +39,7 @@ weapondata_gun_t weapon_akimbocolts = weapon_akimbocolts_akimbo_onSecondaryAttackRelease, weapon_akimbocolts_akimbo_onThink, weapon_akimbocolts_akimbo_onColdCock, + NULL, weaponseq_akimbocolts::idle, weaponseq_akimbocolts::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_barrettm82.qc b/src/shared/weapons/weapon_barrettm82.qc index a7e4c71..42e0244 100644 --- a/src/shared/weapons/weapon_barrettm82.qc +++ b/src/shared/weapons/weapon_barrettm82.qc @@ -20,6 +20,13 @@ void weapon_barrettm82_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_barrettm82_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_barrettm82_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.40f;break; + case 2:pl.flZoomTarget = 0.10f;break; + } +} weapondata_gun_t weapon_barrettm82 = { @@ -34,6 +41,7 @@ weapondata_gun_t weapon_barrettm82 = weapon_barrettm82_onSecondaryAttackRelease, weapon_barrettm82_onThink, weapon_barrettm82_onColdCock, + weapon_barrettm82_onSetZoomLevel, weaponseq_barrettm82::idle, weaponseq_barrettm82::draw, 31.0f / 30.0f, @@ -174,12 +182,8 @@ w_barrettm82_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 3; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.40f);break; - case 2:pl.setZoom(0.10f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 3; + pl.setZoomLevel(newZoomLevel); } } diff --git a/src/shared/weapons/weapon_benellim3.qc b/src/shared/weapons/weapon_benellim3.qc index d328744..604c57b 100644 --- a/src/shared/weapons/weapon_benellim3.qc +++ b/src/shared/weapons/weapon_benellim3.qc @@ -24,6 +24,12 @@ void weapon_benellim3_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_benellim3_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_benellim3_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.50f;break; + } +} weapondata_gun_t weapon_benellim3 = { @@ -38,6 +44,7 @@ weapondata_gun_t weapon_benellim3 = weapon_benellim3_onSecondaryAttackRelease, weapon_benellim3_onThink, weapon_benellim3_onColdCock, + weapon_benellim3_onSetZoomLevel, weaponseq_benellim3::idle, weaponseq_benellim3::draw, 31.0f / 30.0f, @@ -242,11 +249,8 @@ w_benellim3_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.50f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); } } diff --git a/src/shared/weapons/weapon_beretta.qc b/src/shared/weapons/weapon_beretta.qc index fbddfa8..713f2d1 100644 --- a/src/shared/weapons/weapon_beretta.qc +++ b/src/shared/weapons/weapon_beretta.qc @@ -35,6 +35,7 @@ weapondata_gun_t weapon_beretta = weapon_beretta_onSecondaryAttackRelease, weapon_beretta_onThink, weapon_beretta_onColdCock, + NULL, weaponseq_beretta::idle, weaponseq_beretta::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_beretta_akimbo.qc b/src/shared/weapons/weapon_beretta_akimbo.qc index b5a095a..1eeb9ca 100644 --- a/src/shared/weapons/weapon_beretta_akimbo.qc +++ b/src/shared/weapons/weapon_beretta_akimbo.qc @@ -63,6 +63,7 @@ weapondata_gun_t weapon_beretta_akimbo = weapon_beretta_akimbo_onSecondaryAttackRelease, weapon_beretta_akimbo_onThink, weapon_beretta_akimbo_onColdCock, + NULL, weaponseq_beretta_akimbo::idle_1, weaponseq_beretta_akimbo::draw, 41.0f / 55.0f, diff --git a/src/shared/weapons/weapon_combatknife.qc b/src/shared/weapons/weapon_combatknife.qc index 042111f..733ae4c 100644 --- a/src/shared/weapons/weapon_combatknife.qc +++ b/src/shared/weapons/weapon_combatknife.qc @@ -40,6 +40,7 @@ weapondata_throwable_t weapon_combatknife = weapon_combatknife_onSecondaryAttackRelease, weapon_combatknife_onThink, weapon_combatknife_onColdCock, + NULL, weaponseq_combatknife::idle, weaponseq_combatknife::draw, 31.0f / 30.0f, @@ -146,8 +147,6 @@ w_combatknife_primary(void) } #endif - //Animation_ShootWeapon( self ); - //self.fAttackFinished = time + wptKNIFE.fAttackFinished; // actually do this animation the same regardless as far as we know. // Do these go through some kind of cycle, I forget diff --git a/src/shared/weapons/weapon_contenderg2.qc b/src/shared/weapons/weapon_contenderg2.qc index c84d39f..44e2f1f 100644 --- a/src/shared/weapons/weapon_contenderg2.qc +++ b/src/shared/weapons/weapon_contenderg2.qc @@ -20,6 +20,12 @@ void weapon_contenderg2_onThink(player pl, weapondynamic_t arg_thisWeapon){ } void weapon_contenderg2_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_contenderg2_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.325f;break; + } +} weapondata_gun_t weapon_contenderg2 = { @@ -34,6 +40,7 @@ weapondata_gun_t weapon_contenderg2 = weapon_contenderg2_onSecondaryAttackRelease, weapon_contenderg2_onThink, weapon_contenderg2_onColdCock, + weapon_contenderg2_onSetZoomLevel, weaponseq_contenderg2::idle, weaponseq_contenderg2::draw, 31.0f / 30.0f, @@ -176,11 +183,8 @@ w_contenderg2_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.325f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); } } diff --git a/src/shared/weapons/weapon_deserteagle.qc b/src/shared/weapons/weapon_deserteagle.qc index 276652e..3ab7a68 100644 --- a/src/shared/weapons/weapon_deserteagle.qc +++ b/src/shared/weapons/weapon_deserteagle.qc @@ -26,6 +26,12 @@ void weapon_deserteagle_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_deserteagle_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_deserteagle_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.75f;break; + } +} weapondata_ironsight_t weapon_deserteagle = { @@ -40,6 +46,7 @@ weapondata_ironsight_t weapon_deserteagle = weapon_deserteagle_onSecondaryAttackRelease, weapon_deserteagle_onThink, weapon_deserteagle_onColdCock, + weapon_deserteagle_onSetZoomLevel, weaponseq_deserteagle::idle, weaponseq_deserteagle::draw, 31.0f / 50.0f, @@ -223,11 +230,8 @@ w_deserteagle_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.75f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); }else{ if(pl.w_attack_next > 0){ return; diff --git a/src/shared/weapons/weapon_fiveseven.qc b/src/shared/weapons/weapon_fiveseven.qc index fd9ba25..4d9014b 100644 --- a/src/shared/weapons/weapon_fiveseven.qc +++ b/src/shared/weapons/weapon_fiveseven.qc @@ -33,6 +33,7 @@ weapondata_gun_t weapon_fiveseven = weapon_fiveseven_onSecondaryAttackRelease, weapon_fiveseven_onThink, weapon_fiveseven_onColdCock, + NULL, weaponseq_fiveseven::idle, weaponseq_fiveseven::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_fiveseven_akimbo.qc b/src/shared/weapons/weapon_fiveseven_akimbo.qc index c248df2..3fa49d9 100644 --- a/src/shared/weapons/weapon_fiveseven_akimbo.qc +++ b/src/shared/weapons/weapon_fiveseven_akimbo.qc @@ -34,6 +34,7 @@ weapondata_gun_t weapon_fiveseven_akimbo = weapon_fiveseven_akimbo_onSecondaryAttackRelease, weapon_fiveseven_akimbo_onThink, weapon_fiveseven_akimbo_onColdCock, + NULL, weaponseq_fiveseven_akimbo::idle, weaponseq_fiveseven_akimbo::draw, 31.0f / 40.0f, diff --git a/src/shared/weapons/weapon_glock18.qc b/src/shared/weapons/weapon_glock18.qc index bbd327d..18761ef 100644 --- a/src/shared/weapons/weapon_glock18.qc +++ b/src/shared/weapons/weapon_glock18.qc @@ -34,6 +34,7 @@ weapondata_gun_t weapon_glock18 = weapon_glock18_onSecondaryAttackRelease, weapon_glock18_onThink, weapon_glock18_onColdCock, + NULL, weaponseq_glock18::idle, weaponseq_glock18::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_glock20.qc b/src/shared/weapons/weapon_glock20.qc index f3b741c..62fc523 100644 --- a/src/shared/weapons/weapon_glock20.qc +++ b/src/shared/weapons/weapon_glock20.qc @@ -34,6 +34,7 @@ weapondata_gun_t weapon_glock20 = weapon_glock20_onSecondaryAttackRelease, weapon_glock20_onThink, weapon_glock20_onColdCock, + NULL, weaponseq_glock20::idle, weaponseq_glock20::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_hkpdw.qc b/src/shared/weapons/weapon_hkpdw.qc index dd9ffe2..ae62d26 100644 --- a/src/shared/weapons/weapon_hkpdw.qc +++ b/src/shared/weapons/weapon_hkpdw.qc @@ -20,6 +20,12 @@ void weapon_hkpdw_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_hkpdw_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_hkpdw_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.50f;break; + } +} weapondata_gun_t weapon_hkpdw = { @@ -34,6 +40,7 @@ weapondata_gun_t weapon_hkpdw = weapon_hkpdw_onSecondaryAttackRelease, weapon_hkpdw_onThink, weapon_hkpdw_onColdCock, + weapon_hkpdw_onSetZoomLevel, weaponseq_hkpdw::idle, weaponseq_hkpdw::draw, 31.0f / 30.0f, @@ -184,11 +191,8 @@ w_hkpdw_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.50f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); } } diff --git a/src/shared/weapons/weapon_karate.qc b/src/shared/weapons/weapon_karate.qc index 298ba11..7e1de38 100644 --- a/src/shared/weapons/weapon_karate.qc +++ b/src/shared/weapons/weapon_karate.qc @@ -45,6 +45,7 @@ weapondata_basic_t weapon_karate = weapon_karate_onSecondaryAttackRelease, weapon_karate_onThink, weapon_karate_onColdCock, + NULL, weaponseq_karate::idle, weaponseq_karate::draw, 31 / 35, // 31/35 ? @@ -152,7 +153,6 @@ w_karate_primary(void) } #endif - //Animation_ShootWeapon( self ); pl.fKarateStamina = bound(0, pl.fKarateStamina - 0.085, 1); int r = (float)input_sequence % 4; @@ -283,7 +283,6 @@ w_karate_secondary(void) w_karate_determineSecondaryAttack(hitRep, meleeAnimToPlay); pl.fUncrouchBlockDelay = 1.0f; - //Animation_ShootWeapon( self ); #ifdef SERVER // need the fleshhit sound diff --git a/src/shared/weapons/weapon_katana.qc b/src/shared/weapons/weapon_katana.qc index 832af44..6d93e59 100644 --- a/src/shared/weapons/weapon_katana.qc +++ b/src/shared/weapons/weapon_katana.qc @@ -33,6 +33,7 @@ weapondata_melee_t weapon_katana = weapon_katana_onSecondaryAttackRelease, weapon_katana_onThink, weapon_katana_onColdCock, + NULL, weaponseq_katana::idle, weaponseq_katana::draw, 31.0f / 33.0f, @@ -141,10 +142,6 @@ w_katana_primary(void) pl.fMoveBlockDelay = 1.0f; pl.fUncrouchBlockDelay = 1.0f; - // So this works now? Or not. - #ifdef CLIENT - //SAVE_STATE(pl.fUncrouchBlockDelay); - #endif }else{ // Check. Are we moving backwards, enough?? And not looking up/down too far? diff --git a/src/shared/weapons/weapon_m16a4.qc b/src/shared/weapons/weapon_m16a4.qc index eee2703..ceb931a 100644 --- a/src/shared/weapons/weapon_m16a4.qc +++ b/src/shared/weapons/weapon_m16a4.qc @@ -30,6 +30,13 @@ void weapon_m16a4_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_m16a4_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_m16a4_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.40f;break; + case 2:pl.flZoomTarget = 0.10f;break; + } +} weapondata_ironsight_t weapon_m16a4 = { @@ -44,6 +51,7 @@ weapondata_ironsight_t weapon_m16a4 = weapon_m16a4_onSecondaryAttackRelease, weapon_m16a4_onThink, weapon_m16a4_onColdCock, + weapon_m16a4_onSetZoomLevel, weaponseq_m16a4::idle, weaponseq_m16a4::draw, 31.0f / 35.0f, @@ -231,12 +239,8 @@ w_m16a4_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 3; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.40f);break; - case 2:pl.setZoom(0.10f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 3; + pl.setZoomLevel(newZoomLevel); }else{ if(pl.w_attack_next > 0){ return; diff --git a/src/shared/weapons/weapon_m4a1.qc b/src/shared/weapons/weapon_m4a1.qc index f461252..bfd9a1c 100644 --- a/src/shared/weapons/weapon_m4a1.qc +++ b/src/shared/weapons/weapon_m4a1.qc @@ -51,6 +51,12 @@ void weapon_m4a1_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } } +void weapon_m4a1_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.325f;break; + } +} weapondata_ironsight_t weapon_m4a1 = @@ -66,6 +72,7 @@ weapondata_ironsight_t weapon_m4a1 = weapon_m4a1_onSecondaryAttackRelease, weapon_m4a1_onThink, weapon_m4a1_onColdCock, + weapon_m4a1_onSetZoomLevel, weaponseq_m4a1::idle, weaponseq_m4a1::draw, 31.0f / 35.0f, @@ -242,11 +249,9 @@ w_m4a1_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.325f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); + }else{ if(pl.w_attack_next > 0){ return; diff --git a/src/shared/weapons/weapon_m60.qc b/src/shared/weapons/weapon_m60.qc index 79d2ee4..149d910 100644 --- a/src/shared/weapons/weapon_m60.qc +++ b/src/shared/weapons/weapon_m60.qc @@ -31,6 +31,7 @@ weapondata_gun_t weapon_m60 = weapon_m60_onSecondaryAttackRelease, weapon_m60_onThink, weapon_m60_onColdCock, + NULL, weaponseq_m60::idle, weaponseq_m60::draw, 31.0f / 33.0f, diff --git a/src/shared/weapons/weapon_m61grenade.qc b/src/shared/weapons/weapon_m61grenade.qc index a81effc..ae1ff8d 100644 --- a/src/shared/weapons/weapon_m61grenade.qc +++ b/src/shared/weapons/weapon_m61grenade.qc @@ -19,8 +19,7 @@ void weapon_m61grenade_onSecondaryAttackRelease(player pl, weapondynamic_t arg_t } -//Serverside only method, generates an entity -// TODO - just be an entity in its own file at this point. +// Serverside only method, generates an entity #ifdef SERVER void weapon_m61grenade_spawnProjectile(player pl, weapondynamic_t arg_thisWeapon, BOOL wasToss, float heldDuration){ makevectors( GET_VIEW_ANGLES ); @@ -149,6 +148,7 @@ weapondata_throwable_t weapon_m61grenade = weapon_m61grenade_onSecondaryAttackRelease, weapon_m61grenade_onThink, weapon_m61grenade_onColdCock, + NULL, weaponseq_m61grenade::idle, weaponseq_m61grenade::draw, 31.0f / 40.0f, diff --git a/src/shared/weapons/weapon_mac10.qc b/src/shared/weapons/weapon_mac10.qc index d38442b..6f6131e 100644 --- a/src/shared/weapons/weapon_mac10.qc +++ b/src/shared/weapons/weapon_mac10.qc @@ -47,6 +47,7 @@ weapondata_ironsight_t weapon_mac10 = weapon_mac10_onSecondaryAttackRelease, weapon_mac10_onThink, weapon_mac10_onColdCock, + NULL, weaponseq_mac10::idle, weaponseq_mac10::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_miniuzi.qc b/src/shared/weapons/weapon_miniuzi.qc index de46ae0..607913b 100644 --- a/src/shared/weapons/weapon_miniuzi.qc +++ b/src/shared/weapons/weapon_miniuzi.qc @@ -46,6 +46,7 @@ weapondata_ironsight_t weapon_miniuzi = weapon_miniuzi_onSecondaryAttackRelease, weapon_miniuzi_onThink, weapon_miniuzi_onColdCock, + NULL, weaponseq_miniuzi::idle, weaponseq_miniuzi::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_miniuzi_akimbo.qc b/src/shared/weapons/weapon_miniuzi_akimbo.qc index 24b3b3a..e5b4135 100644 --- a/src/shared/weapons/weapon_miniuzi_akimbo.qc +++ b/src/shared/weapons/weapon_miniuzi_akimbo.qc @@ -54,6 +54,7 @@ weapondata_gun_t weapon_miniuzi_akimbo = weapon_miniuzi_akimbo_onSecondaryAttackRelease, weapon_miniuzi_akimbo_onThink, weapon_miniuzi_akimbo_onColdCock, + NULL, weaponseq_miniuzi_akimbo::akimbo_idle, weaponseq_miniuzi_akimbo::akimbo_draw, 31.0f / 35.0f, diff --git a/src/shared/weapons/weapon_mossberg500.qc b/src/shared/weapons/weapon_mossberg500.qc index c032299..6e29495 100644 --- a/src/shared/weapons/weapon_mossberg500.qc +++ b/src/shared/weapons/weapon_mossberg500.qc @@ -45,6 +45,7 @@ weapondata_ironsight_t weapon_mossberg500 = weapon_mossberg500_onSecondaryAttackRelease, weapon_mossberg500_onThink, weapon_mossberg500_onColdCock, + NULL, weaponseq_mossberg500::idle, weaponseq_mossberg500::draw, 31.0f / 35.0f, diff --git a/src/shared/weapons/weapon_mp5k.qc b/src/shared/weapons/weapon_mp5k.qc index 970d992..6b73a44 100644 --- a/src/shared/weapons/weapon_mp5k.qc +++ b/src/shared/weapons/weapon_mp5k.qc @@ -27,6 +27,12 @@ void weapon_mp5k_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_mp5k_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_mp5k_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.40f;break; + } +} weapondata_ironsight_t weapon_mp5k = { @@ -41,6 +47,7 @@ weapondata_ironsight_t weapon_mp5k = weapon_mp5k_onSecondaryAttackRelease, weapon_mp5k_onThink, weapon_mp5k_onColdCock, + weapon_mp5k_onSetZoomLevel, weaponseq_mp5k::idle, weaponseq_mp5k::draw, 31.0f / 30.0f, @@ -227,11 +234,8 @@ w_mp5k_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.40f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); }else{ if(pl.w_attack_next > 0){ return; diff --git a/src/shared/weapons/weapon_mp5sd.qc b/src/shared/weapons/weapon_mp5sd.qc index 25cc9e5..d76fb0b 100644 --- a/src/shared/weapons/weapon_mp5sd.qc +++ b/src/shared/weapons/weapon_mp5sd.qc @@ -21,6 +21,12 @@ void weapon_mp5sd_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_mp5sd_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_mp5sd_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.40f;break; + } +} weapondata_gun_t weapon_mp5sd = { @@ -35,6 +41,7 @@ weapondata_gun_t weapon_mp5sd = weapon_mp5sd_onSecondaryAttackRelease, weapon_mp5sd_onThink, weapon_mp5sd_onColdCock, + weapon_mp5sd_onSetZoomLevel, weaponseq_mp5sd::idle, weaponseq_mp5sd::draw, 31.0f / 30.0f, @@ -197,11 +204,8 @@ w_mp5sd_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.40f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); } } diff --git a/src/shared/weapons/weapon_ragingbull.qc b/src/shared/weapons/weapon_ragingbull.qc index 78d026a..35c3dd1 100644 --- a/src/shared/weapons/weapon_ragingbull.qc +++ b/src/shared/weapons/weapon_ragingbull.qc @@ -19,6 +19,12 @@ void weapon_ragingbull_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_ragingbull_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_ragingbull_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.50f;break; + } +} weapondata_gun_t weapon_ragingbull = { @@ -33,6 +39,7 @@ weapondata_gun_t weapon_ragingbull = weapon_ragingbull_onSecondaryAttackRelease, weapon_ragingbull_onThink, weapon_ragingbull_onColdCock, + weapon_ragingbull_onSetZoomLevel, weaponseq_ragingbull::idle, weaponseq_ragingbull::draw, 31.0f / 33.0f, @@ -171,11 +178,8 @@ w_ragingbull_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.50f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); } } diff --git a/src/shared/weapons/weapon_rugermk1.qc b/src/shared/weapons/weapon_rugermk1.qc index 2147080..fe4d651 100644 --- a/src/shared/weapons/weapon_rugermk1.qc +++ b/src/shared/weapons/weapon_rugermk1.qc @@ -33,6 +33,7 @@ weapondata_gun_t weapon_rugermk1 = weapon_rugermk1_onSecondaryAttackRelease, weapon_rugermk1_onThink, weapon_rugermk1_onColdCock, + NULL, weaponseq_rugermk1::idle, weaponseq_rugermk1::draw, 31.0f / 35.0f, diff --git a/src/shared/weapons/weapon_sawedoff.qc b/src/shared/weapons/weapon_sawedoff.qc index d5c5888..71390d4 100644 --- a/src/shared/weapons/weapon_sawedoff.qc +++ b/src/shared/weapons/weapon_sawedoff.qc @@ -63,6 +63,7 @@ weapondata_ironsight_t weapon_sawedoff = weapon_sawedoff_onSecondaryAttackRelease, weapon_sawedoff_onThink, weapon_sawedoff_onColdCock, + NULL, weaponseq_sawedoff::idle, weaponseq_sawedoff::draw, 31.0f / 33.0f, diff --git a/src/shared/weapons/weapon_sealknife.qc b/src/shared/weapons/weapon_sealknife.qc index bc0de36..6365aaa 100644 --- a/src/shared/weapons/weapon_sealknife.qc +++ b/src/shared/weapons/weapon_sealknife.qc @@ -31,6 +31,7 @@ weapondata_throwable_t weapon_sealknife = weapon_sealknife_onSecondaryAttackRelease, weapon_sealknife_onThink, weapon_sealknife_onColdCock, + NULL, weaponseq_sealknife::idle, weaponseq_sealknife::draw, 31.0f / 30.0f, @@ -138,8 +139,6 @@ w_sealknife_primary(void) } #endif - //Animation_ShootWeapon( self ); - //self.fAttackFinished = time + wptKNIFE.fAttackFinished; // actually do this animation the same regardless as far as we know. int r = (float)input_sequence % 3; diff --git a/src/shared/weapons/weapon_skorpion.qc b/src/shared/weapons/weapon_skorpion.qc index 7a448a0..11842f5 100644 --- a/src/shared/weapons/weapon_skorpion.qc +++ b/src/shared/weapons/weapon_skorpion.qc @@ -35,6 +35,7 @@ weapondata_gun_t weapon_skorpion = weapon_skorpion_onSecondaryAttackRelease, weapon_skorpion_onThink, weapon_skorpion_onColdCock, + NULL, weaponseq_skorpion::idle, weaponseq_skorpion::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_skorpion_akimbo.qc b/src/shared/weapons/weapon_skorpion_akimbo.qc index e95eecb..d6a656a 100644 --- a/src/shared/weapons/weapon_skorpion_akimbo.qc +++ b/src/shared/weapons/weapon_skorpion_akimbo.qc @@ -34,6 +34,7 @@ weapondata_gun_t weapon_skorpion_akimbo = weapon_skorpion_akimbo_onSecondaryAttackRelease, weapon_skorpion_akimbo_onThink, weapon_skorpion_akimbo_onColdCock, + NULL, weaponseq_skorpion_akimbo::idle, weaponseq_skorpion_akimbo::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_socommk23.qc b/src/shared/weapons/weapon_socommk23.qc index 20e3d11..c508fbc 100644 --- a/src/shared/weapons/weapon_socommk23.qc +++ b/src/shared/weapons/weapon_socommk23.qc @@ -41,6 +41,7 @@ weapondata_ironsight_t weapon_socommk23 = weapon_socommk23_onSecondaryAttackRelease, weapon_socommk23_onThink, weapon_socommk23_onColdCock, + NULL, weaponseq_socommk23::idleb, weaponseq_socommk23::drawb, 31.0f / 40.0f, diff --git a/src/shared/weapons/weapon_socommk23_akimbo.qc b/src/shared/weapons/weapon_socommk23_akimbo.qc index 279fa03..1834db7 100644 --- a/src/shared/weapons/weapon_socommk23_akimbo.qc +++ b/src/shared/weapons/weapon_socommk23_akimbo.qc @@ -46,6 +46,7 @@ weapondata_ironsight_t weapon_socommk23_akimbo = weapon_socommk23_akimbo_onSecondaryAttackRelease, weapon_socommk23_akimbo_onThink, weapon_socommk23_akimbo_onColdCock, + NULL, weaponseq_socommk23_akimbo::idle, weaponseq_socommk23_akimbo::draw, 31.0f / 40.0f, diff --git a/src/shared/weapons/weapon_spas12.qc b/src/shared/weapons/weapon_spas12.qc index 088af92..8ef6179 100644 --- a/src/shared/weapons/weapon_spas12.qc +++ b/src/shared/weapons/weapon_spas12.qc @@ -38,6 +38,7 @@ weapondata_gun_t weapon_spas12 = weapon_spas12_onSecondaryAttackRelease, weapon_spas12_onThink, weapon_spas12_onColdCock, + NULL, weaponseq_spas12::idle, weaponseq_spas12::draw, 31.0f / 30.0f, diff --git a/src/shared/weapons/weapon_steyraug.qc b/src/shared/weapons/weapon_steyraug.qc index 02011b9..5fa7891 100644 --- a/src/shared/weapons/weapon_steyraug.qc +++ b/src/shared/weapons/weapon_steyraug.qc @@ -18,6 +18,12 @@ void weapon_steyraug_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_steyraug_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_steyraug_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.50f;break; + } +} weapondata_gun_t weapon_steyraug = { @@ -32,6 +38,7 @@ weapondata_gun_t weapon_steyraug = weapon_steyraug_onSecondaryAttackRelease, weapon_steyraug_onThink, weapon_steyraug_onColdCock, + weapon_steyraug_onSetZoomLevel, weaponseq_steyraug::idle, weaponseq_steyraug::draw, 31.0f / 30.0f, @@ -176,11 +183,8 @@ w_steyraug_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.50f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); } } diff --git a/src/shared/weapons/weapon_steyrtmp.qc b/src/shared/weapons/weapon_steyrtmp.qc index 584e8fe..c8c1060 100644 --- a/src/shared/weapons/weapon_steyrtmp.qc +++ b/src/shared/weapons/weapon_steyrtmp.qc @@ -39,6 +39,7 @@ weapondata_ironsight_t weapon_steyrtmp = weapon_steyrtmp_onSecondaryAttackRelease, weapon_steyrtmp_onThink, weapon_steyrtmp_onColdCock, + NULL, weaponseq_steyrtmp::idle, weaponseq_steyrtmp::draw, 31.0f / 35.0f, diff --git a/src/shared/weapons/weapon_ump.qc b/src/shared/weapons/weapon_ump.qc index 6531140..d19fcd5 100644 --- a/src/shared/weapons/weapon_ump.qc +++ b/src/shared/weapons/weapon_ump.qc @@ -20,6 +20,12 @@ void weapon_ump_onThink(player pl, weapondynamic_t arg_thisWeapon){ void weapon_ump_onColdCock(player pl, weapondynamic_t arg_thisWeapon){ } +void weapon_ump_onSetZoomLevel(player pl){ + switch(pl.iZoomLevel){ + case 0:pl.flZoomTarget = 1.00f;break; + case 1:pl.flZoomTarget = 0.50f;break; + } +} weapondata_gun_t weapon_ump = { @@ -34,6 +40,7 @@ weapondata_gun_t weapon_ump = weapon_ump_onSecondaryAttackRelease, weapon_ump_onThink, weapon_ump_onColdCock, + weapon_ump_onSetZoomLevel, weaponseq_ump::idle, weaponseq_ump::draw, 26.0f / 35.0f, @@ -187,11 +194,8 @@ w_ump_secondary(void) if(arg_thisWeapon.iBitsUpgrade & BITS_WEAPONOPT_SCOPE){ // toggle through the zoom. - pl.iZoomLevel = (pl.iZoomLevel + 1) % 2; - switch(pl.iZoomLevel){ - case 0:pl.setZoom(1.00f);break; - case 1:pl.setZoom(0.50f);break; - } + int newZoomLevel = ((float)pl.iZoomLevel + 1) % 2; + pl.setZoomLevel(newZoomLevel); } } diff --git a/src/shared/weapons/weapon_usas12.qc b/src/shared/weapons/weapon_usas12.qc index 8addaa8..8b0be98 100644 --- a/src/shared/weapons/weapon_usas12.qc +++ b/src/shared/weapons/weapon_usas12.qc @@ -31,6 +31,7 @@ weapondata_gun_t weapon_usas12 = weapon_usas12_onSecondaryAttackRelease, weapon_usas12_onThink, weapon_usas12_onColdCock, + NULL, weaponseq_usas12::idle, weaponseq_usas12::draw, 31.0f / 30.0f,