Hacky workaround for "spare eating" store bug.

Health/Armor nuggets can now be bought in bulk (increments of 5 up to 20).
Armor nuggets give 1 armor point per pickup again (sorry, people who constantly stocked up on them like mad).
Add CVars needed for achievements, just more preparation for the next update.
This commit is contained in:
Mari the Deer 2020-11-27 11:56:48 +01:00
commit eec414baa1
6 changed files with 162 additions and 5 deletions

View file

@ -4,7 +4,7 @@ Class ArmorNugget : SWWMArmor
Default
{
Inventory.Icon "graphics/HUD/Icons/I_ArmorNugget.png";
Inventory.Amount 5;
Inventory.Amount 1;
Inventory.MaxAmount 200;
Inventory.InterHubAmount 200;
SWWMArmor.ArmorPriority 10;

View file

@ -2167,7 +2167,16 @@ Class SWWMHandler : EventHandler
if ( !item ) return;
if ( SWWMCredits.Take(players[e.Args[0]],e.Args[1]) )
{
players[e.Args[0]].mo.GiveInventory(item,e.Args[2],true);
if ( (item is 'ArmorNuggetItem') || (item is 'HealthNuggetItem') )
{
// these have to be given in a loop because fun reasons
for ( int i=0; i<e.Args[2]; i++ )
players[e.Args[0]].mo.GiveInventory(item,1,true);
}
else players[e.Args[0]].mo.GiveInventory(item,e.Args[2],true);
// fucky workaround
let inv = players[e.Args[0]].mo.FindInventory(item);
if ( inv && (inv.Amount <= 0) && !inv.bKEEPDEPLETED ) inv.Destroy();
if ( item is 'Weapon' )
{
// special case, select dual guns if we bought a second one

View file

@ -2028,13 +2028,43 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
if ( !type2 || (type2.GetParentClass() != type) ) continue;
let inv2 = GetDefaultByType(type2);
int cprice = int(inv.Stamina*(1.+.75*(inv2.Amount-1)));
if ( (inv2.Amount > amt) && (inv2.Amount <= maxneed) && (cprice <= SWWMCredits.Get(players[consoleplayer])) )
if ( (inv2.Amount > amt) && (inv2.Amount <= maxneed) && SWWMCredits.CanTake(players[consoleplayer],cprice) )
{
price = cprice;
amt = inv2.Amount;
}
}
}
// nuggets can be bought in bulk
else if ( type is 'HealthNuggetItem' )
{
let inv2 = GetDefaultByType(SWWMHealth(inv).giveme);
int maxneed = (inv2.MaxAmount-players[consoleplayer].Health);
for ( int j=5; j<=20; j+=5 )
{
int cprice = int(inv.Stamina*(1.+.75*(j-1)));
if ( (j <= maxneed) && SWWMCredits.CanTake(players[consoleplayer],cprice) )
{
price = cprice;
amt = j;
}
}
}
else if ( type is 'ArmorNuggetItem' )
{
let inv2 = GetDefaultByType(SWWMSpareArmor(inv).giveme);
let cur2 = players[consoleplayer].mo.FindInventory(SWWMSpareArmor(inv).giveme);
int maxneed = cur2?(cur2.MaxAmount-cur2.Amount):inv2.MaxAmount;
for ( int j=5; j<=20; j+=5 )
{
int cprice = int(inv.Stamina*(1.+.75*(j-1)));
if ( (j <= maxneed) && SWWMCredits.CanTake(players[consoleplayer],cprice) )
{
price = cprice;
amt = j;
}
}
}
// sort by unit price
bool greater = false;
for ( int j=0; j<storelist.Size(); j++ )