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.
Various other adjustments.
This commit is contained in:
Mari the Deer 2022-06-22 01:47:34 +02:00
commit 1802b24cf8
20 changed files with 77 additions and 52 deletions

View file

@ -320,6 +320,7 @@ Class RayBolt : MagAmmo
//$Icon ammo
Tag "$T_RAYBOLT";
MagAmmo.PickupTag "RAYBOLT";
Stamina -8000;
Inventory.Icon "graphics/HUD/Icons/A_RayBolt.png";
MagAmmo.ParentAmmo "RayAmmo";
MagAmmo.ClipSize 10;
@ -397,6 +398,7 @@ Class MisterRound : MagAmmo
//$Icon ammo
Tag "$T_MRROUND";
MagAmmo.PickupTag "MRROUND";
Stamina -14000;
Inventory.Icon "graphics/HUD/Icons/A_MRRound.png";
MagAmmo.ParentAmmo "MisterAmmo";
MagAmmo.ClipSize 30;
@ -547,6 +549,7 @@ Class UltimatePod : MagAmmo
//$Icon ammo
Tag "$T_ULTIMATEPOD";
MagAmmo.PickupTag "ULTIMATEPOD";
Stamina -400000;
Inventory.PickupSound "misc/bullet_pkup_vip";
Inventory.Icon "graphics/HUD/Icons/A_UltimatePod.png";
MagAmmo.ParentAmmo "UltimateAmmo";

View file

