forked from elwynor/elwbds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ELWBDS.C
3077 lines (2905 loc) · 78.5 KB
/
ELWBDS.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
/*****************************************************************************
* BattleDroids v2.0 *
* Written by Sean Ferrell of The Sourceror's Guild 1991-1995 *
* *
* June 25, 2012 - Conversion to Worldgroup 3.2 - R. Hadsall *
* *
* Copyright (C) 2005-2024 Rick Hadsall. All Rights Reserved. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as published *
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
* Additional Terms for Contributors: *
* 1. By contributing to this project, you agree to assign all right, title, *
* and interest, including all copyrights, in and to your contributions *
* to Rick Hadsall and Elwynor Technologies. *
* 2. You grant Rick Hadsall and Elwynor Technologies a non-exclusive, *
* royalty-free, worldwide license to use, reproduce, prepare derivative *
* works of, publicly display, publicly perform, sublicense, and *
* distribute your contributions *
* 3. You represent that you have the legal right to make your contributions *
* and that the contributions do not infringe any third-party rights. *
* 4. Rick Hadsall and Elwynor Technologies are not obligated to incorporate *
* any contributions into the project. *
* 5. This project is licensed under the AGPL v3, and any derivative works *
* must also be licensed under the AGPL v3. *
* 6. If you create an entirely new project (a fork) based on this work, it *
* must also be licensed under the AGPL v3, you assign all right, title, *
* and interest, including all copyrights, in and to your contributions *
* to Rick Hadsall and Elwynor Technologies, and you must include these *
* additional terms in your project's LICENSE file(s). *
* *
* By contributing to this project, you agree to these terms. *
* *
*****************************************************************************/
#include "gcomm.h"
#include "majorbbs.h"
#include "elwbds.h"
DFAFILE *bdbb;
typedef struct {
LONG credits; /* Credits */
CHAR weapon; /* Weapon type */
INT xc; /* X coord on field */
INT yc; /* Y coord on field */
CHAR chs; /* Chassis type */
CHAR pwr; /* Power rating */
CHAR cmp; /* Computer rating */
CHAR stb; /* Stability rating */
CHAR man; /* Maneuverablility rating */
CHAR str; /* Strength */
CHAR spd; /* Speed */
CHAR agl; /* Agility */
CHAR trg; /* Targeting */
INT enr; /* Energy available */
INT ar; /* Current armor */
INT mar; /* Maximum armor */
INT rfreq; /* Radio frequencey */
INT pavol; /* PA volume */
INT active; /* Droid is active */
LONG time; /* Time in game */
CHAR inv[12]; /* Inventory */
INT flag; /* Flag */
INT rsp; /* Resource Points */
INT kills; /* Confirmed Kills */
INT cbtdly; /* Combat Delay */
} BDARR;
BDARR *bdarr,*bdptr;
struct bdsave {
CHAR userid[UIDSIZ]; /* User id 30 */
LONG credits; /* Credits 34 */
CHAR weapon; /* Weapon type 35 */
INT xc; /* X coord on field 39 */
INT yc; /* Y coord on field 43 */
CHAR chs; /* Chassis type 44 */
CHAR pwr; /* Power rating 45 */
CHAR cmp; /* Computer rating 46 */
CHAR stb; /* Stability rating 47 */
CHAR man; /* Maneuverablility rating 48 */
CHAR str; /* Strength 49 */
CHAR spd; /* Speed 50 */
CHAR agl; /* Agility 51 */
CHAR trg; /* Targeting 52 */
INT enr; /* Energy available 56 */
INT ar; /* Current armor 60 */
INT mar; /* Maximum armor 64 */
INT rfreq; /* Radio frequency 68 */
INT pavol; /* PA volume 72 */
INT active; /* Droid is active 76 */
CHAR inv[12]; /* Inventory 88 */
INT flag; /* Flag 92 */
INT rsp; /* Resource Points 96 */
INT kills; /* Confirmed Kills 100 */
INT cbtdly; /* Combat Delay 104 */
//CHAR spare[96-84];
} bdsptr;
typedef struct {
CHAR name[21]; /* Borg name */
CHAR user[UIDSIZ]; /* Borg's creator */
LONG credits; /* Credits */
CHAR weapon; /* Weapon type */
INT xc; /* X coord on field */
INT yc; /* Y coord on field */
INT dx; /* X coord of destination */
INT dy; /* Y coord of destination */
INT dir; /* Direction of travel */
CHAR chs; /* Chassis type */
CHAR pwr; /* Power rating */
CHAR cmp; /* Computer rating */
CHAR stb; /* Stability rating */
CHAR man; /* Maneuverablility rating */
CHAR str; /* Strength */
CHAR spd; /* Speed */
CHAR agl; /* Agility */
CHAR trg; /* Targeting */
INT enr; /* Energy available */
INT ar; /* Current armor */
INT mar; /* Maximum armor */
INT active; /* Droid is active */
LONG time; /* Time in game */
INT agr; /* Aggression */
INT mode; /* Active mode */
INT usr; /* Following this user */
INT hst; /* Hostility */
INT mvbl; /* Mode variable */
INT kills; /* Confirmed Kills */
} BDBAR;
BDBAR *bdbar,*bdbpt;
typedef struct {
CHAR name[15]; /* Borg name */
INT lochs; /* Borg low chassis model */
INT hichs; /* Borg high chassis model*/
INT lowep; /* Borg low weapon type */
INT hiwep; /* Borg high weapon type */
} BDBRG;
BDBRG bbrg[]={
{"Blah", 0, 0, 1, 1},
{"Loki", 0, 0, 1, 1},
{"Hermes", 0, 1, 1, 1},
{"Achilles", 1, 2, 2, 2},
{"Proteus", 1, 2, 2, 2},
{"Odysseus", 1, 2, 2, 2},
{"Perseus", 2, 3, 3, 3},
{"Sparticus", 3, 4, 3, 3},
{"Theseus", 3, 4, 3, 3},
{"Prometheus", 4, 5, 4, 4},
{"Freya", 5, 7, 4, 5},
{"Fenris", 6, 8, 4, 6},
{"Thor", 7, 9, 5, 7},
{"Medusa", 10,12, 5, 8},
{"Cyclops", 11,13, 6,10},
{"Titan", 12,14, 8,10},
{"Dragon", 15,15,11,11}};
#define NUM_BBRG (sizeof(bbrg) / sizeof(bbrg[0]))
CHAR brgmode[8][20]={
"Wander",
"Evade",
"Visit Location",
"Follow User",
"Follow Borg",
"Garrison",
"Visit Base",
"Patrol"};
#define NBORGS 50
typedef struct {
CHAR *name; /* obj name */
CHAR *desc; /* obj description */
LONG price; /* price */
} BDOBJ;
BDOBJ bobj[]={
{"Blah-1","a blah beam",0L},
{"Laser-1","a laser beam",100L},
{"Blaster-1","a particle beam",250L},
{"Plasmagun-1","a plasma beam",500L},
{"Disruptor-1","a disruptor beam",750L},
{"Laser-2","a powerful laser beam",2000L},
{"Blaster-2","a powerful particle beam",5000L},
{"Plasmagun-2","a powerful plasma beam",10000L},
{"Disruptor-2","a powerful disruptor beam",15000L},
{"Laser-3","a pulsed laser beam",20000L},
{"Blaster-3","a pulsed particle beam",50000L},
{"Plasmagun-3","a pulsed plasma beam",100000L},
{"Disruptor-3","a pulsed disruptor beam",150000L},
{"Laser-4","a barrage of pulsed laser beams",100000L},
{"Blaster-4","a barrage of pulsed particle beams",250000L},
{"Plasmagun-4","a barrage of pulsed plasma beams",500000L},
{"Disruptor-4","a barrage of pulsed disruptor beams",750000L},
{"RK-1","",50L},
{"RK-2","",500L},
{"RK-3","",1500L},
{"ER-Scanner","",2500L},
{"EnergyScreen","",5000L},
{"SRM-1","an explosion",100L},
{"SRM-2","an explosion",250L},
{"SRM-3","an explosion",500L},
{"SRM-4","an explosion",750L},
{"MRM-1","an explosion",1000L},
{"MRM-2","an explosion",1500L},
{"MRM-3","an explosion",2000L},
{"MRM-4","an explosion",2500L},
{"LRM-1","an explosion",3250L},
{"LRM-2","an explosion",4000L},
{"LRM-3","an explosion",4750L},
{"LRM-4","an explosion",5500L},
{"ERM-1","an explosion",6500L},
{"ERM-2","an explosion",8500L},
{"ERM-3","an explosion",11500L},
{"ERM-4","an explosion",15500L},
{"LM-1", "shrapnel",100L},
{"LM-2", "shrapnel",250L},
{"LM-3", "shrapnel",500L},
{"LM-4", "shrapnel",1000L},
{"LM-5", "shrapnel",2000L}};
#define NUM_BOBJ (sizeof(bobj) / sizeof(bobj[0]))
#define NUMITM 42
#define IRK1 17
#define IRK2 18
#define IRK3 19
#define IERS 20
#define ISCR 21
#define IMS1 22
#define IMS2 23
#define IMS3 24
#define IMS4 25
#define IMS5 26
#define IMS6 27
#define IMS7 28
#define IMS8 29
#define IMS9 30
#define IMS10 31
#define IMS11 32
#define IMS12 33
#define IMS13 34
#define IMS14 35
#define IMS15 36
#define IMS16 37
#define ILM1 38
#define ILM2 39
#define ILM3 40
#define ILM4 41
#define ILM5 42
typedef struct {
INT mindm; /* Minimum Damage */
INT maxdm; /* Maximum Damage */
INT range; /* Range */
INT pwrus; /* Power Use */
INT distd; /* Distance to Detect */
} BDWEP;
BDWEP bwep[]={
{ 0, 0, 0, 0, 0},
{ 2, 4, 6, 4, 1},
{ 3, 6, 5, 5, 2},
{ 7, 14, 4, 10, 3},
{ 9, 18, 3, 12, 4},
{ 4, 8, 12, 8, 2},
{ 6, 12, 10, 10, 4},
{ 14, 28, 8, 20, 6},
{ 18, 36, 6, 24, 8},
{ 8, 16, 24, 16, 3},
{ 12, 24, 20, 20, 8},
{ 28, 56, 16, 40, 12},
{ 36, 72, 12, 48, 15},
{ 16, 32, 48, 32, 6},
{ 24, 48, 40, 40, 16},
{ 56,112, 32, 80, 24},
{ 72,144, 24, 96, 31}};
#define NUM_BWEP (sizeof(bwep) / sizeof(bwep[0]))
typedef struct {
INT mindm; /* Minimum Damage */
INT maxdm; /* Maximum Damage */
INT range; /* Range */
} BDMIS;
BDWEP bmis[]={
{ 2, 4, 10},
{ 3, 6, 10},
{ 4, 8, 10},
{ 5, 10, 10},
{ 7, 14, 20},
{ 10, 20, 20},
{ 14, 28, 20},
{ 18, 36, 20},
{ 23, 46, 40},
{ 28, 56, 40},
{ 34, 68, 40},
{ 40, 80, 40},
{ 50,100,100},
{ 65,130,100},
{ 80,160,100},
{100,200,100}
};
typedef struct {
INT x; /* X Coord */
INT y; /* Y Coord */
INT time; /* Time Left */
INT damage; /* Damage */
INT item; /* Item Number */
} BLAST;
BLAST missle[100],mine[100];
typedef struct {
CHAR *name; /* Chassis name */
CHAR *type; /* Chassis type */
INT weight; /* Chassis weight */
INT armor; /* Chassis armor */
INT pwr; /* Chassis Power Rating */
INT cmp; /* Chassis Computer Rating */
INT stb; /* Chassis stability */
INT man; /* Chassis Maneuverability */
INT str; /* Chassis Strength */
INT spd; /* Chassis Speed */
INT agl; /* Chassis Agility */
INT trg; /* Chassis Targeting */
INT wep; /* Maximum Weapon Power */
INT mis; /* Missle Capabilities */
INT min; /* Landmine Capabilities */
LONG price; /* Chassis price */
} BDCHS;
BDCHS bchs[]={
{"Imp" ,"Biped",
1, 20, 1, 1, 5, 80, 5, 80, 90, 5, 4, 0, 0, 2000L},
{"Scorpion" ,"Insectoid",
2, 30, 2, 2, 10, 90, 10, 90,100, 10, 4, 1, 0, 5000L},
{"Stilleto" ,"Biped",
3, 40, 2, 3, 10,100, 10, 80, 90, 20, 5, 1, 0, 10000L},
{"Weasel" ,"Quadruped",
4, 50, 2, 4, 20, 95, 15,100, 95, 25, 5, 0, 1, 15000L},
{"Rapier" ,"Biped",
5, 60, 3, 5, 15, 90, 20, 80, 90, 40, 5, 2, 0, 20000L},
{"Griffon" ,"Quadruped",
10, 80, 4, 6, 35, 90, 30, 90, 90, 50, 10, 0, 1, 30000L},
{"Marauder" ,"Insectoid",
15, 100, 5, 7, 30, 90, 35, 80, 85, 55, 10, 2, 0, 35000L},
{"Archer" ,"Tracked",
20, 120, 5, 8, 45, 80, 35, 60, 70, 55, 10, 2, 1, 45000L},
{"Jackal" ,"Quadruped",
25, 140, 6, 9, 40, 85, 40, 75, 75, 60, 12, 1, 0, 60000L},
{"Centaur" ,"Quadruped",
30, 160, 7, 9, 45, 85, 40, 70, 75, 60, 12, 1, 1, 80000L},
{"Ares" ,"Biped",
35, 180, 7, 10, 40, 75, 45, 65, 70, 65, 12, 1, 0,110000L},
{"Hyperion" ,"Biped",
40, 200, 8, 11, 45, 75, 45, 65, 70, 70, 16, 2, 0,150000L},
{"Vulcan" ,"Biped",
45, 230, 9, 11, 50, 75, 50, 60, 65, 75, 16, 2, 0,200000L},
{"Shiva" ,"Insectoid",
50, 250, 10, 10, 70, 90, 55, 70, 75, 70, 16,10, 1,275000L},
{"Pleiades" ,"Tracked",
55, 260, 10, 11, 70, 80, 55, 70, 75, 70, 20, 2, 1,300000L},
{"Centipede" ,"Insectoid",
60, 270, 11, 10, 75, 90, 60, 80, 75, 75, 20, 2, 1,350000L},
{"Juggernaut" ,"Biped",
65, 280, 10, 12, 60, 75, 65, 60, 60, 80, 20, 4, 0,375000L},
{"Unicorn" ,"Quadruped",
70, 290, 12, 12, 70, 85, 65, 70, 70, 75, 24, 4, 1,425000L},
{"Phoenix" ,"Biped",
75, 300, 12, 14, 60, 75, 70, 60, 50, 80, 24, 2, 0,475000L},
{"Viper" ,"Tracked",
80, 330, 13, 13, 75, 80, 70, 60, 55, 85, 24, 4, 1,500000L},
{"Spectre" ,"Insectoid",
85, 350, 15, 15, 90, 90, 60, 70, 90, 90, 32, 4, 1,550000L},
{"Ferret" ,"Quadruped",
90, 360, 15, 12, 90, 85, 70, 70, 75, 90, 32, 4, 1,600000L},
{"Colossus" ,"Biped",
95, 400, 14, 13, 75, 75,100, 60, 55, 95, 32, 2, 0,650000L},
{"Goliath" ,"Tracked",
100, 450, 14, 14,100, 80,100, 60, 60,100, 40, 4, 1,700000L},
{"Seraph" ,"Quadruped",
120, 480, 14, 15, 80, 85, 85, 70, 75,100, 40, 4, 0,800000L},
{"Puck" ,"Insectoid",
140, 560, 15, 15, 85, 90, 90, 70, 90,100, 40, 4, 0,900000L},
{"Gremlin" ,"Biped",
160, 640, 15, 16, 80, 80, 80, 60, 55,100, 48, 4, 0,1000000L},
{"Rakshasa" ,"Quadruped",
180, 720, 15, 17, 85, 85, 85, 70, 75,100, 48, 4, 0,1100000L},
{"Diablo" ,"Tracked",
200, 800, 16, 16, 85, 80, 90, 60, 60,100, 48, 4, 1,1200000L},
{"Fury" ,"Tracked",
225, 900, 17, 16, 85, 80, 90, 60, 60,100, 80, 4, 0,1300000L},
{"Nymph" ,"Insectoid",
250,1000, 17, 17, 90, 90, 95, 70, 90,100, 80,10, 1,1400000L},
{"Brahma" ,"Biped",
275,1100, 18, 17, 80, 80, 80, 60, 55,100, 80, 4, 0,1500000L},
{"Devaki" ,"Tracked",
300,1200, 19, 18, 85, 80,100, 60, 60,100, 80,10, 0,1600000L},
{"Savitar" ,"Quadruped",
350,1400, 20, 19, 85, 85,115, 70, 75,100, 96,10, 1,1700000L},
{"Lotus" ,"Biped",
400,1600, 30, 21, 80, 80,130, 60, 55,100, 96, 4, 0,1800000L},
{"Apocalypse" ,"Tracked",
450,1800, 40, 23,100, 80,150, 60, 60,100, 96,10, 0,1900000L},
{"Dragon" ,"Quadruped",
500,2000, 50, 25,100, 20,200, 55, 70,100, 96,10, 1,2000000L}};
#define CHSMOD 37
CHAR *sensor[]={
"movement",
"rapid movement",
"slow movement",
"an explosion",
"an energy blast",
"small explosions",
"a missle arming",
"blah",
"energy pulse",
"energy pulse",
"energy pulse",
"energy pulse",
"energy burst",
"energy burst",
"energy burst",
"energy burst",
"several energy bursts",
"several energy bursts",
"several energy bursts",
"several energy bursts",
"a multitude of energy bursts",
"a multitude of energy bursts",
"a multitude of energy bursts",
"a multitude of energy bursts",
"transport ship",
"heavy impact"};
HMCVFILE bdmb;
INT newstt;
CHAR sel;
INT upddrd;
INT movbrg;
INT spnbrg;
INT chbrgd;
INT dist;
INT showlon;
/***
INT bdnl;
***/
CHAR *dirxl[]={"N","NE","E","SE","S","SW","W","NW"};
CHAR *dirbds[]={"south","southwest","west","northwest","north","northeast","east","southeast"};
CHAR *dirds[]={"north","northeast","east","southeast","south","southwest","west","northwest"};
CHAR *dircds[]={"North","Northeast","East","Southeast","South","Southwest","West","Northwest"};
INT dirmx[]={0,1,1,1,0,-1,-1,-1};
INT dirmy[]={-1,-1,0,1,1,1,0,-1};
typedef struct {
CHAR *name1; /* Obj Name 1 */
CHAR *name2; /* Obj Name 2 */
INT xc; /* Obj X coords */
INT yc; /* Obj Y coords */
} BDTER;
BDTER bter[]={
{"a huge building","the shop",2500,2500},
{"a large building","a headquarters building",2400,2400},
{"a large building","a headquarters building",2600,2600},
{"a large building","a headquarters building",2400,2600},
{"a large building","a headquarters building",2600,2400},
{"a building complex","a cyborg base",2500,2300},
{"a building complex","a cyborg base",2500,2700},
{"a building complex","a cyborg base",2300,2500},
{"a building complex","a cyborg base",2700,2500}
};
#define NTOBJS 9
INT chkbdu(INT usrn);
VOID bdkick(VOID);
VOID updbrg(VOID);
INT genbrg(INT brg, INT usr);
VOID updbchs(INT chs);
INT desbrg(INT brg, INT usr);
VOID brgmod(INT brg);
VOID brgdir(INT brg);
VOID brgmov(INT brg);
VOID mbrgto(INT who, INT newx, INT newy);
INT brgatt(INT brg);
VOID bdmnu(VOID);
GBOOL crsbd(VOID);
INT bdinp(VOID);
INT scan(INT who, INT max, INT di);
INT bscan(INT who, INT brg, INT max, INT di);
INT blast(BLAST *obj);
GBOOL logbd(VOID);
VOID radout(INT user);
VOID outloc(INT xc,INT yc,INT user,INT othusr);
VOID outall(INT user,INT othusr);
VOID outusr(INT brg);
VOID gendrd(VOID);
VOID updchs(INT chs);
INT drdcnt(VOID);
INT brgcnt(VOID);
INT btpcnt(CHAR *type);
VOID shwsta(VOID);
INT locdrd(CHAR *uid);
INT locbrg(CHAR *bid);
VOID lstbrg(INT usr);
INT scndrd(CHAR *drd, INT ds);
INT bscndrd(CHAR *drd, INT brg, INT ds);
VOID scnbrg(INT brg);
VOID exitbd(VOID);
INT bdgdir(CHAR *s);
INT chkdirf(INT xc, INT yc, INT xo, INT yo);
VOID gensnsu(INT from, INT type, INT max, INT pmt ,INT user);
VOID gensns(INT xloc, INT yloc, INT type, INT max, INT user);
VOID pasys(INT xloc, INT yloc, INT volume, CHAR *messg);
VOID shop(VOID);
VOID bdpmt(VOID);
VOID moveto(INT x, INT y);
INT bdmove(CHAR *whatd);
INT comm(CHAR *msg);
INT dmgdrd(INT usr, INT brg, INT who, INT damg, INT itnm, CHAR *dir, INT pmt, INT user);
INT dmgbrg(INT usr, INT brg, INT who, INT damg);
INT fire(CHAR *dir);
INT radio(CHAR *msg);
INT bdinv(INT cmd);
INT putms(INT dmg, INT nm);
INT putlm(INT dmg, INT nm);
INT use(CHAR *what);
INT arm(CHAR *what,INT ds);
INT launch(CHAR *d,INT ds);
VOID scanner(CHAR *d, INT scand);
VOID bscanner(CHAR *d, INT brg, INT scand);
INT attack(CHAR *who);
VOID playbd(VOID);
VOID strbd(VOID);
INT getnum(CHAR *us);
INT invspc(VOID);
VOID bdbuy(VOID);
VOID bdsell(VOID);
INT numinv(INT who, INT obj);
INT bdnum(CHAR *tmpstr);
INT bdrand(INT lo,INT hi);
VOID setbd(VOID);
VOID shtbd(VOID);
VOID hupbd(VOID);
VOID delbd(CHAR *id);
VOID bdlpl(VOID);
VOID bdspl(VOID);
#define VERSION "2.0"
INT bdstt; /* BattleDroids State Number */
struct module elwbds={ /* Module interface block */
"", /* Description for main menu (config'able) */
logbd, /* user logon supplemental routine */
crsbd, /* input routine if selected */
dfsthn, /* status-input routine if selected */
NULL, /* "injoth" routine for this module */
NULL, /* user logoff supplemental routine */
hupbd, /* hangup (lost carrier) routine */
NULL, /* midnight cleanup routine */
delbd, /* delete-account routine */
shtbd, /* finish-up (sys shutdown) routine */
};
/****************************************************************************/
INT
chkbdu(INT usrn)
{
if ((usrn>=0) && (usrn<=nterms)) {
if ((usroff(usrn)->usrcls<=SUPIPG) ||
(usroff(usrn)->state!=bdstt) ||
(bdarr[usrn].active==0))
return(0);
if (usroff(usrn)->substt!=PLYBD)
return(2);
return(1);
} else return(0);
}
VOID EXPORT
init__elwbds(VOID)
{
INT i;
shocst(spr("ELW BattleDroids v%s",VERSION),"(C) Copyright 2005-2024 Elwynor Technologies - www.elwynor.com");
stzcpy(elwbds.descrp,gmdnam("ELWBDS.MDF"),MNMSIZ);
bdstt=register_module(&elwbds);
bdbb=dfaOpen("elwbds.dat",sizeof(struct bdsave),NULL);
bdarr=(BDARR *)alczer(nterms*sizeof(BDARR));
bdbar=(BDBAR *)alczer(NBORGS*sizeof(BDBAR));
for (i=0; i<NBORGS; i++) bdbar[i].active=0;
bdmb=opnmsg("elwbds.mcv");
setmbk(bdmb);
showlon=ynopt(SHOWLON);
#ifdef __BUILDV10MODULE
srand((unsigned)time(NULL)); // BBSV10
#else
randomize(); // WG32
#endif
rtkick(20,bdkick);
}
VOID
bdkick(VOID)
{
BDARR *bdtp;
INT i,p;
setbd();
if (++upddrd==2) {
upddrd=0;
for (i=0; i<nterms; i++) {
if (chkbdu(i)==1) {
bdtp=&bdarr[i];
p=(bdtp->pwr*5);
if (bdtp->enr<p) {
bdtp->enr+=bdtp->pwr;
if (bdtp->enr>p) bdtp->enr=p;
}
bdtp->time+=2;
bdtp->cbtdly-=2;
if (bdtp->cbtdly<1) bdtp->cbtdly=0;
}
}
updbrg();
}
for (i=0; i<100; i++) {
if (missle[i].damage)
if (!(--missle[i].time)) blast(&missle[i]);
if (mine[i].damage)
if (!(--mine[i].time)) mine[i].damage=0;
}
rtkick(1,bdkick);
}
VOID updbrg(VOID)
{
INT i,p;
setbd();
if (++movbrg==2) movbrg=0;
if (++chbrgd==10) chbrgd=0;
if (++spnbrg==20) spnbrg=0;
for (i=0; i<NBORGS; i++) {
if (bdbar[i].active == 1) {
bdbar[i].time+=2;
if (upddrd == 0) {
p=(bdbar[i].pwr*5);
if (bdbar[i].enr<p) bdbar[i].enr+=bdbar[i].pwr;
if (bdbar[i].enr>p) bdbar[i].enr=p;
}
if (movbrg == 0) {
brgmod(i);
brgdir(i);
if ((bdbar[i].mode==1) || ((bdrand(1,100) > bdbar[i].agr) &&
((bdbar[i].mode == 7) || (bdbar[i].dx != bdbar[i].xc) ||
(bdbar[i].dy != bdbar[i].yc)))) {
brgmov(i);
} else brgatt(i);
}
}
}
}
INT
genbrg(INT brg, INT usr)
{
INT j,k,b,c,rb;
CHAR brgnum[12]; // sufficient to hold the largest possible integer - RH to elim V10 crash
CHAR *dash="-",*zero1="0",*zero2="00"; // *brgnum="" RH eliminate V10 crash
setbd();
b=-1;
for (j=0; j<NBORGS; j++) {
if (bdbar[j].active == 0) {
b=j;
j=NBORGS;
}
}
if (b == -1) return(0);
bdbpt=&bdbar[b];
if (usr <= -1) strcpy(bdbpt->user,"System***");
else strcpy(bdbpt->user,uacoff(usr)->userid);
bdbpt->credits=0;
bdbpt->xc= 2526-bdrand(1,51);
bdbpt->yc= 2526-bdrand(1,51);
bdbpt->dx= -1;
bdbpt->dy= -1;
bdbpt->dir=(bdrand(1,8)-1);
bdbpt->agr=bdrand(25,50);
bdbpt->mode=0;
bdbpt->mvbl=0;
bdbpt->usr=-1;
bdbpt->hst= 1;
bdbpt->kills=0;
if ((brg < 1) || (brg > 23) ||
((brg > 23) && (!sameas(usaptr->userid, "Sysop")))) rb = (bdrand(1, 9));
else if (brg > NUM_BBRG - 1) rb = bdrand(1, 9); else rb = brg; // RH 6/19/2024 to eliminate C6385 Reading invalid data
bdbpt->weapon=(CHAR)bdrand(bbrg[rb].lowep,bbrg[rb].hiwep);
updbchs(bdrand(bbrg[rb].lochs,bbrg[rb].hichs));
strcpy(bdbar[b].name,bbrg[rb].name);
c = btpcnt(bbrg[rb].name);
strcat(bdbar[b].name, dash);
if (c < 10) strcat(bdbar[b].name, zero2);
else if (c < 100) strcat(bdbar[b].name, zero1);
itoa(c, brgnum, 10);
strcat(bdbar[b].name, brgnum);
for (k=0; k<NBORGS; k++)
if ((sameas(bdbar[b].name,bdbar[k].name)) &&
(b != k) && (bdbar[k].active == 1)) return(0);
if (usr > -1) {
if (bchs[bdbar[b].chs].weight > bdarr[usrnum].rsp) {
prfmlt(LOWRSP);
outmlt(usrnum);
return(0);
} else {
bdarr[usrnum].rsp-=bchs[bdbar[b].chs].weight;
prfmlt(SPAWNB,b,bdbar[b].name);
outmlt(usrnum);
}
}
if (strlen(bdbar[b].name) > 4) {
bdbpt->active=1;
bdbpt->time=0;
prfmlt(TRNSIN,bdbar[b].name);
bdpmt();
outloc(bdbpt->xc,bdbpt->yc,-1,-1);
gensns(bdbpt->xc,bdbpt->yc,24,5,usr);
return(1);
}
return(0);
}
VOID
updbchs(INT chs)
{
bdbpt->chs= (CHAR)chs;
bdbpt->pwr= (CHAR)bchs[chs].pwr;
bdbpt->cmp= (CHAR)bchs[chs].cmp;
bdbpt->stb= (CHAR)bchs[chs].stb;
bdbpt->man= (CHAR)bchs[chs].man;
bdbpt->str= (CHAR)bchs[chs].str;
bdbpt->spd= (CHAR)bchs[chs].spd;
bdbpt->agl= (CHAR)bchs[chs].agl;
bdbpt->trg= (CHAR)bchs[chs].trg;
bdbpt->enr= bdbpt->pwr*5;
bdbpt->ar= bchs[chs].armor;
bdbpt->mar= bchs[chs].armor;
}
INT
desbrg(INT brg, INT usr)
{
INT j;
setbd();
if (brg < 0) {
for (j=0; j<NBORGS; j++) {
if (bdbar[j].active == 1) {
bdbar[j].active=0;
prfmlt(TRNSOT,bdbar[j].name);
bdpmt();
outloc(bdbar[j].xc,bdbar[j].yc,-1,-1);
gensns(bdbar[j].xc,bdbar[j].yc,24,5,-1);
}
}
return(1);
} else if (sameas(uacoff(usr)->userid,bdbar[brg].user)) {
if (bdbar[brg].active == 1) {
bdbar[brg].active=0;
prfmlt(TRNSOT,bdbar[brg].name);
bdpmt();
outloc(bdbar[brg].xc,bdbar[brg].yc,-1,-1);
gensns(bdbar[brg].xc,bdbar[brg].yc,24,5,-1);
bdarr[usr].rsp+=bchs[bdbar[brg].chs].weight;
return(1);
}
}
return(0);
}
VOID
brgmod(INT brg)
{
LONG a,ca,ma;
if ((bdbar[brg].ar >= 1) && (bdbar[brg].mar > 4) && (bdbar[brg].mar < 2001)) {
ca=(bdbar[brg].ar*100000L);
ma=(bdbar[brg].mar*1000L);
a=(ca/ma);
} else a=0;
// chkdirf(bdbar[brg].xc,bdbar[brg].yc,bdbar[brg].dx,bdbar[brg].dy);
if ((a > (50-bdbar[brg].agr)) && (bdbar[brg].mode < 2))
bdbar[brg].mode=0;
else if (bdbar[brg].mode < 2)
bdbar[brg].mode=1;
else if (((bdbar[brg].mode == 7) && (bdbar[brg].dx==-1)) ||
((bdbar[brg].mode == 6) && (bdbar[brg].dx==-1)) ||
((bdbar[brg].mode == 5) && (bdbar[brg].dx==-1)) ||
((bdbar[brg].mode == 4) && (bdbar[bdbar[brg].usr].active==0)) ||
((bdbar[brg].mode == 3) && (chkbdu(bdbar[brg].usr)==0)) ||
((bdbar[brg].mode == 2) && (bdbar[brg].dx == bdbar[brg].xc) &&
(bdbar[brg].dy == bdbar[brg].yc))) {
bdbar[brg].mode=bdbar[brg].mvbl=0;
bdbar[brg].usr=bdbar[brg].dx=bdbar[brg].dy=-1;
} else if ((bdbar[brg].mode == 6) && (bdbar[brg].dx == bdbar[brg].xc) &&
(bdbar[brg].dy == bdbar[brg].yc))
bdbar[brg].mode=7;
else if ((bdbar[brg].mode == 7) && (dist > bdbar[brg].mvbl))
bdbar[brg].mode=6;
}
VOID
brgdir(INT brg)
{
if ((bdbar[brg].usr != -1) && (chkbdu(bdbar[brg].usr)==1) &&
(bdbar[brg].mode==3)) {
bdbar[brg].dx=bdarr[bdbar[brg].usr].xc;
bdbar[brg].dy=bdarr[bdbar[brg].usr].yc;
} else if ((bdbar[brg].mode==4) && (bdbar[bdbar[brg].usr].active==1)) {
bdbar[brg].dx=bdbar[bdbar[brg].usr].xc;
bdbar[brg].dy=bdbar[bdbar[brg].usr].yc;
} else {
bdbar[brg].usr=-1;
bdbar[brg].hst=1;
}
if ((chbrgd == 0) && ((bdbar[brg].mode == 0) || (bdbar[brg].mode == 7)))
bdbar[brg].dir=(bdrand(1,8)-1);
else if ((movbrg == 0) && (bdbar[brg].dx > -1) && (bdbar[brg].dy > -1) &&
((bdbar[brg].dx != bdbar[brg].xc) || (bdbar[brg].dy != bdbar[brg].yc))
&& (bdbar[brg].mode != 1) && (bdbar[brg].mode != 7))
bdbar[brg].dir=chkdirf(bdbar[brg].xc,bdbar[brg].yc,
bdbar[brg].dx,bdbar[brg].dy);
}
VOID
brgmov(INT brg)
{
INT td,tx,ty,nx,ny;
/*tx=ty=nx=ny=0;*/
tx=(bdbar[brg].xc+dirmx[bdbar[brg].dir]);
ty=(bdbar[brg].yc+dirmy[bdbar[brg].dir]);
if ((tx < 2400 || tx > 2600 || ty < 2400 || ty > 2600) && (bdbar[brg].mode == 0)) {
td=(bdbar[brg].dir-4);
if (td<0) td=(bdbar[brg].dir+4);
bdbar[brg].dir=td;
nx=(bdbar[brg].xc+dirmx[bdbar[brg].dir]);
ny=(bdbar[brg].yc+dirmy[bdbar[brg].dir]);
} else {
nx=(bdbar[brg].xc+dirmx[bdbar[brg].dir]);
ny=(bdbar[brg].yc+dirmy[bdbar[brg].dir]);
}
if (bdbar[brg].enr-=((bchs[bdbar[brg].chs].weight/5)+1)>=0) {
bdbar[brg].enr-=((bchs[bdbar[brg].chs].weight/5)+1);
if (nx >= 0 || nx <= 5000 || ny >= 0 || ny <= 5000)
mbrgto(brg,nx,ny);
else
desbrg(brg,-1);
}
}
VOID
mbrgto(INT who, INT newx, INT newy)
{
INT l;
setbd();
gensns(bdbar[who].xc,bdbar[who].yc,0,((bchs[bdbar[who].chs].weight/5)+2),-1);
prfmlt(LEVING,bdbar[who].name,dirds[bdbar[who].dir]);
bdpmt();
outloc(bdbar[who].xc,bdbar[who].yc,-1,-1);
prfmlt(DROIDAR,bdbar[who].name);
bdpmt();
outloc(newx,newy,-1,-1);
bdbar[who].xc=newx;
bdbar[who].yc=newy;
for (l=0; l<100; l++)
if (mine[l].damage)
if (mine[l].x==newx && mine[l].y==newy) blast(&mine[l]);
}
INT
brgatt(INT brg)
{
INT u,b,d,dm,ds,dir,m,sp,sc;
setbd();
u=-1;
b=-1;
dir=-1;
ds=5001;
for (m=0; m<nterms; m++) {
if ((usroff(m)->state == bdstt) && (usroff(m)->substt == PLYBD) &&
(bdarr[m].active==1)) {
d=chkdirf(bdbar[brg].xc,bdbar[brg].yc,bdarr[m].xc,bdarr[m].yc);
if ((bdbar[brg].hst == 1) ||
((bdbar[brg].usr != m) && (bdbar[brg].mode == 3)) || (bdbar[brg].mode != 3)) {
if ((bdarr[m].xc!=2500) || (bdarr[m].yc!=2500)) {
if (dist < ds) {
if (!sameas(uacoff(m)->userid,bdbar[brg].user)) {
u=m;
dir=d;
ds=dist;
if (u==bdbar[m].usr) m=nterms;
}
}
}
}
}
}
for (m=0; m<NBORGS; m++) {
if ((bdbar[m].active==1) && (m != brg)) {
d=chkdirf(bdbar[brg].xc,bdbar[brg].yc,bdbar[m].xc,bdbar[m].yc);
if ((bdbar[brg].hst == 1) ||
((bdbar[brg].usr != m) && (bdbar[brg].mode == 4)) || (bdbar[brg].mode != 4)) {
if ((bdbar[m].xc!=2500) || (bdbar[m].yc!=2500)) {
if (!sameas(bdbar[brg].user,bdbar[m].user)) {
if (dist < ds) {
u=-1;
b=m;
dir=d;
ds=dist;
if (b==bdbar[m].usr) m=NBORGS;
}
}
}
}
}
}
if ((ds > 0) && (ds <= bwep[bdbar[brg].weapon].range) &&
(bwep[bdbar[brg].weapon].pwrus <= bdbar[brg].enr) &&
((u != -1) || (b != -1))) {
bdbar[brg].enr-=bwep[bdbar[brg].weapon].pwrus;
prfmlt(FIROTH,bdbar[brg].name,bobj[bdbar[brg].weapon].name,dirds[bdgdir(dirxl[dir])]);
bdpmt();
outloc(bdbar[brg].xc,bdbar[brg].yc,-1,-1);
gensns(bdbar[brg].xc,bdbar[brg].yc,7+bdbar[brg].weapon,bwep[bdbar[brg].weapon].distd,-1);
dm=(bdrand(bwep[bdbar[brg].weapon].mindm,bwep[bdbar[brg].weapon].maxdm));
if (u != -1) {
if (numinv(u,ISCR)==-1) sp=0;
else sp=(bdarr[u].pwr*2);
if (sp > 20) sp=20;
if (sp > 0) sc=bdrand((bdarr[u].pwr/2),sp);
else sc=0;
dm-=sc;
if (dm <= 0) {
prfmlt(BDDMG3,bobj[bdbar[brg].weapon].desc,dirbds[dir]);
bdpmt();
outmlt(u);
}
dmgdrd(-1,brg,u,dm,bdbar[brg].weapon,dirxl[dir],-1,-1);
} else dmgbrg(-1,brg,b,dm);
return(1);
} else if ((ds == 0) && ((u != -1) || (b != -1))) {
if ((bdbar[brg].enr-((bchs[bdbar[brg].chs].weight/5)+1)) >= 0) {
bdbar[brg].enr-=((bchs[bdbar[brg].chs].weight/5)+1);
if (u != -1) {
if ((bdrand(1,100))>bdbar[brg].agl) {
prfmlt(BDMSYU,bdbar[brg].name);
bdpmt();
outmlt(u);
prfmlt(BDMSOT,bdbar[brg].name,uacoff(u)->userid);
bdpmt();
outloc(bdbar[brg].xc,bdbar[brg].yc,u,-1);
} else {
dm=bdrand(((bchs[bdbar[brg].chs].weight/5)+1),((bchs[bdbar[brg].chs].weight/2)+2));
prfmlt(BDDMYU,bdbar[brg].name,dm);
bdpmt();
outmlt(u);