mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- removed all direct references of AInventory::Owner and AInventory::Amount from the C++ code.
This commit is contained in:
parent
d6d3dd038e
commit
0e095b0c05
15 changed files with 124 additions and 157 deletions
|
@ -371,8 +371,8 @@ void DBot::WhatToGet (AActor *item)
|
|||
return;
|
||||
auto ammo1 = heldWeapon->PointerVar<AInventory>(NAME_Ammo1);
|
||||
auto ammo2 = heldWeapon->PointerVar<AInventory>(NAME_Ammo2);
|
||||
if ((ammo1 == NULL || ammo1->Amount >= ammo1->MaxAmount) &&
|
||||
(ammo2 == NULL || ammo2->Amount >= ammo2->MaxAmount))
|
||||
if ((ammo1 == NULL || ammo1->IntVar(NAME_Amount) >= ammo1->MaxAmount) &&
|
||||
(ammo2 == NULL || ammo2->IntVar(NAME_Amount) >= ammo2->MaxAmount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ void DBot::WhatToGet (AActor *item)
|
|||
auto parent = item->GetClass();
|
||||
while (parent->ParentClass != ac) parent = static_cast<PClassActor*>(parent->ParentClass);
|
||||
AInventory *holdingammo = player->mo->FindInventory(parent);
|
||||
if (holdingammo != NULL && holdingammo->Amount >= holdingammo->MaxAmount)
|
||||
if (holdingammo != NULL && holdingammo->IntVar(NAME_Amount) >= holdingammo->MaxAmount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ void C_PrintInv(AActor *target)
|
|||
{
|
||||
Printf (" %s #%u (%d/%d)\n", item->GetClass()->TypeName.GetChars(),
|
||||
item->InventoryID,
|
||||
item->Amount, item->MaxAmount);
|
||||
item->IntVar(NAME_Amount), item->MaxAmount);
|
||||
count++;
|
||||
}
|
||||
Printf (" List count: %d\n", count);
|
||||
|
|
|
@ -416,7 +416,7 @@ static bool DoSubstitution (FString &out, const char *in)
|
|||
if (strnicmp(a, "armor", 5) == 0)
|
||||
{
|
||||
AInventory *armor = player->mo->FindInventory(NAME_BasicArmor);
|
||||
out.AppendFormat("%d", armor != NULL ? armor->Amount : 0);
|
||||
out.AppendFormat("%d", armor != NULL ? armor->IntVar(NAME_Amount) : 0);
|
||||
}
|
||||
}
|
||||
else if (len == 9)
|
||||
|
@ -429,10 +429,10 @@ static bool DoSubstitution (FString &out, const char *in)
|
|||
}
|
||||
else
|
||||
{
|
||||
out.AppendFormat("%d", ammo1 != NULL ? ammo1->Amount : 0);
|
||||
out.AppendFormat("%d", ammo1 != NULL ? ammo1->IntVar(NAME_Amount) : 0);
|
||||
if (ammo2 != NULL)
|
||||
{
|
||||
out.AppendFormat("/%d", ammo2->Amount);
|
||||
out.AppendFormat("/%d", ammo2->IntVar(NAME_Amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1549,7 +1549,7 @@ static int PatchAmmo (int ammoNum)
|
|||
if (defaultAmmo != NULL)
|
||||
{
|
||||
max = &defaultAmmo->MaxAmount;
|
||||
per = &defaultAmmo->Amount;
|
||||
per = &defaultAmmo->IntVar(NAME_Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1572,7 +1572,7 @@ static int PatchAmmo (int ammoNum)
|
|||
if (ammoType != NULL)
|
||||
{
|
||||
defaultAmmo->IntVar("BackpackMaxAmount") = defaultAmmo->MaxAmount * 2;
|
||||
defaultAmmo->IntVar("BackpackAmount") = defaultAmmo->Amount;
|
||||
defaultAmmo->IntVar("BackpackAmount") = defaultAmmo->IntVar(NAME_Amount);
|
||||
}
|
||||
|
||||
// Fix per-ammo/max-ammo amounts for descendants of the base ammo class
|
||||
|
@ -1589,7 +1589,7 @@ static int PatchAmmo (int ammoNum)
|
|||
{
|
||||
defaultAmmo = (AInventory *)GetDefaultByType (type);
|
||||
defaultAmmo->MaxAmount = *max;
|
||||
defaultAmmo->Amount = Scale (defaultAmmo->Amount, *per, oldclip);
|
||||
defaultAmmo->IntVar(NAME_Amount) = Scale (defaultAmmo->IntVar(NAME_Amount), *per, oldclip);
|
||||
}
|
||||
else if (type->IsDescendantOf (NAME_Weapon))
|
||||
{
|
||||
|
@ -1673,7 +1673,7 @@ static int PatchWeapon (int weapNum)
|
|||
AmmoType = AmmoNames[val];
|
||||
if (AmmoType != nullptr)
|
||||
{
|
||||
info->IntVar(NAME_AmmoGive1) = ((AInventory*)GetDefaultByType(AmmoType))->Amount * 2;
|
||||
info->IntVar(NAME_AmmoGive1) = ((AInventory*)GetDefaultByType(AmmoType))->IntVar(NAME_Amount) * 2;
|
||||
auto &AmmoUse = info->IntVar(NAME_AmmoUse1);
|
||||
if (AmmoUse == 0)
|
||||
{
|
||||
|
@ -1987,14 +1987,14 @@ static int PatchMisc (int dummy)
|
|||
health = static_cast<AInventory *> (GetDefaultByName ("Soulsphere"));
|
||||
if (health!=NULL)
|
||||
{
|
||||
health->Amount = deh.SoulsphereHealth;
|
||||
health->IntVar(NAME_Amount) = deh.SoulsphereHealth;
|
||||
health->MaxAmount = deh.MaxSoulsphere;
|
||||
}
|
||||
|
||||
health = static_cast<AInventory *> (GetDefaultByName ("MegasphereHealth"));
|
||||
if (health!=NULL)
|
||||
{
|
||||
health->Amount = health->MaxAmount = deh.MegasphereHealth;
|
||||
health->IntVar(NAME_Amount) = health->MaxAmount = deh.MegasphereHealth;
|
||||
}
|
||||
|
||||
APlayerPawn *player = static_cast<APlayerPawn *> (GetDefaultByName ("DoomPlayer"));
|
||||
|
|
|
@ -2409,28 +2409,11 @@ void FParser::SF_IsPlayerObj(void)
|
|||
//
|
||||
// CheckInventory
|
||||
//
|
||||
// Returns how much of a particular item an actor has.
|
||||
// forward to the ACS equivalent.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
static int FS_CheckInventory (AActor *activator, const char *type)
|
||||
{
|
||||
if (activator == NULL)
|
||||
return 0;
|
||||
|
||||
if (strcmp (type, "Armor") == 0)
|
||||
{
|
||||
type = "BasicArmor";
|
||||
}
|
||||
else if (strcmp (type, "Health") == 0)
|
||||
{
|
||||
return activator->health;
|
||||
}
|
||||
|
||||
PClassActor *info = PClass::FindActor (type);
|
||||
AInventory *item = activator->FindInventory (info);
|
||||
return item ? item->Amount : 0;
|
||||
}
|
||||
int CheckInventory(AActor *activator, const char *type, bool max = false);
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
@ -2463,7 +2446,7 @@ void FParser::SF_PlayerKeys(void)
|
|||
if(t_argc == 2)
|
||||
{
|
||||
t_return.type = svt_int;
|
||||
t_return.value.i = FS_CheckInventory(players[playernum].mo, keyname);
|
||||
t_return.value.i = CheckInventory(players[playernum].mo, keyname);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -2707,7 +2690,7 @@ void FParser::SF_CheckInventory(void)
|
|||
return;
|
||||
}
|
||||
t_return.type = svt_int;
|
||||
t_return.value.i = FS_CheckInventory(players[playernum].mo, stringvalue(t_argv[1]));
|
||||
t_return.value.i = CheckInventory(players[playernum].mo, stringvalue(t_argv[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,7 +431,7 @@ CCMD(invquery)
|
|||
AInventory *inv = players[consoleplayer].mo->InvSel;
|
||||
if (inv != NULL)
|
||||
{
|
||||
Printf(PRINT_HIGH, "%s (%dx)\n", inv->GetTag(), inv->Amount);
|
||||
Printf(PRINT_HIGH, "%s (%dx)\n", inv->GetTag(), inv->IntVar(NAME_Amount));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1053,8 +1053,8 @@ public:
|
|||
{
|
||||
ammo1 = ammo2 = nullptr;
|
||||
}
|
||||
ammocount1 = ammo1 != nullptr ? ammo1->Amount : 0;
|
||||
ammocount2 = ammo2 != nullptr ? ammo2->Amount : 0;
|
||||
ammocount1 = ammo1 != nullptr ? ammo1->IntVar(NAME_Amount) : 0;
|
||||
ammocount2 = ammo2 != nullptr ? ammo2->IntVar(NAME_Amount) : 0;
|
||||
|
||||
//prepare ammo counts
|
||||
armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||
|
|
|
@ -257,7 +257,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
else if(type == ARMOR)
|
||||
{
|
||||
auto armor = statusBar->armor;
|
||||
if(armor != NULL && armor->Amount != 0)
|
||||
if(armor != NULL && armor->IntVar(NAME_Amount) != 0)
|
||||
GetIcon(armor);
|
||||
}
|
||||
else if(type == WEAPONICON)
|
||||
|
@ -600,8 +600,8 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
if(armor != NULL)
|
||||
{
|
||||
auto n = armor->NameVar(NAME_ArmorType).GetIndex();
|
||||
bool matches1 = n == armorType[0] && EvaluateOperation(conditionalOperator[0], conditionalValue[0], armor->Amount);
|
||||
bool matches2 = n == armorType[1] && EvaluateOperation(conditionalOperator[1], conditionalValue[1], armor->Amount);
|
||||
bool matches1 = n == armorType[0] && EvaluateOperation(conditionalOperator[0], conditionalValue[0], armor->IntVar(NAME_Amount));
|
||||
bool matches2 = n == armorType[1] && EvaluateOperation(conditionalOperator[1], conditionalValue[1], armor->IntVar(NAME_Amount));
|
||||
|
||||
drawAlt = 1;
|
||||
if(conditionAnd)
|
||||
|
@ -620,12 +620,12 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
else //check the inventory items and draw selected sprite
|
||||
{
|
||||
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem[0]);
|
||||
if(item == NULL || !EvaluateOperation(conditionalOperator[0], conditionalValue[0], item->Amount))
|
||||
if(item == NULL || !EvaluateOperation(conditionalOperator[0], conditionalValue[0], item->IntVar(NAME_Amount)))
|
||||
drawAlt = 1;
|
||||
if(conditionAnd)
|
||||
{
|
||||
item = statusBar->CPlayer->mo->FindInventory(inventoryItem[1]);
|
||||
bool secondCondition = item != NULL && EvaluateOperation(conditionalOperator[1], conditionalValue[1], item->Amount);
|
||||
bool secondCondition = item != NULL && EvaluateOperation(conditionalOperator[1], conditionalValue[1], item->IntVar(NAME_Amount));
|
||||
if((item != NULL && secondCondition) && drawAlt == 0) //both
|
||||
{
|
||||
drawAlt = 0;
|
||||
|
@ -1329,7 +1329,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
interpolationSpeed = script->interpolationSpeed;
|
||||
break;
|
||||
case ARMOR:
|
||||
num = statusBar->armor != NULL ? statusBar->armor->Amount : 0;
|
||||
num = statusBar->armor != NULL ? statusBar->armor->IntVar(NAME_Amount) : 0;
|
||||
if(script->interpolateArmor)
|
||||
interpolationSpeed = script->armorInterpolationSpeed;
|
||||
break;
|
||||
|
@ -1353,7 +1353,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
{
|
||||
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
||||
if(item != NULL)
|
||||
num = item->Amount;
|
||||
num = item->IntVar(NAME_Amount);
|
||||
else
|
||||
num = 0;
|
||||
break;
|
||||
|
@ -1451,7 +1451,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
{
|
||||
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem);
|
||||
if(item != NULL)
|
||||
num = item->Amount;
|
||||
num = item->IntVar(NAME_Amount);
|
||||
else
|
||||
num = 0;
|
||||
break;
|
||||
|
@ -1466,7 +1466,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
}
|
||||
case SELECTEDINVENTORY:
|
||||
if(statusBar->CPlayer->mo->InvSel != NULL)
|
||||
num = statusBar->CPlayer->mo->InvSel->Amount;
|
||||
num = statusBar->CPlayer->mo->InvSel->IntVar(NAME_Amount);
|
||||
break;
|
||||
case ACCURACY:
|
||||
num = statusBar->CPlayer->mo->accuracy;
|
||||
|
@ -1708,7 +1708,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
|
|||
}
|
||||
CommandDrawImage::Draw(block, statusBar);
|
||||
}
|
||||
if(alwaysShowCounter || statusBar->CPlayer->mo->InvSel->Amount != 1)
|
||||
if(alwaysShowCounter || statusBar->CPlayer->mo->InvSel->IntVar(NAME_Amount) != 1)
|
||||
CommandDrawNumber::Draw(block, statusBar);
|
||||
}
|
||||
}
|
||||
|
@ -2131,7 +2131,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
|||
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgARTIBOX], rx, ry, block->XOffset(), block->YOffset(), bgalpha, block->FullScreenOffsets());
|
||||
|
||||
if(style != STYLE_Strife) //Strife draws the cursor before the icons
|
||||
statusBar->DrawGraphic(TexMan(item->Icon), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->Amount <= 0);
|
||||
statusBar->DrawGraphic(TexMan(item->Icon), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
|
||||
if(item == statusBar->CPlayer->mo->InvSel)
|
||||
{
|
||||
if(style == STYLE_Heretic)
|
||||
|
@ -2146,10 +2146,10 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
|||
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgSELECTBOX], rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
}
|
||||
if(style == STYLE_Strife)
|
||||
statusBar->DrawGraphic(TexMan(item->Icon), rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->Amount <= 0);
|
||||
if(counters != NULL && (alwaysShowCounter || item->Amount != 1))
|
||||
statusBar->DrawGraphic(TexMan(item->Icon), rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
|
||||
if(counters != NULL && (alwaysShowCounter || item->IntVar(NAME_Amount) != 1))
|
||||
{
|
||||
counters[i]->valueArgument = item->Amount;
|
||||
counters[i]->valueArgument = item->IntVar(NAME_Amount);
|
||||
counters[i]->Draw(block, statusBar);
|
||||
}
|
||||
}
|
||||
|
@ -2667,7 +2667,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
{
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem); //max comparer
|
||||
if(item != NULL)
|
||||
max = item->Amount;
|
||||
max = item->IntVar(NAME_Amount);
|
||||
else
|
||||
max = 0;
|
||||
}
|
||||
|
@ -2675,14 +2675,14 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
max = statusBar->CPlayer->mo->GetMaxHealth(true);
|
||||
break;
|
||||
case ARMOR:
|
||||
value = statusBar->armor != NULL ? statusBar->armor->Amount : 0;
|
||||
value = statusBar->armor != NULL ? statusBar->armor->IntVar(NAME_Amount) : 0;
|
||||
if(data.useMaximumConstant)
|
||||
max = data.value;
|
||||
else if(data.inventoryItem != NULL)
|
||||
{
|
||||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||
if(item != NULL)
|
||||
max = item->Amount;
|
||||
max = item->IntVar(NAME_Amount);
|
||||
else
|
||||
max = 0;
|
||||
}
|
||||
|
@ -2714,7 +2714,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||
if(item != NULL)
|
||||
{
|
||||
value = item->Amount;
|
||||
value = item->IntVar(NAME_Amount);
|
||||
max = item->MaxAmount;
|
||||
}
|
||||
else
|
||||
|
@ -2742,7 +2742,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
AInventory *item = statusBar->CPlayer->mo->FindInventory(data.inventoryItem);
|
||||
if(item != NULL)
|
||||
{
|
||||
value = item->Amount;
|
||||
value = item->IntVar(NAME_Amount);
|
||||
max = item->MaxAmount;
|
||||
}
|
||||
else
|
||||
|
@ -3178,7 +3178,7 @@ class CommandDrawGem : public SBarInfoCommand
|
|||
}
|
||||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||
{
|
||||
goalValue = armor ? (statusBar->armor ? statusBar->armor->Amount : 0) : statusBar->CPlayer->mo->health;
|
||||
goalValue = armor ? (statusBar->armor ? statusBar->armor->IntVar(NAME_Amount) : 0) : statusBar->CPlayer->mo->health;
|
||||
int max = armor ? 100 : statusBar->CPlayer->mo->GetMaxHealth(true);
|
||||
if(max != 0 && goalValue > 0)
|
||||
{
|
||||
|
@ -3318,7 +3318,7 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
|
|||
conditionAnd(false)
|
||||
{
|
||||
item[0] = item[1] = NULL;
|
||||
amount[0] = amount[1] = 0;
|
||||
Amount[0] = Amount[1] = 0;
|
||||
}
|
||||
|
||||
void ParseNegatable(FScanner &sc, bool fullScreenOffsets)
|
||||
|
@ -3337,7 +3337,7 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
|
|||
if (sc.CheckToken(','))
|
||||
{
|
||||
sc.MustGetNumber();
|
||||
amount[i] = sc.Number;
|
||||
Amount[i] = sc.Number;
|
||||
}
|
||||
|
||||
if(sc.CheckToken(TK_OrOr))
|
||||
|
@ -3361,8 +3361,8 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
|
|||
SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged);
|
||||
|
||||
AInventory *invItem[2] = { statusBar->CPlayer->mo->FindInventory(item[0]), statusBar->CPlayer->mo->FindInventory(item[1]) };
|
||||
if (invItem[0] != NULL && amount[0] > 0 && invItem[0]->Amount < amount[0]) invItem[0] = NULL;
|
||||
if (invItem[1] != NULL && amount[1] > 0 && invItem[1]->Amount < amount[1]) invItem[1] = NULL;
|
||||
if (invItem[0] != NULL && Amount[0] > 0 && invItem[0]->IntVar(NAME_Amount) < Amount[0]) invItem[0] = NULL;
|
||||
if (invItem[1] != NULL && Amount[1] > 0 && invItem[1]->IntVar(NAME_Amount) < Amount[1]) invItem[1] = NULL;
|
||||
|
||||
if (item[1])
|
||||
{
|
||||
|
@ -3377,7 +3377,7 @@ class CommandInInventory : public SBarInfoNegatableFlowControl
|
|||
protected:
|
||||
bool conditionAnd;
|
||||
PClassActor *item[2];
|
||||
int amount[2];
|
||||
int Amount[2];
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -3422,7 +3422,7 @@ class CommandIfHealth : public SBarInfoNegatableFlowControl
|
|||
{
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
percentage = sc.CheckToken('%');
|
||||
hpamount = sc.Number;
|
||||
hpAmount = sc.Number;
|
||||
}
|
||||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||
{
|
||||
|
@ -3430,10 +3430,10 @@ class CommandIfHealth : public SBarInfoNegatableFlowControl
|
|||
|
||||
int phealth = percentage ? statusBar->CPlayer->mo->health * 100 / statusBar->CPlayer->mo->GetMaxHealth() : statusBar->CPlayer->mo->health;
|
||||
|
||||
SetTruth(phealth >= hpamount, block, statusBar);
|
||||
SetTruth(phealth >= hpAmount, block, statusBar);
|
||||
}
|
||||
protected:
|
||||
int hpamount;
|
||||
int hpAmount;
|
||||
bool percentage;
|
||||
};
|
||||
|
||||
|
|
|
@ -1803,7 +1803,7 @@ static int UseInventory (AActor *activator, const char *type)
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
static int CheckInventory (AActor *activator, const char *type, bool max)
|
||||
int CheckInventory (AActor *activator, const char *type, bool max)
|
||||
{
|
||||
if (activator == NULL || type == NULL)
|
||||
return 0;
|
||||
|
@ -1850,7 +1850,7 @@ static int CheckInventory (AActor *activator, const char *type, bool max)
|
|||
return ((AInventory *)GetDefaultByType(info))->MaxAmount;
|
||||
}
|
||||
}
|
||||
return item ? item->Amount : 0;
|
||||
return item ? item->IntVar(NAME_Amount) : 0;
|
||||
}
|
||||
|
||||
//---- Plane watchers ----//
|
||||
|
@ -5536,7 +5536,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
|||
{
|
||||
FName p(FBehavior::StaticLookupString(args[0]));
|
||||
auto armor = players[args[1]].mo->FindInventory(NAME_BasicArmor);
|
||||
if (armor && armor->NameVar(NAME_ArmorType) == p) return armor->Amount;
|
||||
if (armor && armor->NameVar(NAME_ArmorType) == p) return armor->IntVar(NAME_Amount);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -5547,7 +5547,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
|||
|
||||
auto equippedarmor = activator->FindInventory(NAME_BasicArmor);
|
||||
|
||||
if (equippedarmor && equippedarmor->Amount != 0)
|
||||
if (equippedarmor && equippedarmor->IntVar(NAME_Amount) != 0)
|
||||
{
|
||||
switch(args[0])
|
||||
{
|
||||
|
@ -8866,7 +8866,7 @@ scriptwait:
|
|||
if (activator)
|
||||
{
|
||||
auto armor = activator->FindInventory(NAME_BasicArmor);
|
||||
PushToStack (armor ? armor->Amount : 0);
|
||||
PushToStack (armor ? armor->IntVar(NAME_Amount) : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -9390,7 +9390,7 @@ scriptwait:
|
|||
if (item != NULL)
|
||||
{
|
||||
item->MaxAmount = STACK(1);
|
||||
item->Amount = 0;
|
||||
item->IntVar(NAME_Amount) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -326,38 +326,6 @@ DEFINE_ACTION_FUNCTION(AActor, GetMissileDamage)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CountInv
|
||||
//
|
||||
// NON-ACTION function to return the inventory count of an item.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, CountInv)
|
||||
{
|
||||
if (numret > 0)
|
||||
{
|
||||
assert(ret != NULL);
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_CLASS(itemtype, AInventory);
|
||||
PARAM_INT(pick_pointer);
|
||||
|
||||
self = COPY_AAPTR(self, pick_pointer);
|
||||
if (self == NULL || itemtype == NULL)
|
||||
{
|
||||
ret->SetInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
AInventory *item = self->FindInventory(itemtype);
|
||||
ret->SetInt(item ? item->Amount : 0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// GetDistance
|
||||
|
@ -1116,48 +1084,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_Jump)
|
|||
ACTION_RETURN_STATE(NULL);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// State jump function
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, CheckInventory)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_CLASS (itemtype, AInventory);
|
||||
PARAM_INT (itemamount);
|
||||
PARAM_INT (setowner);
|
||||
|
||||
if (itemtype == nullptr)
|
||||
{
|
||||
ACTION_RETURN_BOOL(false);
|
||||
}
|
||||
AActor *owner = COPY_AAPTR(self, setowner);
|
||||
if (owner == nullptr)
|
||||
{
|
||||
ACTION_RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
AInventory *item = owner->FindInventory(itemtype);
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (itemamount > 0)
|
||||
{
|
||||
if (item->Amount >= itemamount)
|
||||
{
|
||||
ACTION_RETURN_BOOL(true);
|
||||
}
|
||||
}
|
||||
else if (item->Amount >= item->MaxAmount)
|
||||
{
|
||||
ACTION_RETURN_BOOL(true);
|
||||
}
|
||||
}
|
||||
ACTION_RETURN_BOOL(false);
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -4142,11 +4068,11 @@ static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amo
|
|||
AInventory *gift = static_cast<AInventory *>(Spawn(item));
|
||||
if (gift->IsKindOf(NAME_Health))
|
||||
{
|
||||
gift->Amount *= amount;
|
||||
gift->IntVar(NAME_Amount) *= amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
gift->Amount = amount;
|
||||
gift->IntVar(NAME_Amount) = amount;
|
||||
}
|
||||
gift->flags |= MF_DROPPED;
|
||||
gift->ClearCounters();
|
||||
|
|
|
@ -612,7 +612,7 @@ static bool CheckStrifeItem (player_t *player, PClassActor *itemtype, int amount
|
|||
if (item == NULL)
|
||||
return false;
|
||||
|
||||
return amount < 0 || item->Amount >= amount;
|
||||
return amount < 0 || item->IntVar(NAME_Amount) >= amount;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
|
@ -625,7 +625,7 @@ DEFINE_ACTION_FUNCTION(AActor, InStateSequence)
|
|||
bool AActor::IsMapActor()
|
||||
{
|
||||
// [SP] Don't remove owned inventory objects.
|
||||
return (!IsKindOf(NAME_Inventory) || static_cast<AInventory *>(this)->Owner == nullptr);
|
||||
return (!IsKindOf(NAME_Inventory) || GC::ReadBarrier(PointerVar<AActor>(NAME_Owner)) == nullptr);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -783,7 +783,7 @@ void AActor::DestroyAllInventory ()
|
|||
toDelete.Push(inv);
|
||||
AInventory *item = inv->Inventory;
|
||||
inv->Inventory = nullptr;
|
||||
inv->Owner = nullptr;
|
||||
inv->PointerVar<AActor>(NAME_Owner) = nullptr;
|
||||
inv = item;
|
||||
}
|
||||
for (auto p : toDelete)
|
||||
|
@ -1006,9 +1006,9 @@ void AActor::ObtainInventory (AActor *other)
|
|||
}
|
||||
|
||||
AInventory *item = Inventory;
|
||||
while (item != NULL)
|
||||
while (item != nullptr)
|
||||
{
|
||||
item->Owner = this;
|
||||
item->PointerVar<AActor>(NAME_Owner) = this;
|
||||
item = item->Inventory;
|
||||
}
|
||||
}
|
||||
|
@ -3788,7 +3788,7 @@ void AActor::Tick ()
|
|||
// by the order in the inventory, not the order in the thinker table
|
||||
AInventory *item = Inventory;
|
||||
|
||||
while (item != NULL && item->Owner == this)
|
||||
while (item != NULL)
|
||||
{
|
||||
IFVIRTUALPTR(item, AInventory, DoEffect)
|
||||
{
|
||||
|
|
|
@ -622,7 +622,7 @@ class Actor : Thinker native
|
|||
native clearscope double Distance3DSquared(Actor other) const;
|
||||
native void SetOrigin(vector3 newpos, bool moving);
|
||||
native void SetXYZ(vector3 newpos);
|
||||
native Actor GetPointer(int aaptr);
|
||||
native clearscope Actor GetPointer(int aaptr);
|
||||
native double BulletSlope(out FTranslatedLineTarget pLineTarget = null, int aimflags = 0);
|
||||
native void CheckFakeFloorTriggers (double oldz, bool oldz_has_viewheight = false);
|
||||
|
||||
|
@ -752,7 +752,6 @@ class Actor : Thinker native
|
|||
native bool Warp(Actor dest, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, double heightoffset = 0, double radiusoffset = 0, double pitch = 0);
|
||||
|
||||
// DECORATE compatible functions
|
||||
native clearscope int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT) const;
|
||||
native double GetDistance(bool checkz, int ptr = AAPTR_TARGET) const;
|
||||
native double GetAngle(int flags, int ptr = AAPTR_TARGET) const;
|
||||
native double GetZAt(double px = 0, double py = 0, double angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
|
||||
|
|
|
@ -91,8 +91,6 @@ extend class Actor
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
native bool CheckInventory(class<Inventory> itemtype, int itemamount, int owner = AAPTR_DEFAULT);
|
||||
|
||||
action state A_JumpIfInventory(class<Inventory> itemtype, int itemamount, statelabel label, int owner = AAPTR_DEFAULT)
|
||||
{
|
||||
return CheckInventory(itemtype, itemamount, owner)? ResolveState(label) : null;
|
||||
|
|
|
@ -671,6 +671,67 @@ extend class Actor
|
|||
return NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CountInv
|
||||
//
|
||||
// NON-ACTION function to return the inventory count of an item.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
clearscope int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT) const
|
||||
{
|
||||
let realself = GetPointer(ptr_select);
|
||||
if (realself == NULL || itemtype == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
let item = realself.FindInventory(itemtype);
|
||||
return item ? item.Amount : 0;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// State jump function
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool CheckInventory(class<Inventory> itemtype, int itemamount, int owner = AAPTR_DEFAULT)
|
||||
{
|
||||
if (itemtype == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let owner = GetPointer(owner);
|
||||
if (owner == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let item = owner.FindInventory(itemtype);
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (itemamount > 0)
|
||||
{
|
||||
if (item.Amount >= itemamount)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (item.Amount >= item.MaxAmount)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue