Nuggets give 2 health / 5 armor.
Mag ammo can now be sold. Fix selling prices of bulk items. Fix rare case where mag ammo can be picked up without a parent. Fix alt hud crash when no weapon is selected. Various other adjustments.
This commit is contained in:
parent
f8ec71cf7f
commit
099d7fd55b
21 changed files with 78 additions and 53 deletions
|
|
@ -141,6 +141,7 @@ Class DemolitionistStoreTab : DemolitionistMenuTab
|
|||
}
|
||||
// ignore child ammos
|
||||
if ( (type is 'Ammo') && (type.GetParentClass() != 'SWWMAmmo') ) return true;
|
||||
if ( (type is 'MagAmmo') && (type.GetParentClass() != 'MagAmmo') ) return true;
|
||||
// items must have a set price
|
||||
if ( inv.Stamina == 0 ) return true;
|
||||
// items with negative stamina can only be sold
|
||||
|
|
@ -478,21 +479,33 @@ Class DemolitionistMenuStoreItem : DemolitionistMenuListItem
|
|||
}
|
||||
}
|
||||
}
|
||||
// nuggets can be bought/sold in bulk
|
||||
else if ( inv is 'MagAmmo' )
|
||||
{
|
||||
// never bought, only sold
|
||||
int maxamt = cur.Amount;
|
||||
// get the largest affordable child pickup amount (that we can sell)
|
||||
for ( int j=0; j<AllActorClasses.Size(); j++ )
|
||||
{
|
||||
let inv2 = (Class<MagAmmo>)(AllActorClasses[j]);
|
||||
if ( !inv2 || (inv2.GetParentClass() != inv) ) continue;
|
||||
let def2 = GetDefaultByType(inv2);
|
||||
int cprice = int(abs(def.Stamina)*(1.+.75*(def2.Amount-1)));
|
||||
if ( (def2.Amount > amt) && (def2.Amount <= maxamt) )
|
||||
{
|
||||
price = cprice;
|
||||
amt = def2.Amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
// nuggets can be bought in bulk
|
||||
else if ( inv is 'HealthNuggetItem' )
|
||||
{
|
||||
let def2 = GetDefaultByType(SWWMHealth(def).giveme);
|
||||
int maxamt;
|
||||
if ( bSell ) maxamt = cur.Amount;
|
||||
else
|
||||
{
|
||||
maxamt = (def2.MaxAmount-players[consoleplayer].Health);
|
||||
maxamt += cur?(cur.MaxAmount-cur.Amount):def.MaxAmount;
|
||||
}
|
||||
for ( int j=5; j<=20; j+=5 )
|
||||
int maxamt = int(ceil((def2.MaxAmount-players[consoleplayer].Health)/double(def2.Amount)));
|
||||
for ( int j=5; j<=25; j+=5 )
|
||||
{
|
||||
int cprice = int(def.Stamina*(1.+.75*(j-1)));
|
||||
if ( (j <= maxamt) && (bSell || SWWMCredits.CanTake(players[consoleplayer],cprice)) )
|
||||
if ( (j <= maxamt) && SWWMCredits.CanTake(players[consoleplayer],cprice) )
|
||||
{
|
||||
price = cprice;
|
||||
amt = j;
|
||||
|
|
@ -503,17 +516,11 @@ Class DemolitionistMenuStoreItem : DemolitionistMenuListItem
|
|||
{
|
||||
let def2 = GetDefaultByType(SWWMSpareArmor(def).giveme);
|
||||
let cur2 = players[consoleplayer].mo.FindInventory(SWWMSpareArmor(def).giveme);
|
||||
int maxamt;
|
||||
if ( bSell ) maxamt = cur.Amount;
|
||||
else
|
||||
{
|
||||
maxamt = cur2?(cur2.MaxAmount-cur2.Amount):def2.MaxAmount;
|
||||
maxamt += cur?(cur.MaxAmount-cur.Amount):def.MaxAmount;
|
||||
}
|
||||
int maxamt = int(ceil((cur2?(cur2.MaxAmount-cur2.Amount):def2.MaxAmount)/double(def2.Amount)));
|
||||
for ( int j=5; j<=20; j+=5 )
|
||||
{
|
||||
int cprice = int(def.Stamina*(1.+.75*(j-1)));
|
||||
if ( (j <= maxamt) && (bSell || SWWMCredits.CanTake(players[consoleplayer],cprice)) )
|
||||
if ( (j <= maxamt) && SWWMCredits.CanTake(players[consoleplayer],cprice) )
|
||||
{
|
||||
price = cprice;
|
||||
amt = j;
|
||||
|
|
@ -527,17 +534,16 @@ Class DemolitionistMenuStoreItem : DemolitionistMenuListItem
|
|||
if ( w.AmmoType1 && (w.AmmoGive1 > 0) )
|
||||
{
|
||||
let am1 = GetDefaultByType(w.AmmoType1);
|
||||
if ( am1.Stamina > 0 ) price -= int(am1.Stamina*(1.+.75*(w.AmmoGive1-1)));
|
||||
if ( am1.Stamina != 0 ) price -= int(abs(am1.Stamina)*(1.+.75*(w.AmmoGive1-1)));
|
||||
}
|
||||
// candygun and rafan-kos are a special case for secondary ammo
|
||||
if ( w.AmmoType2 && (w.AmmoGive2 > 0) && ((inv is 'CandyGun') || (inv is 'RafanKos')) )
|
||||
if ( w.AmmoType2 && (w.AmmoGive2 > 0) )
|
||||
{
|
||||
let am2 = GetDefaultByType(w.AmmoType2);
|
||||
if ( am2.Stamina > 0 ) price -= int(am2.Stamina*(1.+.75*(w.AmmoGive2-1)));
|
||||
if ( am2.Stamina != 0 ) price -= int(abs(am2.Stamina)*(1.+.75*(w.AmmoGive2-1)));
|
||||
}
|
||||
}
|
||||
// sell at half price
|
||||
if ( bSell ) price /= 2;
|
||||
if ( bSell ) price = int(abs(def.Stamina)*amt)/2;
|
||||
return price, amt;
|
||||
}
|
||||
|
||||
|
|
@ -551,14 +557,14 @@ Class DemolitionistMenuStoreItem : DemolitionistMenuListItem
|
|||
{
|
||||
pricelabel = String.Format("\cd¥%d\c-",price);
|
||||
int cur = (inv is 'CandyGun')?(players[consoleplayer].mo.CountInv("CandyGunSpares")+1):players[consoleplayer].mo.CountInv(inv);
|
||||
if ( (cur > 1) || (inv is 'Ammo') ) label = String.Format("%s (%d/%d)",def.GetTag(),amt,cur);
|
||||
if ( (cur > 1) || (inv is 'Ammo') || (inv is 'MagAmmo') ) label = String.Format("%s (%d/%d)",def.GetTag(),amt,cur);
|
||||
else label = def.GetTag();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( price > master.muns ) pricelabel = String.Format("\cm¥%d\c-",price);
|
||||
else pricelabel = String.Format("\cx¥%d\cx",price);
|
||||
if ( (amt > 1) || (inv is 'Ammo') ) label = String.Format("%dx %s",amt,def.GetTag());
|
||||
if ( (amt > 1) || (inv is 'Ammo') || (inv is 'MagAmmo') ) label = String.Format("%dx %s",amt,def.GetTag());
|
||||
else label = def.GetTag();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue