- Added an IF_KEEPDEPLETED flag for inventory items to keep them in the

player's inventory even when they have been used up. If the item also
  has an inventory bar icon, it will be drawn darkened when it is
  depleted.


SVN r497 (trunk)
This commit is contained in:
Randy Heit 2007-03-07 02:24:24 +00:00
parent 560d4f8140
commit e01ff5707c
12 changed files with 52 additions and 22 deletions

View file

@ -1,3 +1,9 @@
March 6, 2007
- Added an IF_KEEPDEPLETED flag for inventory items to keep them in the
player's inventory even when they have been used up. If the item also
has an inventory bar icon, it will be drawn darkened when it is
depleted.
March 5, 2007
- Fixed: Thing_ProjectileAimed did not set the missile's speed correctly.

View file

@ -14,6 +14,9 @@
#include "templates.h"
#include "i_system.h"
// The translation to use for depleted items
#define DIM_MAP &NormalLight.Maps[NUMCOLORMAPS*2/3*256]
#define ST_EVILGRINCOUNT (2*TICRATE)
#define ST_STRAIGHTFACECOUNT (TICRATE/2)
#define ST_TURNCOUNT (1*TICRATE)
@ -476,7 +479,7 @@ private:
}
else
{
DrawImage (TexMan(CPlayer->mo->InvSel->Icon), 144, 0);
DrawImage (TexMan(CPlayer->mo->InvSel->Icon), 144, 0, CPlayer->mo->InvSel->Amount > 0 ? NULL : DIM_MAP);
if (CPlayer->mo->InvSel->Amount != 1)
{
DrSmallNumber (CPlayer->mo->InvSel->Amount, 165, 24);
@ -562,7 +565,7 @@ private:
for (item = CPlayer->mo->InvFirst, i = 0; item != NULL && i < 7; item = item->NextInv(), ++i)
{
DrawImage (Images[imgARTIBOX], 50+i*31, 2);
DrawImage (TexMan(item->Icon), 50+i*31, 2);
DrawImage (TexMan(item->Icon), 50+i*31, 2, item->Amount > 0 ? NULL : DIM_MAP);
if (item->Amount != 1)
{
DrSmallNumber (item->Amount, 66+i*31, 24);
@ -705,6 +708,7 @@ private:
screen->DrawTexture (TexMan(CPlayer->mo->InvSel->Icon), -14, ammotop - 1/*-24*/,
DTA_HUDRules, HUD_Normal,
DTA_CenterBottomOffset, true,
DTA_Translation, CPlayer->mo->InvSel->Amount > 0 ? NULL : DIM_MAP,
TAG_DONE);
DrBNumberOuter (CPlayer->mo->InvSel->Amount, -68, ammotop - 18/*-41*/);
}
@ -723,6 +727,7 @@ private:
TAG_DONE);
screen->DrawTexture (TexMan(item->Icon), -105+i*31, -32,
DTA_HUDRules, HUD_HorizCenter,
DTA_Translation, item->Amount > 0 ? NULL : DIM_MAP,
TAG_DONE);
if (item->Amount != 1)
{

View file

@ -14,6 +14,9 @@
#include "templates.h"
#include "a_keys.h"
// The translation to use for depleted items
#define DIM_MAP &NormalLight.Maps[NUMCOLORMAPS*2/3*256]
static FRandom pr_chainwiggle;
// This texture is used to shade each end of the health chain
@ -323,8 +326,7 @@ private:
DrawImage (Images[imgBLACKSQ], 180, 3);
if (oldarti != NULL)
{
assert (oldarti->Amount > 0);
DrawImage (TexMan(oldarti->Icon), 179, 2);
DrawImage (TexMan(oldarti->Icon), 179, 2, oldarti->Amount > 0 ? NULL : DIM_MAP);
if (oldartiCount != 1)
{
DrSmallNumber (oldartiCount, 197, 24);
@ -483,7 +485,7 @@ private:
{
for (item = CPlayer->mo->InvFirst, i = 0; item != NULL && i < 7; item = item->NextInv(), ++i)
{
DrawImage (TexMan(item->Icon), 50+i*31, 2);
DrawImage (TexMan(item->Icon), 50+i*31, 2, item->Amount > 0 ? NULL : DIM_MAP);
if (item->Amount != 1)
{
DrSmallNumber (item->Amount, 65+i*31, 24);
@ -638,6 +640,7 @@ private:
TAG_DONE);
screen->DrawTexture (TexMan(CPlayer->mo->InvSel->Icon), -61, -31,
DTA_HUDRules, HUD_Normal,
DTA_Translation, CPlayer->mo->InvSel->Amount > 0 ? NULL : DIM_MAP,
TAG_DONE);
if (CPlayer->mo->InvSel->Amount != 1)
{
@ -659,6 +662,7 @@ private:
TAG_DONE);
screen->DrawTexture (TexMan(item->Icon), -100+i*31, -32,
DTA_HUDRules, HUD_HorizCenter,
DTA_Translation, item->Amount > 0 ? NULL : DIM_MAP,
TAG_DONE);
if (item->Amount != 1)
{

View file

@ -15,6 +15,9 @@
#include "a_hexenglobal.h"
#include "a_keys.h"
// The translation to use for depleted items
#define DIM_MAP &NormalLight.Maps[NUMCOLORMAPS*2/3*256]
class FManaBar : public FTexture
{
public:
@ -402,8 +405,7 @@ private:
DrawImage (Images[imgARTICLEAR], 144, -1);
if (oldarti != NULL)
{
assert (oldarti->Amount > 0);
DrawImage (TexMan(oldarti->Icon), 143, 2);
DrawImage (TexMan(oldarti->Icon), 143, 2, oldarti->Amount > 0 ? NULL : DIM_MAP);
if (oldartiCount != 1)
{
DrSmallNumber (oldartiCount, 162, 23);
@ -713,7 +715,7 @@ private:
{
for (item = CPlayer->mo->InvFirst, i = 0; item != NULL && i < 7; item = item->NextInv(), ++i)
{
DrawImage (TexMan(item->Icon), 50+i*31, 1);
DrawImage (TexMan(item->Icon), 50+i*31, 1, item->Amount > 0 ? NULL : DIM_MAP);
if (item->Amount != 1)
{
DrSmallNumber (item->Amount, 68+i*31, 23);
@ -912,6 +914,7 @@ private:
TAG_DONE);
screen->DrawTexture (TexMan(CPlayer->mo->InvSel->Icon), -82, -31,
DTA_HUDRules, HUD_Normal,
DTA_Translation, CPlayer->mo->InvSel->Amount > 0 ? NULL : DIM_MAP,
TAG_DONE);
if (CPlayer->mo->InvSel->Amount != 1)
{
@ -933,6 +936,7 @@ private:
TAG_DONE);
screen->DrawTexture (TexMan(item->Icon), -108+i*31, -33,
DTA_HUDRules, HUD_HorizCenter,
DTA_Translation, item->Amount > 0 ? NULL : DIM_MAP,
TAG_DONE);
if (item->Amount != 1)
{

View file

@ -12,6 +12,7 @@ IMPLEMENT_STATELESS_ACTOR (AArmor, Any, -1, 0)
END_DEFAULTS
IMPLEMENT_STATELESS_ACTOR (ABasicArmor, Any, -1, 0)
PROP_Inventory_FlagsSet (IF_KEEPDEPLETED)
END_DEFAULTS
IMPLEMENT_STATELESS_ACTOR (ABasicArmorPickup, Any, -1, 0)
@ -26,7 +27,7 @@ IMPLEMENT_STATELESS_ACTOR (ABasicArmorBonus, Any, -1, 0)
END_DEFAULTS
IMPLEMENT_STATELESS_ACTOR (AHexenArmor, Any, -1, 0)
PROP_Inventory_FlagsSet (IF_UNDROPPABLE)
PROP_Inventory_FlagsSet (IF_UNDROPPABLE | IF_KEEPDEPLETED)
END_DEFAULTS

View file

@ -17,6 +17,7 @@
static FRandom pr_restore ("RestorePos");
IMPLEMENT_STATELESS_ACTOR (AAmmo, Any, -1, 0)
PROP_Inventory_FlagsSet (IF_KEEPDEPLETED)
PROP_Inventory_PickupSound ("misc/ammo_pkup")
END_DEFAULTS
@ -668,7 +669,7 @@ AInventory *AInventory::CreateTossable ()
{
return NULL;
}
if (Amount == 1 && !IsKindOf (RUNTIME_CLASS(AAmmo)))
if (Amount == 1 && !(ItemFlags & IF_KEEPDEPLETED))
{
BecomePickup ();
DropTime = 30;

View file

@ -94,6 +94,7 @@ enum
IF_ALWAYSPICKUP = 1<<10, // For IF_AUTOACTIVATE, MaxAmount=0 items: Always "pick up", even if it doesn't do anything
IF_FANCYPICKUPSOUND = 1<<11, // Play pickup sound in "surround" mode
IF_BIGPOWERUP = 1<<12, // Affected by RESPAWN_SUPER dmflag
IF_KEEPDEPLETED = 1<<13, // Items with this flag are retained even when they run out.
};
struct vissprite_t;

View file

@ -197,12 +197,12 @@ AInventory *ACoin::CreateTossable ()
Amount -= 10;
tossed = Spawn<AGold10> (Owner->x, Owner->y, Owner->z, NO_REPLACE);
}
else if (Amount > 1)
else if (Amount > 1 || (ItemFlags & IF_KEEPDEPLETED))
{
Amount -= 1;
tossed = Spawn<ACoin> (Owner->x, Owner->y, Owner->z, NO_REPLACE);
}
else
else // Amount == 1 && !(ItemFlags & IF_KEEPDEPLETED)
{
BecomePickup ();
tossed = this;

View file

@ -15,6 +15,9 @@
#include "a_strifeglobal.h"
#include "gi.h"
// The translation to use for depleted items
#define DIM_MAP &NormalLight.Maps[NUMCOLORMAPS*2/3*256]
// Number of tics to move the popscreen up and down.
#define POP_TIME (TICRATE/8)
@ -438,7 +441,7 @@ private:
}
if (item->Icon != 0)
{
DrawImage (TexMan(item->Icon), 48 + 35*i, 14);
DrawImage (TexMan(item->Icon), 48 + 35*i, 14, item->Amount > 0 ? NULL : DIM_MAP);
}
DrINumber (item->Amount, 74 + 35*i, 23, imgFONY0);
}
@ -512,6 +515,7 @@ private:
screen->DrawTexture (TexMan(CPlayer->mo->InvSel->Icon), -42, -17,
DTA_HUDRules, HUD_Normal,
DTA_CenterBottomOffset, true,
DTA_Translation, CPlayer->mo->InvSel->Amount > 0 ? NULL : DIM_MAP,
TAG_DONE);
}
}
@ -535,6 +539,7 @@ private:
{
screen->DrawTexture (TexMan(item->Icon), -94 + i*35, -19,
DTA_HUDRules, HUD_HorizCenter,
DTA_Translation, CPlayer->mo->InvSel->Amount > 0 ? NULL : DIM_MAP,
TAG_DONE);
}
DrINumberOuter (item->Amount, -89 + i*35, -10, true, 7);

View file

@ -293,16 +293,13 @@ static void DoTakeInv (AActor *actor, const PClass *info, int amount)
// amounts a backpack might have given.
// Armor shouldn't be removed because they only work properly when
// they are the last items in the inventory.
if (item->GetClass()->ParentClass != RUNTIME_CLASS(AAmmo) &&
item->GetClass() != RUNTIME_CLASS(ABasicArmor) &&
item->GetClass() != RUNTIME_CLASS(AHexenArmor)
)
if (item->ItemFlags & IF_KEEPDEPLETED)
{
item->Destroy ();
item->Amount = 0;
}
else
{
item->Amount = 0;
item->Destroy ();
}
}
}

View file

@ -730,11 +730,16 @@ bool AActor::UseInventory (AInventory *item)
{
return false;
}
// Don't use it if you don't actually have any of it.
if (item->Amount <= 0)
{
return false;
}
if (!item->Use (false))
{
return false;
}
if (--item->Amount <= 0)
if (--item->Amount <= 0 && !(item->ItemFlags & IF_KEEPDEPLETED))
{
item->Destroy ();
}

View file

@ -4,8 +4,8 @@
** Actor definitions
**
**---------------------------------------------------------------------------
** Copyright 2002-2006 Christoph Oelckers
** Copyright 2004-2006 Randy Heit
** Copyright 2002-2007 Christoph Oelckers
** Copyright 2004-2007 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
@ -248,6 +248,7 @@ static flagdef InventoryFlags[] =
DEFINE_FLAG(IF, ALWAYSPICKUP, AInventory, ItemFlags),
DEFINE_FLAG(IF, FANCYPICKUPSOUND, AInventory, ItemFlags),
DEFINE_FLAG(IF, BIGPOWERUP, AInventory, ItemFlags),
DEFINE_FLAG(IF, KEEPDEPLETED, AInventory, ItemFlags),
};
static flagdef WeaponFlags[] =