gzdoom/code/St_stuff.c

1481 lines
30 KiB
C
Raw Normal View History

1998-04-07 00:00:00 +00:00
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// $Log:$
//
// DESCRIPTION:
// Status bar code.
// Does the face/direction indicator animatin.
// Does palette indicators as well (red pain/berserk, bright pickup)
1998-07-14 00:00:00 +00:00
// [RH] Widget coordinates are relative to the console, not the screen!
1998-04-07 00:00:00 +00:00
//
//-----------------------------------------------------------------------------
#include <stdio.h>
#include "i_system.h"
#include "i_video.h"
#include "z_zone.h"
#include "m_random.h"
#include "w_wad.h"
#include "doomdef.h"
#include "g_game.h"
#include "st_stuff.h"
#include "st_lib.h"
#include "r_local.h"
#include "p_local.h"
#include "p_inter.h"
#include "am_map.h"
#include "m_cheat.h"
#include "s_sound.h"
// Needs access to LFB.
#include "v_video.h"
// State.
#include "doomstat.h"
// Data.
#include "dstrings.h"
#include "sounds.h"
// Cheats and cvars
1998-07-14 00:00:00 +00:00
#include "c_cmds.h"
1998-04-07 00:00:00 +00:00
#include "c_cvars.h"
1998-07-14 00:00:00 +00:00
#include "c_dispch.h"
1998-04-07 00:00:00 +00:00
cvar_t *idmypos;
1998-07-14 00:00:00 +00:00
cvar_t *st_scale; // Stretch status bar to full screen width?
// [RH] Needed when status bar scale changes
BOOL setsizeneeded;
BOOL automapactive;
BOOL am_needtodrawstatusbar;
// [RH] Status bar background screen
screen_t stbarscreen;
// [RH] Active status bar screen
screen_t stnumscreen;
1998-04-07 00:00:00 +00:00
1998-04-07 00:00:00 +00:00
// functions in st_new.c
void ST_initNew (void);
void ST_unloadNew (void);
void ST_newDraw (void);
1998-04-07 00:00:00 +00:00
//
// STATUS BAR DATA
//
// Palette indices.
// For damage/bonus red-/gold-shifts
#define STARTREDPALS 1
#define STARTBONUSPALS 9
#define NUMREDPALS 8
#define NUMBONUSPALS 4
// Radiation suit, green shift.
#define RADIATIONPAL 13
// N/256*100% probability
// that the normal face state will change
#define ST_FACEPROBABILITY 96
// For Responder
#define ST_TOGGLECHAT KEY_ENTER
// Location of status bar
1998-07-14 00:00:00 +00:00
#define ST_X2 (104)
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
#define ST_FX (143)
#define ST_FY (1)
1998-04-07 00:00:00 +00:00
// Should be set to patch width
// for tall numbers later on
#define ST_TALLNUMWIDTH (tallnum[0]->width)
// Number of status faces.
#define ST_NUMPAINFACES 5
#define ST_NUMSTRAIGHTFACES 3
#define ST_NUMTURNFACES 2
#define ST_NUMSPECIALFACES 3
#define ST_FACESTRIDE \
(ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES)
#define ST_NUMEXTRAFACES 2
#define ST_NUMFACES \
(ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES)
#define ST_TURNOFFSET (ST_NUMSTRAIGHTFACES)
#define ST_OUCHOFFSET (ST_TURNOFFSET + ST_NUMTURNFACES)
#define ST_EVILGRINOFFSET (ST_OUCHOFFSET + 1)
#define ST_RAMPAGEOFFSET (ST_EVILGRINOFFSET + 1)
#define ST_GODFACE (ST_NUMPAINFACES*ST_FACESTRIDE)
#define ST_DEADFACE (ST_GODFACE+1)
1998-07-14 00:00:00 +00:00
#define ST_FACESX (143)
#define ST_FACESY (0)
1998-04-07 00:00:00 +00:00
#define ST_EVILGRINCOUNT (2*TICRATE)
#define ST_STRAIGHTFACECOUNT (TICRATE/2)
#define ST_TURNCOUNT (1*TICRATE)
#define ST_OUCHCOUNT (1*TICRATE)
#define ST_RAMPAGEDELAY (2*TICRATE)
#define ST_MUCHPAIN 20
// Location and size of statistics,
// justified according to widget type.
// Problem is, within which space? STbar? Screen?
// Note: this could be read in by a lump.
// Problem is, is the stuff rendered
// into a buffer,
// or into the frame buffer?
// AMMO number pos.
1998-07-14 00:00:00 +00:00
#define ST_AMMOWIDTH 3
#define ST_AMMOX (44)
#define ST_AMMOY (3)
1998-04-07 00:00:00 +00:00
// HEALTH number pos.
1998-07-14 00:00:00 +00:00
#define ST_HEALTHWIDTH 3
#define ST_HEALTHX (90)
#define ST_HEALTHY (3)
1998-04-07 00:00:00 +00:00
// Weapon pos.
1998-07-14 00:00:00 +00:00
#define ST_ARMSX (111)
#define ST_ARMSY (4)
#define ST_ARMSBGX (104)
#define ST_ARMSBGY (0)
1998-04-07 00:00:00 +00:00
#define ST_ARMSXSPACE 12
#define ST_ARMSYSPACE 10
// Frags pos.
1998-07-14 00:00:00 +00:00
#define ST_FRAGSX (138)
#define ST_FRAGSY (3)
1998-04-07 00:00:00 +00:00
#define ST_FRAGSWIDTH 2
// ARMOR number pos.
#define ST_ARMORWIDTH 3
1998-07-14 00:00:00 +00:00
#define ST_ARMORX (221)
#define ST_ARMORY (3)
1998-04-07 00:00:00 +00:00
// Key icon positions.
#define ST_KEY0WIDTH 8
#define ST_KEY0HEIGHT 5
1998-07-14 00:00:00 +00:00
#define ST_KEY0X (239)
#define ST_KEY0Y (3)
1998-04-07 00:00:00 +00:00
#define ST_KEY1WIDTH ST_KEY0WIDTH
1998-07-14 00:00:00 +00:00
#define ST_KEY1X (239)
#define ST_KEY1Y (13)
1998-04-07 00:00:00 +00:00
#define ST_KEY2WIDTH ST_KEY0WIDTH
1998-07-14 00:00:00 +00:00
#define ST_KEY2X (239)
#define ST_KEY2Y (23)
1998-04-07 00:00:00 +00:00
// Ammunition counter.
#define ST_AMMO0WIDTH 3
#define ST_AMMO0HEIGHT 6
1998-07-14 00:00:00 +00:00
#define ST_AMMO0X (288)
#define ST_AMMO0Y (5)
1998-04-07 00:00:00 +00:00
#define ST_AMMO1WIDTH ST_AMMO0WIDTH
1998-07-14 00:00:00 +00:00
#define ST_AMMO1X (288)
#define ST_AMMO1Y (11)
1998-04-07 00:00:00 +00:00
#define ST_AMMO2WIDTH ST_AMMO0WIDTH
1998-07-14 00:00:00 +00:00
#define ST_AMMO2X (288)
#define ST_AMMO2Y (23)
1998-04-07 00:00:00 +00:00
#define ST_AMMO3WIDTH ST_AMMO0WIDTH
1998-07-14 00:00:00 +00:00
#define ST_AMMO3X (288)
#define ST_AMMO3Y (17)
1998-04-07 00:00:00 +00:00
// Indicate maximum ammunition.
// Only needed because backpack exists.
#define ST_MAXAMMO0WIDTH 3
#define ST_MAXAMMO0HEIGHT 5
1998-07-14 00:00:00 +00:00
#define ST_MAXAMMO0X (314)
#define ST_MAXAMMO0Y (5)
1998-04-07 00:00:00 +00:00
#define ST_MAXAMMO1WIDTH ST_MAXAMMO0WIDTH
1998-07-14 00:00:00 +00:00
#define ST_MAXAMMO1X (314)
#define ST_MAXAMMO1Y (11)
1998-04-07 00:00:00 +00:00
#define ST_MAXAMMO2WIDTH ST_MAXAMMO0WIDTH
1998-07-14 00:00:00 +00:00
#define ST_MAXAMMO2X (314)
#define ST_MAXAMMO2Y (23)
1998-04-07 00:00:00 +00:00
#define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH
1998-07-14 00:00:00 +00:00
#define ST_MAXAMMO3X (314)
#define ST_MAXAMMO3Y (17)
1998-04-07 00:00:00 +00:00
// pistol
1998-07-14 00:00:00 +00:00
#define ST_WEAPON0X (110)
#define ST_WEAPON0Y (4)
1998-04-07 00:00:00 +00:00
// shotgun
1998-07-14 00:00:00 +00:00
#define ST_WEAPON1X (122)
#define ST_WEAPON1Y (4)
1998-04-07 00:00:00 +00:00
// chain gun
1998-07-14 00:00:00 +00:00
#define ST_WEAPON2X (134)
#define ST_WEAPON2Y (4)
1998-04-07 00:00:00 +00:00
// missile launcher
1998-07-14 00:00:00 +00:00
#define ST_WEAPON3X (110)
#define ST_WEAPON3Y (13)
1998-04-07 00:00:00 +00:00
// plasma gun
1998-07-14 00:00:00 +00:00
#define ST_WEAPON4X (122)
#define ST_WEAPON4Y (13)
1998-04-07 00:00:00 +00:00
// bfg
1998-07-14 00:00:00 +00:00
#define ST_WEAPON5X (134)
#define ST_WEAPON5Y (13)
1998-04-07 00:00:00 +00:00
// WPNS title
1998-07-14 00:00:00 +00:00
#define ST_WPNSX (109)
#define ST_WPNSY (23)
1998-04-07 00:00:00 +00:00
// DETH title
1998-07-14 00:00:00 +00:00
#define ST_DETHX (109)
#define ST_DETHY (23)
1998-04-07 00:00:00 +00:00
//Incoming messages window location
//UNUSED
// #define ST_MSGTEXTX (viewwindowx)
1998-07-14 00:00:00 +00:00
// #define ST_MSGTEXTY (viewwindowy+realviewheight-18)
1998-04-07 00:00:00 +00:00
#define ST_MSGTEXTX 0
#define ST_MSGTEXTY 0
// Dimensions given in characters.
#define ST_MSGWIDTH 52
// Or shall I say, in lines?
#define ST_MSGHEIGHT 1
#define ST_OUTTEXTX 0
#define ST_OUTTEXTY 6
// Width, in characters again.
1998-07-14 00:00:00 +00:00
#define ST_OUTWIDTH 52
1998-04-07 00:00:00 +00:00
// Height, in lines.
#define ST_OUTHEIGHT 1
1998-07-14 00:00:00 +00:00
// [RH] Turned these into variables
// Size of statusbar.
// Now ([RH] truly) sensitive for scaling.
int ST_HEIGHT;
int ST_WIDTH;
int ST_X;
int ST_Y;
1998-04-07 00:00:00 +00:00
// main player in game
1998-04-07 00:00:00 +00:00
// [RH] not static
player_t* plyr;
1998-04-07 00:00:00 +00:00
// ST_Start() has just been called
1998-07-14 00:00:00 +00:00
BOOL st_firsttime;
1998-04-07 00:00:00 +00:00
// used to execute ST_Init() only once
static int veryfirsttime = 1;
// lump number for PLAYPAL
static int lu_palette;
// used for timing
static unsigned int st_clock;
// used for making messages go away
static int st_msgcounter=0;
// used when in chat
static st_chatstateenum_t st_chatstate;
// whether in automap or first-person
static st_stateenum_t st_gamestate;
// whether left-side main status bar is active
1998-07-14 00:00:00 +00:00
static BOOL st_statusbaron;
1998-04-07 00:00:00 +00:00
// whether status bar chat is active
1998-07-14 00:00:00 +00:00
static BOOL st_chat;
1998-04-07 00:00:00 +00:00
// value of st_chat before message popped up
1998-07-14 00:00:00 +00:00
static BOOL st_oldchat;
1998-04-07 00:00:00 +00:00
// whether chat window has the cursor on
1998-07-14 00:00:00 +00:00
static BOOL st_cursoron;
1998-04-07 00:00:00 +00:00
// !deathmatch
1998-07-14 00:00:00 +00:00
static BOOL st_notdeathmatch;
1998-04-07 00:00:00 +00:00
// !deathmatch && st_statusbaron
1998-07-14 00:00:00 +00:00
static BOOL st_armson;
1998-04-07 00:00:00 +00:00
// !deathmatch
1998-07-14 00:00:00 +00:00
static BOOL st_fragson;
1998-04-07 00:00:00 +00:00
// main bar left
static patch_t* sbar;
// 0-9, tall numbers
1998-04-07 00:00:00 +00:00
// [RH] no longer static
patch_t* tallnum[10];
1998-04-07 00:00:00 +00:00
// tall % sign
1998-04-07 00:00:00 +00:00
// [RH] no longer static
patch_t* tallpercent;
1998-04-07 00:00:00 +00:00
// 0-9, short, yellow (,different!) numbers
static patch_t* shortnum[10];
// 3 key-cards, 3 skulls
static patch_t* keys[NUMCARDS];
// face status patches
1998-04-07 00:00:00 +00:00
// [RH] no longer static
patch_t* faces[ST_NUMFACES];
1998-04-07 00:00:00 +00:00
// face background
static patch_t* faceback;
// main bar right
static patch_t* armsbg;
// weapon ownership patches
static patch_t* arms[6][2];
// ready-weapon widget
static st_number_t w_ready;
// in deathmatch only, summary of frags stats
static st_number_t w_frags;
// health widget
static st_percent_t w_health;
// arms background
static st_binicon_t w_armsbg;
// weapon ownership widgets
static st_multicon_t w_arms[6];
// face status widget
static st_multicon_t w_faces;
// keycard widgets
static st_multicon_t w_keyboxes[3];
// armor widget
static st_percent_t w_armor;
// ammo widgets
static st_number_t w_ammo[4];
// max ammo widgets
static st_number_t w_maxammo[4];
// number of frags so far in deathmatch
static int st_fragscount;
// used to use appopriately pained face
static int st_oldhealth = -1;
// used for evil grin
1998-07-14 00:00:00 +00:00
static BOOL oldweaponsowned[NUMWEAPONS];
1998-04-07 00:00:00 +00:00
// count until face changes
static int st_facecount = 0;
// current face index, used by w_faces
1998-04-07 00:00:00 +00:00
// [RH] not static anymore
int st_faceindex = 0;
1998-04-07 00:00:00 +00:00
// holds key-type for each key box on bar
static int keyboxes[3];
// a random number per tick
static int st_randomnumber;
// Massive bunches of cheat shit
// to keep it from being easy to figure them out.
// Yeah, right...
1998-07-14 00:00:00 +00:00
unsigned char cheat_mus_seq[] =
{
0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff // idmus
};
1998-04-07 00:00:00 +00:00
unsigned char cheat_choppers_seq[] =
{
0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff // id...
};
unsigned char cheat_god_seq[] =
{
0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff // iddqd
};
unsigned char cheat_ammo_seq[] =
{
0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff // idkfa
};
unsigned char cheat_ammonokey_seq[] =
{
0xb2, 0x26, 0x66, 0xa2, 0xff // idfa
};
// Smashing Pumpkins Into Small Piles Of Putrid Debris.
unsigned char cheat_noclip_seq[] =
{
0xb2, 0x26, 0xea, 0x2a, 0xb2, // idspispopd
0xea, 0x2a, 0xf6, 0x2a, 0x26, 0xff
};
//
unsigned char cheat_commercial_noclip_seq[] =
{
0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff // idclip
};
unsigned char cheat_powerup_seq[7][10] =
{
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6e, 0xff }, // beholdv
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xea, 0xff }, // beholds
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xb2, 0xff }, // beholdi
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6a, 0xff }, // beholdr
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xa2, 0xff }, // beholda
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff }, // beholdl
{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xff } // behold
};
unsigned char cheat_clev_seq[] =
{
0xb2, 0x26, 0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff // idclev
};
// my position cheat
unsigned char cheat_mypos_seq[] =
{
0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff // idmypos
};
// Now what?
1998-07-14 00:00:00 +00:00
cheatseq_t cheat_mus = { cheat_mus_seq, 0 };
1998-04-07 00:00:00 +00:00
cheatseq_t cheat_god = { cheat_god_seq, 0 };
cheatseq_t cheat_ammo = { cheat_ammo_seq, 0 };
cheatseq_t cheat_ammonokey = { cheat_ammonokey_seq, 0 };
cheatseq_t cheat_noclip = { cheat_noclip_seq, 0 };
cheatseq_t cheat_commercial_noclip = { cheat_commercial_noclip_seq, 0 };
cheatseq_t cheat_powerup[7] =
{
{ cheat_powerup_seq[0], 0 },
{ cheat_powerup_seq[1], 0 },
{ cheat_powerup_seq[2], 0 },
{ cheat_powerup_seq[3], 0 },
{ cheat_powerup_seq[4], 0 },
{ cheat_powerup_seq[5], 0 },
{ cheat_powerup_seq[6], 0 }
};
cheatseq_t cheat_choppers = { cheat_choppers_seq, 0 };
cheatseq_t cheat_clev = { cheat_clev_seq, 0 };
cheatseq_t cheat_mypos = { cheat_mypos_seq, 0 };
//
// STATUS BAR CODE
//
void ST_Stop(void);
void ST_refreshBackground(void)
{
if (st_statusbaron)
{
1998-07-14 00:00:00 +00:00
// [RH] If screen is wider than the status bar,
// draw stuff around status bar.
if (FG.width > ST_WIDTH) {
R_VideoErase (0, ST_Y, ST_X, FG.height);
R_VideoErase (FG.width - ST_X, ST_Y, FG.width, FG.height);
1998-04-07 00:00:00 +00:00
}
1998-07-14 00:00:00 +00:00
V_DrawPatch(0, 0, &BG, sbar);
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
if (netgame) {
// [RH] Always draw faceback with the player's color
// using a translation rather than a different patch.
// Use displayplayer instead of consoleplayer.
V_ColorMap = translationtables + displayplayer*256;
V_DrawTranslatedPatch (ST_FX, 0, &BG, faceback);
}
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
V_Blit (&BG, 0, 0, 320, 32,
&stnumscreen, 0, 0, 320, 32);
if (!st_scale->value || ST_WIDTH == 320)
V_Blit (&stnumscreen, 0, 0, 320, 32,
&FG, ST_X, ST_Y, ST_WIDTH, ST_HEIGHT);
1998-04-07 00:00:00 +00:00
}
}
1998-07-14 00:00:00 +00:00
BOOL CheckCheatmode (void);
1998-04-07 00:00:00 +00:00
// Respond to keyboard input events,
// intercept cheats.
1998-07-14 00:00:00 +00:00
BOOL ST_Responder (event_t *ev)
1998-04-07 00:00:00 +00:00
{
1998-07-14 00:00:00 +00:00
int i;
1998-04-07 00:00:00 +00:00
// Filter automap on/off.
if (ev->type == ev_keyup
&& ((ev->data1 & 0xffff0000) == AM_MSGHEADER))
{
switch(ev->data1)
{
case AM_MSGENTERED:
st_gamestate = AutomapState;
st_firsttime = true;
break;
case AM_MSGEXITED:
// fprintf(stderr, "AM exited\n");
st_gamestate = FirstPersonState;
break;
}
}
// if a user keypress...
else if (ev->type == ev_keydown)
{
// cheats are now allowed in netgames if
// 'cheats' cvar is set...
// 'dqd' cheat for toggleable god mode
if (cht_CheckCheat(&cheat_god, (char)ev->data2))
{
1998-07-14 00:00:00 +00:00
if (CheckCheatmode ())
return false;
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
Net_WriteByte (DEM_GENERICCHEAT);
Net_WriteByte (CHT_IDDQD);
1998-04-07 00:00:00 +00:00
}
// 'fa' cheat for killer fucking arsenal
else if (cht_CheckCheat(&cheat_ammonokey, (char)ev->data2))
{
1998-07-14 00:00:00 +00:00
if (CheckCheatmode ())
return false;
Net_WriteByte (DEM_GENERICCHEAT);
Net_WriteByte (CHT_IDFA);
1998-04-07 00:00:00 +00:00
}
// 'kfa' cheat for key full ammo
else if (cht_CheckCheat(&cheat_ammo, (char)ev->data2))
{
1998-07-14 00:00:00 +00:00
if (CheckCheatmode ())
return false;
Net_WriteByte (DEM_GENERICCHEAT);
Net_WriteByte (CHT_IDKFA);
1998-04-07 00:00:00 +00:00
}
// Simplified, accepting both "noclip" and "idspispopd".
// no clipping mode cheat
else if ( cht_CheckCheat(&cheat_noclip, (char)ev->data2)
|| cht_CheckCheat(&cheat_commercial_noclip,(char)ev->data2) )
1998-07-14 00:00:00 +00:00
{
if (CheckCheatmode ())
return false;
Net_WriteByte (DEM_GENERICCHEAT);
Net_WriteByte (CHT_NOCLIP);
1998-04-07 00:00:00 +00:00
}
// 'behold?' power-up cheats
for (i=0;i<6;i++)
{
if (cht_CheckCheat(&cheat_powerup[i], (char)ev->data2))
{
1998-07-14 00:00:00 +00:00
if (CheckCheatmode ())
return false;
Net_WriteByte (DEM_GENERICCHEAT);
Net_WriteByte ((byte)(CHT_BEHOLDV + i));
1998-04-07 00:00:00 +00:00
}
}
// 'behold' power-up menu
if (cht_CheckCheat(&cheat_powerup[6], (char)ev->data2))
{
1998-07-14 00:00:00 +00:00
if (CheckCheatmode ())
return false;
plyr->message = STSTR_BEHOLD;
1998-04-07 00:00:00 +00:00
}
// 'choppers' invulnerability & chainsaw
else if (cht_CheckCheat(&cheat_choppers, (char)ev->data2))
{
1998-07-14 00:00:00 +00:00
Net_WriteByte (DEM_GENERICCHEAT);
Net_WriteByte (CHT_CHAINSAW);
1998-04-07 00:00:00 +00:00
}
// 'mypos' for player position
else if (cht_CheckCheat(&cheat_mypos, (char)ev->data2))
{
1998-04-07 00:00:00 +00:00
AddCommandString ("toggle idmypos");
1998-04-07 00:00:00 +00:00
}
// 'clev' change-level cheat
else if (cht_CheckCheat(&cheat_clev, (char)ev->data2))
{
char buf[3];
char *argv[2];
cht_GetParam(&cheat_clev, buf);
buf[2] = 0;
argv[0] = "idclev";
argv[1] = buf;
Cmd_idclev (plyr, 2, argv);
1998-07-14 00:00:00 +00:00
}
// 'idmus' change-music cheat
else if (cht_CheckCheat(&cheat_mus, (char)ev->data2))
{
char buf[16];
cht_GetParam(&cheat_mus, buf);
buf[2] = 0;
sprintf (buf + 3, "idmus %s\n", buf);
AddCommandString (buf + 3);
}
1998-04-07 00:00:00 +00:00
}
return false;
}
int ST_calcPainOffset(void)
{
int health;
static int lastcalc;
static int oldhealth = -1;
health = plyr->health > 100 ? 100 : plyr->health;
if (health != oldhealth)
{
lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101);
oldhealth = health;
}
return lastcalc;
}
//
// This is a not-very-pretty routine which handles
// the face states and their timing.
// the precedence of expressions is:
// dead > evil grin > turned head > straight ahead
//
void ST_updateFaceWidget(void)
{
int i;
angle_t badguyangle;
angle_t diffang;
static int lastattackdown = -1;
static int priority = 0;
1998-07-14 00:00:00 +00:00
BOOL doevilgrin;
1998-04-07 00:00:00 +00:00
if (priority < 10)
{
// dead
if (!plyr->health)
{
priority = 9;
st_faceindex = ST_DEADFACE;
st_facecount = 1;
}
}
if (priority < 9)
{
if (plyr->bonuscount)
{
// picking up bonus
doevilgrin = false;
for (i=0;i<NUMWEAPONS;i++)
{
if (oldweaponsowned[i] != plyr->weaponowned[i])
{
doevilgrin = true;
oldweaponsowned[i] = plyr->weaponowned[i];
}
}
if (doevilgrin)
{
// evil grin if just picked up weapon
priority = 8;
st_facecount = ST_EVILGRINCOUNT;
st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
}
}
}
if (priority < 8)
{
if (plyr->damagecount
&& plyr->attacker
&& plyr->attacker != plyr->mo)
{
// being attacked
priority = 7;
if (plyr->health - st_oldhealth > ST_MUCHPAIN)
{
st_facecount = ST_TURNCOUNT;
st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
}
else
{
badguyangle = R_PointToAngle2(plyr->mo->x,
plyr->mo->y,
plyr->attacker->x,
plyr->attacker->y);
if (badguyangle > plyr->mo->angle)
{
// whether right or left
diffang = badguyangle - plyr->mo->angle;
i = diffang > ANG180;
}
else
{
// whether left or right
diffang = plyr->mo->angle - badguyangle;
i = diffang <= ANG180;
} // confusing, aint it?
st_facecount = ST_TURNCOUNT;
st_faceindex = ST_calcPainOffset();
if (diffang < ANG45)
{
// head-on
st_faceindex += ST_RAMPAGEOFFSET;
}
else if (i)
{
// turn face right
st_faceindex += ST_TURNOFFSET;
}
else
{
// turn face left
st_faceindex += ST_TURNOFFSET+1;
}
}
}
}
if (priority < 7)
{
// getting hurt because of your own damn stupidity
if (plyr->damagecount)
{
if (plyr->health - st_oldhealth > ST_MUCHPAIN)
{
priority = 7;
st_facecount = ST_TURNCOUNT;
st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
}
else
{
priority = 6;
st_facecount = ST_TURNCOUNT;
st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
}
}
}
if (priority < 6)
{
// rapid firing
if (plyr->attackdown)
{
if (lastattackdown==-1)
lastattackdown = ST_RAMPAGEDELAY;
else if (!--lastattackdown)
{
priority = 5;
st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
st_facecount = 1;
lastattackdown = 1;
}
}
else
lastattackdown = -1;
}
if (priority < 5)
{
// invulnerability
if ((plyr->cheats & CF_GODMODE)
|| plyr->powers[pw_invulnerability])
{
priority = 4;
st_faceindex = ST_GODFACE;
st_facecount = 1;
}
}
// look left or look right if the facecount has timed out
if (!st_facecount)
{
st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
st_facecount = ST_STRAIGHTFACECOUNT;
priority = 0;
}
st_facecount--;
}
void ST_updateWidgets(void)
{
static int largeammo = 1994; // means "n/a"
int i;
// must redirect the pointer if the ready weapon has changed.
// if (w_ready.data != plyr->readyweapon)
// {
if (weaponinfo[plyr->readyweapon].ammo == am_noammo)
w_ready.num = &largeammo;
else
w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo];
//{
// static int tic=0;
// static int dir=-1;
// if (!(tic&15))
// plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir;
// if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100)
// dir = 1;
// tic++;
// }
w_ready.data = plyr->readyweapon;
// if (*w_ready.on)
// STlib_updateNum(&w_ready, true);
// refresh weapon change
// }
// update keycard multiple widgets
for (i=0;i<3;i++)
{
keyboxes[i] = plyr->cards[i] ? i : -1;
if (plyr->cards[i+3])
keyboxes[i] = i+3;
}
// refresh everything if this is him coming back to life
ST_updateFaceWidget();
// used by the w_armsbg widget
1998-07-14 00:00:00 +00:00
st_notdeathmatch = !((int)deathmatch->value);
1998-04-07 00:00:00 +00:00
// used by w_arms[] widgets
1998-07-14 00:00:00 +00:00
st_armson = st_statusbaron && !((int)deathmatch->value);
1998-04-07 00:00:00 +00:00
// used by w_frags widget
1998-07-14 00:00:00 +00:00
st_fragson = (int)deathmatch->value && st_statusbaron;
st_fragscount = plyr->fragcount; // [RH] Just use cumulative total
1998-04-07 00:00:00 +00:00
// get rid of chat window if up because of message
if (!--st_msgcounter)
st_chat = st_oldchat;
}
void ST_Ticker (void)
{
st_clock++;
st_randomnumber = M_Random();
ST_updateWidgets();
st_oldhealth = plyr->health;
}
static int st_palette = 0;
void ST_doPaletteStuff (void)
{
int palette;
int cnt;
int bzc;
1998-07-14 00:00:00 +00:00
cnt = plyr->damagecount << 1;
1998-04-07 00:00:00 +00:00
if (plyr->powers[pw_strength])
{
// slowly fade the berzerk out
1998-07-14 00:00:00 +00:00
bzc = 128 - ((plyr->powers[pw_strength]>>3) & (~0x1f));
1998-04-07 00:00:00 +00:00
if (bzc > cnt)
cnt = bzc;
}
if (cnt)
{
1998-07-14 00:00:00 +00:00
if (cnt > 228)
cnt = 228;
else if (cnt < 28)
cnt = 28;
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
palette = MAKEARGB(cnt,255,0,0);
1998-04-07 00:00:00 +00:00
}
else if (plyr->bonuscount)
{
1998-07-14 00:00:00 +00:00
cnt = plyr->bonuscount << 3;
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
palette = MAKEARGB((cnt > 128) ? 128 : cnt,215,186,69);
1998-04-07 00:00:00 +00:00
}
else if ( plyr->powers[pw_ironfeet] > 4*32
|| plyr->powers[pw_ironfeet]&8)
{
1998-07-14 00:00:00 +00:00
palette = MAKEARGB(32,0,255,0);
1998-04-07 00:00:00 +00:00
}
1998-07-14 00:00:00 +00:00
else
palette = MAKEARGB(0,0,0,0);
1998-04-07 00:00:00 +00:00
1998-07-14 00:00:00 +00:00
if (palette != st_palette) {
st_palette = palette;
V_SetBlend (RPART(palette), GPART(palette), BPART(palette), APART(palette));
}
1998-04-07 00:00:00 +00:00
}
1998-07-14 00:00:00 +00:00
void ST_drawWidgets(BOOL refresh)
1998-04-07 00:00:00 +00:00
{
1998-07-14 00:00:00 +00:00
int i;
1998-04-07 00:00:00 +00:00
// used by w_arms[] widgets
1998-07-14 00:00:00 +00:00
st_armson = st_statusbaron && !((int)deathmatch->value);
1998-04-07 00:00:00 +00:00
// used by w_frags widget
1998-07-14 00:00:00 +00:00
st_fragson = (int)deathmatch->value && st_statusbaron;
1998-04-07 00:00:00 +00:00
STlib_updateNum(&w_ready, refresh);
for (i=0;i<4;i++)
{
STlib_updateNum(&w_ammo[i], refresh);
STlib_updateNum(&w_maxammo[i], refresh);
}
STlib_updatePercent(&w_health, refresh);
STlib_updatePercent(&w_armor, refresh);
STlib_updateBinIcon(&w_armsbg, refresh);
for (i=0;i<6;i++)
STlib_updateMultIcon(&w_arms[i], refresh);
STlib_updateMultIcon(&w_faces, refresh);
for (i=0;i<3;i++)
STlib_updateMultIcon(&w_keyboxes[i], refresh);
STlib_updateNum(&w_frags, refresh);
1998-07-14 00:00:00 +00:00
if (st_scale->value && ST_WIDTH != 320 && st_statusbaron)
V_Blit (&stnumscreen, 0, 0, 320, 32,
&FG, ST_X, ST_Y, ST_WIDTH, ST_HEIGHT);
1998-04-07 00:00:00 +00:00
}
void ST_doRefresh(void)
{
st_firsttime = false;
// draw status bar background to off-screen buff
ST_refreshBackground();
// and refresh all widgets
ST_drawWidgets(true);
}
void ST_diffDraw(void)
{
// update all widgets
ST_drawWidgets(false);
}
1998-07-14 00:00:00 +00:00
void ST_Drawer (BOOL fullscreen, BOOL refresh)
1998-04-07 00:00:00 +00:00
{
st_statusbaron = (!fullscreen) || automapactive;
st_firsttime = st_firsttime || refresh;
// Do red-/gold-shifts from damage/items
ST_doPaletteStuff();
1998-07-14 00:00:00 +00:00
V_LockScreen (&stbarscreen);
V_LockScreen (&stnumscreen);
1998-04-07 00:00:00 +00:00
// If just after ST_Start(), refresh all
if (st_firsttime) ST_doRefresh();
// Otherwise, update as little as possible
else ST_diffDraw();
1998-07-14 00:00:00 +00:00
V_UnlockScreen (&stnumscreen);
V_UnlockScreen (&stbarscreen);
// [RH] Hey, it's somewhere to put the idmypos stuff!
// Use displayplayer instead of consoleplayer
1998-04-07 00:00:00 +00:00
if (idmypos->value)
1998-07-14 00:00:00 +00:00
Printf ("ang=%d;x,y=(%d,%d)\n",
players[displayplayer].mo->angle/FRACUNIT,
players[displayplayer].mo->x/FRACUNIT,
players[displayplayer].mo->y/FRACUNIT);
1998-04-07 00:00:00 +00:00
}
void ST_loadGraphics(void)
{
int i;
int j;
int facenum;
char namebuf[9];
// Load the numbers, tall and short
for (i=0;i<10;i++)
{
sprintf(namebuf, "STTNUM%d", i);
tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STYSNUM%d", i);
shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
}
// Load percent key.
//Note: why not load STMINUS here, too?
tallpercent = (patch_t *) W_CacheLumpName("STTPRCNT", PU_STATIC);
// key cards
for (i=0;i<NUMCARDS;i++)
{
sprintf(namebuf, "STKEYS%d", i);
keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
}
// arms background
armsbg = (patch_t *) W_CacheLumpName("STARMS", PU_STATIC);
// arms ownership widgets
for (i=0;i<6;i++)
{
sprintf(namebuf, "STGNUM%d", i+2);
// gray #
arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
// yellow #
arms[i][1] = shortnum[i+2];
}
// face backgrounds for different color players
1998-07-14 00:00:00 +00:00
// [RH] only one face background used for all players
// different colors are accomplished with translations
faceback = (patch_t *) W_CacheLumpName("STFBANY", PU_STATIC);
1998-04-07 00:00:00 +00:00
// status bar background bits
sbar = (patch_t *) W_CacheLumpName("STBAR", PU_STATIC);
// face states
facenum = 0;
for (i=0;i<ST_NUMPAINFACES;i++)
{
for (j=0;j<ST_NUMSTRAIGHTFACES;j++)
{
sprintf(namebuf, "STFST%d%d", i, j);
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
}
sprintf(namebuf, "STFTR%d0", i); // turn right
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STFTL%d0", i); // turn left
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STFOUCH%d", i); // ouch!
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STFEVL%d", i); // evil grin ;)
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
sprintf(namebuf, "STFKILL%d", i); // pissed off
faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);
}
faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC);
faces[facenum++] = W_CacheLumpName("STFDEAD0", PU_STATIC);
}
void ST_loadData(void)
{
lu_palette = W_GetNumForName ("PLAYPAL");
ST_loadGraphics();
}
void ST_unloadGraphics(void)
{
int i;
// unload the numbers, tall and short
for (i=0;i<10;i++)
{
Z_ChangeTag(tallnum[i], PU_CACHE);
Z_ChangeTag(shortnum[i], PU_CACHE);
}
// unload tall percent
Z_ChangeTag(tallpercent, PU_CACHE);
// unload arms background
Z_ChangeTag(armsbg, PU_CACHE);
// unload gray #'s
for (i=0;i<6;i++)
Z_ChangeTag(arms[i][0], PU_CACHE);
// unload the key cards
for (i=0;i<NUMCARDS;i++)
Z_ChangeTag(keys[i], PU_CACHE);
Z_ChangeTag(sbar, PU_CACHE);
Z_ChangeTag(faceback, PU_CACHE);
for (i=0;i<ST_NUMFACES;i++)
Z_ChangeTag(faces[i], PU_CACHE);
// Note: nobody ain't seen no unloading
// of stminus yet. Dude.
}
void ST_unloadData(void)
{
ST_unloadGraphics();
1998-04-07 00:00:00 +00:00
ST_unloadNew();
1998-04-07 00:00:00 +00:00
}
void ST_initData(void)
{
1998-07-14 00:00:00 +00:00
int i;
1998-04-07 00:00:00 +00:00
st_firsttime = true;
1998-07-14 00:00:00 +00:00
plyr = &players[displayplayer]; // [RH] Not consoleplayer
1998-04-07 00:00:00 +00:00
st_clock = 0;
st_chatstate = StartChatState;
st_gamestate = FirstPersonState;
st_statusbaron = true;
st_oldchat = st_chat = false;
st_cursoron = false;
st_faceindex = 0;
st_palette = -1;
st_oldhealth = -1;
for (i=0;i<NUMWEAPONS;i++)
oldweaponsowned[i] = plyr->weaponowned[i];
for (i=0;i<3;i++)
keyboxes[i] = -1;
STlib_init();
1998-04-07 00:00:00 +00:00
ST_initNew();
1998-04-07 00:00:00 +00:00
}
void ST_createWidgets(void)
{
int i;
// ready weapon ammo
STlib_initNum(&w_ready,
ST_AMMOX,
ST_AMMOY,
tallnum,
&plyr->ammo[weaponinfo[plyr->readyweapon].ammo],
&st_statusbaron,
ST_AMMOWIDTH );
// the last weapon type
w_ready.data = plyr->readyweapon;
// health percentage
STlib_initPercent(&w_health,
ST_HEALTHX,
ST_HEALTHY,
tallnum,
&plyr->health,
&st_statusbaron,
tallpercent);
// arms background
STlib_initBinIcon(&w_armsbg,
ST_ARMSBGX,
ST_ARMSBGY,
armsbg,
&st_notdeathmatch,
&st_statusbaron);
// weapons owned
for(i=0;i<6;i++)
{
STlib_initMultIcon(&w_arms[i],
ST_ARMSX+(i%3)*ST_ARMSXSPACE,
ST_ARMSY+(i/3)*ST_ARMSYSPACE,
arms[i], (int *) &plyr->weaponowned[i+1],
&st_armson);
}
// frags sum
STlib_initNum(&w_frags,
ST_FRAGSX,
ST_FRAGSY,
tallnum,
&st_fragscount,
&st_fragson,
ST_FRAGSWIDTH);
// faces
STlib_initMultIcon(&w_faces,
ST_FACESX,
ST_FACESY,
faces,
&st_faceindex,
&st_statusbaron);
// armor percentage - should be colored later
STlib_initPercent(&w_armor,
ST_ARMORX,
ST_ARMORY,
tallnum,
&plyr->armorpoints,
&st_statusbaron, tallpercent);
// keyboxes 0-2
STlib_initMultIcon(&w_keyboxes[0],
ST_KEY0X,
ST_KEY0Y,
keys,
&keyboxes[0],
&st_statusbaron);
STlib_initMultIcon(&w_keyboxes[1],
ST_KEY1X,
ST_KEY1Y,
keys,
&keyboxes[1],
&st_statusbaron);
STlib_initMultIcon(&w_keyboxes[2],
ST_KEY2X,
ST_KEY2Y,
keys,
&keyboxes[2],
&st_statusbaron);
// ammo count (all four kinds)
STlib_initNum(&w_ammo[0],
ST_AMMO0X,
ST_AMMO0Y,
shortnum,
&plyr->ammo[0],
&st_statusbaron,
ST_AMMO0WIDTH);
STlib_initNum(&w_ammo[1],
ST_AMMO1X,
ST_AMMO1Y,
shortnum,
&plyr->ammo[1],
&st_statusbaron,
ST_AMMO1WIDTH);
STlib_initNum(&w_ammo[2],
ST_AMMO2X,
ST_AMMO2Y,
shortnum,
&plyr->ammo[2],
&st_statusbaron,
ST_AMMO2WIDTH);
STlib_initNum(&w_ammo[3],
ST_AMMO3X,
ST_AMMO3Y,
shortnum,
&plyr->ammo[3],
&st_statusbaron,
ST_AMMO3WIDTH);
// max ammo count (all four kinds)
STlib_initNum(&w_maxammo[0],
ST_MAXAMMO0X,
ST_MAXAMMO0Y,
shortnum,
&plyr->maxammo[0],
&st_statusbaron,
ST_MAXAMMO0WIDTH);
STlib_initNum(&w_maxammo[1],
ST_MAXAMMO1X,
ST_MAXAMMO1Y,
shortnum,
&plyr->maxammo[1],
&st_statusbaron,
ST_MAXAMMO1WIDTH);
STlib_initNum(&w_maxammo[2],
ST_MAXAMMO2X,
ST_MAXAMMO2Y,
shortnum,
&plyr->maxammo[2],
&st_statusbaron,
ST_MAXAMMO2WIDTH);
STlib_initNum(&w_maxammo[3],
ST_MAXAMMO3X,
ST_MAXAMMO3Y,
shortnum,
&plyr->maxammo[3],
&st_statusbaron,
ST_MAXAMMO3WIDTH);
}
1998-07-14 00:00:00 +00:00
static BOOL st_stopped = true;
1998-04-07 00:00:00 +00:00
void ST_Start (void)
{
if (!st_stopped)
ST_Stop();
ST_initData();
ST_createWidgets();
st_stopped = false;
}
void ST_Stop (void)
{
if (st_stopped)
return;
1998-07-14 00:00:00 +00:00
V_SetBlend (0,0,0,0);
1998-04-07 00:00:00 +00:00
st_stopped = true;
}
1998-07-14 00:00:00 +00:00
// [RH] Enable/disable scaling of status bar
void ST_ChangeScale (cvar_t *var)
{
if (var->value) {
// Stretch status bar to fill fill width of screen
ST_WIDTH = screens[0].width;
if (ST_WIDTH == 320) {
// Do not scale height for 320 x 2X0 screens
ST_HEIGHT = 32;
} else {
ST_HEIGHT = (32 * screens[0].height) / 200;
}
} else {
// Do not stretch status bar
ST_WIDTH = 320;
ST_HEIGHT = 32;
}
ST_X = (screens[0].width-ST_WIDTH)/2;
ST_Y = screens[0].height - ST_HEIGHT;
setsizeneeded = true;
if (automapactive)
am_needtodrawstatusbar = true;
}
1998-04-07 00:00:00 +00:00
void ST_Init (void)
{
veryfirsttime = 0;
1998-07-14 00:00:00 +00:00
if (!V_AllocScreen (&stbarscreen, 320, 32, 8) ||
!V_AllocScreen (&stnumscreen, 320, 32, 8))
I_FatalError ("Could not create status bar surface\n");
// [RH] Catch any changes to st_scale cvar...
st_scale->u.callback = ST_ChangeScale;
// [RH] ...and make sure the routine gets called at least once.
ST_ChangeScale (st_scale);
1998-04-07 00:00:00 +00:00
ST_loadData();
}