I have started work on converting my unwieldy SBARINFO status bars into the new reliable ZScript class. However, i do have some questions about that:
1. Is it possible to give separate Status bars to various player classes? Currentl I've created an enormous class with "if (CPlayer.mo is <PlayerClass>)" for each class.
2. Is conversion string to inventory still unavailable? I've looked through the forums but i have not found if it changed. This would be handy (and probably clear some memory):
Spoiler:
- Code: Select all • Expand view
static const String ItemClasses[]
{
"Item0",
"Item1",
"Item2",
"Item3",
"Item4",
"Item5"
}
for (int i = 0; i < 5; ++i)
{
if CheckInventory(ItemClasses[i])
{
<Code>
}
}
Right now i use "Static const Inventory", but these leads to following problem:
3. Is there a limit to the amount of "Static const" declared values? With enough of such arrays, any operation on an array with Inventory class type inside a "for" loop caused the iteration index to change, causing nearly immediate VM crash due to "index out of bounds". As a simple loop is not enough to cause the issue i have attached a full statusbar here:
Spoiler:
- Code: Select all • Expand view
class DoomStatusBar2 : BaseStatusBar
{
HUDFont mHUDFont;
HUDFont mIndexFont;
HUDFont mAmountFont;
InventoryBarState diparms;
override void Init()
{
Super.Init();
SetSize(32, 320, 200);
// Create the font used for the fullscreen HUD
Font fnt = "HUDFONT_DOOM";
mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true, 1, 1);
fnt = "INDEXFONT_DOOM";
mIndexFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true);
mAmountFont = HUDFont.Create("INDEXFONT");
diparms = InventoryBarState.Create();
}
override void Draw (int state, double TicFrac)
{
Super.Draw (state, TicFrac);
if (state == HUD_StatusBar)
{
BeginStatusBar();
DrawMainBar (TicFrac);
}
else if (state == HUD_Fullscreen)
{
BeginHUD();
DrawFullScreenStuff ();
}
}
protected void DrawMainBar (double TicFrac)
{
DrawImage("STBAR", (0, 168), DI_ITEM_OFFSETS);
DrawImage("STTPRCNT", (90, 171), DI_ITEM_OFFSETS);
DrawImage("STTPRCNT", (221, 171), DI_ITEM_OFFSETS);
Inventory a1 = GetCurrentAmmo();
if (a1 != null) DrawString(mHUDFont, FormatNumber(a1.Amount, 3), (44, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (90, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (221, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
DrawBarKeys();
DrawBarAmmo();
if (deathmatch || teamplay)
{
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (138, 171), DI_TEXT_ALIGN_RIGHT);
}
else
{
DrawBarWeapons();
}
if (multiplayer)
{
DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE);
}
if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar)
{
DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198));
if (CPlayer.mo.InvSel.Amount > 1)
{
DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
}
}
else
{
DrawTexture(GetMugShot(5), (143, 168), DI_ITEM_OFFSETS);
}
if (isInventoryBarVisible())
{
DrawInventoryBar(diparms, (48, 169), 7, DI_ITEM_LEFT_TOP);
}
static const class<Inventory> FoxinSkillList[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const class<Weapon> FoxinWeaponList[] =
{
"Pistol",
"Pistol",
"Pistol",
"Pistol",
"Pistol",
"Pistol",
"Pistol"
};
static const String FoxinWeaponListNames[] =
{
"Dual Sword",
"Ice Bolt",
"Doom Bolt",
"Healing",
"Armor",
"Mirror Image",
"Time Stop"
};
static const int SkillX[] = {8, 8, 71, 71, 134, 134, 196};
static const int SkillY[] = {173, 187, 173, 187, 173, 187, 173};
static const String NovaProtossImages[] =
{
"B_COUN",
"B_ROBO",
"B_IMMO",
"B_DSHR",
"B_ARCH",
"B_SUPP",
"I_ASSI",
"B_NEXS",
"B_PYLO",
"B_GATE",
"B_CYBR",
"B_STAR",
"B_FLET",
"B_FRGE",
"B_STLK",
"B_VOID",
"B_PHOX",
"B_CARR",
"B_DARK",
"B_ZEAL"
};
static const class<Inventory> NovaProtossItemControllers[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const class<Inventory> NovaProtossItemUnitDeployed[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const class<Inventory> NovaProtossItemUnitAvailable[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const int ProtossIconX[] = {114, 164, 214, 64, 114, 164, 14, 14, 14, 64, 114, 164, 214, 64, 114, 164, 214, 264, 14, 64};
static const int ProtossIconY[] = {59, 59, 59, 9, 9, 9, 59, 109, 159, 109, 109, 109, 109, 159, 159, 159, 159, 159, 9, 59};
static const String NovaTerranImages[] =
{
"B_COMM",
"B_BRKS",
"B_TECH",
"B_TANK",
"B_FUSI",
"B_ENGI",
"B_FCTR",
"B_PORT",
"B_TECH",
"B_SNSR",
"B_ARMO",
"I_GHST",
"B_GHST",
"B_HELL",
"I_VIKI",
"B_RAVN",
"B_BNSH",
"I_WRAI",
"I_REFI",
"B_SUPL",
"B_PRDR",
"B_MARA",
"B_BATT"
};
static const class<Inventory> NovaTerranItemControllers[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const class<Inventory> NovaTerranItemUnitDeployed[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const class<Inventory> NovaTerranItemUnitAvailable[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const int TerranIconX[] = {14, 64, 114, 164, 214, 14, 114, 164, 214, 14, 64, 64, 114, 164, 214, 264, 264, 264, 14, 64, 164, 114, 214};
static const int TerranIconY[] = {109, 109, 109, 109, 109, 59, 59, 59, 59, 9, 59, 9, 9, 9, 9, 9, 59, 109, 159, 159, 159, 159, 159};
static const String ZaShaHelmetlist[] =
{
"Helmet", // No item
"Fur Helmet",
"Fur H.-Fire",
"Fur H.-Frost",
"Fur H.-Shock",
"Fur H.-Magic",
"Mage Circlet",
"",
"",
"",
"",
"Steel Helmet",
"Steel H.-Fire",
"Steel H.-Frost",
"Steel H.-Shock",
"Steel H.-Magic",
"",
"",
"",
"",
"",
"Dragon Helmet",
"Dragon H.-Fire",
"Dragon H.-Frost",
"Dragon H.-Shock",
"Dragon H.-Magic",
"",
"",
"",
"",
"",
"Forsworn Helmet",
"Forsworn H.-Fire",
"Forsworn H.-Frost",
"Forsworn H.-Shock",
"Forsworn H.-Magic"
};
static const String ZaShaArmorlist[] =
{
"Armor", // No item
"Fur Armor",
"Fur A.-Fire",
"Fur A.-Frost",
"Fur A.-Shock",
"Fur A.-Magic",
"Mage Robes",
"",
"",
"",
"",
"Steel Armor",
"Steel A.-Fire",
"Steel A.-Frost",
"Steel A.-Shock",
"Steel A.-Magic",
"",
"",
"",
"",
"",
"Dragon Armor",
"Dragon A.-Fire",
"Dragon A.-Frost",
"Dragon A.-Shock",
"Dragon A.-Magic",
"",
"",
"",
"",
"",
"Forsworn Armor",
"Forsworn A.-Fire",
"Forsworn A.-Frost",
"Forsworn A.-Shock",
"Forsworn A.-Magic"
};
static const String ZaShaBootslist[] =
{
"Boots", // No item
"Fur Boots",
"Fur B.-Fire",
"Fur B.-Frost",
"Fur B.-Shock",
"Fur B.-Magic",
"Mage Boots",
"",
"",
"",
"",
"Steel Boots",
"Steel B.-Fire",
"Steel B.-Frost",
"Steel B.-Shock",
"Steel B.-Magic",
"",
"",
"",
"",
"",
"Dragon Boots",
"Dragon B.-Fire",
"Dragon B.-Frost",
"Dragon B.-Shock",
"Dragon B.-Magic",
"",
"",
"",
"",
"",
"Forsworn Boots",
"Forsworn B.-Fire",
"Forsworn B.-Frost",
"Forsworn B.-Shock",
"Forsworn B.-Magic"
};
static const String ZaShaGauntletslist[] =
{
"Gauntlets", // No item
"Fur Gauntlets",
"Fur G.-Fire",
"Fur G.-Frost",
"Fur G.-Shock",
"Fur G.-Magic",
"Mage Gloves",
"",
"",
"",
"",
"Steel Gauntlets",
"Steel G.-Fire",
"Steel G.-Frost",
"Steel G.-Shock",
"Steel G.-Magic",
"",
"",
"",
"",
"",
"Dragon Gauntlets",
"Dragon G.-Fire",
"Dragon G.-Frost",
"Dragon G.-Shock",
"Dragon G.-Magic",
"",
"",
"",
"",
"",
"Forsworn Gauntlets",
"Forsworn G.-Fire",
"Forsworn G.-Frost",
"Forsworn G.-Shock",
"Forsworn G.-Magic"
};
static const String ZaShaAmuletlist[] =
{
"Amulet", // No item
"Amulet of Talos",
"Healing",
"Recharging",
"Unweariness",
"",
"",
"Minor Slime",
"",
"",
"",
"",
"Remedy",
"Replenishing",
"Recuperation",
"",
"",
"Slime",
"",
"",
"",
"",
"Mending",
"Quickening",
"Rejuvenation",
"",
"",
"Major Slime",
"",
"",
"",
"",
"Regeneration",
"Resurgence",
"Invigoration",
"",
"",
"Eminent Slime",
"",
"",
"",
"",
"Revival",
"Recovery",
"Renewal",
"",
"",
"Extreme Slime"
};
static const String ZaShaRinglist[] =
{
"Ring", // No item
"Minor Archery",
"Minor Wielding",
"Minor Sure Grip",
"Embers",
"Cold",
"Sparks",
"Minor Slime",
"Minor Speed",
"",
"",
"Archery",
"Wielding",
"Sure Grip",
"Burning",
"Frost",
"Arcing",
"Slime",
"Speed",
"",
"",
"Major Archery",
"Major Wielding",
"Major Sure Grip",
"Scorching",
"Ice",
"Shocks",
"Major Slime",
"Major speed",
"",
"",
"Eminent Archery",
"Eminent Wielding",
"Eminent Sure Grip",
"Fire",
"Freezing",
"Thunderbolts",
"Eminent Slime",
"Eminent Speed",
"",
"",
"Extreme Archery",
"Extreme Wielding",
"Extreme Sure Grip",
"Blaze",
"Blizzards",
"Lightning",
"Extreme Slime",
"Extreme Speed"
};
static const String ZaShaDaggerlist[] =
{
"Dagger", // No item
"Iron Dagger",
"Iron-Fire",
"Iron-Frost",
"Iron-Shock",
"Iron-A.Health",
"Iron-A.Stamina",
"Iron-A.Magicka",
"Iron-Soul Trap",
"Iron-Chaos",
"",
"Steel Dagger",
"Steel-Fire",
"Steel-Frost",
"Steel-Shock",
"Steel-A.Health",
"Steel-A.Stamina",
"Steel-A.Magicka",
"Steel-Soul Trap",
"Steel-Chaos",
"",
"Dwarven Dagger",
"Dwarven-Fire",
"Dwarven-Frost",
"Dwarven-Shock",
"Dwarven-A.Health",
"Dwarven-A.Stamina",
"Dwarven-A.Magicka",
"Dwarven-Soul Trap",
"Dwarven-Chaos",
"",
"Ebony Dagger",
"Ebony-Fire",
"Ebony-Frost",
"Ebony-Shock",
"Ebony-A.Health",
"Ebony-A.Stamina",
"Ebony-A.Magicka",
"Ebony-Soul Trap",
"Ebony-Chaos",
"",
"Daedric Dagger",
"Daedric-Fire",
"Daedric-Frost",
"Daedric-Shock",
"Daedric-A.Health",
"Daedric-A.Stamina",
"Daedric-A.Magicka",
"Daedric-Soul Trap",
"Daedric-Chaos",
"",
"Lifestealer",
"Venomfang",
"Chaos Fang"
};
static const String ZaShaBowlist[] =
{
"Bow", // No item
"Hunting Bow",
"Hunting-Fire",
"Hunting-Frost",
"Hunting-Shock",
"Hunting-A.Health",
"Hunting-A.Stamina",
"Hunting-A.Magicka",
"Hunting-Soul Trap",
"Hunting-Chaos",
"",
"Imperial Bow",
"Imperial-Fire",
"Imperial-Frost",
"Imperial-Shock",
"Imperial-A.Health",
"Imperial-A.Stamina",
"Imperial-A.Magicka",
"Imperial-Soul Trap",
"Imperial-Chaos",
"",
"Dwarven Bow",
"Dwarven-Fire",
"Dwarven-Frost",
"Dwarven-Shock",
"Dwarven-A.Health",
"Dwarven-A.Stamina",
"Dwarven-A.Magicka",
"Dwarven-Soul Trap",
"Dwarven-Chaos",
"",
"Ebony Bow",
"Ebony-Fire",
"Ebony-Frost",
"Ebony-Shock",
"Ebony-A.Health",
"Ebony-A.Stamina",
"Ebony-A.Magicka",
"Ebony-Soul Trap",
"Ebony-Chaos",
"",
"Dragonbone Bow",
"Dragon-Fire",
"Dragon-Frost",
"Dragon-Shock",
"Dragon-A.Health",
"Dragon-A.Stamina",
"Dragon-A.Magicka",
"Dragon-Soul Trap",
"Dragon-Chaos",
"",
"ColdFire",
"FrostBlood"
};
static const String ZaShaGreatswordlist[] =
{
"Greatsword", // No item
"Iron Greatsword",
"Iron-Fire",
"Iron-Frost",
"Iron-Shock",
"Iron-A.Health",
"Iron-A.Stamina",
"Iron-A.Magicka",
"Iron-Soul Trap",
"Iron-Chaos",
"",
"Steel Greatsword",
"Steel-Fire",
"Steel-Frost",
"Steel-Shock",
"Steel-A.Health",
"Steel-A.Stamina",
"Steel-A.Magicka",
"Steel-Soul Trap",
"Steel-Chaos",
"",
"Dwarven Greatsword",
"Dwarven-Fire",
"Dwarven-Frost",
"Dwarven-Shock",
"Dwarven-A.Health",
"Dwarven-A.Stamina",
"Dwarven-A.Magicka",
"Dwarven-Soul Trap",
"Dwarven-Chaos",
"",
"Ebony Greatsword",
"Ebony-Fire",
"Ebony-Frost",
"Ebony-Shock",
"Ebony-A.Health",
"Ebony-A.Stamina",
"Ebony-A.Magicka",
"Ebony-Soul Trap",
"Ebony-Chaos",
"",
"Daedric Greatsword",
"Daedric-Fire",
"Daedric-Frost",
"Daedric-Shock",
"Daedric-A.Health",
"Daedric-A.Stamina",
"Daedric-A.Magicka",
"Daedric-Soul Trap",
"Daedric-Chaos",
"",
"Ebony Blade"
};
static const String ZaShaSelectedItemType[] =
{
"<Helmet>",
"<Armor>",
"<Boots>",
"<Gauntlets>",
"<Ring>",
"<Amulet>",
"<GreatSword>",
"<Bow>",
"<Left Hand Dagger>",
"<Right Hand Dagger>"
};
static const String ZaShaSelectedWeaponMaterial[] =
{
"<Iron>",
"<Steel>",
"<Dwarven>",
"<Ebony>",
"<Daedric>"
};
static const String ZaShaSelectedBowMaterial[] =
{
"<Hunting>",
"<Imperial>",
"<Dwarven>",
"<Ebony>",
"<Dragonbone>"
};
static const String ZaShaSelectedJewelryMaterial[] =
{
"<Tier 1>",
"<Tier 2>",
"<Tier 3>",
"<Tier 4>",
"<Tier 5>"
};
static const String ZaShaSelectedArmorMaterial[] =
{
"<None>",
"<Fur>",
"<Steel>",
"<Dragonplate>",
"<Forsworn>"
};
static const class<Inventory> ZaShaHelmetInventorylist4[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const class<Inventory> ZaShaHelmetInventorylist3[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const class<Inventory> ZaShaHelmetInventorylist2[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
static const class<Inventory> ZaShaHelmetInventorylist[] =
{
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip",
"Clip"
};
int DisplayY = 20;
for (int y = 0; y < 10; ++y)
{
DisplayY = DisplayY +10;
DrawString(mHUDFont, TEXTCOLOR_Yellow .. y, (130, DisplayY), DI_TEXT_ALIGN_CENTER);
DrawString(mHUDFont, TEXTCOLOR_Yellow .. ZaShaHelmetInventorylist[y].GetClassName(), (170, DisplayY), DI_TEXT_ALIGN_CENTER);
DrawString(mHUDFont, TEXTCOLOR_Yellow .. y, (150, DisplayY), DI_TEXT_ALIGN_CENTER);
if (ZaShaHelmetInventorylist[y].GetClassName() != "Clip") // Check for valid item
{
if (Checkinventory(ZaShaHelmetInventorylist[y], 1))
{
}
else
{
}
}
// DrawString(ConsoleFont, TEXTCOLOR_Yellow .. y, (130, DisplayY), DI_TEXT_ALIGN_CENTER);
}
}
protected virtual void DrawBarKeys()
{
bool locks[6];
String image;
for(int i = 0; i < 6; i++) locks[i] = CPlayer.mo.CheckKeys(i + 1, false, true);
// key 1
if (locks[1] && locks[4]) image = "STKEYS6";
else if (locks[1]) image = "STKEYS0";
else if (locks[4]) image = "STKEYS3";
DrawImage(image, (239, 171), DI_ITEM_OFFSETS);
// key 2
if (locks[2] && locks[5]) image = "STKEYS7";
else if (locks[2]) image = "STKEYS1";
else if (locks[5]) image = "STKEYS4";
else image = "";
DrawImage(image, (239, 181), DI_ITEM_OFFSETS);
// key 3
if (locks[0] && locks[3]) image = "STKEYS8";
else if (locks[0]) image = "STKEYS2";
else if (locks[3]) image = "STKEYS5";
else image = "";
DrawImage(image, (239, 191), DI_ITEM_OFFSETS);
}
protected virtual void DrawBarAmmo()
{
int amt1, maxamt;
[amt1, maxamt] = GetAmount("Clip");
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 173), DI_TEXT_ALIGN_RIGHT);
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 173), DI_TEXT_ALIGN_RIGHT);
[amt1, maxamt] = GetAmount("Shell");
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 179), DI_TEXT_ALIGN_RIGHT);
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 179), DI_TEXT_ALIGN_RIGHT);
[amt1, maxamt] = GetAmount("RocketAmmo");
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 185), DI_TEXT_ALIGN_RIGHT);
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 185), DI_TEXT_ALIGN_RIGHT);
[amt1, maxamt] = GetAmount("Cell");
DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 191), DI_TEXT_ALIGN_RIGHT);
DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 191), DI_TEXT_ALIGN_RIGHT);
}
protected virtual void DrawBarWeapons()
{
DrawImage("STARMS", (104, 168), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 172), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 172), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 172), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 182), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 182), DI_ITEM_OFFSETS);
DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 182), DI_ITEM_OFFSETS);
}
protected void DrawFullScreenStuff ()
{
Vector2 iconbox = (40, 20);
// Draw health
let berserk = CPlayer.mo.FindInventory("PowerStrength");
DrawImage(berserk? "PSTRA0" : "MEDIA0", (20, -2));
DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (44, -20));
let armor = CPlayer.mo.FindInventory("BasicArmor");
if (armor != null && armor.Amount > 0)
{
DrawInventoryIcon(armor, (20, -22));
DrawString(mHUDFont, FormatNumber(armor.Amount, 3), (44, -40));
}
Inventory ammotype1, ammotype2;
[ammotype1, ammotype2] = GetCurrentAmmo();
int invY = -20;
if (ammotype1 != null)
{
DrawInventoryIcon(ammotype1, (-14, -4));
DrawString(mHUDFont, FormatNumber(ammotype1.Amount, 3), (-30, -20), DI_TEXT_ALIGN_RIGHT);
invY -= 20;
}
if (ammotype2 != null && ammotype2 != ammotype1)
{
DrawInventoryIcon(ammotype2, (-14, invY + 17));
DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
invY -= 20;
}
if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null)
{
DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17));
DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
}
if (deathmatch)
{
DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (-3, 1), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
}
DrawFullscreenKeys();
if (isInventoryBarVisible())
{
DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW);
}
}
protected virtual void DrawFullscreenKeys()
{
// Draw the keys. This does not use a special draw function like SBARINFO because the specifics will be different for each mod
// so it's easier to copy or reimplement the following piece of code instead of trying to write a complicated all-encompassing solution.
Vector2 keypos = (-10, 2);
int rowc = 0;
double roww = 0;
for(let i = CPlayer.mo.Inv; i != null; i = i.Inv)
{
if (i is "Key" && i.Icon.IsValid())
{
DrawTexture(i.Icon, keypos, DI_SCREEN_RIGHT_TOP|DI_ITEM_LEFT_TOP);
Vector2 size = TexMan.GetScaledSize(i.Icon);
keypos.Y += size.Y + 2;
roww = max(roww, size.X);
if (++rowc == 3)
{
keypos.Y = 2;
keypos.X -= roww + 2;
roww = 0;
rowc = 0;
}
}
}
}
}
Running this status bar will immediately cause the VM to crash. However, commenting out some of these declared constants, will cause the script to work properly. (This status bar is not my actual status bar, but uses close to the quantity of static declarations as i use currently (and i planned to use several more). (I also have a very dirty workaround for this problem, but like all other problems with memory, it can run deeper.)
4. Is there any benefit to use
- Code: Select all • Expand view
int amt;
amt = GetAmount("Item");
if (amt > 0)
{
<code>
}
instead of
- Code: Select all • Expand view
if (GetAmount("Item") > 0)
{
<code>
}