1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471
|
// 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
//
// 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_X2 104
#define ST_FX 143
#define ST_FY 169
// 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_FACESY 168
#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_AMMOY 171
// HEALTH number pos.
#define ST_HEALTHWIDTH 3
#define ST_HEALTHX 90
#define ST_HEALTHY 171
// Weapon pos.
#define ST_ARMSX 111
#define ST_ARMSY 172
#define ST_ARMSBGX 104
#define ST_ARMSBGY 168
#define ST_ARMSXSPACE 12
#define ST_ARMSYSPACE 10
// Frags pos.
#define ST_FRAGSX 138
#define ST_FRAGSY 171
#define ST_FRAGSWIDTH 2
// ARMOR number pos.
#define ST_ARMORWIDTH 3
#define ST_ARMORX 221
#define ST_ARMORY 171
// Key icon positions.
#define ST_KEY0WIDTH 8
#define ST_KEY0HEIGHT 5
#define ST_KEY0X 239
#define ST_KEY0Y 171
#define ST_KEY1WIDTH ST_KEY0WIDTH
#define ST_KEY1X 239
#define ST_KEY1Y 181
#define ST_KEY2WIDTH ST_KEY0WIDTH
#define ST_KEY2X 239
#define ST_KEY2Y 191
// Ammunition counter.
#define ST_AMMO0WIDTH 3
#define ST_AMMO0HEIGHT 6
#define ST_AMMO0X 288
#define ST_AMMO0Y 173
#define ST_AMMO1WIDTH ST_AMMO0WIDTH
#define ST_AMMO1X 288
#define ST_AMMO1Y 179
#define ST_AMMO2WIDTH ST_AMMO0WIDTH
#define ST_AMMO2X 288
#define ST_AMMO2Y 191
#define ST_AMMO3WIDTH ST_AMMO0WIDTH
#define ST_AMMO3X 288
#define ST_AMMO3Y 185
// Indicate maximum ammunition.
// Only needed because backpack exists.
#define ST_MAXAMMO0WIDTH 3
#define ST_MAXAMMO0HEIGHT 5
#define ST_MAXAMMO0X 314
#define ST_MAXAMMO0Y 173
#define ST_MAXAMMO1WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO1X 314
#define ST_MAXAMMO1Y 179
#define ST_MAXAMMO2WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO2X 314
#define ST_MAXAMMO2Y 191
#define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO3X 314
#define ST_MAXAMMO3Y 185
// pistol
#define ST_WEAPON0X 110
#define ST_WEAPON0Y 172
// shotgun
#define ST_WEAPON1X 122
#define ST_WEAPON1Y 172
// chain gun
#define ST_WEAPON2X 134
#define ST_WEAPON2Y 172
// missile launcher
#define ST_WEAPON3X 110
#define ST_WEAPON3Y 181
// plasma gun
#define ST_WEAPON4X 122
#define ST_WEAPON4Y 181
// bfg
#define ST_WEAPON5X 134
#define ST_WEAPON5Y 181
// WPNS title
#define ST_WPNSX 109
#define ST_WPNSY 191
// DETH title
#define ST_DETHX 109
#define ST_DETHY 191
//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
};
// Now what?
cheatseq_t cheat_mus = { cheat_mus_seq, 0 };
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 };
//
extern char* mapnames[];
//
// STATUS BAR CODE
//
void ST_Stop(void);
void ST_refreshBackground(void)
{
if (st_statusbaron)
{
V_DrawPatch(ST_X, 0, BG, sbar);
if (netgame)
V_DrawPatch(ST_FX, 0, BG, faceback);
V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG);
}
}
// Respond to keyboard input events,
// intercept cheats.
boolean
ST_Responder (event_t* ev)
{
int i;
// 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)
{
if (!netgame)
{
// b. - enabled for more debug fun.
// if (gameskill != sk_nightmare) {
// 'dqd' cheat for toggleable god mode
if (cht_CheckCheat(&cheat_god, ev->data1))
{
plyr->cheats ^= CF_GODMODE;
if (plyr->cheats & CF_GODMODE)
{
if (plyr->mo)
plyr->mo->health = 100;
plyr->health = 100;
plyr->message = STSTR_DQDON;
}
else
plyr->message = STSTR_DQDOFF;
}
// 'fa' cheat for killer fucking arsenal
else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))
{
plyr->armorpoints = 200;
plyr->armortype = 2;
for (i=0;i<NUMWEAPONS;i++)
plyr->weaponowned[i] = true;
for (i=0;i<NUMAMMO;i++)
plyr->ammo[i] = plyr->maxammo[i];
plyr->message = STSTR_FAADDED;
}
// 'kfa' cheat for key full ammo
else if (cht_CheckCheat(&cheat_ammo, ev->data1))
{
plyr->armorpoints = 200;
plyr->armortype = 2;
for (i=0;i<NUMWEAPONS;i++)
plyr->weaponowned[i] = true;
for (i=0;i<NUMAMMO;i++)
plyr->ammo[i] = plyr->maxammo[i];
for (i=0;i<NUMCARDS;i++)
plyr->cards[i] = true;
plyr->message = STSTR_KFAADDED;
}
// 'mus' cheat for changing music
else if (cht_CheckCheat(&cheat_mus, ev->data1))
{
char buf[3];
int musnum;
plyr->message = STSTR_MUS;
cht_GetParam(&cheat_mus, buf);
if (gamemode == commercial)
{
musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
if (((buf[0]-'0')*10 + buf[1]-'0') > 35)
plyr->message = STSTR_NOMUS;
else
S_ChangeMusic(musnum, 1);
}
else
{
musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');
if (((buf[0]-'1')*9 + buf[1]-'1') > 31)
plyr->message = STSTR_NOMUS;
else
S_ChangeMusic(musnum, 1);
}
}
// Simplified, accepting both "noclip" and "idspispopd".
// no clipping mode cheat
else if ( cht_CheckCheat(&cheat_noclip, ev->data1)
|| cht_CheckCheat(&cheat_commercial_noclip,ev->data1) )
{
plyr->cheats ^= CF_NOCLIP;
if (plyr->cheats & CF_NOCLIP)
plyr->message = STSTR_NCON;
else
plyr->message = STSTR_NCOFF;
}
// 'behold?' power-up cheats
for (i=0;i<6;i++)
{
if (cht_CheckCheat(&cheat_powerup[i], ev->data1))
{
if (!plyr->powers[i])
P_GivePower( plyr, i);
else if (i!=pw_strength)
plyr->powers[i] = 1;
else
plyr->powers[i] = 0;
plyr->message = STSTR_BEHOLDX;
}
}
// 'behold' power-up menu
if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
{
plyr->message = STSTR_BEHOLD;
}
// 'choppers' invulnerability & chainsaw
else if (cht_CheckCheat(&cheat_choppers, ev->data1))
{
plyr->weaponowned[wp_chainsaw] = true;
plyr->powers[pw_invulnerability] = true;
plyr->message = STSTR_CHOPPERS;
}
// 'mypos' for player position
else if (cht_CheckCheat(&cheat_mypos, ev->data1))
{
static char buf[ST_MSGWIDTH];
sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
players[consoleplayer].mo->angle,
players[consoleplayer].mo->x,
players[consoleplayer].mo->y);
plyr->message = buf;
}
}
// 'clev' change-level cheat
if (cht_CheckCheat(&cheat_clev, ev->data1))
{
char buf[3];
int epsd;
int map;
cht_GetParam(&cheat_clev, buf);
if (gamemode == commercial)
{
epsd = 0;
map = (buf[0] - '0')*10 + buf[1] - '0';
}
else
{
epsd = buf[0] - '0';
map = buf[1] - '0';
}
// Catch invalid maps.
if (epsd < 1)
return false;
if (map < 1)
return false;
// Ohmygod - this is not going to work.
if ((gamemode == retail)
&& ((epsd > 4) || (map > 9)))
return false;
if ((gamemode == registered)
&& ((epsd > 3) || (map > 9)))
return false;
if ((gamemode == shareware)
&& ((epsd > 1) || (map > 9)))
return false;
if ((gamemode == commercial)
&& (( epsd > 1) || (map > 34)))
return false;
// So be it.
plyr->message = STSTR_CLEV;
G_DeferedInitNew(gameskill, epsd, map);
}
}
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;
boolean doevilgrin;
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
st_notdeathmatch = !deathmatch;
// used by w_arms[] widgets
st_armson = st_statusbaron && !deathmatch;
// used by w_frags widget
st_fragson = deathmatch && st_statusbaron;
st_fragscount = 0;
for (i=0 ; i<MAXPLAYERS ; i++)
{
if (i != consoleplayer)
st_fragscount += plyr->frags[i];
else
st_fragscount -= plyr->frags[i];
}
// 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;
byte* pal;
int cnt;
int bzc;
cnt = plyr->damagecount;
if (plyr->powers[pw_strength])
{
// slowly fade the berzerk out
bzc = 12 - (plyr->powers[pw_strength]>>6);
if (bzc > cnt)
cnt = bzc;
}
if (cnt)
{
palette = (cnt+7)>>3;
if (palette >= NUMREDPALS)
palette = NUMREDPALS-1;
palette += STARTREDPALS;
}
else if (plyr->bonuscount)
{
palette = (plyr->bonuscount+7)>>3;
if (palette >= NUMBONUSPALS)
palette = NUMBONUSPALS-1;
palette += STARTBONUSPALS;
}
else if ( plyr->powers[pw_ironfeet] > 4*32
|| plyr->powers[pw_ironfeet]&8)
palette = RADIATIONPAL;
else
palette = 0;
if (palette != st_palette)
{
st_palette = palette;
pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768;
I_SetPalette (pal);
}
}
void ST_drawWidgets(boolean refresh)
{
int i;
// used by w_arms[] widgets
st_armson = st_statusbaron && !deathmatch;
// used by w_frags widget
st_fragson = deathmatch && st_statusbaron;
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);
}
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);
}
void ST_Drawer (boolean fullscreen, boolean refresh)
{
st_statusbaron = (!fullscreen) || automapactive;
st_firsttime = st_firsttime || refresh;
// Do red-/gold-shifts from damage/items
ST_doPaletteStuff();
// If just after ST_Start(), refresh all
if (st_firsttime) ST_doRefresh();
// Otherwise, update as little as possible
else ST_diffDraw();
}
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
sprintf(namebuf, "STFB%d", consoleplayer);
faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);
// 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();
}
void ST_initData(void)
{
int i;
st_firsttime = true;
plyr = &players[consoleplayer];
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();
}
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);
}
static boolean st_stopped = true;
void ST_Start (void)
{
if (!st_stopped)
ST_Stop();
ST_initData();
ST_createWidgets();
st_stopped = false;
}
void ST_Stop (void)
{
if (st_stopped)
return;
I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE));
st_stopped = true;
}
void ST_Init (void)
{
veryfirsttime = 0;
ST_loadData();
screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0);
}
|