doom3-bfg/doomclassic/doom/st_stuff.cpp

1620 lines
32 KiB
C++
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
2022-09-05 20:25:33 +00:00
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#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
//
// Palette indices.
// For damage/bonus red-/gold-shifts
// Radiation suit, green shift.
// N/256*100% probability
// that the normal face state will change
// For Responder
// Location of status bar
// Should be set to patch width
// for tall numbers later on
// Number of status ::g->faces.
// 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.
// HEALTH number pos.
// Weapon pos.
// Frags pos.
// ARMOR number pos.
// Key icon positions.
// Ammunition counter.
// Indicate maximum ammunition.
// Only needed because backpack exists.
// pistol
// shotgun
// chain gun
// missile launcher
// plasma gun
// bfg
// WPNS title
// DETH title
//Incoming messages window location
//UNUSED
// #define ST_MSGTEXTX (::g->viewwindowx)
// #define ST_MSGTEXTY (::g->viewwindowy+::g->viewheight-18)
// Dimensions given in characters.
// Or shall I say, in lines?
// Width, in characters again.
2022-09-05 20:25:33 +00:00
// Height, in ::g->lines.
2012-11-26 18:58:24 +00:00
// main player in game
// ST_Start() has just been called
// used to execute ST_Init() only once
// lump number for PLAYPAL
// used for timing
// used for making messages go away
2022-09-05 20:25:33 +00:00
// used when in chat
2012-11-26 18:58:24 +00:00
// States for the intermission
// whether in automap or first-person
// whether left-side main status bar is active
// whether status bar chat is active
// value of ::g->st_chat before message popped up
// whether chat window has the cursor on
// !::g->deathmatch
// !::g->deathmatch && ::g->st_statusbaron
// !::g->deathmatch
// main bar left
// 0-9, tall numbers
// tall % sign
// 0-9, short, yellow (,different!) numbers
// 3 key-cards, 3 skulls
// face status patches
// face background
// main bar right
// weapon ownership patches
// ready-weapon widget
// in ::g->deathmatch only, summary of frags stats
// health widget
// ::g->arms background
// weapon ownership widgets
// face status widget
// keycard widgets
// armor widget
// ammo widgets
// max ammo widgets
// number of frags so far in ::g->deathmatch
// used to use appopriately pained face
// used for evil grin
// count until face changes
// current face index, used by ::g->w_faces
// holds key-type for each key box on bar
// a random number per tick
// Massive bunches of cheat shit
// to keep it from being easy to figure them out.
// Yeah, right...
const unsigned char cheat_mus_seq[] =
{
0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff
};
const unsigned char cheat_choppers_seq[] =
{
0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff // id...
};
const unsigned char cheat_god_seq[] =
{
0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff // iddqd
};
const unsigned char cheat_ammo_seq[] =
{
0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff // idkfa
};
const unsigned char cheat_ammonokey_seq[] =
{
0xb2, 0x26, 0x66, 0xa2, 0xff // idfa
};
2022-09-05 20:25:33 +00:00
// Smashing Pumpkins Into Samml Piles Of Putried Debris.
2012-11-26 18:58:24 +00:00
const unsigned char cheat_noclip_seq[] =
{
0xb2, 0x26, 0xea, 0x2a, 0xb2, // idspispopd
2022-09-05 20:25:33 +00:00
0xea, 0x2a, 0xf6, 0x2a, 0x26, 0xff
2012-11-26 18:58:24 +00:00
};
//
const unsigned char cheat_commercial_noclip_seq[] =
{
0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff // idclip
2022-09-05 20:25:33 +00:00
};
2012-11-26 18:58:24 +00:00
const 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
};
const unsigned char cheat_clev_seq[] =
{
0xb2, 0x26, 0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff // idclev
};
// my position cheat
const unsigned char cheat_mypos_seq[] =
{
0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff // idmypos
2022-09-05 20:25:33 +00:00
};
2012-11-26 18:58:24 +00:00
// Now what?
cheatseq_t cheat_mus = cheatseq_t( cheat_mus_seq, 0 );
cheatseq_t cheat_god = cheatseq_t( cheat_god_seq, 0 );
cheatseq_t cheat_ammo = cheatseq_t( cheat_ammo_seq, 0 );
cheatseq_t cheat_ammonokey = cheatseq_t( cheat_ammonokey_seq, 0 );
cheatseq_t cheat_noclip = cheatseq_t( cheat_noclip_seq, 0 );
cheatseq_t cheat_commercial_noclip = cheatseq_t( cheat_commercial_noclip_seq, 0 );
// ALAN
// DISABLED cheatseq_t( cheat_powerup_seq[0], 0 ), cheatseq_t( cheat_powerup_seq[1], 0 ),
// cheatseq_t( cheat_powerup_seq[2], 0 ),
2022-09-05 20:25:33 +00:00
// DISABLED cheatseq_t( cheat_powerup_seq[3], 0 ),
2012-11-26 18:58:24 +00:00
// cheatseq_t( cheat_powerup_seq[4], 0 ),cheatseq_t( cheat_powerup_seq[5], 0 ),cheatseq_t( cheat_powerup_seq[6], 0 ) };
cheatseq_t cheat_choppers = cheatseq_t( cheat_choppers_seq, 0 );
cheatseq_t cheat_clev = cheatseq_t( cheat_clev_seq, 0 );
cheatseq_t cheat_mypos = cheatseq_t( cheat_mypos_seq, 0 );
2022-09-05 20:25:33 +00:00
//
2012-11-26 18:58:24 +00:00
const extern char* mapnames[];
//
// STATUS BAR CODE
//
2022-09-05 20:25:33 +00:00
void ST_Stop( void );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
void ST_refreshBackground( void )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->st_statusbaron )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
V_DrawPatch( ST_X, 0, BG, ::g->sbar );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ::g->netgame )
{
V_DrawPatch( ST_FX, 0, BG, ::g->faceback );
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
V_CopyRect( ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG );
2012-11-26 18:58:24 +00:00
}
}
// Respond to keyboard input ::g->events,
// intercept cheats.
qboolean
2022-09-05 20:25:33 +00:00
ST_Responder( event_t* ev )
2012-11-26 18:58:24 +00:00
{
int i;
// Filter automap on/off.
2022-09-05 20:25:33 +00:00
if( ev->type == ev_keyup
&& ( ( ev->data1 & 0xffff0000 ) == AM_MSGHEADER ) )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
switch( ev->data1 )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
case AM_MSGENTERED:
::g->st_gamestate = AutomapState;
::g->st_firsttime = true;
break;
case AM_MSGEXITED:
// I_PrintfE( "AM exited\n");
::g->st_gamestate = FirstPersonState;
break;
2012-11-26 18:58:24 +00:00
}
}
// if a user keypress...
2022-09-05 20:25:33 +00:00
else if( ev->type == ev_keydown )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( !::g->netgame )
2012-11-26 18:58:24 +00:00
{
// b. - enabled for more debug fun.
// if (::g->gameskill != sk_nightmare) {
// 'dqd' cheat for toggleable god mode
2022-09-05 20:25:33 +00:00
if( cht_CheckCheat( &cheat_god, ev->data1 ) )
2012-11-26 18:58:24 +00:00
{
::g->plyr->cheats ^= CF_GODMODE;
2022-09-05 20:25:33 +00:00
if( ::g->plyr->cheats & CF_GODMODE )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->plyr->mo )
{
2012-11-26 18:58:24 +00:00
::g->plyr->mo->health = 100;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
::g->plyr->health = 100;
::g->plyr->message = STSTR_DQDON;
}
2022-09-05 20:25:33 +00:00
else
{
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_DQDOFF;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
}
// 'fa' cheat for killer fucking arsenal
2022-09-05 20:25:33 +00:00
else if( cht_CheckCheat( &cheat_ammonokey, ev->data1 ) )
2012-11-26 18:58:24 +00:00
{
::g->plyr->armorpoints = 200;
::g->plyr->armortype = 2;
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMWEAPONS; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->weaponowned[i] = true;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMAMMO; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_FAADDED;
}
// 'kfa' cheat for key full ammo
2022-09-05 20:25:33 +00:00
else if( cht_CheckCheat( &cheat_ammo, ev->data1 ) )
2012-11-26 18:58:24 +00:00
{
::g->plyr->armorpoints = 200;
::g->plyr->armortype = 2;
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMWEAPONS; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->weaponowned[i] = true;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMAMMO; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMCARDS; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->cards[i] = true;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_KFAADDED;
}
// 'mus' cheat for changing music
2022-09-05 20:25:33 +00:00
else if( cht_CheckCheat( &cheat_mus, ev->data1 ) )
2012-11-26 18:58:24 +00:00
{
char buf[3];
int musnum;
::g->plyr->message = STSTR_MUS;
2022-09-05 20:25:33 +00:00
cht_GetParam( &cheat_mus, buf );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ::g->gamemode == commercial )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
musnum = mus_runnin + ( buf[0] - '0' ) * 10 + buf[1] - '0' - 1;
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ( ( buf[0] - '0' ) * 10 + buf[1] - '0' ) > 35 )
{
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_NOMUS;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
else
2022-09-05 20:25:33 +00:00
{
S_ChangeMusic( musnum, 1 );
}
2012-11-26 18:58:24 +00:00
}
else
{
2022-09-05 20:25:33 +00:00
musnum = mus_e1m1 + ( buf[0] - '1' ) * 9 + ( buf[1] - '1' );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ( ( buf[0] - '1' ) * 9 + buf[1] - '1' ) > 31 )
{
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_NOMUS;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
else
2022-09-05 20:25:33 +00:00
{
S_ChangeMusic( musnum, 1 );
}
2012-11-26 18:58:24 +00:00
}
}
// Simplified, accepting both "noclip" and "idspispopd".
// no clipping mode cheat
2022-09-05 20:25:33 +00:00
else if( cht_CheckCheat( &cheat_noclip, ev->data1 )
|| cht_CheckCheat( &cheat_commercial_noclip, ev->data1 ) )
{
2012-11-26 18:58:24 +00:00
::g->plyr->cheats ^= CF_NOCLIP;
2022-09-05 20:25:33 +00:00
if( ::g->plyr->cheats & CF_NOCLIP )
{
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_NCON;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
else
2022-09-05 20:25:33 +00:00
{
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_NCOFF;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
}
// 'behold?' power-up cheats
2022-09-05 20:25:33 +00:00
for( i = 0; i < 6; i++ )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( cht_CheckCheat( &::g->cheat_powerup[i], ev->data1 ) )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( !::g->plyr->powers[i] )
{
P_GivePower( ::g->plyr, i );
}
else if( i != pw_strength )
{
2012-11-26 18:58:24 +00:00
::g->plyr->powers[i] = 1;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
else
2022-09-05 20:25:33 +00:00
{
2012-11-26 18:58:24 +00:00
::g->plyr->powers[i] = 0;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_BEHOLDX;
}
}
// 'behold' power-up menu
2022-09-05 20:25:33 +00:00
if( cht_CheckCheat( &::g->cheat_powerup[6], ev->data1 ) )
2012-11-26 18:58:24 +00:00
{
::g->plyr->message = STSTR_BEHOLD;
}
// 'choppers' invulnerability & chainsaw
2022-09-05 20:25:33 +00:00
else if( cht_CheckCheat( &cheat_choppers, ev->data1 ) )
2012-11-26 18:58:24 +00:00
{
::g->plyr->weaponowned[wp_chainsaw] = true;
::g->plyr->powers[pw_invulnerability] = true;
::g->plyr->message = STSTR_CHOPPERS;
}
// 'mypos' for player position
2022-09-05 20:25:33 +00:00
else if( cht_CheckCheat( &cheat_mypos, ev->data1 ) )
2012-11-26 18:58:24 +00:00
{
static char buf[ST_MSGWIDTH];
idStr::snPrintf( buf, sizeof( buf ), "ang=0x%x;x,y=(0x%x,0x%x)",
2023-07-14 09:35:37 +00:00
::g->players[::g->consoleplayer].mo->angle,
::g->players[::g->consoleplayer].mo->x,
::g->players[::g->consoleplayer].mo->y );
2012-11-26 18:58:24 +00:00
::g->plyr->message = buf;
}
}
// 'clev' change-level cheat
// ALAN NETWORKING
2022-09-05 20:25:33 +00:00
if( false ) // cht_CheckCheat(&cheat_clev, ev->data1))
2012-11-26 18:58:24 +00:00
{
char buf[3];
int epsd;
int map;
2022-09-05 20:25:33 +00:00
cht_GetParam( &cheat_clev, buf );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ::g->gamemode == commercial )
2012-11-26 18:58:24 +00:00
{
epsd = 0;
2022-09-05 20:25:33 +00:00
map = ( buf[0] - '0' ) * 10 + buf[1] - '0';
2012-11-26 18:58:24 +00:00
}
else
{
epsd = buf[0] - '0';
map = buf[1] - '0';
}
// Catch invalid maps.
2022-09-05 20:25:33 +00:00
if( epsd < 1 )
{
2012-11-26 18:58:24 +00:00
return false;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( map < 1 )
{
2012-11-26 18:58:24 +00:00
return false;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
// Ohmygod - this is not going to work.
2022-09-05 20:25:33 +00:00
if( ( ::g->gamemode == retail )
&& ( ( epsd > 4 ) || ( map > 9 ) ) )
{
2012-11-26 18:58:24 +00:00
return false;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ( ::g->gamemode == registered )
&& ( ( epsd > 3 ) || ( map > 9 ) ) )
{
2012-11-26 18:58:24 +00:00
return false;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ( ::g->gamemode == shareware )
&& ( ( epsd > 1 ) || ( map > 9 ) ) )
{
2012-11-26 18:58:24 +00:00
return false;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ( ::g->gamemode == commercial )
&& ( ( epsd > 1 ) || ( map > 34 ) ) )
{
2012-11-26 18:58:24 +00:00
return false;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
// So be it.
::g->plyr->message = STSTR_CLEV;
2022-09-05 20:25:33 +00:00
G_DeferedInitNew( ::g->gameskill, epsd, map );
}
2012-11-26 18:58:24 +00:00
}
return false;
}
2022-09-05 20:25:33 +00:00
int ST_calcPainOffset( void )
2012-11-26 18:58:24 +00:00
{
int health;
health = ::g->plyr->health > 100 ? 100 : ::g->plyr->health;
2022-09-05 20:25:33 +00:00
if( health != ::g->oldhealth )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
::g->lastcalc = ST_FACESTRIDE * ( ( ( 100 - health ) * ST_NUMPAINFACES ) / 101 );
2012-11-26 18:58:24 +00:00
::g->oldhealth = health;
}
return ::g->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
//
2022-09-05 20:25:33 +00:00
void ST_updateFaceWidget( void )
2012-11-26 18:58:24 +00:00
{
int i;
angle_t badguyangle;
angle_t diffang;
qboolean doevilgrin;
2022-09-05 20:25:33 +00:00
if( ::g->priority < 10 )
2012-11-26 18:58:24 +00:00
{
// dead
2022-09-05 20:25:33 +00:00
if( !::g->plyr->health )
2012-11-26 18:58:24 +00:00
{
::g->priority = 9;
::g->st_faceindex = ST_DEADFACE;
::g->st_facecount = 1;
}
}
2022-09-05 20:25:33 +00:00
if( ::g->priority < 9 )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->plyr->bonuscount )
2012-11-26 18:58:24 +00:00
{
// picking up bonus
doevilgrin = false;
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMWEAPONS; i++ )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->oldweaponsowned[i] != ::g->plyr->weaponowned[i] )
2012-11-26 18:58:24 +00:00
{
doevilgrin = true;
::g->oldweaponsowned[i] = ::g->plyr->weaponowned[i];
}
}
2022-09-05 20:25:33 +00:00
if( doevilgrin )
2012-11-26 18:58:24 +00:00
{
// evil grin if just picked up weapon
::g->priority = 8;
::g->st_facecount = ST_EVILGRINCOUNT;
::g->st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
}
}
}
2022-09-05 20:25:33 +00:00
if( ::g->priority < 8 )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->plyr->damagecount
&& ::g->plyr->attacker
&& ::g->plyr->attacker != ::g->plyr->mo )
2012-11-26 18:58:24 +00:00
{
// being attacked
::g->priority = 7;
2022-09-05 20:25:33 +00:00
if( ::g->plyr->health - ::g->st_oldhealth > ST_MUCHPAIN )
2012-11-26 18:58:24 +00:00
{
::g->st_facecount = ST_TURNCOUNT;
::g->st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
}
else
{
2022-09-05 20:25:33 +00:00
badguyangle = R_PointToAngle2( ::g->plyr->mo->x,
::g->plyr->mo->y,
::g->plyr->attacker->x,
::g->plyr->attacker->y );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( badguyangle > ::g->plyr->mo->angle )
2012-11-26 18:58:24 +00:00
{
// whether right or left
diffang = badguyangle - ::g->plyr->mo->angle;
2022-09-05 20:25:33 +00:00
i = diffang > ANG180;
2012-11-26 18:58:24 +00:00
}
else
{
// whether left or right
diffang = ::g->plyr->mo->angle - badguyangle;
2022-09-05 20:25:33 +00:00
i = diffang <= ANG180;
2012-11-26 18:58:24 +00:00
} // confusing, aint it?
::g->st_facecount = ST_TURNCOUNT;
::g->st_faceindex = ST_calcPainOffset();
2022-09-05 20:25:33 +00:00
if( diffang < ANG45 )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
// head-on
2012-11-26 18:58:24 +00:00
::g->st_faceindex += ST_RAMPAGEOFFSET;
}
2022-09-05 20:25:33 +00:00
else if( i )
2012-11-26 18:58:24 +00:00
{
// turn face right
::g->st_faceindex += ST_TURNOFFSET;
}
else
{
// turn face left
2022-09-05 20:25:33 +00:00
::g->st_faceindex += ST_TURNOFFSET + 1;
2012-11-26 18:58:24 +00:00
}
}
}
}
2022-09-05 20:25:33 +00:00
if( ::g->priority < 7 )
2012-11-26 18:58:24 +00:00
{
// getting hurt because of your own damn stupidity
2022-09-05 20:25:33 +00:00
if( ::g->plyr->damagecount )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->plyr->health - ::g->st_oldhealth > ST_MUCHPAIN )
2012-11-26 18:58:24 +00:00
{
::g->priority = 7;
::g->st_facecount = ST_TURNCOUNT;
::g->st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
}
else
{
::g->priority = 6;
::g->st_facecount = ST_TURNCOUNT;
::g->st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
}
}
}
2022-09-05 20:25:33 +00:00
if( ::g->priority < 6 )
2012-11-26 18:58:24 +00:00
{
// rapid firing
2022-09-05 20:25:33 +00:00
if( ::g->plyr->attackdown )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->lastattackdown == -1 )
{
2012-11-26 18:58:24 +00:00
::g->lastattackdown = ST_RAMPAGEDELAY;
2022-09-05 20:25:33 +00:00
}
else if( !--::g->lastattackdown )
2012-11-26 18:58:24 +00:00
{
::g->priority = 5;
::g->st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
::g->st_facecount = 1;
::g->lastattackdown = 1;
}
}
else
2022-09-05 20:25:33 +00:00
{
2012-11-26 18:58:24 +00:00
::g->lastattackdown = -1;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
if( ::g->priority < 5 )
2012-11-26 18:58:24 +00:00
{
// invulnerability
2022-09-05 20:25:33 +00:00
if( ( ::g->plyr->cheats & CF_GODMODE )
|| ::g->plyr->powers[pw_invulnerability] )
2012-11-26 18:58:24 +00:00
{
::g->priority = 4;
::g->st_faceindex = ST_GODFACE;
::g->st_facecount = 1;
}
}
// look left or look right if the facecount has timed out
2022-09-05 20:25:33 +00:00
if( !::g->st_facecount )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
::g->st_faceindex = ST_calcPainOffset() + ( ::g->st_randomnumber % 3 );
2012-11-26 18:58:24 +00:00
::g->st_facecount = ST_STRAIGHTFACECOUNT;
::g->priority = 0;
}
::g->st_facecount--;
}
2022-09-05 20:25:33 +00:00
void ST_updateWidgets( void )
2012-11-26 18:58:24 +00:00
{
int i;
// must redirect the pointer if the ready weapon has changed.
// if (::g->w_ready.data != ::g->plyr->readyweapon)
// {
2022-09-05 20:25:33 +00:00
if( weaponinfo[::g->plyr->readyweapon].ammo == am_noammo )
{
2012-11-26 18:58:24 +00:00
::g->w_ready.num = &::g->largeammo;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
else
2022-09-05 20:25:33 +00:00
{
2012-11-26 18:58:24 +00:00
::g->w_ready.num = &::g->plyr->ammo[weaponinfo[::g->plyr->readyweapon].ammo];
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
//{
// static int tic=0;
// static int dir=-1;
// if (!(tic&15))
// ::g->plyr->ammo[weaponinfo[::g->plyr->readyweapon].ammo]+=dir;
// if (::g->plyr->ammo[weaponinfo[::g->plyr->readyweapon].ammo] == -100)
// dir = 1;
// tic++;
// }
::g->w_ready.data = ::g->plyr->readyweapon;
// if (*::g->w_ready.on)
// STlib_updateNum(&::g->w_ready, true);
// refresh weapon change
// }
// update keycard multiple widgets
2022-09-05 20:25:33 +00:00
for( i = 0; i < 3; i++ )
2012-11-26 18:58:24 +00:00
{
::g->keyboxes[i] = ::g->plyr->cards[i] ? i : -1;
2022-09-05 20:25:33 +00:00
if( ::g->plyr->cards[i + 3] )
{
::g->keyboxes[i] = i + 3;
}
2012-11-26 18:58:24 +00:00
}
// refresh everything if this is him coming back to life
ST_updateFaceWidget();
// used by the ::g->w_armsbg widget
::g->st_notdeathmatch = !::g->deathmatch;
// used by ::g->w_arms[] widgets
2022-09-05 20:25:33 +00:00
::g->st_armson = ::g->st_statusbaron && !::g->deathmatch;
2012-11-26 18:58:24 +00:00
// used by ::g->w_frags widget
2022-09-05 20:25:33 +00:00
::g->st_fragson = ::g->deathmatch && ::g->st_statusbaron;
2012-11-26 18:58:24 +00:00
::g->st_fragscount = 0;
2022-09-05 20:25:33 +00:00
for( i = 0 ; i < MAXPLAYERS ; i++ )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( i != ::g->consoleplayer )
{
2012-11-26 18:58:24 +00:00
::g->st_fragscount += ::g->plyr->frags[i];
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
else
2022-09-05 20:25:33 +00:00
{
2012-11-26 18:58:24 +00:00
::g->st_fragscount -= ::g->plyr->frags[i];
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
}
// get rid of chat window if up because of message
2022-09-05 20:25:33 +00:00
if( !--::g->st_msgcounter )
{
2012-11-26 18:58:24 +00:00
::g->st_chat = ::g->st_oldchat;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
void ST_Ticker( void )
2012-11-26 18:58:24 +00:00
{
::g->st_clock++;
::g->st_randomnumber = M_Random();
ST_updateWidgets();
::g->st_oldhealth = ::g->plyr->health;
}
2022-09-05 20:25:33 +00:00
void ST_doPaletteStuff( void )
2012-11-26 18:58:24 +00:00
{
int palette;
byte* pal;
int cnt;
int bzc;
cnt = ::g->plyr->damagecount;
2022-09-05 20:25:33 +00:00
if( ::g->plyr->powers[pw_strength] )
2012-11-26 18:58:24 +00:00
{
// slowly fade the berzerk out
2022-09-05 20:25:33 +00:00
bzc = 12 - ( ::g->plyr->powers[pw_strength] >> 6 );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( bzc > cnt )
{
2012-11-26 18:58:24 +00:00
cnt = bzc;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
if( cnt )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
palette = ( cnt + 7 ) >> 3;
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( palette >= NUMREDPALS )
{
palette = NUMREDPALS - 1;
}
2012-11-26 18:58:24 +00:00
palette += STARTREDPALS;
}
2022-09-05 20:25:33 +00:00
else if( ::g->plyr->bonuscount )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
palette = ( ::g->plyr->bonuscount + 7 ) >> 3;
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( palette >= NUMBONUSPALS )
{
palette = NUMBONUSPALS - 1;
}
2012-11-26 18:58:24 +00:00
palette += STARTBONUSPALS;
}
2022-09-05 20:25:33 +00:00
else if( ::g->plyr->powers[pw_ironfeet] > 4 * 32
|| ::g->plyr->powers[pw_ironfeet] & 8 )
{
2012-11-26 18:58:24 +00:00
palette = RADIATIONPAL;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
else
2022-09-05 20:25:33 +00:00
{
2012-11-26 18:58:24 +00:00
palette = 0;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( palette != ::g->st_palette )
2012-11-26 18:58:24 +00:00
{
::g->st_palette = palette;
2022-09-05 20:25:33 +00:00
pal = ( byte* ) W_CacheLumpNum( ::g->lu_palette, PU_CACHE_SHARED ) + palette * 768;
I_SetPalette( pal );
2012-11-26 18:58:24 +00:00
}
}
2022-09-05 20:25:33 +00:00
void ST_drawWidgets( qboolean refresh )
2012-11-26 18:58:24 +00:00
{
int i;
::g->st_notdeathmatch = !::g->deathmatch;
// used by ::g->w_arms[] widgets
::g->st_armson = ::g->st_statusbaron && !::g->deathmatch;
// used by ::g->w_frags widget
2022-09-05 20:25:33 +00:00
::g->st_fragson = ::g->deathmatch && ::g->st_statusbaron;
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
STlib_updateNum( &::g->w_ready, refresh );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < 4; i++ )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
STlib_updateNum( &::g->w_ammo[i], refresh );
STlib_updateNum( &::g->w_maxammo[i], refresh );
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
STlib_updatePercent( &::g->w_health, refresh );
STlib_updatePercent( &::g->w_armor, refresh );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
STlib_updateBinIcon( &::g->w_armsbg, refresh );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < 6; i++ )
{
STlib_updateMultIcon( &::g->w_arms[i], refresh );
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
STlib_updateMultIcon( &::g->w_faces, refresh );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < 3; i++ )
{
STlib_updateMultIcon( &::g->w_keyboxes[i], refresh );
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
STlib_updateNum( &::g->w_frags, refresh );
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
void ST_doRefresh( void )
2012-11-26 18:58:24 +00:00
{
::g->st_firsttime = false;
// draw status bar background to off-screen buff
ST_refreshBackground();
// and refresh all widgets
2022-09-05 20:25:33 +00:00
ST_drawWidgets( true );
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
void ST_diffDraw( void )
2012-11-26 18:58:24 +00:00
{
// update all widgets
2022-09-05 20:25:33 +00:00
ST_drawWidgets( false );
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
void ST_Drawer( qboolean fullscreen, qboolean refresh )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
::g->st_statusbaron = ( !fullscreen ) || ::g->automapactive;
2012-11-26 18:58:24 +00:00
::g->st_firsttime = ::g->st_firsttime || refresh;
// Do red-/gold-shifts from damage/items
ST_doPaletteStuff();
// If just after ST_Start(), refresh all
2022-09-05 20:25:33 +00:00
if( ::g->st_firsttime )
{
ST_doRefresh();
}
2012-11-26 18:58:24 +00:00
// Otherwise, update as little as possible
2022-09-05 20:25:33 +00:00
else
{
ST_diffDraw();
}
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
void ST_loadGraphics( void )
2012-11-26 18:58:24 +00:00
{
static bool ST_HasBeenCalled = false;
// if (ST_HasBeenCalled == true)
// return;
ST_HasBeenCalled = true;
2022-09-05 20:25:33 +00:00
2012-11-26 18:58:24 +00:00
int i;
int j;
int facenum;
char namebuf[9];
// Load the numbers, tall and short
2022-09-05 20:25:33 +00:00
for( i = 0; i < 10; i++ )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
idStr::snPrintf( namebuf, sizeof( namebuf ), "STTNUM%d", i );
::g->tallnum[i] = ( patch_t* ) W_CacheLumpName( namebuf, PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
idStr::snPrintf( namebuf, sizeof( namebuf ), "STYSNUM%d", i );
::g->shortnum[i] = ( patch_t* ) W_CacheLumpName( namebuf, PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
}
// Load percent key.
//Note: why not load STMINUS here, too?
2022-09-05 20:25:33 +00:00
::g->tallpercent = ( patch_t* ) W_CacheLumpName( "STTPRCNT", PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
// key cards
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMCARDS; i++ )
2012-11-26 18:58:24 +00:00
{
idStr::snPrintf( namebuf, sizeof( namebuf ), "STKEYS%d", i );
2022-09-05 20:25:33 +00:00
::g->keys[i] = ( patch_t* ) W_CacheLumpName( namebuf, PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
}
// ::g->arms background
2022-09-05 20:25:33 +00:00
::g->armsbg = ( patch_t* ) W_CacheLumpName( "STARMS", PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
// ::g->arms ownership widgets
2022-09-05 20:25:33 +00:00
for( i = 0; i < 6; i++ )
2012-11-26 18:58:24 +00:00
{
idStr::snPrintf( namebuf, sizeof( namebuf ), "STGNUM%d", i + 2 );
2012-11-26 18:58:24 +00:00
// gray #
2022-09-05 20:25:33 +00:00
::g->arms[i][0] = ( patch_t* ) W_CacheLumpName( namebuf, PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
// yellow #
2022-09-05 20:25:33 +00:00
::g->arms[i][1] = ::g->shortnum[i + 2];
2012-11-26 18:58:24 +00:00
}
// face backgrounds for different color ::g->players
idStr::snPrintf( namebuf, sizeof( namebuf ), "STFB%d", ::g->consoleplayer );
2022-09-05 20:25:33 +00:00
::g->faceback = ( patch_t* ) W_CacheLumpName( namebuf, PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
// status bar background bits
2022-09-05 20:25:33 +00:00
::g->sbar = ( patch_t* ) W_CacheLumpName( "STBAR", PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
// face states
facenum = 0;
2022-09-05 20:25:33 +00:00
for( i = 0; i < ST_NUMPAINFACES; i++ )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
for( j = 0; j < ST_NUMSTRAIGHTFACES; j++ )
2012-11-26 18:58:24 +00:00
{
idStr::snPrintf( namebuf, sizeof( namebuf ), "STFST%d%d", i, j );
2022-09-05 20:25:33 +00:00
::g->faces[facenum++] = ( patch_t* )W_CacheLumpName( namebuf, PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
}
idStr::snPrintf( namebuf, sizeof( namebuf ), "STFTR%d0", i ); // turn right
2022-09-05 20:25:33 +00:00
::g->faces[facenum++] = ( patch_t* )W_CacheLumpName( namebuf, PU_STATIC_SHARED );
idStr::snPrintf( namebuf, sizeof( namebuf ), "STFTL%d0", i ); // turn left
2022-09-05 20:25:33 +00:00
::g->faces[facenum++] = ( patch_t* )W_CacheLumpName( namebuf, PU_STATIC_SHARED );
idStr::snPrintf( namebuf, sizeof( namebuf ), "STFOUCH%d", i ); // ouch!
2022-09-05 20:25:33 +00:00
::g->faces[facenum++] = ( patch_t* )W_CacheLumpName( namebuf, PU_STATIC_SHARED );
idStr::snPrintf( namebuf, sizeof( namebuf ), "STFEVL%d", i ); // evil grin ;)
2022-09-05 20:25:33 +00:00
::g->faces[facenum++] = ( patch_t* )W_CacheLumpName( namebuf, PU_STATIC_SHARED );
idStr::snPrintf( namebuf, sizeof( namebuf ), "STFKILL%d", i ); // pissed off
2022-09-05 20:25:33 +00:00
::g->faces[facenum++] = ( patch_t* )W_CacheLumpName( namebuf, PU_STATIC_SHARED );
}
::g->faces[facenum++] = ( patch_t* )W_CacheLumpName( "STFGOD0", PU_STATIC_SHARED );
::g->faces[facenum++] = ( patch_t* )W_CacheLumpName( "STFDEAD0", PU_STATIC_SHARED );
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
void ST_loadData( void )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
::g->lu_palette = W_GetNumForName( "PLAYPAL" );
2012-11-26 18:58:24 +00:00
ST_loadGraphics();
}
2022-09-05 20:25:33 +00:00
void ST_unloadGraphics( void )
2012-11-26 18:58:24 +00:00
{
// These things are always reloaded... so just don't bother to clean them up!
}
2022-09-05 20:25:33 +00:00
void ST_unloadData( void )
2012-11-26 18:58:24 +00:00
{
ST_unloadGraphics();
}
2022-09-05 20:25:33 +00:00
void ST_initData( void )
2012-11-26 18:58:24 +00:00
{
int i;
::g->st_firsttime = true;
::g->plyr = &::g->players[::g->consoleplayer];
::g->st_clock = 0;
::g->st_chatstate = StartChatState;
::g->st_gamestate = FirstPersonState;
::g->st_statusbaron = true;
::g->st_oldchat = ::g->st_chat = false;
::g->st_cursoron = false;
::g->st_faceindex = 0;
::g->st_palette = -1;
::g->st_oldhealth = -1;
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMWEAPONS; i++ )
{
2012-11-26 18:58:24 +00:00
::g->oldweaponsowned[i] = ::g->plyr->weaponowned[i];
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < 3; i++ )
{
2012-11-26 18:58:24 +00:00
::g->keyboxes[i] = -1;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
STlib_init();
}
2022-09-05 20:25:33 +00:00
void ST_createWidgets( void )
2012-11-26 18:58:24 +00:00
{
int i;
// ready weapon ammo
2022-09-05 20:25:33 +00:00
STlib_initNum( &::g->w_ready,
ST_AMMOX,
ST_AMMOY,
::g->tallnum,
&::g->plyr->ammo[weaponinfo[::g->plyr->readyweapon].ammo],
&::g->st_statusbaron,
ST_AMMOWIDTH );
2012-11-26 18:58:24 +00:00
// the last weapon type
2022-09-05 20:25:33 +00:00
::g->w_ready.data = ::g->plyr->readyweapon;
2012-11-26 18:58:24 +00:00
// health percentage
2022-09-05 20:25:33 +00:00
STlib_initPercent( &::g->w_health,
ST_HEALTHX,
ST_HEALTHY,
::g->tallnum,
&::g->plyr->health,
&::g->st_statusbaron,
::g->tallpercent );
2012-11-26 18:58:24 +00:00
// ::g->arms background
2022-09-05 20:25:33 +00:00
STlib_initBinIcon( &::g->w_armsbg,
ST_ARMSBGX,
ST_ARMSBGY,
::g->armsbg,
&::g->st_notdeathmatch,
&::g->st_statusbaron );
2012-11-26 18:58:24 +00:00
// weapons owned
2022-09-05 20:25:33 +00:00
for( i = 0; i < 6; i++ )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
STlib_initMultIcon( &::g->w_arms[i],
ST_ARMSX + ( i % 3 )*ST_ARMSXSPACE,
ST_ARMSY + ( i / 3 )*ST_ARMSYSPACE,
::g->arms[i], ( int* ) &::g->plyr->weaponowned[i + 1],
&::g->st_armson );
2012-11-26 18:58:24 +00:00
}
// frags sum
2022-09-05 20:25:33 +00:00
STlib_initNum( &::g->w_frags,
ST_FRAGSX,
ST_FRAGSY,
::g->tallnum,
&::g->st_fragscount,
&::g->st_fragson,
ST_FRAGSWIDTH );
2012-11-26 18:58:24 +00:00
// ::g->faces
2022-09-05 20:25:33 +00:00
STlib_initMultIcon( &::g->w_faces,
ST_FACESX,
ST_FACESY,
::g->faces,
&::g->st_faceindex,
&::g->st_statusbaron );
2012-11-26 18:58:24 +00:00
// armor percentage - should be colored later
2022-09-05 20:25:33 +00:00
STlib_initPercent( &::g->w_armor,
ST_ARMORX,
ST_ARMORY,
::g->tallnum,
&::g->plyr->armorpoints,
&::g->st_statusbaron, ::g->tallpercent );
2012-11-26 18:58:24 +00:00
// ::g->keyboxes 0-2
2022-09-05 20:25:33 +00:00
STlib_initMultIcon( &::g->w_keyboxes[0],
ST_KEY0X,
ST_KEY0Y,
::g->keys,
&::g->keyboxes[0],
&::g->st_statusbaron );
STlib_initMultIcon( &::g->w_keyboxes[1],
ST_KEY1X,
ST_KEY1Y,
::g->keys,
&::g->keyboxes[1],
&::g->st_statusbaron );
STlib_initMultIcon( &::g->w_keyboxes[2],
ST_KEY2X,
ST_KEY2Y,
::g->keys,
&::g->keyboxes[2],
&::g->st_statusbaron );
2012-11-26 18:58:24 +00:00
// ammo count (all four kinds)
2022-09-05 20:25:33 +00:00
STlib_initNum( &::g->w_ammo[0],
ST_AMMO0X,
ST_AMMO0Y,
::g->shortnum,
&::g->plyr->ammo[0],
&::g->st_statusbaron,
ST_AMMO0WIDTH );
STlib_initNum( &::g->w_ammo[1],
ST_AMMO1X,
ST_AMMO1Y,
::g->shortnum,
&::g->plyr->ammo[1],
&::g->st_statusbaron,
ST_AMMO1WIDTH );
STlib_initNum( &::g->w_ammo[2],
ST_AMMO2X,
ST_AMMO2Y,
::g->shortnum,
&::g->plyr->ammo[2],
&::g->st_statusbaron,
ST_AMMO2WIDTH );
STlib_initNum( &::g->w_ammo[3],
ST_AMMO3X,
ST_AMMO3Y,
::g->shortnum,
&::g->plyr->ammo[3],
&::g->st_statusbaron,
ST_AMMO3WIDTH );
2012-11-26 18:58:24 +00:00
// max ammo count (all four kinds)
2022-09-05 20:25:33 +00:00
STlib_initNum( &::g->w_maxammo[0],
ST_MAXAMMO0X,
ST_MAXAMMO0Y,
::g->shortnum,
&::g->plyr->maxammo[0],
&::g->st_statusbaron,
ST_MAXAMMO0WIDTH );
STlib_initNum( &::g->w_maxammo[1],
ST_MAXAMMO1X,
ST_MAXAMMO1Y,
::g->shortnum,
&::g->plyr->maxammo[1],
&::g->st_statusbaron,
ST_MAXAMMO1WIDTH );
STlib_initNum( &::g->w_maxammo[2],
ST_MAXAMMO2X,
ST_MAXAMMO2Y,
::g->shortnum,
&::g->plyr->maxammo[2],
&::g->st_statusbaron,
ST_MAXAMMO2WIDTH );
STlib_initNum( &::g->w_maxammo[3],
ST_MAXAMMO3X,
ST_MAXAMMO3Y,
::g->shortnum,
&::g->plyr->maxammo[3],
&::g->st_statusbaron,
ST_MAXAMMO3WIDTH );
2012-11-26 18:58:24 +00:00
}
2022-09-05 20:25:33 +00:00
void ST_Start( void )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( !::g->st_stopped )
{
2012-11-26 18:58:24 +00:00
ST_Stop();
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
ST_initData();
ST_createWidgets();
::g->st_stopped = false;
}
2022-09-05 20:25:33 +00:00
void ST_Stop( void )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->st_stopped )
{
2012-11-26 18:58:24 +00:00
return;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
I_SetPalette( ( byte* )W_CacheLumpNum( ( int )::g->lu_palette, PU_CACHE_SHARED ) );
2012-11-26 18:58:24 +00:00
::g->st_stopped = true;
}
2022-09-05 20:25:33 +00:00
void ST_Init( void )
2012-11-26 18:58:24 +00:00
{
::g->veryfirsttime = 0;
ST_loadData();
2022-09-05 20:25:33 +00:00
::g->screens[4] = ( byte* ) DoomLib::Z_Malloc( SCREENWIDTH * SCREENHEIGHT /*ST_WIDTH*ST_HEIGHT*/, PU_STATIC, 0 );
2012-11-26 18:58:24 +00:00
memset( ::g->screens[4], 0, SCREENWIDTH * SCREENHEIGHT );
}
2022-09-05 20:25:33 +00:00
CONSOLE_COMMAND_SHIP( idqd, "cheat for toggleable god mode", 0 )
{
2012-11-26 18:58:24 +00:00
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
2022-09-05 20:25:33 +00:00
if( ::g == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
2022-09-05 20:25:33 +00:00
if( ::g->gamestate != GS_LEVEL )
{
2012-11-26 18:58:24 +00:00
return;
}
::g->plyr->cheats ^= CF_GODMODE;
2022-09-05 20:25:33 +00:00
if( ::g->plyr->cheats & CF_GODMODE )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( ::g->plyr->mo )
{
2012-11-26 18:58:24 +00:00
::g->plyr->mo->health = 100;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
::g->plyr->health = 100;
::g->plyr->message = STSTR_DQDON;
}
2022-09-05 20:25:33 +00:00
else
{
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_DQDOFF;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
DoomLib::SetPlayer( oldPlayer );
}
2022-09-05 20:25:33 +00:00
CONSOLE_COMMAND_SHIP( idfa, "cheat for killer fucking arsenal", 0 )
{
2012-11-26 18:58:24 +00:00
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
2022-09-05 20:25:33 +00:00
if( ::g == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
2022-09-05 20:25:33 +00:00
if( ::g->gamestate != GS_LEVEL )
{
2012-11-26 18:58:24 +00:00
return;
}
int i = 0;
::g->plyr->armorpoints = 200;
::g->plyr->armortype = 2;
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMWEAPONS; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->weaponowned[i] = true;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMAMMO; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_FAADDED;
DoomLib::SetPlayer( oldPlayer );
}
2022-09-05 20:25:33 +00:00
CONSOLE_COMMAND_SHIP( idkfa, "cheat for key full ammo", 0 )
{
2012-11-26 18:58:24 +00:00
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
2022-09-05 20:25:33 +00:00
if( ::g == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
2022-09-05 20:25:33 +00:00
if( ::g->gamestate != GS_LEVEL )
{
2012-11-26 18:58:24 +00:00
return;
}
int i = 0;
::g->plyr->armorpoints = 200;
::g->plyr->armortype = 2;
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMWEAPONS; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->weaponowned[i] = true;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMAMMO; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
for( i = 0; i < NUMCARDS; i++ )
{
2012-11-26 18:58:24 +00:00
::g->plyr->cards[i] = true;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_KFAADDED;
DoomLib::SetPlayer( oldPlayer );
}
2022-09-05 20:25:33 +00:00
CONSOLE_COMMAND_SHIP( idclip, "cheat for no clip", 0 )
{
2012-11-26 18:58:24 +00:00
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
2022-09-05 20:25:33 +00:00
if( ::g == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
2022-09-05 20:25:33 +00:00
if( ::g->gamestate != GS_LEVEL )
{
2012-11-26 18:58:24 +00:00
return;
}
::g->plyr->cheats ^= CF_NOCLIP;
2022-09-05 20:25:33 +00:00
if( ::g->plyr->cheats & CF_NOCLIP )
{
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_NCON;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
else
2022-09-05 20:25:33 +00:00
{
2012-11-26 18:58:24 +00:00
::g->plyr->message = STSTR_NCOFF;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
DoomLib::SetPlayer( oldPlayer );
}
2022-09-05 20:25:33 +00:00
CONSOLE_COMMAND_SHIP( idmypos, "for player position", 0 )
{
2012-11-26 18:58:24 +00:00
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
2022-09-05 20:25:33 +00:00
if( ::g == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
2022-09-05 20:25:33 +00:00
if( ::g->gamestate != GS_LEVEL )
{
2012-11-26 18:58:24 +00:00
return;
}
static char buf[ST_MSGWIDTH];
idStr::snPrintf( buf, sizeof( buf ), "ang=0x%x;x,y=(0x%x,0x%x)",
2023-07-14 09:35:37 +00:00
::g->players[::g->consoleplayer].mo->angle,
::g->players[::g->consoleplayer].mo->x,
::g->players[::g->consoleplayer].mo->y );
2012-11-26 18:58:24 +00:00
::g->plyr->message = buf;
DoomLib::SetPlayer( oldPlayer );
}
2022-09-05 20:25:33 +00:00
CONSOLE_COMMAND_SHIP( idclev, "warp to next level", 0 )
{
2012-11-26 18:58:24 +00:00
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
2022-09-05 20:25:33 +00:00
if( ::g == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
2022-09-05 20:25:33 +00:00
if( ::g->gamestate != GS_LEVEL )
{
2012-11-26 18:58:24 +00:00
return;
}
int epsd;
int map;
2022-09-05 20:25:33 +00:00
if( ::g->gamemode == commercial )
2012-11-26 18:58:24 +00:00
{
2022-09-05 20:25:33 +00:00
if( args.Argc() > 1 )
{
2012-11-26 18:58:24 +00:00
epsd = 1;
map = atoi( args.Argv( 1 ) );
2022-09-05 20:25:33 +00:00
}
else
{
idLib::Printf( "idclev takes map as first argument \n" );
2012-11-26 18:58:24 +00:00
return;
}
2022-09-05 20:25:33 +00:00
if( map > 32 )
{
2012-11-26 18:58:24 +00:00
map = 1;
}
}
else
{
2022-09-05 20:25:33 +00:00
if( args.Argc() > 2 )
{
2012-11-26 18:58:24 +00:00
epsd = atoi( args.Argv( 1 ) );
map = atoi( args.Argv( 2 ) );
2022-09-05 20:25:33 +00:00
}
else
{
idLib::Printf( "idclev takes episode and map as first two arguments \n" );
2012-11-26 18:58:24 +00:00
return;
}
}
// Catch invalid maps.
2022-09-05 20:25:33 +00:00
if( epsd < 1 )
{
2012-11-26 18:58:24 +00:00
return;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( map < 1 )
{
2012-11-26 18:58:24 +00:00
return;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
// Ohmygod - this is not going to work.
2022-09-05 20:25:33 +00:00
if( ( ::g->gamemode == retail )
&& ( ( epsd > 4 ) || ( map > 9 ) ) )
{
2012-11-26 18:58:24 +00:00
return;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ( ::g->gamemode == registered )
&& ( ( epsd > 3 ) || ( map > 9 ) ) )
{
2012-11-26 18:58:24 +00:00
return;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ( ::g->gamemode == shareware )
&& ( ( epsd > 1 ) || ( map > 9 ) ) )
{
2012-11-26 18:58:24 +00:00
return;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
2022-09-05 20:25:33 +00:00
if( ( ::g->gamemode == commercial )
&& ( ( epsd > 1 ) || ( map > 34 ) ) )
{
2012-11-26 18:58:24 +00:00
return;
2022-09-05 20:25:33 +00:00
}
2012-11-26 18:58:24 +00:00
// So be it.
::g->plyr->message = STSTR_CLEV;
2022-09-05 20:25:33 +00:00
G_DeferedInitNew( ::g->gameskill, epsd, map );
2012-11-26 18:58:24 +00:00
DoomLib::SetPlayer( oldPlayer );
}