Add debug command to fix item max amounts mid-playthrough.
This commit is contained in:
parent
80a7408d5c
commit
55db5ca150
3 changed files with 83 additions and 6 deletions
|
|
@ -1,2 +1,2 @@
|
|||
[default]
|
||||
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r777 \cu(Thu 21 Jan 17:22:26 CET 2021)";
|
||||
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r778 \cu(Thu 21 Jan 18:16:09 CET 2021)";
|
||||
|
|
|
|||
|
|
@ -1678,7 +1678,6 @@ Class HammerspaceEmbiggener : Inventory
|
|||
double factor = (ammoitem.BackpackMaxAmount-ammoitem.default.MaxAmount)/double(MaxAmount);
|
||||
ammoitem.MaxAmount = int(ammoitem.default.MaxAmount+self.Amount*factor);
|
||||
}
|
||||
else ammoitem.MaxAmount = int(ammoitem.default.MaxAmount*(1+self.Amount));
|
||||
if ( (ammoitem.Amount > ammoitem.MaxAmount) && !sv_unlimited_pickup )
|
||||
ammoitem.Amount = ammoitem.MaxAmount;
|
||||
ammoitem.AttachToOwner(other);
|
||||
|
|
@ -1691,7 +1690,6 @@ Class HammerspaceEmbiggener : Inventory
|
|||
double factor = (ammoitem.BackpackMaxAmount-ammoitem.default.MaxAmount)/double(MaxAmount);
|
||||
ammoitem.MaxAmount = int(ammoitem.default.MaxAmount+self.Amount*factor);
|
||||
}
|
||||
else ammoitem.MaxAmount = int(ammoitem.default.MaxAmount*(1+self.Amount));
|
||||
if ( ammoitem.Amount < ammoitem.MaxAmount )
|
||||
{
|
||||
ammoitem.Amount += amount;
|
||||
|
|
@ -1718,7 +1716,6 @@ Class HammerspaceEmbiggener : Inventory
|
|||
double factor = (Ammo(i).BackpackMaxAmount-i.default.MaxAmount)/double(MaxAmount);
|
||||
i.MaxAmount = int(i.default.MaxAmount+Amount*factor);
|
||||
}
|
||||
else i.MaxAmount = int(i.default.MaxAmount*(1+Amount));
|
||||
int amount = Ammo(i).BackpackAmount;
|
||||
if ( !bIgnoreSkill ) amount = int(amount*G_SkillPropertyFloat(SKILLP_AmmoFactor));
|
||||
i.Amount += amount;
|
||||
|
|
@ -1734,7 +1731,6 @@ Class HammerspaceEmbiggener : Inventory
|
|||
double factor = (Ammo(item).BackpackMaxAmount-item.default.MaxAmount)/double(MaxAmount);
|
||||
item.MaxAmount = int(item.default.MaxAmount+Amount*factor);
|
||||
}
|
||||
else item.MaxAmount = int(item.default.MaxAmount*1+Amount);
|
||||
if ( Ammo(item).BackpackMaxAmount > 0 )
|
||||
item.MaxAmount = min(item.MaxAmount,Ammo(item).BackpackMaxAmount);
|
||||
}
|
||||
|
|
@ -1748,7 +1744,12 @@ Class HammerspaceEmbiggener : Inventory
|
|||
{
|
||||
if ( !(i is 'Ammo') ) continue;
|
||||
i.MaxAmount = i.default.MaxAmount;
|
||||
if ( i.Amount > i.MaxAmount ) i.Amount = i.MaxAmount;
|
||||
if ( i.Amount > i.MaxAmount )
|
||||
{
|
||||
int dropme = max(0,i.Amount-i.MaxAmount);
|
||||
if ( dropme > 0 ) i.CreateTossable(dropme);
|
||||
i.Amount = i.MaxAmount;
|
||||
}
|
||||
}
|
||||
Super.DepleteOrDestroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2513,6 +2513,82 @@ Class SWWMHandler : EventHandler
|
|||
}
|
||||
return;
|
||||
}
|
||||
else if ( e.Name ~== "swwmfixitemcaps" )
|
||||
{
|
||||
// this command is only really needed when I update item max amounts mid-playthrough
|
||||
if ( multiplayer && (e.player != Net_Arbitrator) )
|
||||
{
|
||||
if ( e.player == consoleplayer )
|
||||
Console.Printf("Only the net arbitrator can call this event.");
|
||||
return;
|
||||
}
|
||||
for ( int i=0; i<MAXPLAYERS; i++ )
|
||||
{
|
||||
if ( !playeringame[i] || !players[i].mo ) continue;
|
||||
let mo = players[i].mo;
|
||||
Inventory hams = mo.FindInventory("HammerspaceEmbiggener");
|
||||
if ( hams )
|
||||
{
|
||||
if ( hams.MaxAmount != hams.default.MaxAmount )
|
||||
Console.Printf("Adjust %s capacity (%d -> %d)",hams.GetTag(),hams.MaxAmount,hams.default.MaxAmount);
|
||||
hams.MaxAmount = hams.default.MaxAmount;
|
||||
hams.Amount = min(hams.Amount,hams.MaxAmount);
|
||||
}
|
||||
for ( Inventory inv=mo.inv; inv; inv=inv.inv )
|
||||
{
|
||||
if ( inv is 'Ammo' )
|
||||
{
|
||||
Ammo(inv).BackpackMaxAmount = Ammo(inv).default.BackpackMaxAmount;
|
||||
int newmax = inv.default.MaxAmount;
|
||||
if ( (hams.Amount > 0) && (Ammo(inv).BackpackMaxAmount > 0) )
|
||||
{
|
||||
double factor = (Ammo(inv).BackpackMaxAmount-inv.default.MaxAmount)/double(hams.MaxAmount);
|
||||
newmax = int(inv.default.MaxAmount+hams.Amount*factor);
|
||||
}
|
||||
if ( inv.MaxAmount != newmax )
|
||||
Console.Printf("Adjust %s capacity (%d -> %d)",inv.GetTag(),inv.MaxAmount,newmax);
|
||||
int dropme = max(0,inv.Amount-newmax);
|
||||
if ( dropme )
|
||||
{
|
||||
Console.Printf("Dropped %dx %s.",dropme,inv.GetTag());
|
||||
// non-SWWM ammos won't subdivide, but whatever, this is a debug command
|
||||
inv.CreateTossable(dropme);
|
||||
}
|
||||
inv.MaxAmount = newmax;
|
||||
}
|
||||
else if ( inv is 'MagAmmo' )
|
||||
{
|
||||
if ( inv.MaxAmount != inv.default.MaxAmount )
|
||||
Console.Printf("Adjust %s capacity (%d -> %d)",inv.GetTag(),inv.MaxAmount,inv.default.MaxAmount);
|
||||
// just drop the extras
|
||||
int dropme = max(0,inv.Amount-inv.default.MaxAmount);
|
||||
if ( dropme )
|
||||
{
|
||||
Console.Printf("Dropped %dx %s.",dropme,inv.GetTag());
|
||||
inv.CreateTossable(dropme);
|
||||
}
|
||||
inv.MaxAmount = inv.default.MaxAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( inv.MaxAmount != inv.default.MaxAmount )
|
||||
Console.Printf("Adjust %s capacity (%d -> %d)",inv.GetTag(),inv.MaxAmount,inv.default.MaxAmount);
|
||||
// only drop droppables (obviously)
|
||||
if ( !inv.bUNDROPPABLE && !inv.bUNTOSSABLE )
|
||||
{
|
||||
int dropme = max(0,inv.Amount-inv.default.MaxAmount);
|
||||
if ( dropme )
|
||||
{
|
||||
Console.Printf("Dropped %dx %s.",dropme,inv.GetTag());
|
||||
for ( int j=0; j<dropme; j++ ) inv.CreateTossable(j);
|
||||
}
|
||||
}
|
||||
inv.MaxAmount = inv.default.MaxAmount;
|
||||
inv.Amount = min(inv.Amount,inv.MaxAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( e.Name ~== "swwmupdatetrackers" )
|
||||
{
|
||||
if ( multiplayer && (e.player != Net_Arbitrator) )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue