⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 st_stuff.c

📁 游戏类程序源代码---WinDoom 3D源程序.zip
💻 C
📖 第 1 页 / 共 3 页
字号:
// 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)
//
//-----------------------------------------------------------------------------

static const char
rcsid[] = "$Id: st_stuff.c,v 1.6 1997/02/03 22:45:13 b1 Exp $";


#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"

//
// STATUS BAR DATA
//

char MsgText[256];
void WriteDebug(char *);

// 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
//#define ST_X				0
#define ST_X				((SCREENWIDTH-ST_WIDTH)/2)
//#define ST_X2				104
#define ST_X2				((SCREENWIDTH/2)-56)

//#define ST_FX  			143
#define ST_FX  			((SCREENWIDTH/2)-17)
//#define ST_FY  			169
#define ST_FY  			(SCREENHEIGHT-31)

// 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)

//#define ST_FACESX			143
#define ST_FACESX			((SCREENWIDTH/2)-17)
//#define ST_FACESY			168
#define ST_FACESY			(SCREENHEIGHT-32)

#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.
#define ST_AMMOWIDTH		3	
//#define ST_AMMOX			44
#define ST_AMMOX			((SCREENWIDTH/2)-116)
//#define ST_AMMOY			171
#define ST_AMMOY			(SCREENHEIGHT-29)

// HEALTH number pos.
#define ST_HEALTHWIDTH		3	
//#define ST_HEALTHX			90
#define ST_HEALTHX			((SCREENWIDTH/2)-70)
//#define ST_HEALTHY			171
#define ST_HEALTHY			(SCREENHEIGHT-29)

// Weapon pos.
//#define ST_ARMSX			111
#define ST_ARMSX			((SCREENWIDTH/2)-49)
//#define ST_ARMSY			172
#define ST_ARMSY			(SCREENHEIGHT-28)
//#define ST_ARMSBGX			104
#define ST_ARMSBGX			((SCREENWIDTH/2)-56)
//#define ST_ARMSBGY			168
#define ST_ARMSBGY			(SCREENHEIGHT-32)
#define ST_ARMSXSPACE		12
#define ST_ARMSYSPACE		10

// Frags pos.
//#define ST_FRAGSX			138
#define ST_FRAGSX			((SCREENWIDTH/2)-22)
//#define ST_FRAGSY			171	
#define ST_FRAGSY			(SCREENHEIGHT-29)	
#define ST_FRAGSWIDTH		2

// ARMOR number pos.
#define ST_ARMORWIDTH		3
//#define ST_ARMORX			221
#define ST_ARMORX			((SCREENWIDTH/2)+61)
//#define ST_ARMORY			171
#define ST_ARMORY			(SCREENHEIGHT-29)

// Key icon positions.
#define ST_KEY0WIDTH		8
#define ST_KEY0HEIGHT		5
//#define ST_KEY0X			239
#define ST_KEY0X			((SCREENWIDTH/2)+79)
//#define ST_KEY0Y			171
#define ST_KEY0Y			(SCREENHEIGHT-29)
#define ST_KEY1WIDTH		ST_KEY0WIDTH
//#define ST_KEY1X			239
#define ST_KEY1X			((SCREENWIDTH/2)+79)
//#define ST_KEY1Y			181
#define ST_KEY1Y			(SCREENHEIGHT-19)
#define ST_KEY2WIDTH		ST_KEY0WIDTH
//#define ST_KEY2X			239
#define ST_KEY2X			((SCREENWIDTH/2)+79)
//#define ST_KEY2Y			191
#define ST_KEY2Y			(SCREENHEIGHT-9)

// Ammunition counter.
#define ST_AMMO0WIDTH		3
#define ST_AMMO0HEIGHT		6
//#define ST_AMMO0X			288
#define ST_AMMO0X			((SCREENWIDTH/2)+128)
//#define ST_AMMO0Y			173
#define ST_AMMO0Y			(SCREENHEIGHT-27)
#define ST_AMMO1WIDTH		ST_AMMO0WIDTH
//#define ST_AMMO1X			288
#define ST_AMMO1X			((SCREENWIDTH/2)+128)
//#define ST_AMMO1Y			179
#define ST_AMMO1Y			(SCREENHEIGHT-21)
#define ST_AMMO2WIDTH		ST_AMMO0WIDTH
//#define ST_AMMO2X			288
#define ST_AMMO2X			((SCREENWIDTH/2)+128)
//#define ST_AMMO2Y			191
#define ST_AMMO2Y			(SCREENHEIGHT-9)
#define ST_AMMO3WIDTH		ST_AMMO0WIDTH
//#define ST_AMMO3X			288
#define ST_AMMO3X			((SCREENWIDTH/2)+128)
//#define ST_AMMO3Y			185
#define ST_AMMO3Y			(SCREENHEIGHT-15)

