- Added CountInv(itemtype, [ptr_select]).

- Returns an inventory item count.
This commit is contained in:
MajorCooke 2016-02-04 21:45:31 -06:00
parent 4751bffd5f
commit 1f8d425a1e
3 changed files with 35 additions and 0 deletions

View file

@ -306,6 +306,7 @@ xx(CallACS)
xx(Sqrt) xx(Sqrt)
xx(CheckClass) xx(CheckClass)
xx(IsPointerEqual) xx(IsPointerEqual)
xx(CountInv)
xx(Pick) xx(Pick)
xx(Mass) xx(Mass)
xx(VelX) xx(VelX)

View file

@ -217,6 +217,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, IsPointerEqual)
return 0; return 0;
} }
//==========================================================================
//
// CountInv
//
// NON-ACTION function to return the inventory count of an item.
//
//==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, CountInv)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_PROLOGUE;
PARAM_OBJECT(self, AActor);
PARAM_CLASS(itemtype, AInventory);
PARAM_INT_OPT(pick_pointer) { pick_pointer = AAPTR_DEFAULT; }
self = COPY_AAPTR(self, pick_pointer);
if (self == NULL || itemtype == NULL)
{
ret->SetInt(false);
}
else
{
AInventory *item = self->FindInventory(itemtype);
ret->SetInt(item ? item->Amount : 0);
return 1;
}
}
return 0;
}
//========================================================================== //==========================================================================
// //
// A_RearrangePointers // A_RearrangePointers

View file

@ -35,6 +35,7 @@ ACTOR Actor native //: Thinker
// Functions // Functions
native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false);
native bool IsPointerEqual(int ptr_select1, int ptr_select2); native bool IsPointerEqual(int ptr_select1, int ptr_select2);
native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT);
// Action functions // Action functions