Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weapon Selection Modifiers #2804

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/g_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion wadsrc/static/zscript/actors/inventory/inventory.zs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

Expand Down
75 changes: 75 additions & 0 deletions wadsrc/static/zscript/actors/player/player.zs
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,31 @@ 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;
}

virtual Weapon PostFindWeapon(int slot, bool checkammo, Weapon orig, Weapon mod)
{
return mod;
}

Weapon FindWeapon(int slot, bool checkammo)
{
let orig = PickWeapon(slot, checkammo);
let mod = CallModifyPickWeapon(slot, checkammo, orig);
return PostFindWeapon(slot, checkammo, orig, mod);
}

//===========================================================================
//
// FindMostRecentWeapon
Expand Down Expand Up @@ -2438,6 +2463,31 @@ 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;
}

virtual Weapon PostFindNextWeapon(Weapon orig, Weapon mod)
{
return mod;
}

Weapon FindNextWeapon()
{
let orig = PickNextWeapon();
let mod = CallModifyPickNextWeapon(orig);
return PostFindNextWeapon(orig, mod);
}

//===========================================================================
//
// FWeaponSlots :: PickPrevWeapon
Expand Down Expand Up @@ -2491,6 +2541,31 @@ 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;
}

virtual Weapon PostFindPrevWeapon(Weapon orig, Weapon mod)
{
return mod;
}

Weapon FindPrevWeapon()
{
let orig = PickPrevWeapon();
let mod = CallModifyPickPrevWeapon(orig);
return PostFindPrevWeapon(orig, mod);
}

//============================================================================
//
// P_BobWeapon
Expand Down