mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-22 19:01:12 +00:00
Allow for Basic and Hexen armor replacing
This commit is contained in:
parent
5fa220219e
commit
0d43272c8f
21 changed files with 56 additions and 34 deletions
|
@ -436,7 +436,7 @@ static bool DoSubstitution (FString &out, const char *in)
|
|||
{
|
||||
if (strnicmp(a, "armor", 5) == 0)
|
||||
{
|
||||
auto armor = player->mo->FindInventory(NAME_BasicArmor);
|
||||
auto armor = player->mo->FindInventory(NAME_BasicArmor, true);
|
||||
out.AppendFormat("%d", armor != NULL ? armor->IntVar(NAME_Amount) : 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1036,7 +1036,7 @@ public:
|
|||
ammocount2 = ammo2 != nullptr ? ammo2->IntVar(NAME_Amount) : 0;
|
||||
|
||||
//prepare ammo counts
|
||||
armor = CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||
armor = CPlayer->mo->FindInventory(NAME_BasicArmor, true);
|
||||
}
|
||||
|
||||
void _Draw (EHudState state)
|
||||
|
|
|
@ -276,7 +276,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
{
|
||||
int armorType = type - HEXENARMOR_ARMOR;
|
||||
|
||||
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor);
|
||||
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor, true);
|
||||
if (harmor != NULL)
|
||||
{
|
||||
double *Slots = (double*)harmor->ScriptVar(NAME_Slots, nullptr);
|
||||
|
@ -596,7 +596,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
|
|||
}
|
||||
else if(condition == ARMORTYPE)
|
||||
{
|
||||
auto armor = statusBar->CPlayer->mo->FindInventory(NAME_BasicArmor);
|
||||
auto armor = statusBar->CPlayer->mo->FindInventory(NAME_BasicArmor, true);
|
||||
if(armor != NULL)
|
||||
{
|
||||
auto n = armor->NameVar(NAME_ArmorType).GetIndex();
|
||||
|
@ -1413,7 +1413,7 @@ class CommandDrawNumber : public CommandDrawString
|
|||
case SAVEPERCENT:
|
||||
{
|
||||
double add = 0;
|
||||
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor);
|
||||
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor, true);
|
||||
if(harmor != NULL)
|
||||
{
|
||||
double *Slots = (double*)harmor->ScriptVar(NAME_Slots, nullptr);
|
||||
|
@ -2775,7 +2775,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
case SAVEPERCENT:
|
||||
{
|
||||
double add = 0;
|
||||
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor);
|
||||
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor, true);
|
||||
if (harmor != NULL)
|
||||
{
|
||||
double *Slots = (double*)harmor->ScriptVar(NAME_Slots, nullptr);
|
||||
|
|
|
@ -52,6 +52,8 @@ DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, backpacktype)
|
|||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, Armor2Percent)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, ArmorIcon1)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, ArmorIcon2)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, BasicArmorClass)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, HexenArmorClass)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, gametype)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, norandomplayerclass)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, infoPages)
|
||||
|
@ -392,6 +394,8 @@ void FMapInfoParser::ParseGameInfo()
|
|||
GAMEINFOKEY_SOUNDARRAY(PrecachedSounds, "precachesounds", 0, false)
|
||||
GAMEINFOKEY_STRINGARRAY(EventHandlers, "addeventhandlers", 0, false)
|
||||
GAMEINFOKEY_STRINGARRAY(EventHandlers, "eventhandlers", 0, false)
|
||||
GAMEINFOKEY_STRING(BasicArmorClass, "BasicArmorClass")
|
||||
GAMEINFOKEY_STRING(HexenArmorClass, "HexenArmorClass")
|
||||
GAMEINFOKEY_STRING(PauseSign, "pausesign")
|
||||
GAMEINFOKEY_STRING(quitSound, "quitSound")
|
||||
GAMEINFOKEY_STRING(BorderFlat, "borderFlat")
|
||||
|
|
|
@ -148,6 +148,8 @@ struct gameinfo_t
|
|||
FString SkyFlatName;
|
||||
FString ArmorIcon1;
|
||||
FString ArmorIcon2;
|
||||
FName BasicArmorClass;
|
||||
FName HexenArmorClass;
|
||||
FString PauseSign;
|
||||
FString Endoom;
|
||||
double Armor2Percent;
|
||||
|
|
|
@ -5506,7 +5506,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args, int &
|
|||
else
|
||||
{
|
||||
FName p(Level->Behaviors.LookupString(args[0]));
|
||||
auto armor = Level->Players[args[1]]->mo->FindInventory(NAME_BasicArmor);
|
||||
auto armor = Level->Players[args[1]]->mo->FindInventory(NAME_BasicArmor, true);
|
||||
if (armor && armor->NameVar(NAME_ArmorType) == p) return armor->IntVar(NAME_Amount);
|
||||
}
|
||||
return 0;
|
||||
|
@ -5517,7 +5517,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args, int &
|
|||
{
|
||||
if (activator == NULL || activator->player == NULL) return 0;
|
||||
|
||||
auto equippedarmor = activator->FindInventory(NAME_BasicArmor);
|
||||
auto equippedarmor = activator->FindInventory(NAME_BasicArmor, true);
|
||||
|
||||
if (equippedarmor && equippedarmor->IntVar(NAME_Amount) != 0)
|
||||
{
|
||||
|
@ -8898,7 +8898,7 @@ scriptwait:
|
|||
case PCD_PLAYERARMORPOINTS:
|
||||
if (activator)
|
||||
{
|
||||
auto armor = activator->FindInventory(NAME_BasicArmor);
|
||||
auto armor = activator->FindInventory(NAME_BasicArmor, true);
|
||||
PushToStack (armor ? armor->IntVar(NAME_Amount) : 0);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -110,7 +110,7 @@ extend class Actor
|
|||
|
||||
bool CheckArmorType(name Type, int amount = 1)
|
||||
{
|
||||
let myarmor = BasicArmor(FindInventory("BasicArmor"));
|
||||
let myarmor = BasicArmor(FindInventory("BasicArmor", true));
|
||||
return myarmor != null && myarmor.ArmorType == type && myarmor.Amount >= amount;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class ArtiBoostArmor : Inventory
|
|||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
armor = HexenArmor(Spawn("HexenArmor"));
|
||||
armor = HexenArmor(Spawn(GetHexenArmorClass()));
|
||||
armor.bDropped = true;
|
||||
armor.health = i;
|
||||
armor.Amount = 1;
|
||||
|
|
|
@ -51,7 +51,7 @@ class ArtiHealingRadius : Inventory
|
|||
case 'Armor':
|
||||
for (int j = 0; j < 4; ++j)
|
||||
{
|
||||
HexenArmor armor = HexenArmor(Spawn("HexenArmor"));
|
||||
HexenArmor armor = HexenArmor(Spawn(GetHexenArmorClass()));
|
||||
armor.health = j;
|
||||
armor.Amount = 1;
|
||||
if (!armor.CallTryPickup (mo))
|
||||
|
|
|
@ -106,7 +106,7 @@ class BasicArmor : Armor
|
|||
{
|
||||
// BasicArmor that is in use is stored in the inventory as BasicArmor.
|
||||
// BasicArmor that is in reserve is not.
|
||||
let copy = BasicArmor(Spawn("BasicArmor"));
|
||||
let copy = BasicArmor(Spawn(GetBasicArmorClass()));
|
||||
copy.SavePercent = SavePercent != 0 ? SavePercent : 0.33335; // slightly more than 1/3 to avoid roundoff errors.
|
||||
copy.Amount = Amount;
|
||||
copy.MaxAmount = MaxAmount;
|
||||
|
@ -127,7 +127,7 @@ class BasicArmor : Armor
|
|||
|
||||
override bool HandlePickup (Inventory item)
|
||||
{
|
||||
if (item.GetClass() == "BasicArmor")
|
||||
if (item is "BasicArmor")
|
||||
{
|
||||
// You shouldn't be picking up BasicArmor anyway.
|
||||
return true;
|
||||
|
@ -271,13 +271,13 @@ class BasicArmorBonus : Armor
|
|||
|
||||
override bool Use (bool pickup)
|
||||
{
|
||||
let armor = BasicArmor(Owner.FindInventory("BasicArmor"));
|
||||
let armor = BasicArmor(Owner.FindInventory("BasicArmor", true));
|
||||
bool result = false;
|
||||
|
||||
// This should really never happen but let's be prepared for a broken inventory.
|
||||
if (armor == null)
|
||||
{
|
||||
armor = BasicArmor(Spawn("BasicArmor"));
|
||||
armor = BasicArmor(Spawn(GetBasicArmorClass()));
|
||||
armor.BecomeItem ();
|
||||
armor.Amount = 0;
|
||||
armor.MaxAmount = MaxSaveAmount;
|
||||
|
@ -391,12 +391,12 @@ class BasicArmorPickup : Armor
|
|||
override bool Use (bool pickup)
|
||||
{
|
||||
int SaveAmount = GetSaveAmount();
|
||||
let armor = BasicArmor(Owner.FindInventory("BasicArmor"));
|
||||
let armor = BasicArmor(Owner.FindInventory("BasicArmor", true));
|
||||
|
||||
// This should really never happen but let's be prepared for a broken inventory.
|
||||
if (armor == null)
|
||||
{
|
||||
armor = BasicArmor(Spawn("BasicArmor"));
|
||||
armor = BasicArmor(Spawn(GetBasicArmorClass()));
|
||||
armor.BecomeItem ();
|
||||
Owner.AddInventory (armor);
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ class HexenArmor : Armor
|
|||
// Like BasicArmor, HexenArmor is used in the inventory but not the map.
|
||||
// health is the slot this armor occupies.
|
||||
// Amount is the quantity to give (0 = normal max).
|
||||
let copy = HexenArmor(Spawn("HexenArmor"));
|
||||
let copy = HexenArmor(Spawn(GetHexenArmorClass()));
|
||||
copy.AddArmorToSlot (health, Amount);
|
||||
GoAwayAndDie ();
|
||||
return copy;
|
||||
|
|
|
@ -855,8 +855,22 @@ extend class Actor
|
|||
}
|
||||
}
|
||||
|
||||
clearscope static class<BasicArmor> GetBasicArmorClass()
|
||||
{
|
||||
class<BasicArmor> cls = (class<BasicArmor>)(GameInfo.BasicArmorClass);
|
||||
if (cls)
|
||||
return cls;
|
||||
|
||||
return "BasicArmor";
|
||||
}
|
||||
|
||||
clearscope static class<HexenArmor> GetHexenArmorClass()
|
||||
{
|
||||
class<HexenArmor> cls = (class<HexenArmor>)(GameInfo.HexenArmorClass);
|
||||
if (cls)
|
||||
return cls;
|
||||
|
||||
return "HexenArmor";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1906,8 +1906,8 @@ class PlayerPawn : Actor
|
|||
// it provides player class based protection that should not affect
|
||||
// any other protection item.
|
||||
let myclass = GetClass();
|
||||
GiveInventoryType('HexenArmor');
|
||||
let harmor = HexenArmor(FindInventory('HexenArmor'));
|
||||
GiveInventoryType(GetHexenArmorClass());
|
||||
let harmor = HexenArmor(FindInventory('HexenArmor', true));
|
||||
|
||||
harmor.Slots[4] = self.HexenArmor[0];
|
||||
for (int i = 0; i < 4; ++i)
|
||||
|
@ -1918,7 +1918,7 @@ class PlayerPawn : Actor
|
|||
// 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.
|
||||
GiveInventoryType('BasicArmor');
|
||||
GiveInventoryType(GetBasicArmorClass());
|
||||
|
||||
// Now add the items from the DECORATE definition
|
||||
let di = GetDropItems();
|
||||
|
|
|
@ -139,7 +139,7 @@ extend class PlayerPawn
|
|||
{
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
let armoritem = Inventory(Spawn("HexenArmor"));
|
||||
let armoritem = Inventory(Spawn(GetHexenArmorClass()));
|
||||
armoritem.health = i;
|
||||
armoritem.Amount = 0;
|
||||
if (!armoritem.CallTryPickup (self))
|
||||
|
|
|
@ -347,7 +347,7 @@ extend class PlayerPawn
|
|||
}
|
||||
|
||||
// Reset the base AC of the player's Hexen armor back to its default.
|
||||
let hexArmor = HexenArmor(alt.FindInventory("HexenArmor"));
|
||||
let hexArmor = HexenArmor(alt.FindInventory("HexenArmor", true));
|
||||
if (hexArmor)
|
||||
hexArmor.Slots[4] = alt.HexenArmor[0];
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ extend struct GameInfoStruct
|
|||
native double Armor2Percent;
|
||||
native String ArmorIcon1;
|
||||
native String ArmorIcon2;
|
||||
native Name BasicArmorClass;
|
||||
native Name HexenArmorClass;
|
||||
native bool norandomplayerclass;
|
||||
native Array<Name> infoPages;
|
||||
native GIFont mStatscreenMapNameFont;
|
||||
|
|
|
@ -61,7 +61,7 @@ class ScriptUtil play
|
|||
}
|
||||
if (type == 'Armor')
|
||||
{
|
||||
type = "BasicArmor";
|
||||
type = Actor.GetBasicArmorClass().GetClassName();
|
||||
}
|
||||
if (amount <= 0)
|
||||
{
|
||||
|
|
|
@ -930,7 +930,7 @@ class AltHud ui
|
|||
int armory = hud_swaphealtharmor ? hudheight-45 : hudheight-20;
|
||||
int healthy = hud_swaphealtharmor ? hudheight-20 : hudheight-45;
|
||||
DrawHealth(CPlayer, 5, healthy);
|
||||
DrawArmor(BasicArmor(CPlayer.mo.FindInventory('BasicArmor')), HexenArmor(CPlayer.mo.FindInventory('HexenArmor')), 5, armory);
|
||||
DrawArmor(BasicArmor(CPlayer.mo.FindInventory('BasicArmor', true)), HexenArmor(CPlayer.mo.FindInventory('HexenArmor', true)), 5, armory);
|
||||
|
||||
int y = DrawKeys(CPlayer, hudwidth-4, hudheight-10);
|
||||
y = DrawAmmo(CPlayer, hudwidth-5, y);
|
||||
|
|
|
@ -146,7 +146,7 @@ class DoomStatusBar : BaseStatusBar
|
|||
DrawImage(berserk? "PSTRA0" : "MEDIA0", (20, -2));
|
||||
DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (44, -20));
|
||||
|
||||
let armor = CPlayer.mo.FindInventory("BasicArmor");
|
||||
let armor = CPlayer.mo.FindInventory("BasicArmor", true);
|
||||
if (armor != null && armor.Amount > 0)
|
||||
{
|
||||
DrawInventoryIcon(armor, (20, -22));
|
||||
|
|
|
@ -148,7 +148,7 @@ class HereticStatusBar : BaseStatusBar
|
|||
DrawString(mBigFont, FormatNumber(mHealthInterpolator.GetValue()), (41, -21), DI_TEXT_ALIGN_RIGHT);
|
||||
|
||||
//armor
|
||||
let armor = CPlayer.mo.FindInventory("BasicArmor");
|
||||
let armor = CPlayer.mo.FindInventory("BasicArmor", true);
|
||||
if (armor != null && armor.Amount > 0)
|
||||
{
|
||||
DrawInventoryIcon(armor, (58, -24));
|
||||
|
|
|
@ -430,7 +430,7 @@ class BaseStatusBar : StatusBarCore native
|
|||
|
||||
int GetArmorAmount()
|
||||
{
|
||||
let armor = CPlayer.mo.FindInventory("BasicArmor");
|
||||
let armor = CPlayer.mo.FindInventory("BasicArmor", true);
|
||||
return armor? armor.Amount : 0;
|
||||
}
|
||||
|
||||
|
@ -451,13 +451,13 @@ class BaseStatusBar : StatusBarCore native
|
|||
int GetArmorSavePercent()
|
||||
{
|
||||
double add = 0;
|
||||
let harmor = HexenArmor(CPlayer.mo.FindInventory("HexenArmor"));
|
||||
let harmor = HexenArmor(CPlayer.mo.FindInventory("HexenArmor", true));
|
||||
if(harmor != NULL)
|
||||
{
|
||||
add = harmor.Slots[0] + harmor.Slots[1] + harmor.Slots[2] + harmor.Slots[3] + harmor.Slots[4];
|
||||
}
|
||||
//Hexen counts basic armor also so we should too.
|
||||
let armor = BasicArmor(CPlayer.mo.FindInventory("BasicArmor"));
|
||||
let armor = BasicArmor(CPlayer.mo.FindInventory("BasicArmor", true));
|
||||
if(armor != NULL && armor.Amount > 0)
|
||||
{
|
||||
add += armor.SavePercent * 100;
|
||||
|
@ -771,7 +771,7 @@ class BaseStatusBar : StatusBarCore native
|
|||
|
||||
void DrawHexenArmor(int armortype, String image, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 boxsize = (-1, -1), Vector2 scale = (1.,1.))
|
||||
{
|
||||
let harmor = HexenArmor(statusBar.CPlayer.mo.FindInventory("HexenArmor"));
|
||||
let harmor = HexenArmor(statusBar.CPlayer.mo.FindInventory("HexenArmor", true));
|
||||
if (harmor != NULL)
|
||||
{
|
||||
let slotval = harmor.Slots[armorType];
|
||||
|
|
|
@ -287,7 +287,7 @@ class StrifeStatusBar : BaseStatusBar
|
|||
DrawHealthBar (points, 49, 175);
|
||||
|
||||
// Armor
|
||||
item = CPlayer.mo.FindInventory('BasicArmor');
|
||||
item = CPlayer.mo.FindInventory('BasicArmor', true);
|
||||
if (item != NULL && item.Amount > 0)
|
||||
{
|
||||
DrawInventoryIcon(item, (2, 177), DI_ITEM_OFFSETS);
|
||||
|
@ -333,7 +333,7 @@ class StrifeStatusBar : BaseStatusBar
|
|||
DrawImage("I_MDKT", (14, -17));
|
||||
|
||||
// Draw armor
|
||||
let armor = CPlayer.mo.FindInventory('BasicArmor');
|
||||
let armor = CPlayer.mo.FindInventory('BasicArmor', true);
|
||||
if (armor != NULL && armor.Amount != 0)
|
||||
{
|
||||
DrawString(mYelFont, FormatNumber(armor.Amount, 3), (35, -10));
|
||||
|
|
Loading…
Reference in a new issue