- scriptified HexenArmor.

This commit is contained in:
Christoph Oelckers 2017-01-18 23:42:08 +01:00
commit 632a29e365
12 changed files with 217 additions and 242 deletions

View file

@ -364,10 +364,11 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
}
pmo->Destroy ();
// Restore playerclass armor to its normal amount.
AHexenArmor *hxarmor = mo->FindInventory<AHexenArmor>();
auto hxarmor = mo->FindInventory(NAME_HexenArmor);
if (hxarmor != nullptr)
{
hxarmor->Slots[4] = mo->GetClass()->HexenArmor[0];
double *Slots = (double*)hxarmor->ScriptVar(NAME_Slots, nullptr);
Slots[4] = mo->GetClass()->HexenArmor[0];
}
return true;
}

View file

@ -276,13 +276,15 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
{
int armorType = type - HEXENARMOR_ARMOR;
AHexenArmor *harmor = statusBar->CPlayer->mo->FindInventory<AHexenArmor>();
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor);
if (harmor != NULL)
{
if (harmor->Slots[armorType] > 0 && harmor->SlotsIncrement[armorType] > 0)
double *Slots = (double*)harmor->ScriptVar(NAME_Slots, nullptr);
double *SlotsIncrement = (double*)harmor->ScriptVar(NAME_SlotsIncrement, nullptr);
if (Slots[armorType] > 0 && SlotsIncrement[armorType] > 0)
{
//combine the alpha values
alpha *= MIN(1., harmor->Slots[armorType] / harmor->SlotsIncrement[armorType]);
alpha *= MIN(1., Slots[armorType] / SlotsIncrement[armorType]);
texture = statusBar->Images[image];
}
else
@ -1409,11 +1411,11 @@ class CommandDrawNumber : public CommandDrawString
case SAVEPERCENT:
{
double add = 0;
AHexenArmor *harmor = statusBar->CPlayer->mo->FindInventory<AHexenArmor>();
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor);
if(harmor != NULL)
{
add = harmor->Slots[0] + harmor->Slots[1] +
harmor->Slots[2] + harmor->Slots[3] + harmor->Slots[4];
double *Slots = (double*)harmor->ScriptVar(NAME_Slots, nullptr);
add = Slots[0] + Slots[1] + Slots[2] + Slots[3] + Slots[4];
}
//Hexen counts basic armor also so we should too.
if(statusBar->armor != NULL)
@ -2842,12 +2844,13 @@ class CommandDrawBar : public SBarInfoCommand
case SAVEPERCENT:
{
double add = 0;
AHexenArmor *harmor = statusBar->CPlayer->mo->FindInventory<AHexenArmor>();
if(harmor != NULL)
auto harmor = statusBar->CPlayer->mo->FindInventory(NAME_HexenArmor);
if (harmor != NULL)
{
add = harmor->Slots[0] + harmor->Slots[1] +
harmor->Slots[2] + harmor->Slots[3] + harmor->Slots[4];
double *Slots = (double*)harmor->ScriptVar(NAME_Slots, nullptr);
add = Slots[0] + Slots[1] + Slots[2] + Slots[3] + Slots[4];
}
//Hexen counts basic armor also so we should too.
if(statusBar->armor != NULL)
{

View file

@ -310,14 +310,15 @@ static void DrawHealth(player_t *CPlayer, int x, int y)
//
//===========================================================================
static void DrawArmor(AInventory * barmor, AHexenArmor * harmor, int x, int y)
static void DrawArmor(AInventory * barmor, AInventory * harmor, int x, int y)
{
int ap = 0;
int bestslot = 4;
if (harmor)
{
auto ac = (harmor->Slots[0] + harmor->Slots[1] + harmor->Slots[2] + harmor->Slots[3] + harmor->Slots[4]);
double *Slots = (double*)harmor->ScriptVar(NAME_Slots, nullptr);
auto ac = (Slots[0] + Slots[1] + Slots[2] + Slots[3] + Slots[4]);
ap += int(ac);
if (ac)
@ -326,7 +327,7 @@ static void DrawArmor(AInventory * barmor, AHexenArmor * harmor, int x, int y)
bestslot = 0;
for (int i = 1; i < 4; ++i)
{
if (harmor->Slots[i] > harmor->Slots[bestslot])
if (Slots[i] > Slots[bestslot])
{
bestslot = i;
}
@ -1141,8 +1142,7 @@ void DrawHUD()
DrawFrags(CPlayer, 5, hudheight-70);
}
DrawHealth(CPlayer, 5, hudheight-45);
DrawArmor(CPlayer->mo->FindInventory(NAME_BasicArmor),
CPlayer->mo->FindInventory<AHexenArmor>(), 5, hudheight-20);
DrawArmor(CPlayer->mo->FindInventory(NAME_BasicArmor), CPlayer->mo->FindInventory(NAME_HexenArmor), 5, hudheight-20);
i=DrawKeys(CPlayer, hudwidth-4, hudheight-10);
i=DrawAmmo(CPlayer, hudwidth-5, i);
if (hud_showweapons) DrawWeapons(CPlayer, hudwidth - 5, i);