- moved Restricted/ForbiddenToPlayerClass fully to the script side.

This required some fixes for allowing to read from metadata arrays.
This commit is contained in:
Christoph Oelckers 2017-04-11 15:11:13 +02:00
commit 6a3ddaa8fa
7 changed files with 49 additions and 55 deletions

View file

@ -484,43 +484,6 @@ bool AInventory::CallTryPickup(AActor *toucher, AActor **toucher_return)
return !!res;
}
//===========================================================================
//
// AInventory :: CanPickup
//
//===========================================================================
DEFINE_ACTION_FUNCTION(AInventory, CanPickup)
{
PARAM_SELF_PROLOGUE(AInventory);
PARAM_OBJECT(toucher, AActor);
if (!toucher)
ACTION_RETURN_BOOL(false);
auto ai = self->GetClass();
// Is the item restricted to certain player classes?
if (ai->RestrictedToPlayerClass.Size() != 0)
{
for (unsigned i = 0; i < ai->RestrictedToPlayerClass.Size(); ++i)
{
if (toucher->IsKindOf(ai->RestrictedToPlayerClass[i]))
ACTION_RETURN_BOOL(true);
}
ACTION_RETURN_BOOL(false);
}
// Or is it forbidden to certain other classes?
else
{
for (unsigned i = 0; i < ai->ForbiddenToPlayerClass.Size(); ++i)
{
if (toucher->IsKindOf(ai->ForbiddenToPlayerClass[i]))
ACTION_RETURN_BOOL(false);
}
}
ACTION_RETURN_BOOL(true);
}
//===========================================================================
//
// CCMD printinv