-
Notifications
You must be signed in to change notification settings - Fork 18
/
pcaction.pp
3472 lines (3054 loc) · 113 KB
/
pcaction.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 pcaction;
{ This unit specifically handles PC actions. }
{
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,locale;
Procedure PCSaveCampaign( Camp: CampaignPtr; PC: gearPtr; PrintMsg: Boolean );
Procedure DoTraining( GB: GameBoardPtr; PC: GearPtr );
Procedure FieldHQ( GB: GameBoardPtr; PC: GearPtr );
Procedure GetPlayerInput( Mek: GearPtr; Camp: CampaignPtr );
implementation
{$IFDEF SDLMODE}
uses ability,action,aibrain,arenacfe,arenascript,backpack,
damage,effects,gearutil,gflooker,ghchars,ghparser,
ghprop,ghswag,ghweapon,interact,menugear,movement,
playwright,randchar,rpgdice,skilluse,texutil,ui4gh,
sdlgfx,sdlinfo,sdlmap,sdlmenus;
{$ELSE}
uses ability,action,aibrain,arenacfe,arenascript,backpack,
damage,effects,gearutil,gflooker,ghchars,ghparser,
ghprop,ghswag,ghweapon,interact,menugear,movement,
playwright,randchar,rpgdice,skilluse,texutil,ui4gh,
congfx,coninfo,conmap,conmenus,context;
{$ENDIF}
const
{ This array cross-references the RL direction key with }
{ the gearhead direction number it corresponds to. }
Roguelike_D: Array [1..9] of Byte = ( 3, 2, 1, 4, 0, 0, 5, 6, 7 );
Reverse_RL_D: Array [0..7] of Byte = ( 6 , 3 , 2 , 1 , 4 , 7, 8 , 9 );
{$IFDEF SDLMODE}
var
PCACTIONRD_PC,PCACTIONRD_Source: GearPtr;
PCACTIONRD_GB: GameBoardPtr;
PCACTIONRD_CAPTION: String;
PCACTIONRD_Menu: RPGMenuPtr;
Procedure PCActionRedraw;
{ Redraw the map and the PC's info. }
begin
SDLCombatDisplay( PCACTIONRD_GB );
end;
Procedure PhoneRedraw;
{ Redraw the map and the PC's info. }
begin
SDLCombatDisplay( PCACTIONRD_GB );
InfoBox( ZONE_PhoneInstructions.GetRect() );
CMessage( MsgString( 'PHONE_INSTRUCTIONS' ), ZONE_PhoneInstructions.GetRect(), InfoGreen );
end;
Procedure MenuControlRedraw;
{ Redraw the map and the PC's info. }
begin
SDLCombatDisplay( PCACTIONRD_GB );
InfoBox( ZONE_Menu.GetRect() );
end;
Procedure CenterMenuRedraw;
{ Redraw the map and the PC's info. }
begin
SDLCombatDisplay( PCACTIONRD_GB );
InfoBox( ZONE_CenterMenu.GetRect() );
end;
Procedure PCSRedraw;
{ Redraw the map and the PC's info. }
begin
SDLCombatDisplay( PCACTIONRD_GB );
SetupMemoDisplay;
end;
Procedure CharViewRedraw;
{ Redraw for the character browser. }
begin
SDLCombatDisplay( PCACTIONRD_GB );
InfoBox( ZONE_CharViewChar.GetRect() );
InfoBox( ZONE_CharViewMenu.GetRect() );
InfoBox( ZONE_CharViewDesc.GetRect() );
if PCACTIONRD_PC <> Nil then CharacterDisplay( PCACTIONRD_PC , PCACTIONRD_GB, ZONE_CharViewChar );
if PCACTIONRD_CAPTION <> '' then begin
InfoBox( ZONE_CharViewCaption.GetRect() );
CMessage( PCACTIONRD_CAPTION , ZONE_CharViewCaption.GetRect() , InfoGreen );
end;
end;
Procedure ThisLancemateWasSelectedRedraw;
{ Redraw for the character browser. }
begin
CharViewRedraw();
DisplayTargetInfo( PCACTIONRD_PC, PCACTIONRD_GB, ZONE_CharViewDesc );
end;
Procedure FieldHQRedraw;
{ Do a redraw for the Field HQ. }
var
Part: GearPtr;
begin
SDLCombatDisplay( PCACTIONRD_GB );
if PCACTIONRD_CAPTION <> '' then begin
InfoBox( ZONE_FHQTitle.GetRect() );
CMessage( PCACTIONRD_CAPTION , ZONE_FHQTitle.GetRect() , InfoHilight );
end;
InfoBox( ZONE_FHQMenu.GetRect() );
InfoBox( ZONE_FHQInfo.GetRect() );
if ( PCACTIONRD_Menu <> Nil ) and ( PCACTIONRD_Source <> Nil ) then begin
Part := RetrieveGearSib( PCACTIONRD_Source , CurrentMenuItemValue( PCACTIONRD_Menu ) );
if Part <> Nil then begin
LongformGearInfo( Part , PCACTIONRD_GB, ZONE_FHQInfo );
end;
end;
end;
{$ENDIF}
Procedure FHQ_Rename( GB: GameBoardPtr; NPC: GearPtr );
{ Enter a new name for NPC. }
var
name: String;
begin
{$IFDEF SDLMODE}
name := GetStringFromUser( ReplaceHash( MsgString( 'FHQ_Rename_Prompt' ) , GearName( NPC ) ) , @PCActionRedraw );
{$ELSE}
name := GetStringFromUser( ReplaceHash( MsgString( 'FHQ_Rename_Prompt' ) , GearName( NPC ) ) );
GFCombatDisplay( GB );
{$ENDIF}
if name <> '' then SetSAtt( NPC^.SA , 'name <' + name + '>' );
end;
Procedure FHQ_Rejoin( GB: GameBoardPtr; PC,NPC: GearPtr );
{ NPC will rejoin the party if there's enough room. }
begin
if LancematesPresent( GB ) < LancematePoints( PC ) then begin
DialogMsg( ReplaceHash( MsgString( 'REJOIN_OK' ) , GearName( NPC ) ) );
AddLancemate( GB , NPC );
end else begin
DialogMsg( ReplaceHash( MsgString( 'REJOIN_DontWant' ) , GearName( NPC ) ) );
end;
end;
Procedure AutoTraining( GB: GameBoardPtr; var NPC: GearPtr );
{ The NPC in question is going to raise some skills. }
var
N,T: Integer;
FXP: LongInt;
TrainedSome: Boolean;
M,M2: GearPtr;
Gene: String;
begin
TrainedSome := False;
repeat
FXP := NAttValue( NPC^.NA , NAG_Experience , NAS_TotalXP ) - NAttValue( NPC^.NA , NAG_Experience , NAS_SpentXP );
{ Determine how many skills or stats may be trained. }
N := 0;
for t := 1 to NumSkill do begin
if ( NAttValue( NPC^.NA , NAG_SKill , T ) > 0 ) and ( SkillAdvCost( NPC , NAttValue( NPC^.NA , NAG_SKill , T ) ) <= FXP ) then begin
Inc( N );
end;
end;
if N > 0 then begin
N := Random( N );
for t := 1 to NumSkill do begin
if ( NAttValue( NPC^.NA , NAG_SKill , T ) > 0 ) and ( SkillAdvCost( NPC , NAttValue( NPC^.NA , NAG_SKill , T ) ) <= FXP ) then begin
if N = 0 then begin
AddNAtt( NPC^.NA , NAG_Experience , NAS_SpentXP , SkillAdvCost( NPC , NAttValue( NPC^.NA , NAG_SKill , T ) ) );
AddNAtt( NPC^.NA , NAG_Skill , T , 1 );
dialogmsg( ReplaceHash( ReplaceHash( MsgString( 'AUTOTRAIN_LEARN' ) , GearName( NPC ) ) , SkillMan[ T ].Name ) );
TrainedSome := True;
N := 5;
break;
end;
Dec( N );
end;
end;
end;
until N < 1;
{ Free XP now becomes Freaky XP... check for evolution. }
FXP := NAttValue( NPC^.NA , NAG_GearOps , NAS_EvolveAt );
if ( FXP > 0 ) and ( NAttValue( NPC^.NA , NAG_Experience , NAS_TotalXP ) > FXP ) then begin
{ Search the monster list for another creature which is: 1) from the }
{ same genepool as our original, and 2) more powerful. }
M := WMOnList;
Gene := UpCase( SATtValue( NPC^.SA , 'GENEPOOL' ) );
N := 0;
while M <> Nil do begin
if ( UpCase( SAttValue( M^.SA , 'GENEPOOL' ) ) = Gene ) and ( M^.V > NPC^.V ) then Inc( N );
M := M^.Next;
end;
{ If at least one such monster has been found, }
{ it's time to do the evolution! }
if N > 0 then begin
N := Random( N );
M2 := Nil;
M := WMonList;
while M <> Nil do begin
if ( UpCase( SAttValue( M^.SA , 'GENEPOOL' ) ) = Gene ) and ( M^.V > NPC^.V ) then begin
Dec( N );
if N = -1 then M2 := M;
end;
M := M^.Next;
end;
{ We've selected a new body. Change over. }
if ( M2 <> Nil ) and ( NPC^.Parent = Nil ) then begin
{ First, make the current monster drop everything }
{ it's carrying. }
ShakeDown( GB , NPC , NAttValue( NPC^.NA , NAG_Location , NAS_X ) , NAttValue( NPC^.NA , NAG_Location , NAS_Y ) );
{ Then copy the new body to the map. }
M := CloneGear( M2 );
{ Insert M into the map. }
DeployMek( GB , M , True );
DialogMsg( ReplaceHash( ReplaceHash( MsgString( 'AUTOTRAIN_EVOLVE' ) , GearName( NPC ) ) , GearName( M ) ) );
{ Copy over name, XP, team, location, and skills. }
SetSAtt( M^.SA , 'name <' + GearName( NPC ) + '>' );
SetNAtt( M^.NA , NAG_Experience , NAS_SpentXP , NAttValue( NPC^.NA , NAG_Experience , NAS_SpentXP ) );
SetNAtt( M^.NA , NAG_Experience , NAS_TotalXP , NAttValue( NPC^.NA , NAG_Experience , NAS_TotalXP ) );
SetNAtt( M^.NA , NAG_Location , NAS_Team , NAttValue( NPC^.NA , NAG_Location , NAS_Team ) );
SetNAtt( M^.NA , NAG_Location , NAS_X , NAttValue( NPC^.NA , NAG_Location , NAS_X ) );
SetNAtt( M^.NA , NAG_Location , NAS_Y , NAttValue( NPC^.NA , NAG_Location , NAS_Y ) );
SetNAtt( M^.NA , NAG_Personal , NAS_CID , NAttValue( NPC^.NA , NAG_Personal , NAS_CID ) );
SetNAtt( M^.NA , NAG_CharDescription , NAS_CharType , NAttValue( NPC^.NA , NAG_CharDescription , NAS_CharType ) );
GearUp( M );
for t := 1 to NumSkill do begin
if NAttValue( NPC^.NA , NAG_Skill , T ) > NAttValue( M^.NA , NAG_Skill , T ) then SetNAtt( M^.NA , NAG_Skill , T , NAttValue( NPC^.NA , NAG_Skill , T ) );
end;
TrainedSome := True;
{ Now, delete the original. }
RemoveGear( GB^.Meks , NPC );
NPC := M;
end;
end;
end;
if not TrainedSome then DialogMsg( ReplaceHash( MsgString( 'AUTOTRAIN_FAIL' ) , GearName( NPC ) ) );
end;
Procedure FHQ_Disassemble( GB: GameBoardPtr; PC,NPC: GearPtr );
{ Robot NPC is no longer desired. Disassemble it into spare parts, delete the NPC, }
{ then give the parts to PC. }
const
V_MAX = 32767;
var
M: LongInt;
begin
{ Error check- NPC must be on the gameboard. }
if not IsFoundAlongTrack( GB^.Meks , NPC ) then Exit;
{ First, make the robot drop everything it's carrying. }
ShakeDown( GB , NPC , NAttValue( NPC^.NA , NAG_Location , NAS_X ) , NAttValue( NPC^.NA , NAG_Location , NAS_Y ) );
{ Print a message. }
DialogMsg( ReplaceHash( MsgString( 'FHQ_DIS_Doing' ) , GearName( NPC ) ) );
{ The size of the spare parts is to be determined by the weight of the robot. }
M := GearMass( NPC );
{ Delete the NPC. }
RemoveGear( GB^.Meks , NPC );
{ Get the spare parts. }
NPC := LoadNewSTC( 'SPAREPARTS-1' );
if (V_MAX < (Int64(M) * 5)) then begin
NPC^.V := V_MAX;
end else begin
NPC^.V := M * 5;
end;
InsertInvCom( PC , NPC );
end;
Procedure SetPlayOptions( GB: GameBoardPtr; Mek: GearPtr );
{ Allow the player to set control type, default burst value settings, }
{ and whatever other stuff you think is appropriate. }
var
RPM: RPGMenuPtr;
N: Integer;
begin
{ The menu needs to be re-created with each iteration, since the }
{ data in it needs to be updated. }
{$IFNDEF SDLMODE}
CMessage( 'Set game prefrences' , ZONE_Menu1 , NeutralGrey );
{$ENDIF}
N := 1;
repeat
{$IFDEF SDLMODE}
RPM := CreateRPGMenu( MenuItem , MenuSelect , ZONE_CenterMenu );
{$ELSE}
RPM := CreateRPGMenu( MenuItem , MenuSelect , ZONE_Menu2 );
{$ENDIF}
AddRPGMenuItem( RPM , 'Mecha Control: '+ControlTypeName[ControlMethod] , 1 );
AddRPGMenuItem( RPM , 'Chara Control: '+ControlTypeName[CharacterMethod] , 5 );
AddRPGMenuItem( RPM , 'Explore Control: '+ControlTypeName[WorldMapMethod] , 6 );
AddRPGMenuItem( RPM , 'Ballistic Wpn BV: '+BVTypeName[DefBallisticBV] , 2 );
AddRPGMenuItem( RPM , 'Energy Wpn BV: '+BVTypeName[DefBeamGunBV] , 3 );
AddRPGMenuItem( RPM , 'Missile BV: '+BVTypeName[DefMissileBV] , 4 );
{$IFDEF SDLMODE}
if Use_Alpha_Blending then begin
AddRPGMenuItem( RPM , 'Disable Transparency' , 7 );
end else begin
AddRPGMenuItem( RPM , 'Enable Transparency' , 7 );
end;
if Display_Mini_Map then begin
AddRPGMenuItem( RPM , 'Disable Mini-Map' , 8 );
end else begin
AddRPGMenuItem( RPM , 'Enable Mini-Map' , 8 );
end;
if Names_Above_Heads then begin
AddRPGMenuItem( RPM , 'Disable Name Display' , 9 );
end else begin
AddRPGMenuItem( RPM , 'Enable Name Display' , 9 );
end;
{$ELSE}
if Accessibility_On then begin
AddRPGMenuItem( RPM , 'Disable Accessibility+' , 10 );
end else begin
AddRPGMenuItem( RPM , 'Enable Accessibility+' , 10 );
end;
{$ENDIF}
AddRPGMenuItem( RPM , ' Exit Prefrences' , -1 );
SetItemByValue( RPM , N );
{$IFDEF SDLMODE}
N := SelectMenu( RPM , @CenterMenuRedraw );
{$ELSE}
N := SelectMenu( RPM );
{$ENDIF}
DisposeRPGMenu( RPM );
if N = 1 then begin
if ControlMethod = MenuBasedInput then ControlMethod := RLBasedInput
else ControlMethod := MenuBasedInput;
WaitAMinute( GB , Mek , 1 );
end else if N = 5 then begin
if CharacterMethod = MenuBasedInput then CharacterMethod := RLBasedInput
else CharacterMethod := MenuBasedInput;
WaitAMinute( GB , Mek , 1 );
end else if N = 6 then begin
if WorldMapMethod = MenuBasedInput then WorldMapMethod := RLBasedInput
else WorldMapMethod := MenuBasedInput;
WaitAMinute( GB , Mek , 1 );
end else if N = 2 then begin
if DefBallisticBV = BV_Off then DefBallisticBV := BV_Max
else DefBallisticBV := BV_Off;
end else if N = 3 then begin
if DefBeamGunBV = BV_Off then DefBeamGunBV := BV_Max
else DefBeamGunBV := BV_Off;
end else if N = 4 then begin
DefMissileBV := DefMissileBV + 1;
if DefMissileBV > BV_Max then DefMissileBV := BV_Off;
end else if N = 7 then begin
{ Toggle the Alpha_Blending boolean. }
Use_Alpha_Blending := Not Use_Alpha_Blending;
end else if N = 8 then begin
{ Toggle the Mini-Map. }
Display_Mini_Map := Not Display_Mini_Map;
end else if N = 9 then begin
Names_Above_Heads := Not Names_Above_Heads;
end else if N = 10 then begin
Accessibility_On := Not Accessibility_On;
end;
until N = -1;
end;
Procedure BrowsePersonalHistory( GB: GameBoardPtr; PC: GearPtr );
{ As the PC advances throughout the campaign, she will likely }
{ accumulate a number of history messages. This procedure will }
{ allow those messages to be browsed. }
var
HList,SA: SAttPtr;
Adv: GearPtr;
begin
HList := Nil;
Adv := FindRoot( GB^.Scene );
if Adv <> Nil then begin
SA := Adv^.SA;
while SA <> Nil do begin
if UpCase( Copy( SA^.Info , 1 , 7 ) ) = 'HISTORY' then begin
StoreSAtt( HList , RetrieveAString( SA^.Info ) );
end;
SA := SA^.Next;
end;
if HList <> Nil then begin
{$IFDEF SDLMODE}
PCACTIONRD_GB := GB;
MoreText( HList , 1, @PCActionRedraw );
{$ELSE}
MoreText( HList , 1 );
{$ENDIF}
DisposeSAtt( HList );
{$IFNDEF SDLMODE}
DisplayGearInfo( PC , GB );
{$ENDIF}
end;
end;
end;
Procedure FHQ_ThisLancemateWasSelected( GB: GameBoardPtr; PC,NPC: GearPtr; AllowFHQ: Boolean );
{ NPC was selected by the lancemate browser. Allow the PC to train, }
{ equip, or dismiss this character. }
var
RPM: RPGMenuPtr;
N: Integer;
begin
N := 1;
repeat
{ Create the menu. }
{$IFDEF SDLMODE}
RPM := CreateRPGMenu( MenuItem , MenuSelect , ZONE_CharViewMenu );
{$ELSE}
RPM := CreateRPGMenu( MenuItem , MenuSelect , ZONE_Menu );
{$ENDIF}
if IsSafeArea( GB ) or OnTheMap( NPC ) then AddRPGMenuItem( RPM , MsgString( 'FHQ_LMV_Equip' ) , 1 );
AddRPGMenuItem( RPM , MsgString( 'FHQ_LMV_Train' ) , 2 );
if NAttValue( NPC^.NA, NAG_Location, NAS_Team ) = NAV_DefPlayerTeam then begin
AddRPGMenuItem( RPM , MsgString( 'FHQ_SelectMecha' ) , 4 );
AddRPGMenuItem( RPM , MsgString( 'PCVIEW_Injuries' ) , 9 );
if AllowFHQ then AddRPGMenuItem( RPM , MsgString( 'PCVIEW_FieldHQ' ) , 10 );
AddRPGMenuItem( RPM , MsgString( 'PCVIEW_SetOptions' ) , 11 );
AddRPGMenuItem( RPM , MsgString( 'HELP_PersonalHistory' ) , 12 );
{$IFDEF SDLMODE}
AddRPGMenuItem( RPM , MsgString( 'PCVIEW_SetColor' ) , 13 );
if NPC^.G = GG_Character then AddRPGMenuItem( RPM , MsgString( 'PCVIEW_SetSprite' ) , 14 );
{$ENDIF}
end else begin
if ( NAttValue( NPC^.NA , NAG_Personal , NAS_CID ) <> 0 ) then AddRPGMenuItem( RPM , MsgString( 'FHQ_SelectMecha' ) , 4 );
if ( NAttValue( NPC^.NA , NAG_Personal , NAS_CID ) = 0 ) or ( UpCase( SAttValue( NPC^.SA , 'JOB' ) ) = 'ROBOT' ) then AddRPGMenuItem( RPM , MsgString( 'FHQ_Rename' ) , 5 );
if ( NAttValue( NPC^.NA , NAG_Personal , NAS_CID ) = 0 ) and ( NAttValue( NPC^.NA , NAG_Location , NAS_Team ) <> NAV_LancemateTeam ) then AddRPGMenuItem( RPM , MsgString( 'FHQ_Rejoin' ) , 6 );
if ( GB <> Nil ) and ( GB^.Scene <> Nil ) and IsSubCom( GB^.Scene ) and IsSAfeArea( GB ) and OnTheMap( NPC ) and ( NAttValue( NPC^.NA , NAG_Location , NAS_Team ) = NAV_LancemateTeam ) then AddRPGMenuItem( RPM , MsgString( 'FHQ_LMV_Dismiss' ) , 3 );
if ( NAttValue( NPC^.NA , NAG_Personal , NAS_CID ) = 0 ) and ( UpCase( SAttValue( NPC^.SA , 'JOB' ) ) = 'ROBOT' ) then AddRPGMenuItem( RPM , MsgString( 'FHQ_Disassemble' ) , 7 );
end;
AddRPGMenuItem( RPM , MsgString( 'FHQ_PartViewer' ) , 8 );
AddRPGMenuItem( RPM , MsgString( 'EXIT' ) , -1 );
SetItemByValue( RPM, N );
{$IFDEF SDLMODE}
PCACTIONRD_PC := NPC;
PCACTIONRD_GB := GB;
PCACTIONRD_CAPTION := '';
n := SelectMenu( RPM , @ThisLancemateWasSelectedRedraw );
{$ELSE}
DisplayGearInfo( NPC , GB );
n := SelectMenu( RPM );
{$ENDIF}
case N of
1: LancemateBackpack( GB , PC , NPC );
2: if PC = NPC then DoTraining( GB , NPC )
else if NAttValue( NPC^.NA , NAG_Personal , NAS_CID ) <> 0 then DoTraining( GB , NPC )
else AutoTraining( GB , NPC );
3: begin
RemoveLancemate( GB , NPC );
DialogMsg( ReplaceHash( MsgString( 'FHQ_LMV_Removed' ) , GearName( NPC ) ) );
N := -1;
end;
4: FHQ_SelectMechaForPilot( GB , NPC );
5: FHQ_Rename( GB , NPC );
6: FHQ_Rejoin( GB , PC , NPC );
7: begin
FHQ_Disassemble( GB , PC , NPC );
N := -1;
end;
8:
{$IFDEF SDLMODE}
MechaPartBrowser( NPC , @PCActionRedraw );
{$ELSE}
MechaPartBrowser( NPC );
{$ENDIF}
9: begin
{$IFDEF SDLMODE}
InjuryViewer( NPC , @PCActionRedraw );
{$ELSE}
InjuryViewer( NPC );
{$ENDIF}
RPGKey;
end;
10: FieldHQ( GB , NPC );
11: SetPlayOptions( GB , NPC );
12: BrowsePersonalHistory( GB , NPC );
{$IFDEF SDLMODE}
13: SelectColors( NPC , @PCActionRedraw );
14: SelectSprite( NPC , @CharViewRedraw );
{$ENDIF}
end;
DisposeRPGMenu( RPM );
until N = -1;
end;
Procedure FieldHQ( GB: GameBoardPtr; PC: GearPtr );
{ View the PC's lancemates. This menu should allow the PC to view, equip, }
{ train and dismiss these characters. }
var
RPM: RPGMenuPtr;
N,OldPos: Integer;
M: GearPtr;
begin
OldPos := 1;
repeat
{ Create the menu. }
{$IFDEF SDLMODE}
RPM := CreateRPGMenu( MenuItem , MenuSelect , ZONE_FHQMenu );
{$ELSE}
RPM := CreateRPGMenu( MenuItem , MenuSelect , ZONE_Menu );
{$ENDIF}
M := GB^.Meks;
N := 1;
while M <> Nil do begin
if ( NAttValue( M^.NA , NAG_Location , NAS_Team ) = NAV_LancemateTeam ) then begin
AddRPGMenuItem( RPM , LanceMateMenuName( M ) , N );
end else if ( NAttValue( M^.NA , NAG_CharDescription , NAS_CharType ) = NAV_CTLancemate ) and ( NAttValue( M^.NA , NAG_Personal , NAS_CID ) = 0 ) Then begin
AddRPGMenuItem( RPM , LanceMateMenuName( M ) , N );
end else if ( M^.G <> GG_Character ) and ( NAttValue( M^.NA , NAG_Location , NAS_Team ) = NAV_DefPlayerTeam ) then begin
AddRPGMenuItem( RPM , LanceMateMenuName( M ) , N );
end;
M := M^.Next;
Inc( N );
end;
RPMSortAlpha( RPM );
AlphaKeyMenu( RPM );
AddRPGMenuItem( RPM , MSgString( 'EXIT' ) , -1 );
SetItemByPosition( RPM, OldPos );
{ Get a selection from the menu. }
{$IFDEF SDLMODE}
PCACTIONRD_GB := GB;
PCACTIONRD_Source := GB^.Meks;
PCACTIONRD_PC := PC;
PCACTIONRD_Menu := RPM;
PCACTIONRD_Caption := MsgString('FIELDHQ_TITLE');
n := SelectMenu( RPM , @FieldHQRedraw );
{$ELSE}
n := SelectMenu( RPM );
{$ENDIF}
OldPos := RPM^.selectitem;
DisposeRPGMenu( RPM );
if N > 0 Then begin
M := RetrieveGearSib( GB^.Meks , N );
if M^.G = GG_Character then begin
FHQ_ThisLancemateWasSelected( GB , PC , M, False );
end else begin
FHQ_ThisWargearWasSelected( GB , GB^.Meks , PC , M );
end;
end;
until N = -1;
end;
Procedure CheckHiddenMetaterrain( GB: GameBoardPtr; Mek: GearPtr );
{ Some metaterrain might be hidden. If any hidden metaterrain }
{ is located, reveal it and run its REVEAL trigger. }
var
MT: GearPtr;
T: String;
P: Point;
begin
{ First record the PC's current position, for future reference. }
P := GearCurrentLocation( Mek );
{ Look through all the gears on the board, searching for metaterrain. }
MT := GB^.Meks;
while MT <> Nil do begin
{ If this terrain matches our basic criteria, }
{ we'll perform the next few tests. }
if ( MT^.G = GG_MetaTerrain ) and ( MT^.Stat[ STAT_MetaVisibility ] > 0 ) and ( Range( MT , P.X , P.Y ) <= 1 ) then begin
{ Roll the PC's INVESTIGATION skill. If it beats }
{ the terrain's concealment score, reveal it. }
if RollStep( SkillValue( Mek , NAS_Investigation ) ) > MT^.Stat[ STAT_MetaVisibility ] then begin
MT^.Stat[ STAT_MetaVisibility ] := 0;
T := 'REVEAL';
TriggerGearScript( GB , MT , T );
VisionCheck( GB , Mek );
end;
end;
MT := MT^.Next;
end;
end;
Procedure PCSearch( GB: GameBoardPtr; PC: GearPtr );
{ The PC will search for enemy units and hidden things. }
{ This action costs MENTAL. }
var
Mek: GearPtr;
begin
{ Costs one point of MENTAL and an action. }
AddMentalDown( PC , 1 );
WaitAMinute( GB , PC , ReactionTime( PC ) );
{ Look through all the gears on the board, searching for ones }
{ that aren't visible yet. }
{ Note that by searching in this way, the PC will not be vunerable }
{ to being spotted himself. }
Mek := GB^.Meks;
while Mek <> Nil do begin
if OnTheMap( Mek ) and not MekCanSeeTarget( GB , PC , Mek ) then begin
if IsMasterGear( Mek ) and CheckLOS( GB , PC , Mek ) then begin
{ The mek has just been spotted. }
RevealMek( GB , Mek , PC );
end;
end;
Mek := Mek^.Next;
end;
CheckHiddenMetaTerrain( GB , PC );
end;
Procedure MemoBrowser( GB: GameBoardPtr; PC: GearPtr );
{ Find all the memos that the player has accumulated, then allow }
{ them to be browsed through, then restore the display afterwards. }
const
m_email = 1;
m_memo = 2;
m_rumor = 3;
m_news = 4;
m_Personadex = 5;
var
MainMenu: RPGMenuPtr;
CRating,A: Integer;
begin
CRating := PCommRating( PC );
if CRating < 1 then begin
DialogMsg( MsgString( 'MEMO_NoBrowser' ) );
Exit;
end;
if CRating >= PCC_EMail then begin
{$IFNDEF SDLMODE}
SetupMemoDisplay;
{$ENDIF}
MainMenu := CreateRPGMenu( MenuItem , MenuSelect , ZONE_MemoText );
AddRPGMenuItem( MainMenu , MsgString( 'MEMO_ReadMemo' ) , PCC_Memo );
if CRating >= PCC_EMail then AddRPGMenuItem( MainMenu , MsgString( 'MEMO_ReadEMail' ) , PCC_EMail );
if CRating >= PCC_News then AddRPGMenuItem( MainMenu , MsgString( 'MEMO_ReadNews' ) , PCC_News );
AlphaKeyMenu( MainMenu );
repeat
{$IFDEF SDLMODE}
A := SelectMenu( MainMenu , @PCSRedraw );
{$ELSE}
A := SelectMenu( MainMenu );
{$ENDIF}
case A of
PCC_Memo: BrowseMemoType( GB , 'MEMO' );
PCC_News: BrowseMemoType( GB , 'NEWS' );
PCC_EMail: BrowseMemoType( GB , 'EMAIL' );
end;
until A = -1;
DisposeRPGMenu( MainMenu );
end else begin
{ If all we have is the memo browser, might as well just go there. }
BrowseMemoType( GB , 'MEMO' );
end;
{$IFNDEF SDLMODE}
GFCombatDisplay( GB );
{$ENDIF}
end;
Function InterfaceType( GB: GameBoardPtr; Mek: GearPtr ): Integer;
{ Return the constant for the currently-being-used control type. }
begin
if GB^.Scale > 2 then begin
InterfaceType := WorldMapMethod;
end else if Mek^.G = GG_Character then begin
InterfaceType := CharacterMethod;
end else begin
InterfaceType := ControlMethod;
end;
end;
Procedure DoTalkingWIthNPC( GB: GameBoardPtr; PC,NPC: GearPtr; ByTelephone: Boolean );
{ Actually handle the talking with an NPC already selected. }
var
Persona: GearPtr;
CID: Integer;
React: Integer;
ReTalk: LongInt;
begin
if ( NPC <> Nil ) and GearActive( NPC ) then begin
if ByTelephone or ( Range( GB , PC , NPC ) < 5 ) then begin
CID := NAttValue( NPC^.NA , NAG_Personal , NAS_CID );
if CID <> 0 then begin
{ Everything should be okay to talk... Now see if the NPC wants to. }
{ Determine the NPC's RETALK and REACT values. }
ReTalk := NAttValue( NPC^.NA , NAG_Personal , NAS_Retalk );
React := ReactionScore( GB^.Scene , PC , NPC );
if NAttValue( NPC^.NA , NAG_Location , NAS_Team ) = NAV_LancemateTeam then begin
Persona := lancemate_tactics_persona;
end else begin
Persona := SeekPersona( GB , CID );
end;
{ If the NPC really doesn't like the PC, }
{ they'll refuse to talk on principle. }
if ( ( React + RollStep( SkillValue ( PC , 28 ) ) ) < -Random( 120 ) ) or AreEnemies( GB , NPC , PC ) then begin
DialogMsg( GearName( NPC ) + ' doesn''t want to talk to you.' );
SetNAtt( NPC^.NA , NAG_Personal , NAS_Retalk , GB^.ComTime + 1500 );
{ If the NPC is ready to talk, is friendly with the PC, or has a PERSONA gear defined, }
{ they'll be willing to talk. }
end else if ( ReTalk < GB^.ComTime ) or ( Random( 50 ) < ( React + 20 ) ) or ( Persona <> Nil ) then begin
DialogMsg( 'You strike up a conversation with ' + GearName( NPC ) + '.' );
HandleInteract( GB , PC , NPC , Persona );
{$IFNDEF SDLMODE}
GFCombatDisplay( gb );
DisplayGearInfo( PC , GB );
{$ENDIF}
end else begin
DialogMsg( GearName( NPC ) + ' doesn''t want to talk right now.' );
end;
end else begin
DialogMsg( 'No response!' );
end;
end else begin
DialogMsg( 'You''re too far away to talk with ' + GearName( NPC ) + '.' );
end;
end else begin
DialogMsg( 'Not found!' );
end;
end;
Procedure PCTalk( GB: GameBoardPtr; PC: GearPtr );
{ PC wants to do some talking. Select an NPC, then let 'er rip. }
begin
DialogMsg( 'Select a character to talk with.' );
if LookAround( GB , PC ) then begin
DoTalkingWithNPC( GB , PC , LOOKER_Gear , False );
end else begin
DialogMsg( 'Talking cancelled.' );
end;
end;
Procedure PCTelephone( GB: GameBoardPtr; PC: GearPtr );
{ Make a telephone call, if the PC has a telephone. }
var
Name: String;
NPC: GearPtr;
begin
if HasPCommCapability( PC , PCC_Phone ) then begin
DialogMsg( MsgString( 'PHONE_Prompt' ) );
{$IFDEF SDLMODE}
Name := GetStringFromUser( MsgString( 'PHONE_GetName' ) , @PhoneRedraw );
{$ELSE}
Name := GetStringFromUser( MsgString( 'PHONE_GetName' ) );
{$ENDIF}
if Name = '*' then Name := SAttValue( PC^.SA , 'REDIAL' )
else SetSAtt( PC^.SA , 'REDIAL <' + Name + '>' );
if Name <> '' then begin
NPC := SeekGearByName( GB^.Meks , Name );
if NPC = Nil then NPC := FindNPCByKeyword( GB , Name );
if NPC <> Nil then begin
DoTalkingWithNPC( GB , PC , NPC , True );
end else begin
DialogMsg( ReplaceHash( MsgString( 'PHONE_NotFound' ) , Name ) );
end;
{$IFNDEF SDLMODE}
GFCombatDisplay( gb );
end else begin
GFCombatDisplay( gb );
{$ENDIF}
end;
end else begin
DialogMsg( MsgString( 'PHONE_NoPhone' ) );
end;
end;
Procedure UsePropFrontEnd( GB: GameBoardPtr; PC , Prop: GearPtr; T: String );
{ Do everything that needs to be done when a prop is used. }
begin
TriggerGearScript( GB , Prop , T );
VisionCheck( GB , PC );
WaitAMinute( GB , PC , ReactionTime( PC ) );
end;
Function SelectOneVisibleUsableGear( GB: GameBoardPtr; X,Y: Integer; Trigger: String ): GearPtr;
{ Create a menu, then select one of the visible, usable gears }
{ from tile X,Y. }
var
RPM: RPGMenuPtr;
it: GearPtr;
N: Integer;
begin
{ Create and fill the menu. }
RPM := CreateRPGMenu( MenuItem , MenuSelect , ZONE_Menu );
N := NumVisibleUsableGearsXY( GB , X , Y , Trigger );
while N > 0 do begin
it := FindVisibleUsableGearXY( GB , X , Y , N , Trigger );
AddRPGMenuItem( RPM , GearName( it ) , N );
Dec( N );
end;
{ Select an item. }
{$IFDEF SDLMODE}
N := SelectMenu( RPM , @MenuControlRedraw );
{$ELSE}
N := SelectMenu( RPM );
{$ENDIF}
DisposeRPGMenu( RPM );
if N > 0 then begin
SelectOneVisibleUsableGear := FindVisibleUsableGearXY( GB , X , Y , N , Trigger );
end else begin
SelectOneVisibleUsableGear := Nil;
end;
end;
Function ActivatePropAtSpot( GB: GameBoardPtr; PC: GearPtr; X,Y: Integer; Trigger: String ): Boolean;
{ Check spot X,Y. If there are any usable items there, use one. }
{ If there are multiple items in the spot, prompt for a selection. }
{ Return TRUE if a prop was activated, or FALSE otherwise. }
var
N: Integer;
Prop: GearPtr;
begin
{ First count how many usable items there are at the spot. }
N := NumVisibleUsableGearsXY( GB , X , Y , Trigger );
{ Next, choose the item which is to be used. }
if N > 0 then begin
if N = 1 then begin
Prop := FindVisibleUsableGearXY( GB , X , Y , 1 , Trigger );
end else begin
Prop := SelectOneVisibleUsableGear( GB , X , Y , Trigger );
end;
if ( Prop <> Nil ) then begin
UsePropFrontEnd( GB , PC , Prop , Trigger );
ActivatePropAtSpot := True;
end else begin
ActivatePropAtSpot := False;
end;
end else begin
ActivatePropAtSpot := False;
end;
end;
Procedure PCUseProp( GB: GameBoardPtr; PC: GearPtr );
{ PC wants to do something with a prop. Select an item, then let 'er rip. }
var
D,PropD: Integer;
P: Point;
begin
{ See whether or not there's only one prop to use. }
PropD := -1;
P := GearCurrentLocation( PC );
for D := 0 to 7 do begin
if NumVisibleUsableGearsXY( GB , P.X + AngDir[ D , 1 ] , P.Y + AngDir[ D , 2 ] , 'USE' ) > 0 then begin
if PropD = -1 then PropD := D
else PropD := -2;
end;
end;
if PropD < 0 then begin
DialogMsg( MsgString( 'PCUS_Prompt' ) );
{$IFDEF SDLMODE}
PropD := DirKey( @PCActionRedraw );
{$ELSE}
PropD := DirKey;
{$ENDIF}
end;
if PropD > -1 then begin
if not ActivatePropAtSpot( GB , PC , P.X + AngDir[ PropD , 1 ] , P.Y + AngDir[ PropD , 2 ] , 'USE' ) then DialogMsg( MsgString( 'PCUS_NotFound' ) );
end;
end;
Procedure PCEnter( GB: GameBoardPtr; PC: GearPtr );
{ The PC is attempting to enter a place. }
{ Seek a usable gear in this tile, then try to activate it. }
var
P: Point;
begin
P := GearCurrentLocation( PC );
if not ActivatePropAtSpot( GB , PC , P.X , P.Y , 'USE' ) then DialogMsg( MsgString( 'PCUS_NotFound' ) );;
end;
Procedure PCUseSkillOnProp( GB: GameBoardPtr; PC: GearPtr; Skill: Integer );
{ PC wants to do something with a prop. Select an item, then let 'er rip. }
var
PropD: Integer;
P: Point;
Trigger: String;
begin
P := GearCurrentLocation( PC );
DialogMsg( MsgString( 'PCUSOP_Prompt' ) );
{$IFDEF SDLMODE}
PropD := DirKey( @PCActionRedraw );
{$ELSE}
PropD := DirKey;
{$ENDIF}
Trigger := 'CLUE' + BStr( Skill );
if ( PropD = -1 ) and ( NumVisibleUsableGearsXY( GB , P.X , P.Y , Trigger ) > 0 ) then begin
if not ActivatePropAtSpot( GB , PC , P.X , P.Y , Trigger ) then DialogMsg( MsgString( 'PCUS_NotFound' ) );;
end else if ( PropD <> -1 ) and ( NumVisibleUsableGearsXY( GB , P.X + AngDir[ PropD , 1 ] , P.Y + AngDir[ PropD , 2 ] , Trigger ) > 0 ) then begin
if not ActivatePropAtSpot( GB , PC , P.X + AngDir[ PropD , 1 ] , P.Y + AngDir[ PropD , 2 ] , Trigger ) then DialogMsg( MsgString( 'PCUS_NotFound' ) );;
end else if GB^.Scene <> Nil then begin
TriggerGearScript( GB , GB^.Scene , Trigger );
end;
end;
Procedure DoPCRepair( GB: GameBoardPtr; PC: GearPtr; Skill: Integer );
{ The PC is going to use one of the repair skills. Call the }
{ standard procedure, then print output. }
var
D,Best: Integer;
P: Point;
Mek,Target: GearPtr;
begin
DialogMsg( MsgString( 'PCREPAIR_Prompt' ) );
{$IFDEF SDLMODE}
D := DirKey( @PCActionRedraw );
{$ELSE}
D := DirKey;
{$ENDIF}
P := GearCurrentLocation( PC );
if D <> -1 then begin
P.X := P.X + AngDir[ D , 1 ];
P.Y := P.Y + AngDir[ D , 2 ];
end;
Mek := GB^.Meks;
Target := Nil;
Best := 0;
while Mek <> Nil do begin
if ( not AreEnemies( GB , PC , Mek ) ) and ( TotalRepairableDamage( Mek , Skill ) > Best ) and ( NAttValue( Mek^.NA , NAG_Location , NAS_X ) = P.X ) and ( NAttValue( Mek^.NA , NAG_Location , NAS_Y ) = P.Y ) then begin
Target := Mek;
Best := TotalRepairableDamage( Mek , Skill );
end;
mek := mek^.Next;
end;
if Target <> Nil then begin
DoFieldRepair( GB , PC , FindRoot( Target ) , Skill );
{$IFNDEF SDLMODE}
DisplayGearInfo( PC , GB );
{$ENDIF}
end else begin
if not ActivatePropAtSpot( GB , PC , P.X , P.Y , 'CLUE' + BStr( Skill ) ) then DialogMsg( MsgString( 'PCREPAIR_NoDamageDone' ) );
end;
end;