Allow certain items to be sold (but not bought).

Readjust Tier 4 Ammo Fabricator so it produces 50% of (base) max ammo, rather than full ammo (mainly for balance).
This commit is contained in:
Mari the Deer 2021-02-14 19:35:51 +01:00
commit 15b04386a1
5 changed files with 69 additions and 47 deletions

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r274 \cu(Sun 14 Feb 18:21:28 CET 2021)\c-";
SWWM_SHORTVER="\cw0.9.11b-pre r274 \cu(2021-02-14 18:21:29)\c-";
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r275 \cu(Sun 14 Feb 19:35:51 CET 2021)\c-";
SWWM_SHORTVER="\cw0.9.11b-pre r275 \cu(2021-02-14 19:35:51)\c-";

View file

@ -783,7 +783,7 @@ Class GoldShell : Ammo
Default
{
Tag "$T_GOLDSHELLS";
Stamina 0;
Stamina -1000000;
Inventory.Icon "graphics/HUD/Icons/A_ShellsGold.png";
Inventory.Amount 1;
Inventory.MaxAmount 7;
@ -1555,7 +1555,7 @@ Class AmmoFabricator : Inventory abstract
// only direct descendants of ammo with a set price below our max unit price
if ( !a || (a.GetParentClass() != 'Ammo') ) continue;
let def = GetDefaultByType(a);
if ( !(def.Stamina) || (def.Stamina > maxunitprice) ) continue;
if ( (def.Stamina <= 0) || (def.Stamina > maxunitprice) ) continue;
// only ammo for weapons that are valid (can be used)
bool isvalid = false;
for ( int j=0; j<AllActorClasses.Size(); j++ )
@ -1589,6 +1589,7 @@ Class AmmoFabricator : Inventory abstract
int consumed = 0;
String fabstr = "";
bool comma = false;
int tpertype = pertype;
for ( int i=0; i<available.Size(); i++ )
{
int amt, lim;
@ -1606,7 +1607,9 @@ Class AmmoFabricator : Inventory abstract
lim = cur.MaxAmount;
cur.AttachToOwner(Owner);
}
while ( (amt < lim) && (consumed+cur.default.Stamina < budget) && (cnt < pertype) )
// percentage based on DEFAULT max amount (capped at 1 minimum)
if ( pertype < 0 ) tpertype = max(1,-int(cur.default.MaxAmount*pertype*.01));
while ( (amt < lim) && (consumed+cur.default.Stamina < budget) && (cnt < tpertype) )
{
consumed += cur.default.Stamina;
amt = ++cur.Amount;
@ -1665,6 +1668,7 @@ Class FabricatorTier1 : AmmoFabricator
Default
{
Tag "$T_FABRICATOR1";
Stamina -2500;
Inventory.Icon "graphics/HUD/Icons/I_Fabricator1.png";
Inventory.PickupMessage "$T_FABRICATOR1";
Inventory.MaxAmount 20;
@ -1681,6 +1685,7 @@ Class FabricatorTier2 : AmmoFabricator
Default
{
Tag "$T_FABRICATOR2";
Stamina -12000;
Inventory.Icon "graphics/HUD/Icons/I_Fabricator2.png";
Inventory.PickupMessage "$T_FABRICATOR2";
Inventory.MaxAmount 15;
@ -1697,11 +1702,12 @@ Class FabricatorTier3 : AmmoFabricator
Default
{
Tag "$T_FABRICATOR3";
Stamina -80000;
Inventory.Icon "graphics/HUD/Icons/I_Fabricator3.png";
Inventory.PickupMessage "$T_FABRICATOR3";
Inventory.MaxAmount 10;
Inventory.InterHubAmount 10;
AmmoFabricator.Budget 80000;
AmmoFabricator.Budget 100000;
AmmoFabricator.PerType 4;
AmmoFabricator.MaxUnitPrice 80000;
}
@ -1711,12 +1717,13 @@ Class FabricatorTier4 : AmmoFabricator
Default
{
Tag "$T_FABRICATOR4";
Stamina -1000000;
Inventory.Icon "graphics/HUD/Icons/I_Fabricator4.png";
Inventory.PickupMessage "$T_FABRICATOR4";
Inventory.MaxAmount 5;
Inventory.InterHubAmount 5;
AmmoFabricator.Budget int.max;
AmmoFabricator.PerType int.max;
AmmoFabricator.PerType -50;
AmmoFabricator.MaxUnitPrice 1000000;
-INVENTORY.AUTOACTIVATE;
}
@ -1842,8 +1849,6 @@ Class HammerspaceEmbiggener : Inventory
double factor = (Ammo(item).BackpackMaxAmount-item.default.MaxAmount)/double(MaxAmount);
item.MaxAmount = int(item.default.MaxAmount+Amount*factor);
}
if ( Ammo(item).BackpackMaxAmount > 0 )
item.MaxAmount = min(item.MaxAmount,Ammo(item).BackpackMaxAmount);
}
return res;
}
@ -1863,6 +1868,7 @@ Class HammerspaceEmbiggener : Inventory
Default
{
Tag "$T_EMBIGGENER";
Stamina -800000;
Inventory.PickupMessage "$T_EMBIGGENER";
Inventory.MaxAmount 8;
Inventory.InterHubAmount 8;

View file

@ -2917,6 +2917,23 @@ Class SWWMHandler : EventHandler
players[e.Args[0]].SetPSprite(PSP_WEAPON+1,null); // delete left weapon psprite
}
}
// if we're selling an embiggener, we need to readjust ammo
if ( item is 'HammerspaceEmbiggener' )
{
let ritm = players[e.Args[0]].mo.FindInventory(item);
for ( Inventory i=players[e.Args[0]].mo.Inv; i; i=i.Inv )
{
if ( !(i is 'Ammo') ) continue;
if ( Ammo(i).BackpackMaxAmount > 0 )
{
double factor = (Ammo(i).BackpackMaxAmount-i.default.MaxAmount)/double(ritm.MaxAmount);
i.MaxAmount = int(i.default.MaxAmount+(ritm.Amount-amt)*factor);
}
// drop excess ammo
int excess = i.Amount-i.MaxAmount;
if ( excess > 0 ) i.CreateTossable(excess);
}
}
players[e.Args[0]].mo.TakeInventory(item,amt);
SWWMCredits.Give(players[e.Args[0]],e.Args[1]);
}

