Add inventory virtuals for weapon selection

This commit is contained in:
Ricardo Luís Vaz Silva 2024-10-21 15:22:33 -03:00 committed by Major Cooke
parent 04cdbd1898
commit 362100fcf0
3 changed files with 71 additions and 4 deletions

View file

@ -315,7 +315,7 @@ CCMD (slot)
if (slot < NUM_WEAPON_SLOTS && mo) if (slot < NUM_WEAPON_SLOTS && mo)
{ {
// Needs to be redone // Needs to be redone
IFVIRTUALPTRNAME(mo, NAME_PlayerPawn, PickWeapon) IFVM(PlayerPawn, FindWeapon)
{ {
VMValue param[] = { mo, slot, !(dmflags2 & DF2_DONTCHECKAMMO) }; VMValue param[] = { mo, slot, !(dmflags2 & DF2_DONTCHECKAMMO) };
VMReturn ret((void**)&SendItemUse); VMReturn ret((void**)&SendItemUse);
@ -367,7 +367,7 @@ CCMD (weapnext)
if (mo) if (mo)
{ {
// Needs to be redone // Needs to be redone
IFVIRTUALPTRNAME(mo, NAME_PlayerPawn, PickNextWeapon) IFVM(PlayerPawn, FindNextWeapon)
{ {
VMValue param[] = { mo }; VMValue param[] = { mo };
VMReturn ret((void**)&SendItemUse); VMReturn ret((void**)&SendItemUse);
@ -394,7 +394,7 @@ CCMD (weapprev)
if (mo) if (mo)
{ {
// Needs to be redone // Needs to be redone
IFVIRTUALPTRNAME(mo, NAME_PlayerPawn, PickPrevWeapon) IFVM(PlayerPawn, FindPrevWeapon)
{ {
VMValue param[] = { mo }; VMValue param[] = { mo };
VMReturn ret((void**)&SendItemUse); VMReturn ret((void**)&SendItemUse);

View file

@ -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;
}
} }

View file

@ -2334,6 +2334,24 @@ class PlayerPawn : Actor
return ReadyWeapon; 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 // FindMostRecentWeapon
@ -2438,6 +2456,24 @@ class PlayerPawn : Actor
return ReadyWeapon; 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 // FWeaponSlots :: PickPrevWeapon
@ -2491,6 +2527,24 @@ class PlayerPawn : Actor
return player.ReadyWeapon; 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 // P_BobWeapon