mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
Added GetMaxInventory ACS function
This commit is contained in:
parent
03ccf03b8f
commit
c51abb0161
1 changed files with 27 additions and 4 deletions
|
@ -1264,7 +1264,7 @@ static int UseInventory (AActor *activator, const char *type)
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
static int CheckInventory (AActor *activator, const char *type)
|
static int CheckInventory (AActor *activator, const char *type, bool max)
|
||||||
{
|
{
|
||||||
if (activator == NULL || type == NULL)
|
if (activator == NULL || type == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1275,11 +1275,26 @@ static int CheckInventory (AActor *activator, const char *type)
|
||||||
}
|
}
|
||||||
else if (stricmp (type, "Health") == 0)
|
else if (stricmp (type, "Health") == 0)
|
||||||
{
|
{
|
||||||
|
if (max)
|
||||||
|
{
|
||||||
|
if (activator->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
|
||||||
|
return static_cast<APlayerPawn *>(activator)->MaxHealth;
|
||||||
|
else
|
||||||
|
return activator->SpawnHealth();
|
||||||
|
}
|
||||||
return activator->health;
|
return activator->health;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PClass *info = PClass::FindClass (type);
|
const PClass *info = PClass::FindClass (type);
|
||||||
AInventory *item = activator->FindInventory (info);
|
AInventory *item = activator->FindInventory (info);
|
||||||
|
|
||||||
|
if (max)
|
||||||
|
{
|
||||||
|
if (item)
|
||||||
|
return item->MaxAmount;
|
||||||
|
else
|
||||||
|
return ((AInventory *)GetDefaultByType (info))->MaxAmount;
|
||||||
|
}
|
||||||
return item ? item->Amount : 0;
|
return item ? item->Amount : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4442,6 +4457,7 @@ enum EACSFunctions
|
||||||
ACSF_GetActorRoll,
|
ACSF_GetActorRoll,
|
||||||
ACSF_QuakeEx,
|
ACSF_QuakeEx,
|
||||||
ACSF_Warp, // 92
|
ACSF_Warp, // 92
|
||||||
|
ACSF_GetMaxInventory,
|
||||||
|
|
||||||
/* Zandronum's - these must be skipped when we reach 99!
|
/* Zandronum's - these must be skipped when we reach 99!
|
||||||
-100:ResetMap(0),
|
-100:ResetMap(0),
|
||||||
|
@ -5915,6 +5931,13 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case ACSF_GetMaxInventory:
|
||||||
|
actor = SingleActorFromTID(args[0], activator);
|
||||||
|
if (actor != NULL)
|
||||||
|
{
|
||||||
|
return CheckInventory(actor, FBehavior::StaticLookupString(args[1]), true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -8339,17 +8362,17 @@ scriptwait:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCD_CHECKINVENTORY:
|
case PCD_CHECKINVENTORY:
|
||||||
STACK(1) = CheckInventory (activator, FBehavior::StaticLookupString (STACK(1)));
|
STACK(1) = CheckInventory (activator, FBehavior::StaticLookupString (STACK(1)), false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCD_CHECKACTORINVENTORY:
|
case PCD_CHECKACTORINVENTORY:
|
||||||
STACK(2) = CheckInventory (SingleActorFromTID(STACK(2), NULL),
|
STACK(2) = CheckInventory (SingleActorFromTID(STACK(2), NULL),
|
||||||
FBehavior::StaticLookupString (STACK(1)));
|
FBehavior::StaticLookupString (STACK(1)), false);
|
||||||
sp--;
|
sp--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCD_CHECKINVENTORYDIRECT:
|
case PCD_CHECKINVENTORYDIRECT:
|
||||||
PushToStack (CheckInventory (activator, FBehavior::StaticLookupString (TAGSTR(uallong(pc[0])))));
|
PushToStack (CheckInventory (activator, FBehavior::StaticLookupString (TAGSTR(uallong(pc[0]))), false));
|
||||||
pc += 1;
|
pc += 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue