diff --git a/src/g_game.cpp b/src/g_game.cpp index 42ce6e99a9..2e47af8303 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -315,7 +315,7 @@ CCMD (slot) if (slot < NUM_WEAPON_SLOTS && mo) { // Needs to be redone - IFVIRTUALPTRNAME(mo, NAME_PlayerPawn, PickWeapon) + IFVM(PlayerPawn, FindWeapon) { VMValue param[] = { mo, slot, !(dmflags2 & DF2_DONTCHECKAMMO) }; VMReturn ret((void**)&SendItemUse); @@ -367,7 +367,7 @@ CCMD (weapnext) if (mo) { // Needs to be redone - IFVIRTUALPTRNAME(mo, NAME_PlayerPawn, PickNextWeapon) + IFVM(PlayerPawn, FindNextWeapon) { VMValue param[] = { mo }; VMReturn ret((void**)&SendItemUse); @@ -394,7 +394,7 @@ CCMD (weapprev) if (mo) { // Needs to be redone - IFVIRTUALPTRNAME(mo, NAME_PlayerPawn, PickPrevWeapon) + IFVM(PlayerPawn, FindPrevWeapon) { VMValue param[] = { mo }; VMReturn ret((void**)&SendItemUse); diff --git a/wadsrc/static/zscript/actors/inventory/inventory.zs b/wadsrc/static/zscript/actors/inventory/inventory.zs index 52009f2e11..512e10a009 100644 --- a/wadsrc/static/zscript/actors/inventory/inventory.zs +++ b/wadsrc/static/zscript/actors/inventory/inventory.zs @@ -1366,7 +1366,20 @@ class Inventory : Actor } } - + virtual Weapon ModifyPickWeapon(int slot, bool checkammo, Weapon originalPick) + { + return originalPick; + } + + virtual Weapon ModifyPickNextWeapon(Weapon originalPick) + { + return originalPick; + } + + virtual Weapon ModifyPickPrevWeapon(Weapon originalPick) + { + return originalPick; + } } diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index b320b62534..91432ee200 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -2334,6 +2334,24 @@ class PlayerPawn : Actor return ReadyWeapon; } + Weapon CallModifyPickWeapon(int slot, bool checkammo, Weapon pick) + { + let cur = inv; + + if(cur) do + { + pick = cur.ModifyPickWeapon(slot, checkammo, pick); + } + while(cur = cur.inv) + + return pick; + } + + Weapon FindWeapon(int slot, bool checkammo) + { + return CallModifyPickWeapon(slot, checkammo, PickWeapon(slot, checkammo)); + } + //=========================================================================== // // FindMostRecentWeapon @@ -2438,6 +2456,24 @@ class PlayerPawn : Actor return ReadyWeapon; } + Weapon CallModifyPickNextWeapon(Weapon pick) + { + let cur = inv; + + if(cur) do + { + pick = cur.ModifyPickNextWeapon(pick); + } + while(cur = cur.inv) + + return pick; + } + + Weapon FindNextWeapon() + { + return CallModifyPickNextWeapon(PickNextWeapon()); + } + //=========================================================================== // // FWeaponSlots :: PickPrevWeapon @@ -2491,6 +2527,24 @@ class PlayerPawn : Actor return player.ReadyWeapon; } + Weapon CallModifyPickPrevWeapon(Weapon pick) + { + let cur = inv; + + if(cur) do + { + pick = cur.ModifyPickPrevWeapon(pick); + } + while(cur = cur.inv) + + return pick; + } + + Weapon FindPrevWeapon() + { + return CallModifyPickPrevWeapon(PickPrevWeapon()); + } + //============================================================================ // // P_BobWeapon