// Indicate maximum ammunition.
// Only needed because backpack exists.
#define ST_MAXAMMO0WIDTH		3
#define ST_MAXAMMO0HEIGHT		5
//#define ST_MAXAMMO0X		314
#define ST_MAXAMMO0X		((SCREENWIDTH/2)+154)
//#define ST_MAXAMMO0Y		173
#define ST_MAXAMMO0Y		(SCREENHEIGHT-27)
#define ST_MAXAMMO1WIDTH		ST_MAXAMMO0WIDTH
//#define ST_MAXAMMO1X		314
#define ST_MAXAMMO1X		((SCREENWIDTH/2)+154)
//#define ST_MAXAMMO1Y		179
#define ST_MAXAMMO1Y		(SCREENHEIGHT-21)
#define ST_MAXAMMO2WIDTH		ST_MAXAMMO0WIDTH
//#define ST_MAXAMMO2X		314
#define ST_MAXAMMO2X		((SCREENWIDTH/2)+154)
//#define ST_MAXAMMO2Y		191
#define ST_MAXAMMO2Y		(SCREENHEIGHT-9)
#define ST_MAXAMMO3WIDTH		ST_MAXAMMO0WIDTH
//#define ST_MAXAMMO3X		314
#define ST_MAXAMMO3X		((SCREENWIDTH/2)+154)
//#define ST_MAXAMMO3Y		185
#define ST_MAXAMMO3Y		(SCREENHEIGHT-15)

// pistol
//#define ST_WEAPON0X			110 
#define ST_WEAPON0X			((SCREENWIDTH/2)-50)
//#define ST_WEAPON0Y			172
#define ST_WEAPON0Y			(SCREENHEIGHT-28)

// shotgun
//#define ST_WEAPON1X			122 
#define ST_WEAPON1X			((SCREENWIDTH/2)-38)
//#define ST_WEAPON1Y			172
#define ST_WEAPON1Y			(SCREENHEIGHT-28)

// chain gun
//#define ST_WEAPON2X			134 
#define ST_WEAPON2X			((SCREENWIDTH/2)-26)
//#define ST_WEAPON2Y			172
#define ST_WEAPON2Y			(SCREENHEIGHT-28)

// missile launcher
//#define ST_WEAPON3X			110 
#define ST_WEAPON3X			((SCREENWIDTH/2)-50) 
//#define ST_WEAPON3Y			181
#define ST_WEAPON3Y			(SCREENHEIGHT-19)

// plasma gun
//#define ST_WEAPON4X			122 
#define ST_WEAPON4X			((SCREENWIDTH/2)-38) 
//#define ST_WEAPON4Y			181
#define ST_WEAPON4Y			(SCREENHEIGHT-19)

 // bfg
//#define ST_WEAPON5X			134
#define ST_WEAPON5X			((SCREENWIDTH/2)-26)
//#define ST_WEAPON5Y			181
#define ST_WEAPON5Y			(SCREENHEIGHT-19)

// WPNS title
//#define ST_WPNSX			109 
#define ST_WPNSX			((SCREENWIDTH/2)-51)
//#define ST_WPNSY			191
#define ST_WPNSY			(SCREENHEIGHT-9)

 // DETH title
//#define ST_DETHX			109
#define ST_DETHX			((SCREENWIDTH/2)-51)
//#define ST_DETHY			191
#define ST_DETHY			(SCREENHEIGHT-9)

//Incoming messages window location
//UNUSED
// #define ST_MSGTEXTX	   (viewwindowx)
// #define ST_MSGTEXTY	   (viewwindowy+viewheight-18)
#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.
#define ST_OUTWIDTH			52 
 // Height, in lines. 
#define ST_OUTHEIGHT		1

#define ST_MAPWIDTH	\
    (strlen(mapnames[(gameepisode-1)*9+(gamemap-1)]))

#define ST_MAPTITLEX \
    (SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH)

#define ST_MAPTITLEY		0
#define ST_MAPHEIGHT		1

	    
// main player in game
static player_t*	plyr; 

// ST_Start() has just been called
static boolean		st_firsttime;

// 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
static boolean		st_statusbaron;

// whether status bar chat is active
static boolean		st_chat;

// value of st_chat before message popped up
static boolean		st_oldchat;

// whether chat window has the cursor on
static boolean		st_cursoron;

// !deathmatch
static boolean		st_notdeathmatch; 

// !deathmatch && st_statusbaron
static boolean		st_armson;

// !deathmatch
static boolean		st_fragson; 

// main bar left
static patch_t*		sbar;

// 0-9, tall numbers
static patch_t*		tallnum[10];

// tall % sign
static patch_t*		tallpercent;

// 0-9, short, yellow (,different!) numbers
static patch_t*		shortnum[10];

// 3 key-cards, 3 skulls
static patch_t*		keys[NUMCARDS]; 

// face status patches
static patch_t*		faces[ST_NUMFACES];

// 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
static boolean	oldweaponsowned[NUMWEAPONS]; 

 // count until face changes
static int	st_facecount = 0;

// current face index, used by w_faces
static int	st_faceindex = 0;

// 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...
unsigned char	cheat_mus_seq[] =
{
    0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff
};

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 Samml Piles Of Putried 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -