@@ -6,6 +6,7 @@ namespace Components
66{
77 const Game::dvar_t * Weapon::BGWeaponOffHandFix;
88 const Game::dvar_t * Weapon::CGRecoilMultiplier;
9+ const Game::dvar_t * Weapon::BGMW3Swapping;
910
1011 Game::WeaponCompleteDef* Weapon::LoadWeaponCompleteDef (const char * name)
1112 {
@@ -520,6 +521,32 @@ namespace Components
520521 GSC::Script::AddMethod (" FreezeControlsAllowLook" , PlayerCmd_FreezeControlsAllowLook);
521522 }
522523
524+
525+ typedef void (*PM_Weapon_t)(Game::pmove_s* pm, Game::pml_t * pml);
526+ PM_Weapon_t PM_Weapon = reinterpret_cast <PM_Weapon_t>(0x44C380 );
527+ ;
528+
529+ void PM_Weapon_stub (Game::pmove_s* pm, Game::pml_t * pml)
530+ {
531+ if (Weapon::BGMW3Swapping->current .enabled )
532+ {
533+ int state = pm->ps ->weapState [0x0 ].weaponState ;
534+ if (pm->cmd .weapon == pm->ps ->weapCommon .weapon &&
535+ (state == Game::WEAPON_DROPPING ||
536+ state == Game::WEAPON_DROPPING_QUICK ||
537+ state == Game::WEAPON_DROPPING_ALT ))
538+ {
539+ for (int index = 0 ; index < 2 ; index++)
540+ {
541+ pm->ps ->weapState [index].weaponState = 1 ;
542+ pm->ps ->weapState [index].weaponTime = Game::BG_GetWeaponDef (pm->ps ->weapCommon .weapon )->quickRaiseTime ;
543+ pm->ps ->weapState [index].weapAnim = 20 ;
544+ }
545+ }
546+ }
547+ PM_Weapon (pm, pml);
548+ }
549+
523550 Weapon::Weapon ()
524551 {
525552 PatchLimit ();
@@ -545,6 +572,12 @@ namespace Components
545572 Utils::Hook::Nop (0x4B3670 , 5 );
546573 Utils::Hook (0x57B4F0 , LoadNoneWeaponHookStub, HOOK_JUMP ).install ()->quick ();
547574
575+ // Alternate Weapon Swapping Mechanics
576+ BGMW3Swapping = Game::Dvar_RegisterBool (" bg_mw3Swapping" , false , Game::DVAR_CODINFO , " Enables Weapon Swapping mechnics from the iw5/iw6 engine" );
577+ Utils::Hook (0x574960 , PM_Weapon_stub, HOOK_CALL ).install ()->quick ();
578+ Utils::Hook (0x574B69 , PM_Weapon_stub, HOOK_CALL ).install ()->quick ();
579+ Utils::Hook (0x574AB2 , PM_Weapon_stub, HOOK_CALL ).install ()->quick ();
580+
548581 // Clear weapons independently from fs_game
549582 Utils::Hook::Nop (0x452C1D , 2 );
550583 Utils::Hook::Nop (0x452C24 , 5 );
0 commit comments