@ -5,6 +5,7 @@ Class RayKhom : SWWMWeapon
{
int clipcount, clipcount2;
bool chambered;
int charge;
Property ClipCount : clipcount;

View file

@ -5,6 +5,7 @@ Class RafanKos : SWWMWeapon
{
int clipcount;
bool chambered;
int charge;
Property ClipCount : clipcount;

View file

@ -807,6 +807,7 @@ Class SilverBullets : MagAmmo
//$Icon ammo
Tag "$T_XSBBULLET";
MagAmmo.PickupTag "XSBBULLET";
Stamina -12000;
Inventory.Icon "graphics/HUD/Icons/A_SilverBulletBullet.png";
MagAmmo.ParentAmmo "SilverBulletAmmo";
MagAmmo.ClipSize 5;
@ -859,6 +860,7 @@ Class SilverBullets2 : MagAmmo
//$Icon ammo
Tag "$T_FCBBULLET";
MagAmmo.PickupTag "FCBBULLET";
Stamina -15000;
Inventory.Icon "graphics/HUD/Icons/A_SilverBulletBullet2.png";
MagAmmo.ParentAmmo "SilverBulletAmmo2";
MagAmmo.ClipSize 5;
@ -948,6 +950,7 @@ Class CandyGunBullets : MagAmmo
//$Icon ammo
Tag "$T_CANDYBULLET";
MagAmmo.PickupTag "CANDYBULLET";
Stamina -14000;
Inventory.Icon "graphics/HUD/Icons/A_CandyBullet.png";
MagAmmo.ParentAmmo "CandyGunAmmo";
MagAmmo.ClipSize 7;

View file

@ -4,7 +4,7 @@ Class ArmorNugget : SWWMArmor
Default
{
Inventory.Icon "graphics/HUD/Icons/I_ArmorNugget.png";
Inventory.Amount 1;
Inventory.Amount 5;
Inventory.MaxAmount 200;
Inventory.InterHubAmount 200;
SWWMArmor.ArmorPriority 3;
@ -52,7 +52,7 @@ Class ArmorNuggetItem : SWWMSpareArmor
//$Sprite graphics/HUD/Icons/I_ArmorNugget.png
//$Icon armour
Tag "$T_NUGGETA";
Stamina 400;
Stamina 1200;
Inventory.PickupMessage "$T_NUGGETA";
Inventory.MaxAmount 0;
Inventory.InterHubAmount 0;

View file

@ -376,6 +376,17 @@ Class MagAmmo : Inventory abstract
// drop excess mag ammo
if ( (item is 'MagAmmo') && (MagAmmo(item).GetParentMagAmmo() == GetClass()) )
{
// can somehow happen
if ( !pamo )
{
pamo = Ammo(Owner.FindInventory(ParentAmmo));
if ( !pamo )
{
pamo = Ammo(Spawn(ParentAmmo));
pamo.AttachToOwner(Owner);
pamo.Amount = 0;
}
}
if ( bUNDROPPABLE || bUNTOSSABLE )
{
// undroppable mag ammo only drops full mags.

View file

@ -140,7 +140,7 @@ Class SWWMSpareArmor : Inventory abstract
override bool Use( bool pickup )
{
let cur = Owner.FindInventory(giveme);
if ( !cur || (!pickup && (cur.Amount < cur.MaxAmount)) || (GetDefaultByType(giveme).Amount+cur.Amount <= cur.MaxAmount) )
if ( !cur || (!pickup && (cur.Amount < cur.MaxAmount)) || (GetDefaultByType(giveme).Amount+cur.Amount <= cur.MaxAmount) || ((default.MaxAmount > 0) && (cur.Amount < cur.MaxAmount)) )
{
if ( pickup && ((Owner.player == players[consoleplayer]) || bBigPowerup) ) Owner.A_StartSound(UseSound,CHAN_ITEMEXTRA,CHANF_OVERLAP);
Owner.GiveInventory(giveme,GetDefaultByType(giveme).Amount);

View file

@ -70,8 +70,8 @@ Class SWWMHealth : Inventory abstract
override bool Use( bool pickup )
{
if ( Owner.Health >= GetDefaultByType(giveme).MaxAmount ) return false;
// healing items won't get auto-used on pickup if their healing could "be wasted", unless they're powerup health (e.g. Refresher)
if ( pickup && !bBIGPOWERUP && (Owner.Health+GetDefaultByType(giveme).Amount > GetDefaultByType(giveme).MaxAmount) ) return false;
// healing items won't get auto-used on pickup if their healing could "be wasted", unless they're powerup health (e.g. Refresher) or bonus health
if ( pickup && !bBIGPOWERUP && (default.MaxAmount > 0) && (Owner.Health+GetDefaultByType(giveme).Amount > GetDefaultByType(giveme).MaxAmount) ) return false;
if ( pickup && ((Owner.player == players[consoleplayer]) || bBigPowerup) ) Owner.A_StartSound(UseSound,CHAN_ITEMEXTRA,CHANF_OVERLAP);
SWWMHandler.HealthFlash(Owner.PlayerNumber());
Owner.GiveInventory(giveme,GetDefaultByType(giveme).Amount);

View file

@ -3,7 +3,7 @@ Class HealthNugget : Health
{
Default
{
Inventory.Amount 1;
Inventory.Amount 2;
Inventory.MaxAmount 200;
}
}
@ -96,7 +96,7 @@ Class HealthNuggetItem : SWWMHealth
//$Sprite graphics/HUD/Icons/I_HealthNugget.png
//$Icon health
Tag "$T_NUGGETH";
Stamina 200;
Stamina 500;
Inventory.PickupMessage "$T_NUGGETH";
Inventory.MaxAmount 0;
Inventory.InterHubAmount 0;

View file

@ -3018,9 +3018,9 @@ Class MykradvoX : GhostArtifactX
Destroy();
return;
}
prev = target.prev+(0,0,16);
prev = target.prev;
vel = target.vel;
if ( (target.pos != pos+(0,0,16)) || (target.vel != (0,0,0)) ) SetOrigin(target.pos+(0,0,16)+vel,true);
if ( (target.pos != pos) || (target.vel != (0,0,0)) ) SetOrigin(target.pos+vel,true);
if ( angle != target.angle ) A_SetAngle(target.angle,SPF_INTERPOLATE);
FloatBobPhase = target.FloatBobPhase;
A_SetScale(.16+.01*sin(GetAge()*4));

View file

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