mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-23 12:22:45 +00:00
- removed the remaining native parts of ABasicArmor.
- simplified some FindInventory calls using PClass::FindActor to call the variant taking a name directly.
This commit is contained in:
parent
3148496f57
commit
2fcffd1fc1
18 changed files with 62 additions and 107 deletions
|
@ -721,7 +721,7 @@ public:
|
|||
|
||||
// Finds the first item of a particular type.
|
||||
AInventory *FindInventory (PClassActor *type, bool subclass=false);
|
||||
AInventory *FindInventory (FName type);
|
||||
AInventory *FindInventory (FName type, bool subclass = false);
|
||||
template<class T> T *FindInventory ()
|
||||
{
|
||||
return static_cast<T *> (FindInventory (RUNTIME_TEMPLATE_CLASS(T)));
|
||||
|
|
|
@ -3048,7 +3048,7 @@ void AM_Drawer ()
|
|||
return;
|
||||
|
||||
bool allmap = (level.flags2 & LEVEL2_ALLMAP) != 0;
|
||||
bool allthings = allmap && players[consoleplayer].mo->FindInventory(PClass::FindActor(NAME_PowerScanner), true) != nullptr;
|
||||
bool allthings = allmap && players[consoleplayer].mo->FindInventory(NAME_PowerScanner, true) != nullptr;
|
||||
|
||||
if (am_portaloverlay)
|
||||
{
|
||||
|
|
|
@ -434,7 +434,7 @@ static bool DoSubstitution (FString &out, const char *in)
|
|||
{
|
||||
if (strnicmp(a, "armor", 5) == 0)
|
||||
{
|
||||
AInventory *armor = player->mo->FindInventory<ABasicArmor>();
|
||||
AInventory *armor = player->mo->FindInventory(NAME_BasicArmor);
|
||||
out.AppendFormat("%d", armor != NULL ? armor->Amount : 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -447,7 +447,7 @@ CCMD (use)
|
|||
{
|
||||
if (argv.argc() > 1 && who != NULL)
|
||||
{
|
||||
SendItemUse = who->FindInventory(PClass::FindActor(argv[1]));
|
||||
SendItemUse = who->FindInventory(argv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ CCMD (drop)
|
|||
{
|
||||
if (argv.argc() > 1 && who != NULL)
|
||||
{
|
||||
SendItemDrop = who->FindInventory(PClass::FindActor(argv[1]));
|
||||
SendItemDrop = who->FindInventory(argv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ CCMD (select)
|
|||
{
|
||||
if (argv.argc() > 1)
|
||||
{
|
||||
AInventory *item = who->FindInventory(PClass::FindActor(argv[1]));
|
||||
AInventory *item = who->FindInventory(argv[1]);
|
||||
if (item != NULL)
|
||||
{
|
||||
who->InvSel = item;
|
||||
|
|
|
@ -46,44 +46,8 @@
|
|||
#include "cmdlib.h"
|
||||
|
||||
IMPLEMENT_CLASS(AArmor, false, false)
|
||||
IMPLEMENT_CLASS(ABasicArmor, false, false)
|
||||
IMPLEMENT_CLASS(AHexenArmor, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
// BasicArmor
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
DEFINE_FIELD(ABasicArmor, AbsorbCount)
|
||||
DEFINE_FIELD(ABasicArmor, SavePercent)
|
||||
DEFINE_FIELD(ABasicArmor, MaxAbsorb)
|
||||
DEFINE_FIELD(ABasicArmor, MaxFullAbsorb)
|
||||
DEFINE_FIELD(ABasicArmor, BonusCount)
|
||||
DEFINE_FIELD(ABasicArmor, ArmorType)
|
||||
DEFINE_FIELD(ABasicArmor, ActualSaveAmount)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// ABasicArmor :: Serialize
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void ABasicArmor::Serialize(FSerializer &arc)
|
||||
{
|
||||
Super::Serialize (arc);
|
||||
auto def = (ABasicArmor *)GetDefault();
|
||||
arc("savepercent", SavePercent, def->SavePercent)
|
||||
("bonuscount", BonusCount, def->BonusCount)
|
||||
("maxabsorb", MaxAbsorb, def->MaxAbsorb)
|
||||
("maxfullabsorb", MaxFullAbsorb, def->MaxFullAbsorb)
|
||||
("absorbcount", AbsorbCount, def->AbsorbCount)
|
||||
("armortype", ArmorType, def->ArmorType)
|
||||
("actualsaveamount", ActualSaveAmount, def->ActualSaveAmount);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -8,25 +8,6 @@ class AArmor : public AInventory
|
|||
DECLARE_CLASS (AArmor, AInventory)
|
||||
};
|
||||
|
||||
// Basic armor absorbs a specific percent of the damage. You should
|
||||
// never pickup a BasicArmor. Instead, you pickup a BasicArmorPickup
|
||||
// or BasicArmorBonus and those gives you BasicArmor when it activates.
|
||||
class ABasicArmor : public AArmor
|
||||
{
|
||||
DECLARE_CLASS (ABasicArmor, AArmor)
|
||||
public:
|
||||
|
||||
virtual void Serialize(FSerializer &arc) override;
|
||||
|
||||
int AbsorbCount;
|
||||
double SavePercent;
|
||||
int MaxAbsorb;
|
||||
int MaxFullAbsorb;
|
||||
int BonusCount;
|
||||
FNameNoInit ArmorType;
|
||||
int ActualSaveAmount;
|
||||
};
|
||||
|
||||
// Hexen armor consists of four separate armor types plus a conceptual armor
|
||||
// type (the player himself) that work together as a single armor.
|
||||
class AHexenArmor : public AArmor
|
||||
|
|
|
@ -1067,7 +1067,7 @@ public:
|
|||
|
||||
//prepare ammo counts
|
||||
GetCurrentAmmo(ammo1, ammo2, ammocount1, ammocount2);
|
||||
armor = CPlayer->mo->FindInventory<ABasicArmor>();
|
||||
armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||
|
||||
if(state != HUD_AltHud)
|
||||
{
|
||||
|
@ -1517,7 +1517,7 @@ public:
|
|||
|
||||
AInventory *ammo1, *ammo2;
|
||||
int ammocount1, ammocount2;
|
||||
ABasicArmor *armor;
|
||||
AInventory *armor;
|
||||
FImageCollection Images;
|
||||
unsigned int invBarOffset;
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
}
|
||||
else if(type == SIGIL)
|
||||
{
|
||||
auto item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(NAME_Sigil));
|
||||
auto item = statusBar->CPlayer->mo->FindInventory(NAME_Sigil);
|
||||
if (item != NULL)
|
||||
texture = TexMan(item->Icon);
|
||||
}
|
||||
|
@ -592,11 +592,11 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
}
|
||||
else if(condition == ARMORTYPE)
|
||||
{
|
||||
ABasicArmor *armor = (ABasicArmor *) statusBar->CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||
auto armor = statusBar->CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||
if(armor != NULL)
|
||||
{
|
||||
bool matches1 = armor->ArmorType.GetIndex() == armorType[0] && EvaluateOperation(conditionalOperator[0], conditionalValue[0], armor->Amount);
|
||||
bool matches2 = armor->ArmorType.GetIndex() == armorType[1] && EvaluateOperation(conditionalOperator[1], conditionalValue[1], armor->Amount);
|
||||
bool matches1 = armor->NameVar(NAME_ArmorType).GetIndex() == armorType[0] && EvaluateOperation(conditionalOperator[0], conditionalValue[0], armor->Amount);
|
||||
bool matches2 = armor->NameVar(NAME_ArmorType).GetIndex() == armorType[1] && EvaluateOperation(conditionalOperator[1], conditionalValue[1], armor->Amount);
|
||||
|
||||
drawAlt = 1;
|
||||
if(conditionAnd)
|
||||
|
@ -614,12 +614,12 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
}
|
||||
else //check the inventory items and draw selected sprite
|
||||
{
|
||||
AInventory* item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(inventoryItem[0]));
|
||||
AInventory* item = statusBar->CPlayer->mo->FindInventory(inventoryItem[0]);
|
||||
if(item == NULL || !EvaluateOperation(conditionalOperator[0], conditionalValue[0], item->Amount))
|
||||
drawAlt = 1;
|
||||
if(conditionAnd)
|
||||
{
|
||||
item = statusBar->CPlayer->mo->FindInventory(PClass::FindActor(inventoryItem[1]));
|
||||
item = statusBar->CPlayer->mo->FindInventory(inventoryItem[1]);
|
||||
bool secondCondition = item != NULL && EvaluateOperation(conditionalOperator[1], conditionalValue[1], item->Amount);
|
||||
if((item != NULL && secondCondition) && drawAlt == 0) //both
|
||||
{
|
||||
|
@ -1418,7 +1418,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
//Hexen counts basic armor also so we should too.
|
||||
if(statusBar->armor != NULL)
|
||||
{
|
||||
add += statusBar->armor->SavePercent * 100;
|
||||
add += statusBar->armor->FloatVar(NAME_SavePercent) * 100;
|
||||
}
|
||||
if(value == ARMORCLASS)
|
||||
add /= 5;
|
||||
|
@ -2851,7 +2851,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
//Hexen counts basic armor also so we should too.
|
||||
if(statusBar->armor != NULL)
|
||||
{
|
||||
add += statusBar->armor->SavePercent * 100;
|
||||
add += statusBar->armor->FloatVar(NAME_SavePercent) * 100;
|
||||
}
|
||||
value = int(add);
|
||||
max = 100;
|
||||
|
|
|
@ -297,7 +297,7 @@ static void DrawHealth(player_t *CPlayer, int x, int y)
|
|||
|
||||
const bool haveBerserk = hud_berserk_health
|
||||
&& nullptr != berserkpic
|
||||
&& nullptr != CPlayer->mo->FindInventory(PClass::FindActor(NAME_PowerStrength));
|
||||
&& nullptr != CPlayer->mo->FindInventory(NAME_PowerStrength);
|
||||
|
||||
DrawImageToBox(haveBerserk ? berserkpic : healthpic, x, y, 31, 17);
|
||||
DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17);
|
||||
|
@ -310,7 +310,7 @@ static void DrawHealth(player_t *CPlayer, int x, int y)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
static void DrawArmor(ABasicArmor * barmor, AHexenArmor * harmor, int x, int y)
|
||||
static void DrawArmor(AInventory * barmor, AHexenArmor * harmor, int x, int y)
|
||||
{
|
||||
int ap = 0;
|
||||
int bestslot = 4;
|
||||
|
@ -1141,7 +1141,7 @@ void DrawHUD()
|
|||
DrawFrags(CPlayer, 5, hudheight-70);
|
||||
}
|
||||
DrawHealth(CPlayer, 5, hudheight-45);
|
||||
DrawArmor(CPlayer->mo->FindInventory<ABasicArmor>(),
|
||||
DrawArmor(CPlayer->mo->FindInventory(NAME_BasicArmor),
|
||||
CPlayer->mo->FindInventory<AHexenArmor>(), 5, hudheight-20);
|
||||
i=DrawKeys(CPlayer, hudwidth-4, hudheight-10);
|
||||
i=DrawAmmo(CPlayer, hudwidth-5, i);
|
||||
|
|
|
@ -408,7 +408,7 @@ private:
|
|||
DrawImage (&HealthBar, 49, 7);
|
||||
|
||||
// Armor
|
||||
item = CPlayer->mo->FindInventory<ABasicArmor>();
|
||||
item = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||
if (item != NULL && item->Amount > 0)
|
||||
{
|
||||
DrawImage (TexMan(item->Icon), 2, 9);
|
||||
|
@ -436,7 +436,7 @@ private:
|
|||
}
|
||||
|
||||
// Sigil
|
||||
item = CPlayer->mo->FindInventory(PClass::FindActor(NAME_Sigil));
|
||||
item = CPlayer->mo->FindInventory(NAME_Sigil);
|
||||
if (item != NULL)
|
||||
{
|
||||
DrawImage (TexMan(item->Icon), 253, 7);
|
||||
|
@ -473,7 +473,7 @@ private:
|
|||
TAG_DONE);
|
||||
|
||||
// Draw armor
|
||||
ABasicArmor *armor = CPlayer->mo->FindInventory<ABasicArmor>();
|
||||
auto armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||
if (armor != NULL && armor->Amount != 0)
|
||||
{
|
||||
DrINumberOuter (armor->Amount, 35, -10, false, 7);
|
||||
|
|
|
@ -266,7 +266,7 @@ void cht_DoCheat (player_t *player, int cheat)
|
|||
}
|
||||
else if (player->mo != NULL && player->health >= 0)
|
||||
{
|
||||
item = player->mo->FindInventory(PClass::FindActor(BeholdPowers[i]));
|
||||
item = player->mo->FindInventory(BeholdPowers[i]);
|
||||
if (item == NULL)
|
||||
{
|
||||
if (i != 0)
|
||||
|
@ -487,7 +487,7 @@ void cht_DoCheat (player_t *player, int cheat)
|
|||
int oldpieces = 1;
|
||||
ret.IntAt(&oldpieces);
|
||||
GlobalVMStack.Call(gsp, params, 1, &ret, 1, nullptr);
|
||||
item = player->mo->FindInventory(PClass::FindActor(NAME_Sigil));
|
||||
item = player->mo->FindInventory(NAME_Sigil);
|
||||
|
||||
if (item != NULL)
|
||||
{
|
||||
|
|
|
@ -89,6 +89,10 @@ xx(SaveAmount)
|
|||
xx(SavePercent)
|
||||
xx(MaxAbsorb)
|
||||
xx(MaxFullAbsorb)
|
||||
xx(MaxAmount)
|
||||
xx(ActualSaveAmount)
|
||||
xx(ArmorType)
|
||||
|
||||
|
||||
xx(BulletPuff)
|
||||
xx(StrifePuff)
|
||||
|
|
|
@ -4955,8 +4955,8 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
|
|||
else
|
||||
{
|
||||
FName p(FBehavior::StaticLookupString(args[0]));
|
||||
ABasicArmor * armor = (ABasicArmor *) players[args[1]].mo->FindInventory(NAME_BasicArmor);
|
||||
if (armor && armor->ArmorType == p) return armor->Amount;
|
||||
auto armor = players[args[1]].mo->FindInventory(NAME_BasicArmor);
|
||||
if (armor && armor->NameVar(NAME_ArmorType) == p) return armor->Amount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -4965,29 +4965,29 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
|
|||
{
|
||||
if (activator == NULL || activator->player == NULL) return 0;
|
||||
|
||||
ABasicArmor * equippedarmor = (ABasicArmor *) activator->FindInventory(NAME_BasicArmor);
|
||||
auto equippedarmor = activator->FindInventory(NAME_BasicArmor);
|
||||
|
||||
if (equippedarmor && equippedarmor->Amount != 0)
|
||||
{
|
||||
switch(args[0])
|
||||
{
|
||||
case ARMORINFO_CLASSNAME:
|
||||
return GlobalACSStrings.AddString(equippedarmor->ArmorType.GetChars());
|
||||
return GlobalACSStrings.AddString(equippedarmor->NameVar(NAME_ArmorType).GetChars());
|
||||
|
||||
case ARMORINFO_SAVEAMOUNT:
|
||||
return equippedarmor->MaxAmount;
|
||||
return equippedarmor->IntVar(NAME_MaxAmount);
|
||||
|
||||
case ARMORINFO_SAVEPERCENT:
|
||||
return DoubleToACS(equippedarmor->SavePercent);
|
||||
return DoubleToACS(equippedarmor->FloatVar(NAME_SavePercent));
|
||||
|
||||
case ARMORINFO_MAXABSORB:
|
||||
return equippedarmor->MaxAbsorb;
|
||||
return equippedarmor->IntVar(NAME_MaxAbsorb);
|
||||
|
||||
case ARMORINFO_MAXFULLABSORB:
|
||||
return equippedarmor->MaxFullAbsorb;
|
||||
return equippedarmor->IntVar(NAME_MaxFullAbsorb);
|
||||
|
||||
case ARMORINFO_ACTUALSAVEAMOUNT:
|
||||
return equippedarmor->ActualSaveAmount;
|
||||
return equippedarmor->IntVar(NAME_ActualSaveAmount);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
|
@ -8235,7 +8235,7 @@ scriptwait:
|
|||
case PCD_PLAYERARMORPOINTS:
|
||||
if (activator)
|
||||
{
|
||||
ABasicArmor *armor = activator->FindInventory<ABasicArmor>();
|
||||
auto armor = activator->FindInventory(NAME_BasicArmor);
|
||||
PushToStack (armor ? armor->Amount : 0);
|
||||
}
|
||||
else
|
||||
|
@ -8682,7 +8682,7 @@ scriptwait:
|
|||
{
|
||||
AInventory *sigil;
|
||||
|
||||
if (activator == NULL || (sigil = activator->FindInventory(PClass::FindActor(NAME_Sigil))) == NULL)
|
||||
if (activator == NULL || (sigil = activator->FindInventory(NAME_Sigil)) == NULL)
|
||||
{
|
||||
PushToStack (0);
|
||||
}
|
||||
|
|
|
@ -2883,7 +2883,7 @@ FUNC(LS_SetPlayerProperty)
|
|||
{ // Take power from activator
|
||||
if (power != 4)
|
||||
{
|
||||
AInventory *item = it->FindInventory(PClass::FindActor(powers[power]), true);
|
||||
AInventory *item = it->FindInventory(powers[power], true);
|
||||
if (item != NULL)
|
||||
{
|
||||
item->Destroy ();
|
||||
|
|
|
@ -1093,9 +1093,9 @@ AInventory *AActor::FindInventory (PClassActor *type, bool subclass)
|
|||
return item;
|
||||
}
|
||||
|
||||
AInventory *AActor::FindInventory (FName type)
|
||||
AInventory *AActor::FindInventory (FName type, bool subclass)
|
||||
{
|
||||
return FindInventory(PClass::FindActor(type));
|
||||
return FindInventory(PClass::FindActor(type), subclass);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, FindInventory)
|
||||
|
|
|
@ -233,7 +233,7 @@ DPSprite *player_t::GetPSprite(PSPLayers layer)
|
|||
{
|
||||
if (mo != nullptr)
|
||||
{
|
||||
newcaller = mo->FindInventory(PClass::FindActor(NAME_PowerTargeter), true);
|
||||
newcaller = mo->FindInventory(NAME_PowerTargeter, true);
|
||||
}
|
||||
}
|
||||
else if (layer == PSP_STRIFEHANDS)
|
||||
|
|
|
@ -1148,9 +1148,9 @@ void APlayerPawn::FilterCoopRespawnInventory (APlayerPawn *oldplayer)
|
|||
{
|
||||
item->Destroy();
|
||||
}
|
||||
else if (item->IsKindOf(RUNTIME_CLASS(ABasicArmor)))
|
||||
else if (item->IsKindOf(PClass::FindActor(NAME_BasicArmor)))
|
||||
{
|
||||
static_cast<ABasicArmor*>(item)->SavePercent = static_cast<ABasicArmor*>(defitem)->SavePercent;
|
||||
item->IntVar(NAME_SavePercent) = defitem->IntVar(NAME_SavePercent);
|
||||
item->Amount = defitem->Amount;
|
||||
}
|
||||
else if (item->IsKindOf(RUNTIME_CLASS(AHexenArmor)))
|
||||
|
@ -1375,10 +1375,8 @@ void APlayerPawn::GiveDefaultInventory ()
|
|||
// BasicArmor must come right after that. It should not affect any
|
||||
// other protection item as well but needs to process the damage
|
||||
// before the HexenArmor does.
|
||||
ABasicArmor *barmor = Spawn<ABasicArmor> ();
|
||||
auto barmor = (AInventory*)Spawn(NAME_BasicArmor);
|
||||
barmor->BecomeItem ();
|
||||
barmor->SavePercent = 0;
|
||||
barmor->Amount = 0;
|
||||
AddInventory (barmor);
|
||||
|
||||
// Now add the items from the DECORATE definition
|
||||
|
|
|
@ -46,22 +46,27 @@ class Armor : Inventory native
|
|||
//
|
||||
// BasicArmor
|
||||
//
|
||||
// Basic armor absorbs a specific percent of the damage. You should
|
||||
// never pickup a BasicArmor. Instead, you pickup a BasicArmorPickup
|
||||
// or BasicArmorBonus and those gives you BasicArmor when it activates.
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
class BasicArmor : Armor native
|
||||
class BasicArmor : Armor
|
||||
{
|
||||
|
||||
native int AbsorbCount;
|
||||
native double SavePercent;
|
||||
native int MaxAbsorb;
|
||||
native int MaxFullAbsorb;
|
||||
native int BonusCount;
|
||||
native Name ArmorType;
|
||||
native int ActualSaveAmount;
|
||||
int AbsorbCount;
|
||||
double SavePercent;
|
||||
int MaxAbsorb;
|
||||
int MaxFullAbsorb;
|
||||
int BonusCount;
|
||||
Name ArmorType;
|
||||
int ActualSaveAmount;
|
||||
|
||||
Default
|
||||
{
|
||||
Inventory.Amount 0;
|
||||
+Inventory.KEEPDEPLETED
|
||||
}
|
||||
|
||||
|
@ -441,6 +446,9 @@ class BasicArmorPickup : Armor
|
|||
//
|
||||
// HexenArmor
|
||||
//
|
||||
// Hexen armor consists of four separate armor types plus a conceptual armor
|
||||
// type (the player himself) that work together as a single armor.
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
|
|
Loading…
Reference in a new issue