View file

@ -7,9 +7,9 @@ Mixin Class SWWMAutoUseFix
{
if ( Use(true) ) Amount--;
// sell excess if there's a price
if ( bALWAYSPICKUP && (Amount+item.Amount > MaxAmount) && (Stamina > 0) )
if ( bALWAYSPICKUP && (Amount+item.Amount > MaxAmount) && (Stamina != 0) )
{
int sellprice = int(Stamina*.5);
int sellprice = int(abs(Stamina)*.5);
SWWMScoreObj.Spawn(sellprice,Owner.Vec3Offset(FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8)+Owner.Height/2));
SWWMCredits.Give(Owner.player,sellprice);
if ( Owner.player )

View file

@ -819,7 +819,7 @@ Class DemolitionistMenu : GenericMenu
{
let itm = GetDefaultByType(storelist[sel0]);
let amt = storeunits[sel0];
int price = int(itm.Stamina*(1.+.75*(amt-1)));
int price = int(abs(itm.Stamina)*(1.+.75*(amt-1)));
let cur = players[consoleplayer].mo.FindInventory(storelist[sel0]);
if ( sub )
{
@ -1810,16 +1810,16 @@ Class DemolitionistMenu : GenericMenu
int ta = 0, tb = 0;
if ( a is 'Weapon' ) ta = 2;
else if ( (a is 'BackpackItem') || (a is 'HammerspaceEmbiggener') ) ta = 3;
else if ( (a is 'Ammo') ) ta = 4;
else if ( (a is 'MagAmmo') ) ta = 5;
else if ( a is 'Ammo' ) ta = 4;
else if ( a is 'MagAmmo' ) ta = 5;
else if ( (a is 'PowerupGiver') || (a is 'AmmoFabricator') || a.bBIGPOWERUP ) ta = -3;
else if ( (a is 'Health') || (a is 'HealthPickup') || (a is 'SWWMHealth') ) ta = -2;
else if ( (a is 'Armor') || (a is 'SWWMSpareArmor') ) ta = -1;
else if ( a is 'PuzzleItem' ) ta = 1;
if ( b is 'Weapon' ) tb = 2;
else if ( (b is 'BackpackItem') || (b is 'HammerspaceEmbiggener') ) tb = 3;
else if ( (b is 'Ammo') ) tb = 4;
else if ( (b is 'MagAmmo') ) tb = 5;
else if ( b is 'Ammo' ) tb = 4;
else if ( b is 'MagAmmo' ) tb = 5;
else if ( (b is 'PowerupGiver') || (b is 'AmmoFabricator') || b.bBIGPOWERUP ) tb = -3;
else if ( (b is 'Health') || (b is 'HealthPickup') || (b is 'SWWMHealth') ) tb = -2;
else if ( (b is 'Armor') || (b is 'SWWMSpareArmor') ) tb = -1;
@ -1874,11 +1874,8 @@ Class DemolitionistMenu : GenericMenu
if ( slota == slotb )
{
// sort by unit value
// (special, those with zero value go last)
int vala = a.default.Stamina;
if ( vala == 0 ) vala = int.max;
int valb = b.default.Stamina;
if ( valb == 0 ) valb = int.max;
int vala = abs(a.default.Stamina);
int valb = abs(b.default.Stamina);
if ( vala == valb )
{
// sort alphabetically
@ -1929,11 +1926,8 @@ Class DemolitionistMenu : GenericMenu
if ( slota == slotb )
{
// sort by unit value
// (special, those with zero value go last)
int vala = GetDefaultByType(pamoa).Stamina;
if ( vala == 0 ) vala = int.max;
int valb = GetDefaultByType(pamob).Stamina;
if ( valb == 0 ) valb = int.max;
if ( vala == valb )
{
// sort alphabetically
@ -1947,11 +1941,8 @@ Class DemolitionistMenu : GenericMenu
else
{
// sort by unit value
// (special, those with zero value go last)
int vala = a.default.Stamina;
if ( vala == 0 ) vala = int.max;
int valb = b.default.Stamina;
if ( valb == 0 ) valb = int.max;
int vala = abs(a.default.Stamina);
int valb = abs(b.default.Stamina);
if ( vala == valb )
{
// sort alphabetically
@ -1968,25 +1959,29 @@ Class DemolitionistMenu : GenericMenu
int ta = 0, tb = 0;
let da = GetDefaultByType(a);
let db = GetDefaultByType(b);
if ( a is 'Weapon' ) ta = 2;
else if ( a is 'Ammo' ) ta = 1;
else if ( (a is 'PowerupGiver') || da.bBIGPOWERUP ) ta = 3;
else if ( (a is 'Health') || (a is 'HealthPickup') || (a is 'SWWMHealth') ) ta = 5;
else if ( (a is 'Armor') || (a is 'SWWMSpareArmor') ) ta = 4;
if ( b is 'Weapon' ) tb = 2;
else if ( b is 'Ammo' ) tb = 1;
else if ( (b is 'PowerupGiver') || db.bBIGPOWERUP ) tb = 3;
else if ( (b is 'Health') || (b is 'HealthPickup') || (b is 'SWWMHealth') ) tb = 5;
else if ( (b is 'Armor') || (b is 'SWWMSpareArmor') ) tb = 4;
if ( a is 'Weapon' ) ta = 4;
else if ( a is 'HammerspaceEmbiggener' ) ta = 3;
else if ( a is 'Ammo' ) ta = 2;
else if ( a is 'MagAmmo' ) ta = 1;
else if ( (a is 'PowerupGiver') || (a is 'AmmoFabricator') || da.bBIGPOWERUP ) ta = 5;
else if ( (a is 'Health') || (a is 'HealthPickup') || (a is 'SWWMHealth') ) ta = 7;
else if ( (a is 'Armor') || (a is 'SWWMSpareArmor') ) ta = 6;
if ( b is 'Weapon' ) tb = 4;
else if ( b is 'HammerspaceEmbiggener' ) tb = 3;
else if ( b is 'Ammo' ) tb = 2;
else if ( b is 'MagAmmo' ) ta = 1;
else if ( (b is 'PowerupGiver') || (b is 'AmmoFabricator') || db.bBIGPOWERUP ) tb = 5;
else if ( (b is 'Health') || (b is 'HealthPickup') || (b is 'SWWMHealth') ) tb = 7;
else if ( (b is 'Armor') || (b is 'SWWMSpareArmor') ) tb = 6;
if ( ta == tb )
{
// sort by unit price
if ( da.Stamina == db.Stamina )
if ( abs(da.Stamina) == abs(db.Stamina) )
{
// sort alphabetically
return da.GetTag() > db.GetTag();
}
return da.Stamina > db.Stamina;
return abs(da.Stamina) > abs(db.Stamina);
}
return ta < tb;
}
@ -2293,9 +2288,11 @@ Class DemolitionistMenu : GenericMenu
}
// ignore child ammos
if ( (type is 'Ammo') && (type.GetParentClass() != 'Ammo') ) continue;
if ( inv.Stamina <= 0 ) continue;
if ( inv.Stamina == 0 ) continue;
// items with negative stamina can only be sold
if ( (inv.Stamina < 0) && !sub ) continue;
int amt = inv.Amount;
int price = int(inv.Stamina*(1.+.75*(amt-1)));
int price = int(abs(inv.Stamina)*(1.+.75*(amt-1)));
if ( type is 'Ammo' )
{
int maxamt;
@ -2307,7 +2304,7 @@ Class DemolitionistMenu : GenericMenu
let type2 = (Class<Ammo>)(AllActorClasses[j]);
if ( !type2 || (type2.GetParentClass() != type) ) continue;
let inv2 = GetDefaultByType(type2);
int cprice = int(inv.Stamina*(1.+.75*(inv2.Amount-1)));
int cprice = int(abs(inv.Stamina)*(1.+.75*(inv2.Amount-1)));
if ( (inv2.Amount > amt) && (inv2.Amount <= maxamt) && (sub || SWWMCredits.CanTake(players[consoleplayer],cprice)) )
{
price = cprice;
@ -2362,7 +2359,7 @@ Class DemolitionistMenu : GenericMenu
for ( int j=0; j<storelist.Size(); j++ )
{
let inv2 = GetDefaultByType(storelist[j]);
if ( inv.Stamina > inv2.Stamina ) continue;
if ( abs(inv.Stamina) > abs(inv2.Stamina) ) continue;
greater = true;
storelist.Insert(j,type);
storeunits.Insert(j,amt);
@ -3228,8 +3225,10 @@ Class DemolitionistMenu : GenericMenu
else str = def.GetTag();
int clscol = Font.CR_WHITE;
if ( storelist[i] is 'Weapon' ) clscol = Font.CR_GOLD;
else if ( storelist[i] is 'MagAmmo' ) clscol = Font.CR_TAN;
else if ( (storelist[i] is 'BackpackItem') || (storelist[i] is 'HammerspaceEmbiggener') ) clscol = Font.CR_DARKBROWN;
else if ( storelist[i] is 'Ammo' ) clscol = Font.CR_BROWN;
else if ( (storelist[i] is 'PowerupGiver') || def.bBIGPOWERUP ) clscol = Font.CR_PURPLE;
else if ( (storelist[i] is 'PowerupGiver') || (storelist[i] is 'AmmoFabricator') || def.bBIGPOWERUP ) clscol = Font.CR_PURPLE;
else if ( (storelist[i] is 'Health') || (storelist[i] is 'HealthPickup') || (storelist[i] is 'SWWMHealth') ) clscol = Font.CR_RED;
else if ( (storelist[i] is 'Armor') || (storelist[i] is 'SWWMSpareArmor') ) clscol = Font.CR_GREEN;
Screen.DrawText(fnt,clscol,origin.x+xx,origin.y+yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ColorOverlay,(i!=sel0)?Color(96,0,0,0):Color(0,0,0,0));
@ -3249,7 +3248,7 @@ Class DemolitionistMenu : GenericMenu
{
if ( !storelist[i] ) continue;
let def = GetDefaultByType(storelist[i]);
int price = int(def.Stamina*(1.+.75*(storeunits[i]-1)));
int price = int(abs(def.Stamina)*(1.+.75*(storeunits[i]-1)));
if ( sub && (storelist[i] is 'Weapon') )
{
let w = Weapon(def);