/
st_stuff.c
1246 lines (1045 loc) · 33.7 KB
/
st_stuff.c
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
/* Emacs style mode select -*- C++ -*-
*-----------------------------------------------------------------------------
*
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Status bar code.
* Does the face/direction indicator animatin.
* Does palette indicators as well (red pain/berserk, bright pickup)
*
*-----------------------------------------------------------------------------*/
#include "doomdef.h"
#include "doomstat.h"
#include "m_random.h"
#include "i_video.h"
#include "w_wad.h"
#include "st_stuff.h"
#include "st_lib.h"
#include "r_main.h"
#include "am_map.h"
#include "m_cheat.h"
#include "s_sound.h"
#include "sounds.h"
#include "dstrings.h"
#include "r_draw.h"
#include "e6y.h"//e6y
#include "heretic/sb_bar.h"
//
// STATUS BAR DATA
//
int ST_SCALED_HEIGHT;
int ST_SCALED_WIDTH;
int ST_SCALED_Y;
// 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
// Location of status bar
#define ST_X 0
#define ST_X2 104
// proff 08/18/98: Changed for high-res
#define ST_FX (ST_X+143)
#define ST_FY (ST_Y+1)
//#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)
// proff 08/18/98: Changed for high-res
#define ST_FACESX (ST_X+143)
#define ST_FACESY (ST_Y)
//#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?
// I dunno, why don't you go and find out!!! killough
// AMMO number pos.
#define ST_AMMOWIDTH 3
// proff 08/18/98: Changed for high-res
#define ST_AMMOX (ST_X+44)
#define ST_AMMOY (ST_Y+3)
//#define ST_AMMOX 44
//#define ST_AMMOY 171
// HEALTH number pos.
#define ST_HEALTHWIDTH 3
// proff 08/18/98: Changed for high-res
#define ST_HEALTHX (ST_X+90)
#define ST_HEALTHY (ST_Y+3)
//#define ST_HEALTHX 90
//#define ST_HEALTHY 171
// Weapon pos.
// proff 08/18/98: Changed for high-res
#define ST_ARMSX (ST_X+111)
#define ST_ARMSY (ST_Y+4)
#define ST_ARMSBGX (ST_X+104)
#define ST_ARMSBGY (ST_Y)
//#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.
// proff 08/18/98: Changed for high-res
#define ST_FRAGSX (ST_X+138)
#define ST_FRAGSY (ST_Y+3)
//#define ST_FRAGSX 138
//#define ST_FRAGSY 171
#define ST_FRAGSWIDTH 2
// ARMOR number pos.
#define ST_ARMORWIDTH 3
// proff 08/18/98: Changed for high-res
#define ST_ARMORX (ST_X+221)
#define ST_ARMORY (ST_Y+3)
//#define ST_ARMORX 221
//#define ST_ARMORY 171
// Key icon positions.
#define ST_KEY0WIDTH 8
#define ST_KEY0HEIGHT 5
// proff 08/18/98: Changed for high-res
#define ST_KEY0X (ST_X+239)
#define ST_KEY0Y (ST_Y+3)
//#define ST_KEY0X 239
//#define ST_KEY0Y 171
#define ST_KEY1WIDTH ST_KEY0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_KEY1X (ST_X+239)
#define ST_KEY1Y (ST_Y+13)
//#define ST_KEY1X 239
//#define ST_KEY1Y 181
#define ST_KEY2WIDTH ST_KEY0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_KEY2X (ST_X+239)
#define ST_KEY2Y (ST_Y+23)
//#define ST_KEY2X 239
//#define ST_KEY2Y 191
// Ammunition counter.
#define ST_AMMO0WIDTH 3
#define ST_AMMO0HEIGHT 6
// proff 08/18/98: Changed for high-res
#define ST_AMMO0X (ST_X+288)
#define ST_AMMO0Y (ST_Y+5)
//#define ST_AMMO0X 288
//#define ST_AMMO0Y 173
#define ST_AMMO1WIDTH ST_AMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_AMMO1X (ST_X+288)
#define ST_AMMO1Y (ST_Y+11)
//#define ST_AMMO1X 288
//#define ST_AMMO1Y 179
#define ST_AMMO2WIDTH ST_AMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_AMMO2X (ST_X+288)
#define ST_AMMO2Y (ST_Y+23)
//#define ST_AMMO2X 288
//#define ST_AMMO2Y 191
#define ST_AMMO3WIDTH ST_AMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_AMMO3X (ST_X+288)
#define ST_AMMO3Y (ST_Y+17)
//#define ST_AMMO3X 288
//#define ST_AMMO3Y 185
// Indicate maximum ammunition.
// Only needed because backpack exists.
#define ST_MAXAMMO0WIDTH 3
#define ST_MAXAMMO0HEIGHT 5
// proff 08/18/98: Changed for high-res
#define ST_MAXAMMO0X (ST_X+314)
#define ST_MAXAMMO0Y (ST_Y+5)
//#define ST_MAXAMMO0X 314
//#define ST_MAXAMMO0Y 173
#define ST_MAXAMMO1WIDTH ST_MAXAMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_MAXAMMO1X (ST_X+314)
#define ST_MAXAMMO1Y (ST_Y+11)
//#define ST_MAXAMMO1X 314
//#define ST_MAXAMMO1Y 179
#define ST_MAXAMMO2WIDTH ST_MAXAMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_MAXAMMO2X (ST_X+314)
#define ST_MAXAMMO2Y (ST_Y+23)
//#define ST_MAXAMMO2X 314
//#define ST_MAXAMMO2Y 191
#define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_MAXAMMO3X (ST_X+314)
#define ST_MAXAMMO3Y (ST_Y+17)
//#define ST_MAXAMMO3X 314
//#define ST_MAXAMMO3Y 185
// killough 2/8/98: weapon info position macros UNUSED, removed here
// main player in game
static player_t *plyr;
// ST_Start() has just been called
static dboolean st_firsttime;
// used to execute ST_Init() only once
static int veryfirsttime = 1;
// CPhipps - no longer do direct PLAYPAL handling here
// 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 dboolean st_statusbaron;
// whether status bar chat is active
static dboolean st_chat;
// value of st_chat before message popped up
static dboolean st_oldchat;
// whether chat window has the cursor on
static dboolean st_cursoron;
// !deathmatch
static dboolean st_notdeathmatch;
// !deathmatch && st_statusbaron
static dboolean st_armson;
// !deathmatch
static dboolean st_fragson;
// 0-9, tall numbers
static patchnum_t tallnum[10];
// tall % sign
static patchnum_t tallpercent;
// 0-9, short, yellow (,different!) numbers
static patchnum_t shortnum[10];
// 3 key-cards, 3 skulls, 3 card/skull combos
// jff 2/24/98 extend number of patches by three skull/card combos
static patchnum_t keys[NUMCARDS+3];
// face status patches
static patchnum_t faces[ST_NUMFACES];
// face background
static patchnum_t faceback; // CPhipps - single background, translated for different players
//e6y: status bar background
static patchnum_t stbarbg;
patchnum_t grnrock;
patchnum_t brdr_t, brdr_b, brdr_l, brdr_r;
patchnum_t brdr_tl, brdr_tr, brdr_bl, brdr_br;
// main bar right
static patchnum_t armsbg;
// weapon ownership patches
static patchnum_t arms[6][2];
// ready-weapon widget
static st_number_t w_ready;
//jff 2/16/98 status color change levels
int ammo_red; // ammo percent less than which status is red
int ammo_yellow; // ammo percent less is yellow more green
int health_red; // health amount less than which status is red
int health_yellow; // health amount less than which status is yellow
int health_green; // health amount above is blue, below is green
int armor_red; // armor amount less than which status is red
int armor_yellow; // armor amount less than which status is yellow
int armor_green; // armor amount above is blue, below is green
ammo_colour_behaviour_t ammo_colour_behaviour;
const char *ammo_colour_behaviour_list[ammo_colour_behaviour_max] = {
"no",
"full ammo only",
"yes"
};
// 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 dboolean 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;
extern char *mapnames[];
//
// STATUS BAR CODE
//
static void ST_Stop(void);
static void ST_refreshBackground(void)
{
int y = ST_Y;
enum patch_translation_e flags = VPT_ALIGN_LEFT_TOP;
if (st_statusbaron)
{
flags = VPT_ALIGN_BOTTOM;
V_DrawNumPatch(ST_X, y, BG, stbarbg.lumpnum, CR_DEFAULT, flags);
if (!deathmatch)
{
V_DrawNumPatch(ST_ARMSBGX, y, BG, armsbg.lumpnum, CR_DEFAULT, flags);
}
// killough 3/7/98: make face background change with displayplayer
if (netgame)
{
V_DrawNumPatch(ST_FX, y, BG, faceback.lumpnum,
displayplayer ? CR_LIMIT+displayplayer : CR_DEFAULT,
displayplayer ? (VPT_TRANS | VPT_ALIGN_BOTTOM) : flags);
}
V_CopyRect(BG, FG, ST_X + wide_offsetx, SCREENHEIGHT - ST_SCALED_HEIGHT, ST_SCALED_WIDTH, ST_SCALED_HEIGHT, VPT_NONE);
}
}
// Respond to keyboard input events,
// intercept cheats.
dboolean ST_Responder(event_t *ev)
{
if (heretic) return SB_Responder(ev);
// 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:
st_gamestate = FirstPersonState;
break;
}
}
else // if a user keypress...
if (ev->type == ev_keydown) // Try cheat responder in m_cheat.c
return M_FindCheats(ev->data1); // killough 4/17/98, 5/2/98
return false;
}
static int ST_calcPainOffset(void)
{
static int lastcalc;
static int oldhealth = -1;
int 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
//
static void ST_updateFaceWidget(void)
{
int i;
angle_t badguyangle;
angle_t diffang;
static int lastattackdown = -1;
static int priority = 0;
dboolean 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;
// haleyjd 10/12/03: classic DOOM problem of missing OUCH face
// was due to inversion of this test:
// if(plyr->health - st_oldhealth > ST_MUCHPAIN)
// e6y: compatibility optioned
if((comp[comp_ouchface]?
(plyr->health - st_oldhealth):
(st_oldhealth - plyr->health)) > ST_MUCHPAIN)
{
// e6y
// There are TWO bugs in the ouch face code.
// Not only was the condition reversed, but the priority system is
// broken in a way that makes the face not work with monster damage.
if(!comp[comp_ouchface])
priority = 8;
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)
{
// haleyjd 10/12/03: classic DOOM problem of missing OUCH face
// was due to inversion of this test:
// if(plyr->health - st_oldhealth > ST_MUCHPAIN)
// e6y: compatibility optioned
if((comp[comp_ouchface]?
(plyr->health - st_oldhealth):
(st_oldhealth - plyr->health)) > 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--;
}
int sts_traditional_keys; // killough 2/28/98: traditional status bar keys
static 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;
//jff 2/24/98 select double key
//killough 2/28/98: preserve traditional keys by config option
if (plyr->cards[i+3])
keyboxes[i] = keyboxes[i]==-1 || sts_traditional_keys ? i+3 : i+6;
}
// 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 != displayplayer) // killough 3/7/98
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)
{
if (heretic) return SB_Ticker();
st_clock++;
st_randomnumber = M_Random();
ST_updateWidgets();
st_oldhealth = plyr->health;
}
int st_palette = 0;
static void ST_doPaletteStuff(void)
{
int palette;
int cnt = palette_ondamage ? plyr->damagecount : 0;
if (palette_onpowers && plyr->powers[pw_strength])
{
// slowly fade the berzerk out
int bzc = 12 - (plyr->powers[pw_strength]>>6);
if (bzc > cnt)
cnt = bzc;
}
if (cnt)
{
palette = (cnt+7)>>3;
if (palette >= NUMREDPALS)
palette = NUMREDPALS-1;
/* cph 2006/08/06 - if in the menu, reduce the red tint - navigating to
* load a game can be tricky if the screen is all red */
if (menuactive) palette >>=1;
palette += STARTREDPALS;
}
else
if (palette_onbonus && plyr->bonuscount)
{
palette = (plyr->bonuscount+7)>>3;
if (palette >= NUMBONUSPALS)
palette = NUMBONUSPALS-1;
palette += STARTBONUSPALS;
}
else
if (palette_onpowers && (plyr->powers[pw_ironfeet] > 4*32 || plyr->powers[pw_ironfeet] & 8))
palette = RADIATIONPAL;
else
palette = 0;
// In Chex Quest, the player never sees red. Instead, the
// radiation suit palette is used to tint the screen green,
// as though the player is being covered in goo by an
// attacking flemoid.
if (palette_onpowers && gamemission == chex
&& palette >= STARTREDPALS && palette < STARTREDPALS + NUMREDPALS)
{
palette = RADIATIONPAL;
}
if (palette != st_palette) {
V_SetPalette(st_palette = palette); // CPhipps - use new palette function
// have to redraw the entire status bar when the palette changes
// in truecolor modes - POPE
if (V_GetMode() == VID_MODE15 || V_GetMode() == VID_MODE16 || V_GetMode() == VID_MODE32)
st_firsttime = true;
}
}
void M_ChangeApplyPalette(void)
{
ST_doPaletteStuff();
}
static void ST_drawWidgets(dboolean refresh)
{
int i;
int ammopct = 0;
// used by w_arms[] widgets
st_armson = st_statusbaron && !deathmatch;
// used by w_frags widget
st_fragson = deathmatch && st_statusbaron;
//jff 2/16/98 make color of ammo depend on amount
if ((*w_ready.num == plyr->maxammo[weaponinfo[w_ready.data].ammo]) ||
(ammo_colour_behaviour == ammo_colour_behaviour_no && plyr->backpack &&
*w_ready.num*2 >= plyr->maxammo[weaponinfo[w_ready.data].ammo]))
STlib_updateNum(&w_ready, CR_BLUE2, refresh);
else {
if (plyr->maxammo[weaponinfo[w_ready.data].ammo])
ammopct = (*w_ready.num*100)/plyr->maxammo[weaponinfo[w_ready.data].ammo];
if (plyr->backpack && ammo_colour_behaviour != ammo_colour_behaviour_yes)
ammopct *= 2;
if (ammopct < ammo_red)
STlib_updateNum(&w_ready, CR_RED, refresh);
else
if (ammopct < ammo_yellow)
STlib_updateNum(&w_ready, CR_GOLD, refresh);
else
STlib_updateNum(&w_ready, CR_GREEN, refresh);
}
for (i=0;i<4;i++)
{
STlib_updateNum(&w_ammo[i], CR_DEFAULT, refresh); //jff 2/16/98 no xlation
STlib_updateNum(&w_maxammo[i], CR_DEFAULT, refresh);
}
//jff 2/16/98 make color of health depend on amount
if (*w_health.n.num<health_red)
STlib_updatePercent(&w_health, CR_RED, refresh);
else if (*w_health.n.num<health_yellow)
STlib_updatePercent(&w_health, CR_GOLD, refresh);
else if (*w_health.n.num<=health_green)
STlib_updatePercent(&w_health, CR_GREEN, refresh);
else
STlib_updatePercent(&w_health, CR_BLUE2, refresh); //killough 2/28/98
if (sts_armorcolor_type)
{
// armor color dictated by type (Status Bar)
if (plyr->armortype >= 2)
STlib_updatePercent(&w_armor, CR_BLUE2, refresh);
else if (plyr->armortype == 1)
STlib_updatePercent(&w_armor, CR_GREEN, refresh);
else if (plyr->armortype == 0)
STlib_updatePercent(&w_armor, CR_RED, refresh);
}
else
{
//jff 2/16/98 make color of armor depend on amount
if (*w_armor.n.num<armor_red)
STlib_updatePercent(&w_armor, CR_RED, refresh);
else if (*w_armor.n.num<armor_yellow)
STlib_updatePercent(&w_armor, CR_GOLD, refresh);
else if (*w_armor.n.num<=armor_green)
STlib_updatePercent(&w_armor, CR_GREEN, refresh);
else
STlib_updatePercent(&w_armor, CR_BLUE2, refresh); //killough 2/28/98
}
//e6y: moved to ST_refreshBackground() for correct single-pass stretching
//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, CR_DEFAULT, refresh);
}
void ST_SetResolution(void)
{
st_firsttime = true;
R_FillBackScreen();
}
void ST_Drawer(dboolean statusbaron, dboolean refresh, dboolean fullmenu)
{
if (heretic) return SB_Drawer(statusbaron, refresh, fullmenu);
/* cph - let status bar on be controlled
* completely by the call from D_Display
* proff - really do it
*/
st_firsttime = st_firsttime || refresh || fullmenu;
ST_doPaletteStuff(); // Do red-/gold-shifts from damage/items
if (statusbaron) {
if (st_firsttime || (V_GetMode() == VID_MODEGL))
{
/* If just after ST_Start(), refresh all */
st_firsttime = false;
ST_refreshBackground(); // draw status bar background to off-screen buff
if (!fullmenu)
ST_drawWidgets(true); // and refresh all widgets
}
else
{
/* Otherwise, update as little as possible */
if (!fullmenu)
ST_drawWidgets(false); // update all widgets
}
}
}
//
// ST_loadGraphics
//
// CPhipps - Loads graphics needed for status bar if doload is true,
// unloads them otherwise
//
static void ST_loadGraphics(dboolean doload)
{
int i, facenum;
char namebuf[9];
// cph - macro that either acquires a pointer and lock for a lump, or
// unlocks it. var is referenced exactly once in either case, so ++ in arg works
// Load the numbers, tall and short
for (i=0;i<10;i++)
{
sprintf(namebuf, "STTNUM%d", i);
R_SetPatchNum(&tallnum[i],namebuf);
snprintf(namebuf, sizeof(namebuf), "STYSNUM%d", i);
R_SetPatchNum(&shortnum[i],namebuf);
}
// Load percent key.
R_SetPatchNum(&tallpercent,"STTPRCNT");
// key cards
for (i=0;i<NUMCARDS+3;i++) //jff 2/23/98 show both keys too
{
sprintf(namebuf, "STKEYS%d", i);
R_SetPatchNum(&keys[i], namebuf);
}
//e6y: status bar background
R_SetPatchNum(&stbarbg, "STBAR");
R_SetFloorNum(&grnrock, (gamemode == commercial ? "GRNROCK" : "FLOOR7_2"));
R_SetPatchNum(&brdr_t, "brdr_t");
R_SetPatchNum(&brdr_b, "brdr_b");
R_SetPatchNum(&brdr_l, "brdr_l");
R_SetPatchNum(&brdr_r, "brdr_r");
R_SetPatchNum(&brdr_tl, "brdr_tl");
R_SetPatchNum(&brdr_tr, "brdr_tr");
R_SetPatchNum(&brdr_bl, "brdr_bl");
R_SetPatchNum(&brdr_br, "brdr_br");
// arms background
R_SetPatchNum(&armsbg, "STARMS");
// arms ownership widgets
for (i=0;i<6;i++)
{
sprintf(namebuf, "STGNUM%d", i+2);
// gray #
R_SetPatchNum(&arms[i][0], namebuf);
// yellow #
arms[i][1] = shortnum[i+2];
}
// face backgrounds for different color players
// killough 3/7/98: add better support for spy mode by loading all
// player face backgrounds and using displayplayer to choose them:
R_SetPatchNum(&faceback, "STFB0");
// face states
facenum = 0;
for (i=0;i<ST_NUMPAINFACES;i++)