-
Notifications
You must be signed in to change notification settings - Fork 18
/
locale.pp
3091 lines (2700 loc) · 90.8 KB
/
locale.pp
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
unit locale;
{ This unit handles maps & terrain. It doesn't handle }
{ the screen output of said maps. }
{ Also, it handles definitions for SCENE and TEAM gears. }
{
GearHead: Arena, a roguelike mecha CRPG
Copyright (C) 2005 Joseph Hewitt
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
The full text of the LGPL can be found in license.txt.
This library 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
interface
uses gears,movement;
Type
TerrDesc = Record
name: String;
Pass: Integer;
MMPass: Array [1..NumMoveMode ] of Boolean;
Obscurement: Byte;
Altitude: SmallInt;
DMG: Byte; { How much damage required to destroy this terrain. 0 = Cannot be damaged further. }
Destroyed: Integer; { When the terrain is destroyed, what terrain it becomes. }
Flammable: Boolean; { Will it burn? }
end;
Const
NAG_ParaLocation = -6;
NAS_OriginalHome = 255; { The constant is high to avoid conflicts with LOCATION vars copied by PARALOCATION. }
{ This variable holds the scene number from which the }
{ gear in question was originally taken, and to which }
{ it will be returned once the current scene is over. }
NAG_Location = -1; { Numeric Attribute : Map Location }
NAS_X = 0;
NAS_Y = 1;
NAS_D = 2;
NAS_Team = 4;
NAS_LastMenuItem = 5; {Is the theme dead yet?}
NAS_GX = 6; { Waypoint Destination X - the G means "Go". }
NAS_GY = 7; { Waypoint Destination Y }
NAS_SmartAction = 8; { Indicates a continuous action (pcaction.pp) }
NAS_SmartWeapon = 9; { Weapon to be used by smartbump smartattack (pcaction.pp) }
NAS_SmartCount = 10; { Counter for continuous actions }
NAS_SmartX = 11; { X,Y coordinates for SmartAction, }
NAS_SmartY = 12; { used as appropriate. }
NAS_SmartTarget = 13;
NAV_SmartAttack = 10;
NAV_UseItem = 11;
NAV_SmartGo = 12;
NAV_SmartTalk = 13;
NAG_Visibility = -5; { NAS is the team ID which spotted this gear }
NAV_Spotted = 1;
NAV_Hidden = 0;
NAV_DefNeutralTeam = 0;
NAV_DefPlayerTeam = 1;
NAV_LancemateTeam = -3;
NAV_DefEnemyTeam = 2;
NAG_SideReaction = -1; { Same as Location, since teams are virtual. }
NAV_AreEnemies = -1;
NAV_AreNeutral = 0;
NAV_AreAllies = 1;
NAG_EpisodeData = -4;
NAS_UID = 0;
NAS_Target = 1;
NAS_ATarget = 3; { Absolute Target }
NAS_PrevDamage = 4; { Previous damage rating. }
NAS_InitRecharge = 6; { Initiative Recharge for NPCs }
{ Orders are filed under NAG_EpisodeData }
NAS_Orders = 2;
NumAITypes = 5;
NAV_SeekAndDestroy = 0;
NAV_GotoSpot = 1;
NAV_SeekEdge = 2;
NAV_Passive = 3;
NAV_RunAway = 4;
NAV_Follow = 5;
NAS_ContinuousOrders = 7; { reminder variable for the aibrain unit, }
{ so it can remember what a particular model is doing. }
NAS_ChatterRecharge = 8; { Chatter Recharge for NPCs }
{ These refer to things that have happened to corpses/wreckage }
NAS_Ransacked = 11;
NAS_Gutted = 9;
NAS_Flayed = 10;
NAG_SceneData = 17; { Data needed for scenes. }
NAS_TacticsTurnStart = 1; { ComTime at which tactics turn starts. }
AI_Type_Label: Array [0..NumAITypes] of String = (
'SD','GO','EDGE','PASS','RUN','FOL'
);
SA_MapEdgeObstacle = 'NOEXIT';
XMax = 50; {These two constants define the size of}
YMax = 50; {the game map.}
DefaultScale = 2; {The default map scale. 2 = Mecha Scale}
NumTerr = 42;
TerrMan: Array [1..NumTerr] of TerrDesc = (
( name: 'Open Ground';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 20; Destroyed: 11;
Flammable: True; ),
( name: 'Light Forest';
Pass: 50;
MMPass: ( True , False , True , True );
Obscurement: 2;
Altitude: 0;
DMG: 5; Destroyed: 11;
Flammable: True; ),
( name: 'Heavy Forest';
Pass: 100;
MMPass: ( True , False , True , True );
Obscurement: 3;
Altitude: 0;
DMG: 10; Destroyed: 2;
Flammable: True; ),
( name: 'Water';
Pass: 300;
MMPass: ( True , False , True , True );
Obscurement: 2;
Altitude: -1;
DMG: 0; Destroyed: 0;
Flammable: False; ),
( name: 'Rubble';
Pass: 25;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 0; Destroyed: 0;
Flammable: False; ),
{ 6 - 10 }
( name: 'Pavement';
Pass: -5;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 10; Destroyed: 11;
Flammable: False; ),
( name: 'Swamp';
Pass: 50;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 0; Destroyed: 0;
Flammable: False; ),
( name: 'Hill';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 1;
DMG: 32; Destroyed: 11;
Flammable: False; ),
( name: 'Hill';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 2;
DMG: 35; Destroyed: 9;
Flammable: False; ),
( name: 'Hill';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 3;
DMG: 39; Destroyed: 10;
Flammable: False; ),
{ 11 - 15 }
( name: 'Rough Ground';
Pass: 50;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 19; Destroyed: 5;
Flammable: False; ),
( name: 'Low Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 1;
DMG: 18; Destroyed: 40;
Flammable: True; ),
( name: 'Residential Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 26; Destroyed: 40;
Flammable: True; ),
( name: 'Stone Floor';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 20; Destroyed: 11;
Flammable: False; ),
( name: 'Stone Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 26; Destroyed: 31;
Flammable: False; ),
{ 16 - 20 }
( name: 'Floor';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 20; Destroyed: 11;
Flammable: True; ),
( name: 'Dirt';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 20; Destroyed: 11;
Flammable: False; ),
( name: 'Hospital Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 26; Destroyed: 40;
Flammable: False; ),
( name: 'Threshold';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 15; Destroyed: 5;
Flammable: True; ),
( name: 'Blue Carpet';
Pass: -3;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 7; Destroyed: 1;
Flammable: True; ),
{ 21 - 25 }
( name: 'Deep Water';
Pass: 300;
MMPass: ( True , False , True , True );
Obscurement: 2;
Altitude: -2;
DMG: 0; Destroyed: 0;
Flammable: False; ),
( name: 'Very Deep Water';
Pass: 300;
MMPass: ( True , False , True , True );
Obscurement: 2;
Altitude: -3;
DMG: 0; Destroyed: 0;
Flammable: False; ),
( name: 'Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 30; Destroyed: 40;
Flammable: True; ),
( name: 'Gold Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 24; Destroyed: 40;
Flammable: False; ),
( name: 'Red Carpet';
Pass: -3;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 7; Destroyed: 1;
Flammable: True; ),
{ 26 - 30 }
( name: 'Wooden Floor';
Pass: -5;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 7; Destroyed: 11;
Flammable: True; ),
( name: 'Wooden Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 20; Destroyed: 11;
Flammable: True; ),
( name: 'Tile Floor';
Pass: -5;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 9; Destroyed: 11;
Flammable: False; ),
( name: 'Steel Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 50; Destroyed: 40;
Flammable: False; ),
( name: 'Marble Floor';
Pass: -5;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 9; Destroyed: 11;
Flammable: False; ),
{ 31 - 35 }
( name: 'Earth Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 20; Destroyed: 17;
Flammable: False; ),
( name: 'Commercial Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 20; Destroyed: 40;
Flammable: True; ),
( name: 'Fortress Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 42; Destroyed: 40;
Flammable: False; ),
( name: 'Stainless Steel Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 50; Destroyed: 40;
Flammable: False; ),
( name: 'Industrial Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 50; Destroyed: 40;
Flammable: False; ),
{ 36 - 40 }
( name: 'Neon Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 20; Destroyed: 40;
Flammable: True; ),
( name: 'Restaurant Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 20; Destroyed: 40;
Flammable: True; ),
( name: 'Garage Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 20; Destroyed: 40;
Flammable: False; ),
( name: 'Sand';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 20; Destroyed: 11;
Flammable: False; ),
( name: 'Wreckage';
Pass: 100;
MMPass: ( True , False , True , True );
Obscurement: 3;
Altitude: 0;
DMG: 14; Destroyed: 5;
Flammable: True; ),
{ 41 - 45 }
( name: 'Organic Floor';
Pass: 0;
MMPass: ( True , True , True , True );
Obscurement: 0;
Altitude: 0;
DMG: 0; Destroyed: 0;
Flammable: False; ),
( name: 'Organic Wall';
Pass: -100;
MMPass: ( True , True , True , True );
Obscurement: 1;
Altitude: 6;
DMG: 30; Destroyed: 41;
Flammable: False; )
);
{ This array holds the movement vectors for the 8 possible }
{ directions of travel. Dir 0 is at three o'clock, for no }
{ better reason than it's the same convention I've used in }
{ other games. }
AngDir: Array [0..7 , 1..2] of SmallInt = (
(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)
);
LOCALE_CollectTriggers: Boolean = True;
TERRAIN_Threshold = 19;
{ ******************************** }
{ *** SCENE & TEAM CONSTANTS *** }
{ ******************************** }
{ ADVENTURE DEFINITION }
{ G = GG_Adventure }
{ S = Exit Lock }
{ V = Undefined }
{ SCENE DEFINITION }
{ G = GG_Scene }
{ S = Scene ID }
{ V = Map Scale }
{ STAT[ 1 ] = Map Generation Type }
STAT_MapGenerator = 1;
{ TEAM DEFINITION }
{ G = GG_Team }
{ S = Team ID }
{ V = UNDEFINED }
{ STAT[ 1 ] = Default Team Orders }
{ STAT[ 2 ] = Wandering Monster Value }
STAT_TeamOrders = 1;
STAT_WanderMon = 2;
{ *** MAP FEATURE DEFINITION *** }
{ G = GG_MapFeature }
{ S = Feature Type }
{ V = Feature Value }
GS_Building = -1;
STAT_XPos = 1;
STAT_YPos = 2;
STAT_MFWidth = 3;
STAT_MFHeight = 4;
STAT_MFFloor = 5;
STAT_MFMarble = 6;
STAT_MFBorder = 7;
STAT_MFSpecial = 8;
MapFeatureMaxWidth = 25;
MapFeatureMaxHeight = 15;
MapFeatureMinDimension = 5;
{ TIME CONSTANTS }
AP_Minute = 60;
AP_3Minutes = 180;
AP_5Minutes = 300;
AP_10Minutes = 600;
AP_HalfHour = 1800;
AP_Hour = 3600;
AP_Quarter = 21600;
AP_Day = 86400;
TRIGGER_FiveMinutes = '5MIN';
TRIGGER_Hour = 'HOUR';
TRIGGER_HalfHour = 'HALFHOUR';
TRIGGER_Quarter = 'QUARTER';
{ This constant is used by stairs and other portals. If a value }
{ is addigned to it, the player character should appear on that }
{ terrain after leaving the current level. }
SCRIPT_Terrain_To_Seek: Integer = 0;
SCRIPT_Gate_To_Seek: Integer = 0;
PC_Team_X: Integer = 0;
PC_Team_Y: Integer = 0;
type
Point = Record
x,y,z: Integer;
end;
Tile = Record
Terr: Integer;
Visible: Boolean;
end;
Location = Array [1..XMax,1..YMax] of Tile;
gameboard = Record
ComTime: LongInt; { Current game time. }
Scale: SmallInt; { The scale of the map. }
QuitTheGame: Boolean; { Whether or not a QUIT msg was caught. }
ReturnCode: Integer; { Value to return when the game is over. }
map: Location;
Scene: GearPtr; { A gear describing the scenario. }
Trig: SAttPtr; { A list of triggers which have occured - should be routinely checked by the main combat procedure. }
{ See the scripting unit for this implementation for more information, or set LOCALE_CollectTriggers to FALSE to disable scripts. }
meks: GearPtr; {A list of all associated mecha.}
end;
gameboardptr = ^gameboard;
FrozenLocation = Record
Name: String;
map: Location;
Next: Pointer;
end;
FrozenLocationPtr = ^FrozenLocation;
{ This record holds the data needed for an entire campaign. }
Campaign = Record
ComTime: LongInt;
GB: GameBoardPtr;
Maps: FrozenLocationPtr;
Source: GearPtr;
end;
CampaignPtr = ^Campaign;
Function CreateFrozenLocation(var LList: FrozenLocationPtr): FrozenLocationPtr;
Function SolveLine(X1,Y1,X2,Y2,N: Integer): Point;
Function SolveLine(X1,Y1,Z1,X2,Y2,Z2,N: Integer): Point;
function NewMap: GameBoardPtr;
function NewCampaign: CampaignPtr;
procedure DisposeMap(var gb: GameBoardPtr);
procedure DisposeCampaign(var Camp: CampaignPtr);
function GearCurrentLocation( Mek: GearPtr ): Point;
Function LocateTeam( Scene: GearPtr; Team: Integer ): GearPtr;
Function LocateTeam( GB: GameBoardPtr; Team: Integer ): GearPtr;
Function AreEnemies( Scene: GearPtr; T1,T2: Integer ): Boolean;
Function AreEnemies( GB: GameBoardPtr; T1,T2: Integer ): Boolean;
Function AreEnemies( GB: GameBoardPtr; M1 , M2: GearPtr ): Boolean;
Function AreAllies( Scene: GearPtr; T1,T2: Integer ): Boolean;
Function AreAllies( GB: GameBoardPtr; T1,T2: Integer ): Boolean;
Function AreAllies( GB: GameBoardPtr; M1 , M2: GearPtr ): Boolean;
Procedure DeleteObsoleteTeams( GB: GameBoardPtr );
Function IsSafeArea( GB: GameBoardPtr ): Boolean;
Function TeamSkill( GB: GameBoardPtr; Team,Skill: Integer): Integer;
Function TeamHasSkill( GB: GameBoardPtr; Team,Skill: Integer): Boolean;
Function TeamCanSeeTarget( GB: GameBoardPtr; Team: Integer; Target: GearPtr ): Boolean;
Function MekCanSeeTarget( GB: GameBoardPtr; Mek , Target: GearPtr ): Boolean;
Function OnTheMap( X,Y: Integer ): Boolean;
Function OnTheMap( Mek: GearPtr ): Boolean;
function MekVisible( gb: GameBoardPtr; Mek: GearPtr ): Boolean;
function MekAltitude( gb: GameBoardPtr; Mek: GearPtr ): Integer;
Function NumGearsXY( GB: GameBoardPtr; X,Y: Integer ): Integer;
Function FindGearXY( GB: GameBoardPtr; X,Y,N: Integer): GearPtr;
Function NumVisibleGears( GB: GameBoardPtr; X,Y: Integer ): Integer;
Function FindVisibleGear( GB: GameBoardPtr; X,Y,N: Integer): GearPtr;
Function FindBlockerXYZ( GB: GameBoardPtr; X,Y,Z: Integer ): GearPtr;
Function NumVisibleItemsAtSpot( GB: GameBoardPtr; X,Y: Integer ): Integer;
Function GetVisibleItemAtSpot( GB: GameBoardPtr; X,Y,N: Integer ): GearPtr;
Function FindVisibleItemAtSpot( GB: GameBoardPtr; X,Y: Integer ): GearPtr;
Function NumVisibleUsableGearsXY( GB: GameBoardPtr; X,Y: Integer; const Trigger: String ): Integer;
Function FindVisibleUsableGearXY( GB: GameBoardPtr; X,Y,N: Integer; const Trigger: String): GearPtr;
Function FindVisibleBlockerAtSpot( GB: GameBoardPtr; X,Y: Integer ): GearPtr;
Procedure UpdateShadowMap( GB: GameBoardPtr );
Function TileBlocksLOS( GB: GameBoardPtr; X,Y,Z: Integer ): Boolean;
Function CalcObscurement(X1,Y1,Z1,X2,Y2,Z2: Integer; gb: GameBoardPtr): Integer;
Function CalcObscurement(X1,Y1,X2,Y2: Integer; gb: GameBoardPtr): Integer;
Function CalcObscurement( M1: GearPtr; X2,Y2: Integer; gb: GameBoardPtr ): Integer;
Function CalcObscurement( M1 , M2: GearPtr; gb: GameBoardPtr ): Integer;
Function CheckArc( OX , OY , TX , TY , A: Integer ): Boolean;
Function CheckArc( M1: GearPtr; X2,Y2,A: Integer ): Boolean;
Function CheckArc( M1,M2: GearPtr; A: Integer ): Boolean;
Function Range( X1 , Y1 , X2 , Y2: Integer ): Integer;
Function Range( M1: GearPtr; X2,Y2: Integer ): Integer;
Function Range( gb: GameBoardPtr; M1 , M2: GearPtr ): Integer;
function WeaponRange( GB: GameBoardPtr; Weapon: GearPtr ): Integer;
function ThrowingRange( GB: GameBoardPtr; User,Weapon: GearPtr ): Integer;
Function GearDestination( Mek: GearPtr ): Point;
Function IsObstacle( GB: GameBoardPtr; Mek: GearPtr; Terrain: Integer ): Boolean;
Function IsBlocked( Mek: GearPtr; GB: GameBoardPtr; X,Y: Integer ): Boolean;
Function FrontBlocked( Mek: GearPtr; GB: GameBoardPtr; D: Integer ): Boolean;
Function MoveBlocked( Mek: GearPtr; GB: GameBoardPtr ): Boolean;
Function CalcMoveTime( Mek: GearPtr; GB: GameBoardPtr ): Integer;
Function CalcRelativeSpeed( Mek: GearPtr; GB: GameBoardPtr ): Integer;
Function IsInCover( GB: GameBoardPtr; Master: GearPtr ): Boolean;
Function CheckLOS( GB: GameBoardPtr; Observer,Target: GearPtr ): Boolean;
Function NumActiveMasters( GB: GameBoardPtr; Team: Integer ): Integer;
Function NumOperationalMasters( GB: GameBoardPtr; Team: Integer ): Integer;
Procedure SetTrigger( GB: GameBoardPtr; const msg: String );
Function SeekTarget( GB: GameBoardPtr; Mek: GearPtr ): GearPtr;
Procedure FreezeLocation( const Name: String; GB: GameBoardPtr; var FList: FrozenLocationPtr );
Function UnfreezeLocation( const Name: String; var FList: FrozenLocationPtr ): GameBoardPtr;
function FindThisTerrain( GB: GameBoardPtr; TTS: Integer ): Point;
Function NewTeamID( Scene: GearPtr ): LongInt;
Procedure SetTeamReputation( GB: GameBoardPtr; T,R,V: Integer );
Procedure DeclarationOfHostilities( GB: GameBoardPtr; ATeam,DTeam: Integer );
Function BoardMecha( Mek,Pilot: GearPtr ): Boolean;
Function ExtractPilot( Mek: GearPtr ): GearPtr;
Function FindPilotsMecha( LList,PC: GearPtr ): GearPtr;
Procedure AssociatePilotMek( LList , Pilot , Mek: GearPtr );
Function FindGearScene( Part: GearPtr; GB: GameBoardPtr ): Integer;
Function FindActualScene( GB: GameBoardPtr; SID: Integer ): GearPtr;
Procedure WriteMap(Map: Location; var F: Text);
Function ReadMap(var F: Text): Location;
Function FindDeploymentSpot( GB: GameBoardPtr; Mek: GearPtr ): Point;
implementation
uses ability,damage,gearutil,ghchars,ghprop,ghweapon,rpgdice,texutil;
Type
LPattern = Record { Location Pattern }
X,Y,Z: Integer; { Tile to search }
{ Set Z outside normal range -5...+5 to exclude it as a search parameter }
Trigger: String; { USed when searching for triggerable props. }
Only_Visibles: Boolean; { Only search for visible gears? }
Only_Masters: Integer; { Only search for master gears? }
end;
Const
LP_MustBeBlocker = 2;
LP_MustBeMaster = 1;
LP_MustNotBeMaster = -1;
LP_MustBeUsable = -2;
Stealth_Per_Scale = 4;
LowShadow = -3;
HiShadow = 5;
var
Shadow_Map: Array [1..XMax,1..YMax,LowShadow..HiShadow] of SmallInt;
Shadow_Map_Update: LongInt; { ComTime when map last updated. }
Function CreateFrozenLocation(var LList: FrozenLocationPtr): FrozenLocationPtr;
{Add a new element to the head of LList.}
var
it: FrozenLocationPtr;
begin
{Allocate memory for our new element.}
New(it);
if it = Nil then exit;
{Attach IT to the list.}
it^.Next := LList;
LList := it;
{Return a pointer to the new element.}
CreateFrozenLocation := it;
end;
Procedure DisposeFrozenLocation(var LList: FrozenLocationPtr);
{Dispose of the list, freeing all associated system resources.}
var
LTemp: FrozenLocationPtr;
begin
while LList <> Nil do begin
LTemp := LList^.Next;
Dispose(LList);
LList := LTemp;
end;
end;
Procedure RemoveFrozenLocation(var LList,LMember: FrozenLocationPtr);
{Locate and extract member LMember from list LList.}
{Then, dispose of LMember.}
var
a,b: FrozenLocationPtr;
begin
{Initialize A and B}
B := LList;
A := Nil;
{Locate LMember in the list. A will thereafter be either Nil,}
{if LMember if first in the list, or it will be equal to the}
{element directly preceding LMember.}
while (B <> LMember) and (B <> Nil) do begin
A := B;
B := B^.next;
end;
if B = Nil then begin
{Major FUBAR. The member we were trying to remove can't}
{be found in the list.}
writeln('ERROR- RemoveFrozenLocation asked to remove a link that doesnt exist.');
end
else if A = Nil then begin
{There's no element before the one we want to remove,}
{i.e. it's the first one in the list.}
LList := B^.Next;
Dispose(B);
end
else begin
{We found the attribute we want to delete and have another}
{one standing before it in line. Go to work.}
A^.next := B^.next;
Dispose(B);
end;
end;
Function FindFrozenLocation( const Name_In: String; FList: FrozenLocationPtr ): FrozenLocationPtr;
{ Locate a frozen location by looking for its name. }
{ If the specified location cannot be found, return Nil. }
var
Name: String;
begin
{ Make sure name is upper-case. }
Name := UpCase( Name_In );
while ( FList <> Nil ) and ( UpCase( FList^.Name ) <> Name ) do FList := FList^.Next;
FindFrozenLocation := FList;
end;
Function SolveLine(X1,Y1,X2,Y2,N: Integer): Point;
{Find the N'th point along a line starting at X1,Y1 and ending}
{at X2,Y2. Return its location.}
var
tmp: point;
VX1,VY1,VX,VY: Integer;
Rise,Run: Integer; {Rise and Run}
begin
{ERROR CHECK- Solve the trivial case.}
if (X1=X2) and (Y1=Y2) then begin
tmp.x := X1;
tmp.y := Y1;
Exit(tmp);
end;
{For line determinations, we'll use a virtual grid where each game}
{tile is a square 10 units across. Calculations are done from the}
{center of each square.}
VX1 := X1*10 + 5;
VY1 := Y1*10 + 5;
{Do the slope calculations.}
Rise := Y2 - Y1;
Run := X2 - X1;
if Abs(X2 - X1)> Abs(Y2 - Y1) then begin
{The X direction is longer than the Y axis.}
{Therefore, we can infer X pretty easily, then}
{solve the equation for Y.}
{Determine our X value.}
if Run > 0 then VX := (n*10) + VX1
else VX := VX1 - n*10;
VY := n*10*Rise div Abs(Run) + VY1;
end
else begin
{The Y axis is longer.}
if Rise > 0 then VY := (n*10) + VY1
else VY := VY1 - n*10;
VX := (n*10*Run div Abs(Rise)) + VX1;
end;
{Error check- DIV doesn't deal with negative numbers as I would}
{want it to. I'd always like a positive remainder- so, let's modify}
{the values.}
if VX<0 then VX := VX - 10;
if VY<0 then VY := VY - 10;
tmp.x := VX div 10;
tmp.y := VY div 10;
SolveLine := tmp;
end;
Function SolveLine(X1,Y1,Z1,X2,Y2,Z2,N: Integer): Point;
{ Solve the three-dimensional line. }
var
PA,PB: Point;
W: Integer;
begin
if Abs(X2 - X1) > Abs(Y2 - Y1) then
W := Abs(X2-X1)
else
W := Abs(Y2-Y1);
PA := SolveLine( X1 , Y1 , X2 , Y2 , N );
PB := SolveLine( 0 , Z1 , W , Z2 , N );
PA.Z := PB.Y;
SolveLine := PA;
end;
function NewMap: GameBoardPtr;
{Allocate and initialize a new GameBoard structure.}
var
it: GameBoardPtr;
X,Y: Integer;
begin
{Allocate the needed memory space.}
New(it);
if it <> Nil then begin
it^.Scale := DefaultScale;
it^.meks := Nil;
it^.Scene := Nil;
it^.Trig := Nil;
it^.ComTime := 0;
it^.QuitTheGame := False;
it^.ReturnCode := 0;
for X := 1 to XMax do begin
for Y := 1 to YMax do begin
it^.map[X,Y].terr := 1;
it^.map[X,Y].visible := False;
end;
end;
end;
NewMap := it;
end;
function NewCampaign: CampaignPtr;
{Allocate and initialize a new Campaign structure.}
var
it: CampaignPtr;
begin
{Allocate the needed memory space.}
New(it);
if it <> Nil then begin
it^.ComTime := 0;
it^.GB := Nil;
it^.maps := Nil;
it^.Source := Nil;
end;
NewCampaign := it;
end;
procedure DisposeMap(var gb: GameBoardPtr);
{Get rid of the GameBoard.}
{ NOTE: Any gears, triggers, or scenes still attached will be }
{ lost as well!!! }
begin
{ Error check }
if GB = Nil then Exit;
DisposeGear( gb^.Meks );
DisposeGear( gb^.Scene );
DisposeSAtt( gb^.Trig );
Dispose(gb);
GB := Nil;
end;
procedure DisposeCampaign(var Camp: CampaignPtr);
{Get rid of the campaign.}
begin
DisposeGear( Camp^.Source );
DisposeMap( Camp^.GB );
DisposeFrozenLocation( Camp^.Maps );
Dispose(Camp);
Camp := Nil;
end;
function GearCurrentLocation( Mek: GearPtr ): Point;
{ Locate the coordinates of MEK. }
{ BUGS: If Mek is Nil or undefined, this function will cause }
{ a runtime error. }
var
P: Point;
begin
{ Make sure first that we're dealing with a root-level gear. }
Mek := FindRoot( Mek );
{ Locate its X and Y coordinates. }
P.X := NAttValue( Mek^.NA , NAG_Location , NAS_X );
P.Y := NAttValue( Mek^.NA , NAG_Location , NAS_Y );
GearCurrentLocation := P;
end;
Function LocateTeam( Scene: GearPtr; Team: Integer ): GearPtr;
{ Given a SCENE gear, locate the requested team. }
var
TG,SE: GearPtr;
begin
TG := Nil;
if Scene <> Nil then begin
SE := Scene^.SubCom;
while SE <> Nil do begin
if (SE^.G = GG_Team) and (SE^.S = TEAM) then TG := SE;
SE := SE^.Next;
end;
end;
LocateTeam := TG;
end;
Function LocateTeam( GB: GameBoardPtr; Team: Integer ): GearPtr;
{ Search through the SCENE gear attached to the game board, }
{ trying to find the team gear corresponding to the provided }
{ TEAM number. If no such team is found, or if no scene is }
{ defined, return NIL. }
var
TG: GearPtr; { Scene Element, Team Gear }
begin
TG := Nil;
if GB^.Scene <> Nil then begin
TG := LocateTeam( GB^.Scene , Team );
end;
LocateTeam := TG;
end;
Function AreEnemies( Scene: GearPtr; T1,T2: Integer ): Boolean;
{ Locate the TEAM descriptions for the two teams indicated, }
{ then return TRUE if they are enemies, FALSE if they are not. }
{ If no TEAM gears have been defined, even teams are enemies }
{ with odd teams, except team 0 which is perfectly neutral. }
{ Note that this check is performed from the perspective of }
{ team one. }
var
TG1: GearPtr;
SR: Integer;
it: Boolean;
begin
{ First, substitute out the Lancemate team for the PC team. }
if T1 = NAV_LancemateTeam then T1 := NAV_DefPlayerTeam;
if T2 = NAV_LancemateTeam then T2 := NAV_DefPlayerTeam;
TG1 := LocateTeam( Scene , T1 );
it := False;
{ A team is never enemies with itself. }
if T1 = T2 then begin
it := False;