mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- added an amount parameter to the 'drop' CCMD.
This commit is contained in:
parent
fc101049c6
commit
e2d5a708f8
12 changed files with 45 additions and 27 deletions
|
@ -713,7 +713,7 @@ public:
|
|||
virtual bool UseInventory (AInventory *item);
|
||||
|
||||
// Tosses an item out of the inventory.
|
||||
AInventory *DropInventory (AInventory *item);
|
||||
AInventory *DropInventory (AInventory *item, int amt = -1);
|
||||
|
||||
// Removes all items from the inventory.
|
||||
void ClearInventory();
|
||||
|
|
|
@ -2271,6 +2271,9 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
case DEM_INVDROP:
|
||||
{
|
||||
DWORD which = ReadLong (stream);
|
||||
int amt = -1;
|
||||
|
||||
if (type == DEM_INVDROP) amt = ReadLong(stream);
|
||||
|
||||
if (gamestate == GS_LEVEL && !paused
|
||||
&& players[player].playerstate != PST_DEAD)
|
||||
|
@ -2288,7 +2291,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
}
|
||||
else
|
||||
{
|
||||
players[player].mo->DropInventory (item);
|
||||
players[player].mo->DropInventory (item, amt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2764,10 +2767,13 @@ void Net_SkipCommand (int type, BYTE **stream)
|
|||
break;
|
||||
|
||||
case DEM_INVUSE:
|
||||
case DEM_INVDROP:
|
||||
skip = 4;
|
||||
break;
|
||||
|
||||
case DEM_INVDROP:
|
||||
skip = 8;
|
||||
break;
|
||||
|
||||
case DEM_GENERICCHEAT:
|
||||
case DEM_DROPPLAYER:
|
||||
case DEM_FOV:
|
||||
|
|
|
@ -241,6 +241,7 @@ FString BackupSaveName;
|
|||
|
||||
bool SendLand;
|
||||
const AInventory *SendItemUse, *SendItemDrop;
|
||||
int SendItemDropAmount;
|
||||
|
||||
EXTERN_CVAR (Int, team)
|
||||
|
||||
|
@ -457,12 +458,14 @@ CCMD (invdrop)
|
|||
if (players[consoleplayer].mo)
|
||||
{
|
||||
SendItemDrop = players[consoleplayer].mo->InvSel;
|
||||
SendItemDropAmount = -1;
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (weapdrop)
|
||||
{
|
||||
SendItemDrop = players[consoleplayer].ReadyWeapon;
|
||||
SendItemDropAmount = -1;
|
||||
}
|
||||
|
||||
CCMD (drop)
|
||||
|
@ -470,6 +473,7 @@ CCMD (drop)
|
|||
if (argv.argc() > 1 && who != NULL)
|
||||
{
|
||||
SendItemDrop = who->FindInventory(argv[1]);
|
||||
SendItemDropAmount = argv.argc() > 2 ? atoi(argv[2]) : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,6 +766,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
{
|
||||
Net_WriteByte (DEM_INVDROP);
|
||||
Net_WriteLong (SendItemDrop->InventoryID);
|
||||
Net_WriteLong(SendItemDropAmount);
|
||||
SendItemDrop = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ extern AActor *bodyque[BODYQUESIZE];
|
|||
extern int bodyqueslot;
|
||||
class AInventory;
|
||||
extern const AInventory *SendItemUse, *SendItemDrop;
|
||||
extern int SendItemDropAmount;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1035,14 +1035,14 @@ DEFINE_ACTION_FUNCTION(AActor, UseInventory)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
AInventory *AActor::DropInventory (AInventory *item)
|
||||
AInventory *AActor::DropInventory (AInventory *item, int amt)
|
||||
{
|
||||
AInventory *drop = nullptr;
|
||||
IFVIRTUALPTR(item, AInventory, CreateTossable)
|
||||
{
|
||||
VMValue params[1] = { (DObject*)item };
|
||||
VMValue params[] = { (DObject*)item, amt };
|
||||
VMReturn ret((void**)&drop);
|
||||
GlobalVMStack.Call(func, params, 1, &ret, 1, nullptr);
|
||||
GlobalVMStack.Call(func, params, countof(params), &ret, 1, nullptr);
|
||||
}
|
||||
if (drop == nullptr) return NULL;
|
||||
drop->SetOrigin(PosPlusZ(10.), false);
|
||||
|
@ -1059,7 +1059,8 @@ DEFINE_ACTION_FUNCTION(AActor, DropInventory)
|
|||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_OBJECT_NOT_NULL(item, AInventory);
|
||||
ACTION_RETURN_OBJECT(self->DropInventory(item));
|
||||
PARAM_INT(amt);
|
||||
ACTION_RETURN_OBJECT(self->DropInventory(item, amt));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
|
@ -173,9 +173,9 @@ class Ammo : Inventory
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
override Inventory CreateTossable()
|
||||
override Inventory CreateTossable(int amt)
|
||||
{
|
||||
Inventory copy = Super.CreateTossable();
|
||||
Inventory copy = Super.CreateTossable(amt);
|
||||
if (copy != null)
|
||||
{ // Do not increase ammo by dropping it and picking it back up at
|
||||
// certain skill levels.
|
||||
|
@ -306,9 +306,9 @@ class BackpackItem : Inventory
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
override Inventory CreateTossable ()
|
||||
override Inventory CreateTossable (int amount)
|
||||
{
|
||||
let pack = BackpackItem(Super.CreateTossable());
|
||||
let pack = BackpackItem(Super.CreateTossable(-1));
|
||||
if (pack != NULL)
|
||||
{
|
||||
pack.bDepleted = true;
|
||||
|
|
|
@ -489,7 +489,7 @@ class HexenArmor : Armor
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
override Inventory CreateTossable ()
|
||||
override Inventory CreateTossable (int amount)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -120,9 +120,9 @@ class HealthPickup : Inventory
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
override Inventory CreateTossable ()
|
||||
override Inventory CreateTossable (int amount)
|
||||
{
|
||||
Inventory copy = Super.CreateTossable ();
|
||||
Inventory copy = Super.CreateTossable (-1);
|
||||
if (copy != NULL)
|
||||
{
|
||||
copy.health = health;
|
||||
|
|
|
@ -440,7 +440,7 @@ class Inventory : Actor native
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
virtual Inventory CreateTossable ()
|
||||
virtual Inventory CreateTossable (int amt = -1)
|
||||
{
|
||||
// If self actor lacks a SpawnState, don't drop it. (e.g. A base weapon
|
||||
// like the fist can't be dropped because you'll never see it.)
|
||||
|
@ -448,7 +448,7 @@ class Inventory : Actor native
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
if (bUndroppable || bUntossable || Owner == NULL || Amount <= 0)
|
||||
if (bUndroppable || bUntossable || Owner == NULL || Amount <= 0 || amt == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -462,11 +462,13 @@ class Inventory : Actor native
|
|||
let copy = Inventory(Spawn (GetClass(), Owner.Pos, NO_REPLACE));
|
||||
if (copy != NULL)
|
||||
{
|
||||
amt = clamp(amt, 1, Amount);
|
||||
|
||||
copy.MaxAmount = MaxAmount;
|
||||
copy.Amount = 1;
|
||||
copy.Amount = amt;
|
||||
copy.DropTime = 30;
|
||||
copy.bSpecial = copy.bSolid = false;
|
||||
Amount--;
|
||||
Amount -= amt;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ class Powerup : Inventory
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
override Inventory CreateTossable ()
|
||||
override Inventory CreateTossable (int amount)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -435,7 +435,7 @@ class Weapon : StateProvider native
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
override Inventory CreateTossable ()
|
||||
override Inventory CreateTossable (int amt)
|
||||
{
|
||||
// Only drop the weapon that is meant to be placed in a level. That is,
|
||||
// only drop the weapon that normally gives you ammo.
|
||||
|
@ -443,9 +443,9 @@ class Weapon : StateProvider native
|
|||
Default.AmmoGive1 == 0 && Default.AmmoGive2 == 0 &&
|
||||
(SisterWeapon.Default.AmmoGive1 > 0 || SisterWeapon.Default.AmmoGive2 > 0))
|
||||
{
|
||||
return SisterWeapon.CreateTossable ();
|
||||
return SisterWeapon.CreateTossable (amt);
|
||||
}
|
||||
let copy = Weapon(Super.CreateTossable ());
|
||||
let copy = Weapon(Super.CreateTossable (-1));
|
||||
|
||||
if (copy != NULL)
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ class Coin : Inventory
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
override Inventory CreateTossable ()
|
||||
override Inventory CreateTossable (int amt)
|
||||
{
|
||||
Coin tossed;
|
||||
|
||||
|
@ -87,17 +87,20 @@ class Coin : Inventory
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
if (Amount >= 50)
|
||||
if (amt == -1) amt = Amount >= 50? 50 : Amount >= 25? 25 : Amount >= 10? 10 : 1;
|
||||
else if (amt > Amount) amt = Amount;
|
||||
if (amt > 25)
|
||||
{
|
||||
Amount -= 50;
|
||||
Amount -= amt;
|
||||
tossed = Coin(Spawn("Gold50"));
|
||||
tossed.Amount = amt;
|
||||
}
|
||||
else if (Amount >= 25)
|
||||
else if (amt > 10)
|
||||
{
|
||||
Amount -= 25;
|
||||
tossed = Coin(Spawn("Gold25"));
|
||||
}
|
||||
else if (Amount >= 10)
|
||||
else if (amt > 1)
|
||||
{
|
||||
Amount -= 10;
|
||||
tossed = Coin(Spawn("Gold10"));
|
||||
|
|
Loading…
Reference in a new issue