-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path3D_AGENT.C
5291 lines (4303 loc) · 118 KB
/
3D_AGENT.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
// 3D_AGENT.C
#include "3D_DEF.H"
#pragma hdrstop
#include <ctype.h>
#include "jm_tp.h"
void InitWeaponBounce(void);
void HandleWeaponBounce(void);
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
//#define ACTIVATE_TERMINAL
#define MAXMOUSETURN 10
#define MOVESCALE 150l
#define BACKMOVESCALE 100l
#define ANGLESCALE 20
#define MAX_DA 100
#define MAX_TERM_COMMAND_LEN 31
// Max Score displayable
#define MAX_DISPLAY_SCORE (9999999L)
#define SCORE_ROLL_WAIT (60*10) // Tics
// IFDEF switches
//#define NO_STATUS_BAR
// ECG scroll rate (delay).
#define HEALTH_SCROLL_RATE 7
#define HEALTH_PULSE 70
// Text "InfoArea" defines
#define INFOAREA_X 3
#define INFOAREA_Y ((unsigned)200-STATUSLINES+3)
#define INFOAREA_W 109
#define INFOAREA_H 37
#define INFOAREA_BCOLOR 0x01
#define INFOAREA_CCOLOR 0x1A
#define INFOAREA_TCOLOR 0xA6
#define INFOAREA_TSHAD_COLOR 0x04 // Text Shadow Color
#define GRENADE_ENERGY_USE 4
#define BFG_ENERGY_USE (GRENADE_ENERGY_USE<<1)
#define NUM_AMMO_SEGS 21
#define AMMO_SMALL_FONT_NUM_WIDTH 5
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
extern boolean noShots;
extern short bounceOk;
short tryDetonatorDelay=0;
//
// player state info
//
long thrustspeed;
//unsigned plux,pluy; // player coordinates scaled to unsigned
int anglefrac;
objtype *LastAttacker;
boolean PlayerInvisable = false;
char LocationText[MAX_LOCATION_DESC_LEN];
#ifdef ACTIVATE_TERMINAL
char term_com_name[13]= {"TERM_CMD."};
char term_msg_name[13]= {"TERM_MSG."};
#endif
unsigned player_oldtilex;
unsigned player_oldtiley;
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
void writeTokenStr(char far *str);
void ShowOverheadChunk(void);
void LoadOverheadChunk(short tpNum);
void SaveOverheadChunk(short tpNum);
void DisplayTeleportName(char tpNum, boolean locked);
void ForceUpdateStatusBar(void);
void UpdateRadarGuage(void);
void DrawLedStrip(short x,short y,short frac,short max);
void DisplayPinballBonus(void);
void CheckPinballBonus(long points);
byte LevelCompleted(void);
void T_Player (objtype *ob);
void T_Attack (objtype *ob);
statetype s_player = {0,0,0,&T_Player,NULL,NULL};
statetype s_attack = {0,0,0,&T_Attack,NULL,NULL};
long playerxmove,playerymove;
atkinf_t far attackinfo[7][14] =
{
{ {6,0,1},{6,2,2},{6,0,3},{6,-1,4} }, // Auto charge
{ {6,0,1},{6,1,2},{6,0,3},{6,-1,4} }, // Pistol
{ {6,0,1},{6,1,2},{5,3,3},{5,-1,4} }, // Pulse
{ {6,0,1},{6,1,2},{3,4,3},{3,-1,4} }, // ION
{ {6,0,1},{6,5,2},{6,6,3},{6,-1,4} },
{ {6,0,1},{6,9,2},{6,10,3},{6,-1,4} },
{ {5,7,0},{5,8,0},{2,-2,0},{0,0,0} },
};
//int strafeangle[9] = {0,90,180,270,45,135,225,315,0};
#define GD0 0x55
#define YD0 0x35
#define RD0 0x15
#define GD1 0x53
#define YD1 0x33
#define RD1 0x13
char far DimAmmo[2][22] = {{GD0,GD0,GD0,GD0,GD0,GD0,GD0,YD0,YD0,YD0,YD0,YD0,YD0,YD0,RD0,RD0,RD0,RD0,RD0,RD0,RD0,RD0},
{GD1,GD1,GD1,GD1,GD1,GD1,GD1,YD1,YD1,YD1,YD1,YD1,YD1,YD1,RD1,RD1,RD1,RD1,RD1,RD1,RD1,RD1}};
#define GL0 0x58
#define YL0 0x38
#define RL0 0x18
#define GL1 0x56
#define YL1 0x36
#define RL1 0x16
char far LitAmmo[2][22] = {{GL0,GL0,GL0,GL0,GL0,GL0,GL0,YL0,YL0,YL0,YL0,YL0,YL0,YL0,RL0,RL0,RL0,RL0,RL0,RL0,RL0,RL0},
{GL1,GL1,GL1,GL1,GL1,GL1,GL1,YL1,YL1,YL1,YL1,YL1,YL1,YL1,RL1,RL1,RL1,RL1,RL1,RL1,RL1,RL1}};
#define IA_MAX_LINE 30
typedef struct InfoArea_Struct
{
int x,y;
int text_color;
int backgr_color;
int left_margin;
char delay;
char numanims;
char framecount;
} InfoArea_Struct;
unsigned LastMsgPri = 0;
short MsgTicsRemain = 0;
classtype LastInfoAttacker = nothing;
int LastInfoAttacker_Cloaked = 0;
infomsg_type LastMsgType = MT_NOTHING;
InfoArea_Struct InfoAreaSetup;
char DrawRadarGuage_COUNT = 3;
char DrawAmmoNum_COUNT = 3;
char DrawAmmoPic_COUNT = 3;
//char DrawPDAmmoPic_COUNT = 3;
char DrawScoreNum_COUNT = 3;
char DrawWeaponPic_COUNT = 3;
char DrawKeyPics_COUNT = 3;
char DrawHealthNum_COUNT = 3;
char DrawInfoArea_COUNT = 3;
char InitInfoArea_COUNT = 3;
char ClearInfoArea_COUNT = 3;
void DrawWeapon (void);
void GiveWeapon (int weapon);
void GiveAmmo (int ammo);
void DrawGAmmoNum(void);
void DrawMAmmoNum(void);
void DrawPDAmmoMsg(void);
void ComputeAvailWeapons(void);
void SW_HandleActor(objtype *obj);
void SW_HandleStatic(statobj_t *stat,unsigned tilex, unsigned tiley);
//===========================================================================
//----------
byte ShowRatio(short bx, short by, short px, short py, long total, long perc, ss_type type);
void Attack (void);
void Use (void);
void Search (objtype *ob);
void SelectWeapon (void);
void SelectItem (void);
//----------
void SpawnPlayer (int tilex, int tiley, int dir);
void Thrust (int angle, long speed);
boolean TryMove (objtype *ob);
void T_Player (objtype *ob);
boolean ClipMove (objtype *ob, long xmove, long ymove);
void SocketToggle(boolean TurnOn);
void CheckStatsBonus(void);
void T_Stand (objtype *ob);
/*
=============================================================================
CONTROL STUFF
=============================================================================
*/
/*
======================
=
= CheckWeaponChange
=
= Keys 1-6 change weapons
=
=
======================
*/
void CheckWeaponChange (void)
{
int i,buttons,last;
for (i=wp_autocharge;i<=wp_bfg_cannon;i++)
{
if (buttonstate[bt_ready_autocharge+i-wp_autocharge])
{
if (gamestate.useable_weapons & (1<<i))
{
gamestate.weapon = gamestate.chosenweapon = i;
DISPLAY_TIMED_MSG(WeaponAvailMsg, MP_WEAPON_AVAIL, MT_GENERAL);
DrawWeapon();
return;
}
else
DISPLAY_TIMED_MSG(WeaponNotAvailMsg, MP_WEAPON_AVAIL, MT_GENERAL);
}
}
}
/*
=======================
=
= ControlMovement
=
= Takes controlx,controly, and buttonstate[bt_strafe]
=
= Changes the player's angle and position
=
= There is an angle hack because when going 70 fps, the roundoff becomes
= significant
=
=======================
*/
void ControlMovement (objtype *ob)
{
long oldx,oldy;
int angle,maxxmove;
int angleunits;
long speed;
thrustspeed = 0;
oldx = player->x;
oldy = player->y;
//
// side to side move
//
if ((buttonstate[bt_strafe]) && !(gamestate.turn_around))
{
//
// strafing
//
//
if (controlx > 0)
{
angle = ob->angle - ANGLES/4;
if (angle < 0)
angle += ANGLES;
Thrust (angle,controlx*MOVESCALE); // move to left
}
else if (controlx < 0)
{
angle = ob->angle + ANGLES/4;
if (angle >= ANGLES)
angle -= ANGLES;
Thrust (angle,-controlx*MOVESCALE); // move to right
}
}
else
{
if (gamestate.turn_around)
{
controlx = 100*tics;
if (gamestate.turn_around < 0)
controlx = -controlx;
}
//
// not strafing
//
anglefrac += controlx;
angleunits = anglefrac/ANGLESCALE;
anglefrac -= angleunits*ANGLESCALE;
ob->angle -= angleunits;
if (ob->angle >= ANGLES)
ob->angle -= ANGLES;
if (ob->angle < 0)
ob->angle += ANGLES;
if (gamestate.turn_around)
{
boolean done=false;
if (gamestate.turn_around > 0)
{
gamestate.turn_around -= angleunits;
if (gamestate.turn_around <= 0)
done=true;
}
else
{
gamestate.turn_around -= angleunits;
if (gamestate.turn_around >= 0)
done=true;
}
if (done)
{
gamestate.turn_around=0;
ob->angle = gamestate.turn_angle;
}
}
}
//
// forward/backwards move
//
if (controly < 0)
{
Thrust (ob->angle,-controly*MOVESCALE); // move forwards
}
else if (controly > 0)
{
angle = ob->angle + ANGLES/2;
if (angle >= ANGLES)
angle -= ANGLES;
Thrust (angle,controly*BACKMOVESCALE); // move backwards
}
else
if (bounceOk)
bounceOk--;
if (controly)
bounceOk = 8;
else
if (bounceOk)
bounceOk--;
ob->dir = ((ob->angle + 22) % 360)/45;
//
// calculate total move
//
playerxmove = player->x - oldx;
playerymove = player->y - oldy;
}
/*
=============================================================================
STATUS WINDOW STUFF
=============================================================================
*/
#define STATUSDRAWPIC(x, y, picnum) JLatchDrawPic((x),(y+(200-STATUSLINES)),(picnum))
/*
==================
=
= StatusDrawPic
=
==================
*/
void StatusAllDrawPic(unsigned x, unsigned y, unsigned picnum)
{
unsigned temp;
#ifdef PAGEFLIP
temp = bufferofs;
bufferofs = PAGE1START+(200-STATUSLINES)*SCREENWIDTH;
JLatchDrawPic (x,y,picnum);
bufferofs = PAGE2START+(200-STATUSLINES)*SCREENWIDTH;
JLatchDrawPic (x,y,picnum);
bufferofs = PAGE3START+(200-STATUSLINES)*SCREENWIDTH;
JLatchDrawPic (x,y,picnum);
bufferofs = temp;
#else
temp = bufferofs;
bufferofs = screenloc[0]+(200-STATUSLINES)*SCREENWIDTH;
JLatchDrawPic (x,y,picnum);
bufferofs = screenloc[1]+(200-STATUSLINES)*SCREENWIDTH;
JLatchDrawPic (x,y,picnum);
bufferofs = screenloc[2]+(200-STATUSLINES)*SCREENWIDTH;
JLatchDrawPic (x,y,picnum);
bufferofs = temp;
#endif
}
void JLatchDrawPic (unsigned x, unsigned y, unsigned picnum)
{
unsigned wide, height, source;
x <<= 3;
wide = pictable[picnum-STARTPICS].width;
height = pictable[picnum-STARTPICS].height;
source = latchpics[2+picnum-LATCHPICS_LUMP_START];
VL_LatchToScreen (source,wide/4,height,x,y);
}
/*
===============
=
= LatchNumber
=
= right justifies and pads with blanks
=
===============
*/
void LatchNumber (int x, int y, int width, long number)
{
unsigned length,wide=0,c;
char str[20];
ltoa(number,str,10);
length = strlen(str);
while ((length<width) && (wide < width))
{
STATUSDRAWPIC(x,y,N_BLANKPIC);
x++;
wide++;
length++;
}
c = 0;
while (wide<width)
{
STATUSDRAWPIC (x,y,str[c]-'0'+ N_0PIC);
x++;
c++;
wide++;
}
}
//===========================================================================
//
//
// SCORE DISPLAY ROUTINES
//
//
//===========================================================================
//--------------------------------------------------------------------------
// DrawHealth()
//
// PURPOSE : Marks the Health_NUM to be refreshed durring the next
// StatusBarRefresh.
//--------------------------------------------------------------------------
void DrawHealth (void)
{
char *ptr = gamestate.health_str;
itoa(gamestate.health,gamestate.health_str,10);
while (*ptr)
*ptr++ -= '0';
DrawHealthNum_COUNT=3;
}
//--------------------------------------------------------------------------
// DrawHealthNum()
//--------------------------------------------------------------------------
void DrawHealthNum(void)
{
char loop,num;
short check=100;
DrawHealthNum_COUNT--;
for (loop=num=0; loop<3; loop++,check /= 10)
if (gamestate.health < check)
JLatchDrawPic(16+loop,162,NG_BLANKPIC);
else
JLatchDrawPic(16+loop,162,gamestate.health_str[num++]+NG_0PIC);
}
//---------------------------------------------------------------------------
// TakeDamage()
//---------------------------------------------------------------------------
void TakeDamage (int points, objtype *attacker)
{
LastAttacker = attacker;
if (gamestate.flags & GS_ATTACK_INFOAREA)
if (attacker)
{
if ((LastMsgType == MT_ATTACK) && (LastInfoAttacker == attacker->obclass))
MsgTicsRemain = DISPLAY_MSG_STD_TIME;
else
{
if (DISPLAY_TIMED_MSG(ActorInfoMsg[attacker->obclass-rentacopobj],MP_TAKE_DAMAGE,MT_ATTACK))
{
LastInfoAttacker = attacker->obclass;
LastInfoAttacker_Cloaked = attacker->flags2 & FL2_CLOAKED;
}
}
}
if (godmode)
return;
if (gamestate.difficulty==gd_baby)
points>>=2;
gamestate.health -= points;
if (gamestate.health<=0)
{
gamestate.health = 0;
playstate = ex_died;
killerobj = attacker;
if (killerobj)
killerobj->flags |= FL_FREEZE;
}
StartDamageFlash (points);
DrawHealth();
}
//---------------------------------------------------------------------------
// HealSelf()
//---------------------------------------------------------------------------
void HealSelf(int points)
{
gamestate.health += points;
if (gamestate.health > 100)
gamestate.health = 100;
DrawHealth ();
}
//===========================================================================
//
//
// SCORE DISPLAY ROUTINES
//
//
//===========================================================================
//--------------------------------------------------------------------------
// DrawScore()
//
// PURPOSE : Marks the Score to be refreshed durring the next
// StatusBarRefresh.
//--------------------------------------------------------------------------
void DrawScore(void)
{
DrawScoreNum_COUNT = 3;
}
extern unsigned char music_num;
//--------------------------------------------------------------------------
// DrawScoreNum()
//
// NOTE : Could do some sort of "scrolling" animation on LED screen with
// chars and a simple table.....
//--------------------------------------------------------------------------
void DrawScoreNum(void)
{
#define Y 3
#define X 32
if (gamestate.tic_score > MAX_DISPLAY_SCORE)
{
if (gamestate.score_roll_wait)
{
JLatchDrawPic(X+0,(200-STATUSLINES)+Y,N_BLANKPIC);
JLatchDrawPic(X+1,(200-STATUSLINES)+Y,N_DASHPIC);
JLatchDrawPic(X+2,(200-STATUSLINES)+Y,N_RPIC);
JLatchDrawPic(X+3,(200-STATUSLINES)+Y,N_OPIC);
JLatchDrawPic(X+4,(200-STATUSLINES)+Y,N_LPIC);
JLatchDrawPic(X+5,(200-STATUSLINES)+Y,N_LPIC);
JLatchDrawPic(X+6,(200-STATUSLINES)+Y,N_DASHPIC);
}
else
{
LatchNumber(X,Y,7,gamestate.tic_score%(MAX_DISPLAY_SCORE+1));
}
}
else
{
if (gamestate.flags & GS_TICS_FOR_SCORE)
LatchNumber(X,Y,7,realtics);
else
if (gamestate.flags & GS_MUSIC_TEST)
LatchNumber(X,Y,7,music_num);
else
LatchNumber(X,Y,7,gamestate.tic_score);
}
}
//--------------------------------------------------------------------------
// UpdateScore()
//--------------------------------------------------------------------------
void UpdateScore(void)
{
long score_diff, temp_tics;
boolean RollSound;
score_diff = gamestate.score - gamestate.tic_score;
if (score_diff)
{
if (score_diff > 1500)
temp_tics = score_diff>>2;
else
temp_tics = tics<<3;
if (score_diff > temp_tics)
gamestate.tic_score += temp_tics;
else
gamestate.tic_score = gamestate.score;
DrawScore();
}
if (gamestate.score_roll_wait)
{
if ((gamestate.score_roll_wait-=tics) <= 0)
{
gamestate.score_roll_wait = 0;
}
DrawScore();
}
}
//--------------------------------------------------------------------------
// GivePoints()
//
// .score = Holds real score
// .tic_score = Holds displayed score (tic'ing toward .score)
//
//--------------------------------------------------------------------------
void GivePoints(long points,boolean add_to_stats)
{
// Add score to statistics.
//
if (add_to_stats)
gamestuff.level[gamestate.mapon].stats.accum_points += points;
// Check for bonuses!
//
CheckPinballBonus(points);
// Add points to score
//
gamestate.score += points;
}
//===========================================================================
//
//
// SECURITY KEY DISPLAY ROUTINES
//
//
//===========================================================================
//---------------------------------------------------------------------------
// DrawKeys()
//
// PURPOSE : Marks the security key pics to be refreshed during the next
// StatusBarRefresh.
//---------------------------------------------------------------------------
void DrawKeys (void)
{
DrawKeyPics_COUNT = 3;
}
//---------------------------------------------------------------------------
// DrawKeyPics()
//---------------------------------------------------------------------------
void DrawKeyPics(void)
{
char loop;
DrawKeyPics_COUNT--;
for (loop=0; loop<NUMKEYS; loop++)
if (gamestate.numkeys[loop])
JLatchDrawPic(15+2*loop,179,RED_KEYPIC+loop);
else
JLatchDrawPic(15+2*loop,179,NO_KEYPIC);
}
//---------------------------------------------------------------------------
// GiveKey
//---------------------------------------------------------------------------
void GiveKey (int key)
{
gamestate.numkeys[key]++;
DrawKeys();
}
//---------------------------------------------------------------------------
// TakeKey
//---------------------------------------------------------------------------
void TakeKey (int key)
{
gamestate.numkeys[key]--;
DrawKeys();
}
//===========================================================================
//
//
// WEAPON DISPLAY ROUTINES
//
//
//===========================================================================
//---------------------------------------------------------------------------
// DrawWeapon()
//
// PURPOSE : Marks the Weapon pics to be refreshed durring the next
// StatusBarRefresh.
//---------------------------------------------------------------------------
void DrawWeapon(void)
{
DrawWeaponPic_COUNT=3;
DrawAmmo(true);
}
//---------------------------------------------------------------------------
// DrawWeaponPic()
//---------------------------------------------------------------------------
void DrawWeaponPic(void)
{
if (gamestate.weapon == -1)
return;
JLatchDrawPic(31,176,WEAPON1PIC+gamestate.weapon);
DrawWeaponPic_COUNT--;
}
//---------------------------------------------------------------------------
// GiveWeapon()
//---------------------------------------------------------------------------
void GiveWeapon (int weapon)
{
GiveAmmo (6);
if (!(gamestate.weapons & (1<<weapon)))
{
gamestate.weapons |= (1<<weapon);
if (gamestate.weapon < weapon)
{
gamestate.weapon = gamestate.chosenweapon = weapon;
DrawWeapon();
}
}
}
//===========================================================================
//
//
// AMMO DISPLAY ROUTINES
//
//
//===========================================================================
//---------------------------------------------------------------------------
// DrawAmmo()
//
// PURPOSE : Marks the AMMO NUM & AMMO PIC (if necessary) to be refreshed
// durring the next StatusBarRefresh.
//
// NOTE : This re-computes the number of LEDs to be lit.
//---------------------------------------------------------------------------
void DrawAmmo(boolean ForceRefresh)
{
int temp;
unsigned ammo,max_ammo;
ComputeAvailWeapons();
//
// Which weapon are we needing a refresh for?
//
switch (gamestate.weapon)
{
// case wp_plasma_detonators:
// DrawAmmoPic_COUNT = 3;
// DrawAmmoNum_COUNT = 0;
// return;
case wp_autocharge:
DrawAmmoPic_COUNT = 3;
DrawAmmoNum_COUNT = 0;
return;
default:
ammo = gamestate.ammo;
max_ammo = MAX_AMMO;
break;
}
if (ammo)
{
temp = (ammo*NUM_AMMO_SEGS)/max_ammo;
if (!temp)
temp = 1;
}
else
temp = 0;
gamestate.ammo_leds = temp;
if ((temp != gamestate.lastammo_leds) || ForceRefresh)
{
gamestate.lastammo_leds = temp;
DrawAmmoPic_COUNT = 3;
}
DrawAmmoNum_COUNT=3;
}
//---------------------------------------------------------------------------
// DrawAmmoNum()
//---------------------------------------------------------------------------
void DrawAmmoNum(void)
{
if (gamestate.weapon == -1)
return;
fontnumber = 2;
fontcolor = 0x9D;
PrintX = 252;
PrintY = 200-STATUSLINES+38;
#if 0
switch (gamestate.weapon)
{
case wp_plasma_detonators:
case wp_autocharge:
break;
default:
DrawGAmmoNum();
break;
}
#else
DrawGAmmoNum();
#endif
DrawAmmoNum_COUNT--;
}
//---------------------------------------------------------------------------
// DrawGAmmoNum()
//---------------------------------------------------------------------------
void DrawGAmmoNum(void)
{
char buffer[32];
if (gamestate.ammo <100)
{
PrintX+=AMMO_SMALL_FONT_NUM_WIDTH;
if (gamestate.ammo <10)
PrintX+=AMMO_SMALL_FONT_NUM_WIDTH;
}
JLatchDrawPic(31,184,W1_CORNERPIC+gamestate.weapon);
px = PrintX;
py = PrintY;
VW_DrawPropString(ultoa(gamestate.ammo,buffer,10));
VW_DrawPropString("%");
}
//---------------------------------------------------------------------------
// DrawAmmoPic()
//---------------------------------------------------------------------------
void DrawAmmoPic(void)
{
switch (gamestate.weapon)
{
case wp_autocharge:
DrawAmmoMsg();
break;
// case wp_plasma_detonators:
// DrawPDAmmoMsg();
// break;
default:
DrawAmmoGuage();
break;
}
DrawAmmoPic_COUNT--;
}
//---------------------------------------------------------------------------
// DrawAmmoMsg() -
//---------------------------------------------------------------------------
void DrawAmmoMsg(void)
{
if (gamestate.weapon_wait)