Merge pull request #538 from MajorCooke/CountInv
CountInv(itemtype, ptr_select)
This commit is contained in:
commit
1ca2293983
2 changed files with 34 additions and 0 deletions
|
|
@ -217,6 +217,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, IsPointerEqual)
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue