Skip to content

Commit

Permalink
- ported Exhumed's status bar.
Browse files Browse the repository at this point in the history
Not tested yet.
  • Loading branch information
coelckers committed May 15, 2021
1 parent 5a6121d commit b71c725
Show file tree
Hide file tree
Showing 11 changed files with 997 additions and 30 deletions.
8 changes: 4 additions & 4 deletions source/core/gamecontrol.cpp
Expand Up @@ -829,10 +829,10 @@ void CreateStatusBar()
StatusBar->SetSize(0, 320, 200);
InitStatusBar();
// this is for comparing the scriptification with the C++ versions
//stbarclass = PClass::FindClass("NativeBloodStatusBar");
//StatusBar2 = static_cast<DBaseStatusBar*>(stbarclass->CreateNew());
//StatusBar2->SetSize(0, 320, 200);
//StatusBar2->Release();
stbarclass = PClass::FindClass("NativeExhumedStatusBar");
StatusBar2 = static_cast<DBaseStatusBar*>(stbarclass->CreateNew());
StatusBar2->SetSize(0, 320, 200);
StatusBar2->Release();

}

Expand Down
6 changes: 3 additions & 3 deletions source/games/exhumed/src/cheats.cpp
Expand Up @@ -203,17 +203,17 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
if (buttons & kButtonCheatGuns) // LOBOCOP cheat
{
FillWeapons(player);
if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_WEAPONS"));
if (player == myconnectindex) Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_WEAPONS"));
}
if (buttons & kButtonCheatKeys) // LOBOPICK cheat
{
PlayerList[player].keys = 0xFFFF;
if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_KEYS"));
if (player == myconnectindex) Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_KEYS"));
}
if (buttons & kButtonCheatItems) // LOBOSWAG cheat
{
FillItems(player);
if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_ITEMS"));
if (player == myconnectindex) Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_ITEMS"));
}

}
Expand Down
10 changes: 10 additions & 0 deletions source/games/exhumed/src/namelist.h
@@ -1,3 +1,13 @@
x(Torch1, 338)
x(Torch2, 350)
x(TileRamsesGold, 590)
x(TileRamsesWorkTile, 591)
x(TileRamsesNormal, 592)
x(TileStatusBar, 657)
x(KeyIcon1, 675)
x(KeyIcon2, 679)
x(KeyIcon3, 683)
x(KeyIcon4, 687)
x(CrosshairTile, 1579)
x(SkullJaw, 3437)
x(PowerslaveLogo, 3442)
Expand Down
6 changes: 0 additions & 6 deletions source/games/exhumed/src/names.h
Expand Up @@ -20,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

enum
{
kTorch1 = 338,
kTorch2 = 350,
kTileRamsesGold = 590,
kTileRamsesWorkTile = 591,
kTileRamsesNormal = 592,
kTileStatusBar = 657,
kTile985 = 985,
kTile986 = 986,
kTile3000 = 3000,
Expand Down
50 changes: 50 additions & 0 deletions source/games/exhumed/src/player.cpp
Expand Up @@ -2760,4 +2760,54 @@ void SerializePlayer(FSerializer& arc)
}
}


DEFINE_FIELD_X(ExhumedPlayer, Player, nHealth);
DEFINE_FIELD_X(ExhumedPlayer, Player, nLives);
DEFINE_FIELD_X(ExhumedPlayer, Player, nDouble);
DEFINE_FIELD_X(ExhumedPlayer, Player, nInvisible);
DEFINE_FIELD_X(ExhumedPlayer, Player, nTorch);
DEFINE_FIELD_X(ExhumedPlayer, Player, field_2);
DEFINE_FIELD_X(ExhumedPlayer, Player, nAction);
DEFINE_FIELD_X(ExhumedPlayer, Player, nSprite);
DEFINE_FIELD_X(ExhumedPlayer, Player, bIsMummified);
DEFINE_FIELD_X(ExhumedPlayer, Player, invincibility);
DEFINE_FIELD_X(ExhumedPlayer, Player, nAir);
DEFINE_FIELD_X(ExhumedPlayer, Player, nSeq);
DEFINE_FIELD_X(ExhumedPlayer, Player, nMaskAmount);
DEFINE_FIELD_X(ExhumedPlayer, Player, keys);
DEFINE_FIELD_X(ExhumedPlayer, Player, nMagic);
DEFINE_FIELD_X(ExhumedPlayer, Player, nItem);
DEFINE_FIELD_X(ExhumedPlayer, Player, items);
DEFINE_FIELD_X(ExhumedPlayer, Player, nAmmo); // TODO - kMaxWeapons?
DEFINE_FIELD_X(ExhumedPlayer, Player, pad);

DEFINE_FIELD_X(ExhumedPlayer, Player, nCurrentWeapon);
DEFINE_FIELD_X(ExhumedPlayer, Player, field_3FOUR);
DEFINE_FIELD_X(ExhumedPlayer, Player, bIsFiring);
DEFINE_FIELD_X(ExhumedPlayer, Player, field_38);
DEFINE_FIELD_X(ExhumedPlayer, Player, field_3A);
DEFINE_FIELD_X(ExhumedPlayer, Player, field_3C);
DEFINE_FIELD_X(ExhumedPlayer, Player, nRun);
DEFINE_FIELD_X(ExhumedPlayer, Player, bPlayerPan);
DEFINE_FIELD_X(ExhumedPlayer, Player, bLockPan);

DEFINE_ACTION_FUNCTION(_Exhumed, GetViewPlayer)
{
ACTION_RETURN_POINTER(&PlayerList[nLocalPlayer]);
}

DEFINE_ACTION_FUNCTION(_ExhumedPlayer, IsUnderwater)
{
PARAM_SELF_STRUCT_PROLOGUE(Player);
auto nLocalPlayer = self - PlayerList;
ACTION_RETURN_BOOL(SectFlag[nPlayerViewSect[nLocalPlayer]] & kSectUnderwater);
}

DEFINE_ACTION_FUNCTION(_ExhumedPlayer, GetAngle)
{
PARAM_SELF_STRUCT_PROLOGUE(Player);
ACTION_RETURN_INT(sprite[self->nSprite].ang);
}


END_PS_NS
2 changes: 1 addition & 1 deletion source/games/exhumed/src/player.h
Expand Up @@ -65,7 +65,7 @@ struct Player
uint16_t keys;
short nMagic;
short nItem;
char items[8];
uint8_t items[8];
short nAmmo[7]; // TODO - kMaxWeapons?
short pad[2];

Expand Down
102 changes: 89 additions & 13 deletions source/games/exhumed/src/status.cpp
Expand Up @@ -47,9 +47,77 @@ void InitStatus()
nStatusSeqOffset = SeqOffsets[kSeqStatus];
}

class DExhumedStatusBar : public DBaseStatusBar

//---------------------------------------------------------------------------
//
// This is to hide the dirt from the script code.
// These sequence arrays later need to be refactored
// if this is ever supposed to become a useful feature,
// so hide the dirty internals behind a handful of functions.
//
//---------------------------------------------------------------------------

struct ChunkFrame
{
FTextureID tex;
int x, y;
int flags;

void GetChunkFrame(int nFrameBase)
{
x = ChunkXpos[nFrameBase];
y = ChunkYpos[nFrameBase];
auto ttex = tileGetTexture(nFrameBase);
if (ttex) tex = ttex->GetID();
else tex.SetInvalid();
flags = ChunkFlag[nFrameBase];
}
};

DEFINE_ACTION_FUNCTION(_ChunkFrame, GetChunkFrame)
{
DECLARE_CLASS(DExhumedStatusBar, DBaseStatusBar)
PARAM_SELF_STRUCT_PROLOGUE(ChunkFrame);
PARAM_INT(index);
self->GetChunkFrame(index);
return 0;
}

DEFINE_ACTION_FUNCTION(_Exhumed, GetStatusSequence)
{
PARAM_PROLOGUE;
PARAM_INT(nSequence);
PARAM_INT(frameindex);

frameindex += SeqBase[nStatusSeqOffset + nSequence];
if (numret > 0) ret[0].SetInt(FrameBase[frameindex]);
if (numret > 1) ret[1].SetInt(FrameSize[frameindex]);
return min(numret, 2);
}

DEFINE_ACTION_FUNCTION(_Exhumed, MoveStatusSequence)
{
PARAM_PROLOGUE;
PARAM_INT(s1);
PARAM_INT(s2);
seq_MoveSequence(-1, nStatusSeqOffset + s1, s2);
ACTION_RETURN_INT(SeqSize[nStatusSeqOffset + s1]);
}

int SizeOfStatusSequence(int s1)
{
return SeqSize[nStatusSeqOffset + s1];
}

DEFINE_ACTION_FUNCTION_NATIVE(_Exhumed, SizeOfStatusSequence, SizeOfStatusSequence)
{
PARAM_PROLOGUE;
PARAM_INT(s1);
ACTION_RETURN_INT(SeqSize[nStatusSeqOffset + s1]);
}

class DNativeExhumedStatusBar : public DBaseStatusBar
{
DECLARE_CLASS(DNativeExhumedStatusBar, DBaseStatusBar)
HAS_OBJECT_POINTERS

TObjPtr<DHUDFont*> textfont, numberFont;
Expand Down Expand Up @@ -81,7 +149,7 @@ class DExhumedStatusBar : public DBaseStatusBar
};

public:
DExhumedStatusBar()
DNativeExhumedStatusBar()
{
textfont = Create<DHUDFont>(SmallFont, 1, Off, 1, 1);
numberFont = Create<DHUDFont>(BigFont, 0, Off, 1, 1);
Expand Down Expand Up @@ -505,12 +573,6 @@ class DExhumedStatusBar : public DBaseStatusBar
}

DrawMulti();

if (nSnakeCam >= 0)
{
BeginHUD(320, 200, 1);
SBar_DrawString(this, textfont, "S E R P E N T C A M", 0, 0, DI_TEXT_ALIGN_CENTER | DI_SCREEN_CENTER_TOP, CR_UNTRANSLATED, 1, -1, 0, 1, 1);
}
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -898,8 +960,8 @@ class DExhumedStatusBar : public DBaseStatusBar
}
};

IMPLEMENT_CLASS(DExhumedStatusBar, false, true)
IMPLEMENT_POINTERS_START(DExhumedStatusBar)
IMPLEMENT_CLASS(DNativeExhumedStatusBar, false, true)
IMPLEMENT_POINTERS_START(DNativeExhumedStatusBar)
IMPLEMENT_POINTER(textfont)
IMPLEMENT_POINTER(numberFont)
IMPLEMENT_POINTERS_END
Expand Down Expand Up @@ -928,15 +990,29 @@ void StatusMessage(int messageTime, const char* fmt, ...)
va_end(ap);
}


CVAR(Bool, sb_native, false, 0)
void DrawStatusBar()
{
if (nFreeze == 2) return; // Hide when Ramses is talking.
if (hud_size <= Hud_Stbar)
{
UpdateFrame();
}
StatusBar->UpdateStatusBar();
SummaryInfo info{};
info.kills = nCreaturesKilled;
info.maxkills = nCreaturesTotal;
// got no secrets in the game
info.time = Scale(PlayClock, 1000, 120);
if (!sb_native) UpdateStatusBar(&info);
else StatusBar2->UpdateStatusBar();

if (nSnakeCam >= 0)
{
const char* text = "S E R P E N T C A M";
int width = SmallFont->StringWidth(text);
DrawText(twod, SmallFont, CR_UNTRANSLATED, 160 - width / 2, 1, text, DTA_FullscreenScale, FSMode_Fit320x200, TAG_DONE);
}

}

END_PS_NS
1 change: 1 addition & 0 deletions wadsrc/static/zscript.txt
Expand Up @@ -43,4 +43,5 @@ version "4.3"
#include "zscript/games/sw/ui/screens.zs"
#include "zscript/games/exhumed/exhumedgame.zs"
#include "zscript/games/exhumed/ui/menu.zs"
#include "zscript/games/exhumed/ui/sbar.zs"
#include "zscript/games/exhumed/ui/screens.zs"
57 changes: 55 additions & 2 deletions wadsrc/static/zscript/games/exhumed/exhumedgame.zs
Expand Up @@ -7,14 +7,17 @@ struct Exhumed native
native static bool LocalSoundPlaying();
native static void playCDTrack(int track, bool looped);
native static void DrawPlasma();

native static int, int GetStatusSequence(int seq, int index);
native static int MoveStatusSequence(int s1, int s2);
native static int SizeOfStatusSequence(int s1);
native static ExhumedPlayer GetViewPlayer();

static void DrawAbs(String img, int x, int y, int shade = 0)
{
Screen.DrawTexture(TexMan.CheckForTexture(img, TexMan.Type_Any), false, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TopLeft, true, DTA_Color, Raze.shadeToLight(shade));
}

static void DRawRel(String img, int x, int y, int shade = 0)
static void DrawRel(String img, int x, int y, int shade = 0)
{
let tex = TexMan.CheckForTexture(img, TexMan.Type_Any);
if (!tex.IsValid()) return;
Expand All @@ -27,6 +30,56 @@ struct Exhumed native
}
}

struct ExhumedPlayer native
{
native int16 nHealth;
native int16 nLives;
native int16 nDouble;
native int16 nInvisible;
native int16 nTorch;
native int16 field_2;
native int16 nAction;
native int16 nSprite;
native int16 bIsMummified;
native int16 invincibility;
native int16 nAir;
native int16 nSeq;
native int16 nMaskAmount;
native uint16 keys;
native int16 nMagic;
native int16 nItem;
native uint8 items[8];
native int16 nAmmo[7]; // TODO - kMaxWeapons?
native int16 pad[2];

native int16 nCurrentWeapon;
native int16 field_3FOUR;
native int16 bIsFiring;
native int16 field_38;
native int16 field_3A;
native int16 field_3C;
native int16 nRun;
native bool bPlayerPan, bLockPan;
//fixedhoriz nDestVertPan;

//PlayerHorizon horizon;
//PlayerAngle angle;

native bool IsUnderwater();
native int GetAngle();
}

enum EEWeap
{
kWeaponSword = 0,
kWeaponPistol,
kWeaponM60,
kWeaponFlamer,
kWeaponGrenade,
kWeaponStaff,
kWeaponRing,
kWeaponMummified
}

struct ExhumedSnd native
{
Expand Down

0 comments on commit b71c725

Please sign in to comment.