-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADVPREP.CPP
1124 lines (975 loc) · 29 KB
/
ADVPREP.CPP
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
/* ========================================================================
Copyright (c) 1990,1995 Synergistic Software
All Rights Reserved.
=======================================================================
Filename: ADVPREP.C
Author: Greg Hightower
========================================================================
Contains the following internal functions:
Contains the following general functions:
======================================================================== */
/* ------------------------------------------------------------------------
Includes
------------------------------------------------------------------------ */
#include <stdio.h>
#if defined(_WINDOWS)
#include <Windows.h>
#endif
#include "SYSTEM.H"
#include "ENGINE.H"
#include "MACHINE.H"
#include "ACTNMENU.HXX"
#include "AVATAR.HXX"
#include "CHARSEL.HXX"
#include "GAME.H"
#include "GAMETYPE.HXX"
#include "GAMEMAP.HXX"
#include "ANIM.H"
#include "REALM.HXX"
#include "SCNMGR.HXX"
#include "STRMGR.H"
#include "strenum.h"
#include "MULTIMAP.HXX"
#include "MULTIUI.HXX"
#include "SNDVOX.HXX"
#include "LOADSAVE.HXX"
#include "PLAYSTAT.HXX"
#include "INVNGUI.HXX"
#include "VECTOR.HXX"
#include "REGENTS.HXX"
#include "DESCRIBE.HXX"
#include "ADVPREP.HXX"
#include "PLACES.HXX"
#include "SOUNDFX.HXX"
#include "SOUND.HXX"
#ifdef _WINDOWS
#include ".\WINSYS\MULPLAY.HXX"
#endif
#include "MENU.H"
#include "PANEL.H"
#include "GMENUENM.H"
/* ------------------------------------------------------------------------
Notes
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Defines and Compile Flags
------------------------------------------------------------------------ */
#define START_SITE_LIST_X 20
#define START_SITE_LIST_Y 98
#define START_PARTY_LIST_X 20
#define START_PARTY_LIST_Y 273
#define INC_LIST_Y 15
#define LIST_CLASS_X 150
#define LIST_CHECK_X 160
#define LIST_CHECK_REGION_X 140
#define BA_DIFF_COL 170
#define LIST_SIZE MAX_ADV_SITES
#define LISTBOX_SIZE 8
#define SITE_SIZE 29
/* ------------------------------------------------------------------------
Macros
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------ */
DEFINE_VECTOR_DATA_S(BOOL,inParty,LIST_SIZE);
DEFINE_VECTOR_CLASS(BOOL,inParty);
DEFINE_VECTOR_DATA_S(SHORT,SiteList,LIST_SIZE);
DEFINE_VECTOR_CLASS(SHORT,SiteList);
DEFINE_VECTOR_DATA_S(SHORT,Adventures,LIST_SIZE);
DEFINE_VECTOR_CLASS(SHORT,Adventures);
SHORT iAdventureSiteIndex;
static SHORT iLocalCheck[2];
static SHORT iSite = 0;
static SHORT AdvSiteListboxFirst = 0;
static SHORT AdvSiteListboxCount = 0;
static SHORT AdvSiteListboxSel = 0;
static SHORT PartyListboxFirst = 0;
static SHORT PartyListboxCount = 0;
static SHORT PartyListboxSel = 0;
static LONG iPartyLead;
int screennum ;
int screenend ;
BOOL fAdvTut = FALSE;
extern LONG TutorialActionNumber;
extern LONG TutorialScreenNumber;
extern BOOL fPreparingSpells; // from invngui.cpp
extern BOOL fFreezeDomainUI; // from gamemap.cpp
extern BOOL fPractice; // from practice.cpp
extern SHORT localActiveRegent;
extern SHORT sMenusUp;
extern LONG adv_dif; // charsel.cpp
extern LONG fControlMode; // gamemap.cpp
extern LONG iSiteChosen;
extern BOOL fTutorialSelected; // from gamemap.cpp
extern LONG GameSpecificGlobal_type;
extern LONG GameSpecificGlobal_x;
extern LONG GameSpecificGlobal_y;
extern LONG GameSpecificGlobal_w;
extern LONG GameSpecificGlobal_h;
/* ------------------------------------------------------------------------
Prototypes
------------------------------------------------------------------------ */
// private
static void TogglePartyCheck(LONG i, LONG);
static void SelectAdventures(void);
static void DescribeAdvPrep(void);
static void AdvPrepIncTut(LONG, LONG);
static void MagicPrep(SHORT AdvIndex);
void BuildAdventureList(void);
// imported
void InitDomainTurn(LONG);
void DataAreaMode (LONG type, LONG dummy);
/* -----------------------------------------------------------------
-----------------------------------------------------------------
-----------------------------------------------------------------
-----------------------------------------------------------------
----------------------------------------------------------------- */
/* ========================================================================
Function - AdventurePrep
Description - build an adventure party and go
Returns -
======================================================================== */
void AdventurePrep(void)
{
SHORT i,x,y,me;
LONG MenuCombo;
HideMenu(D_GAMEBUTTON);
push_regions();
ShowPanel(D_ADVENTURE_PREP);
ShowMenu(D_GAMEBUTTON);
init_pal("nova_l");
init_shade_table("nova_l");
// set adventure values
localActiveRegent = ActiveRegent;
// shut down the DomainUI
fPractice = TRUE;
fFreezeDomainUI = TRUE;
sMenusUp = 1;
fControlMode |= 0x100;
// reset all dialog variables
AdvSiteListboxFirst = 0;
AdvSiteListboxSel = 0;
PartyListboxFirst = 0;
PartyListboxSel = 0;
memset(&inParty[0], 0, sizeof(BOOL)*LIST_SIZE);
memset(&SiteList[0], -1, sizeof(SHORT)*LIST_SIZE);
memset(&Adventures[0], -1, sizeof(SHORT)*LIST_SIZE);
// build list of possible adventurers
BuildAdventureList();
// just for grins, rebuild the advsite[].iPlaces
// SetupAdvsitePlaces();
// build site list
iSite = 0;
for(int j=0; j<MAX_ADV_SITES; ++j)
{
// if availible, add to list
if (advsite[j].available == SELECTABLE)
{
SiteList[iSite++] = j;
}
}
// save count and reset current site
AdvSiteListboxCount = iSite;
iSite = 0;
// clear hilight bar
for(i=0;i<=LISTBOX_SIZE;++i)
{
if (i > LIST_SIZE - 1)
break;
SetButtonType(
D_ADVENTURE_PREP,
BA_LIST_01 + i,
BUTTON_REGION);
}
// SetButtonType(D_ADVENTURE_PREP, BA_LIST_01 + AdvSiteListboxSel, BUTTON_COLORBEVEL);
// SetButtonType(D_ADVENTURE_PREP, BA_LIST_09 + PartyListboxSel, BUTTON_COLORBEVEL);
// add check regions
del_region(TogglePartyCheck, 0);
x = START_PARTY_LIST_X + LIST_CHECK_REGION_X;
y = START_PARTY_LIST_Y;
for (i = BA_LIST_09; i <= BA_LIST_16; ++i)
{
// checkbox region
add_region(x, y+2, 30,14,0,TogglePartyCheck,i-BA_LIST_09,0,0, -1);
y += INC_LIST_Y;
}
// load checkmark art
iLocalCheck[0] = GetResourceStd ("UI\\DCHECK1.PCX", FALSE);
iLocalCheck[1] = GetResourceStd ("UI\\DCHECK2.PCX", FALSE);
// set up the adventure site list
MenuCombo = BUILD_LONG(D_ADVENTURE_PREP,BA_LIST_01);
AdvPrepListSel (MenuCombo, 0);
// turn on the first member of the party always
TogglePartyCheck(0, 0);
screennum = STR_BASIC_042;
screenend = screennum + 5;
fAdvTut = TRUE;
}
/* ========================================================================
Function - AdvPrepPaint
Description -
Returns -
======================================================================== */
void AdvPrepPaint (LONG MenuCombo, LONG )
{
SHORT i,j;
LONG x,y,w,h;
FILE *in;
SHORT iBitm;
CHAR buffer[20];
char textbuf[3000];
char buff[80];
CHAR color = 228;
LONG MenuId, ButtonId;
SPLIT_LONG(MenuCombo, MenuId, ButtonId);
// current site title
init_gfont(FONT_SANS_16PT);
//print_text_centered(420,30,STRMGR_GetStr(SiteTitle[iSite]), BLACK);
init_gfont(FONT_SANS_8PT);
// select an adventure site
x = START_SITE_LIST_X;
y = START_SITE_LIST_Y;
// add the names of the active adventure sites to the screen
for(i=AdvSiteListboxFirst; i<AdvSiteListboxFirst+LISTBOX_SIZE; ++i)
{
SHORT color;
if (i == iSite)
color = WHITE;
else
color = BEIGE;
if (SiteList[i] == fERROR)
continue;
SHORT iPlacename = advsite[SiteList[i]].iPlaces;
if ( iPlacename != -1 )
{
gprint_text(x, y, place_names[iPlacename], color);
}
else
{
gprint_text(x, y, advsite[SiteList[i]].name, color);
}
// add the name and region
switch(advsite[SiteList[i]].difficulty)
{
case 1:
sprintf( buffer, "^l%d%s", BA_DIFF_COL, STRMGR_GetStr(STR_BA_EASY));
gprint_text(x, y, buffer, color);
break;
case 2:
sprintf( buffer, "^l%d%s", BA_DIFF_COL, STRMGR_GetStr(STR_BA_MED));
gprint_text(x, y, buffer, color);
break;
case 3:
sprintf( buffer, "^l%d%s", BA_DIFF_COL, STRMGR_GetStr(STR_BA_HARD));
gprint_text(x, y, buffer, color);
break;
case 4:
sprintf( buffer, "^l%d%s", BA_DIFF_COL, STRMGR_GetStr(STR_BA_VERYHARD));
gprint_text(x, y, buffer, color);
break;
case 0:
default:
break;
}
y += INC_LIST_Y;
}
// select party members
x = START_PARTY_LIST_X;
y = START_PARTY_LIST_Y;
// add the names of the active party members to the screen
for(i=PartyListboxFirst; i<PartyListboxFirst+LISTBOX_SIZE; ++i)
{
SHORT color;
CHAR sClass0[10], sClass1[10];
CHAR sLevel0[10], sLevel1[10];
SHORT hPlayerStats;
SHORT me;
if (fERROR == Adventures[i])
continue;
me = regents[Adventures[i]].mfGetid();
if (fERROR == me)
continue;
if (fERROR == (hPlayerStats = LoadStats(me, fERROR)))
continue;
DumbAutoLockPtr<PLAYER_STATS const> const pPlayerStats(hPlayerStats);
// get name
sprintf(buff, "%s", regents[Adventures[i]].mfGetname());
// get classes
if (pPlayerStats->mfGetClassType(1) >= 0)
{
sprintf(sClass0, "%s", pPlayerStats->mfGetClass(0));
sprintf(sClass1, "%s", pPlayerStats->mfGetClass(1));
sprintf(sLevel0, "%d", pPlayerStats->mfGetLevel(0));
sprintf(sLevel1, "%d", pPlayerStats->mfGetLevel(1));
if(sClass0[0] == 'P')
sClass0[2] = 0;
else
sClass0[1] = 0;
if(sClass1[0] == 'P')
sClass1[2] = 0;
else
sClass1[1] = 0;
sprintf(buffer,"%s%s/%s%s",
sClass0, sLevel0, sClass1, sLevel1 );
}
else if (pPlayerStats->mfGetClassType(0) >= 0)
{
sprintf(sClass0, "%s", pPlayerStats->mfGetClass(0));
sprintf(sLevel0, "%d", pPlayerStats->mfGetLevel(0));
if(sClass0[0] == 'P')
sClass0[2] = 0;
else
sClass0[1] = 0;
sprintf(buffer,"%s%s",
sClass0, sLevel0);
}
else
{
sprintf(buffer, "Monster");
}
sprintf(textbuf, "^F02%s ^F01(%s)", buff, buffer);
if (pPlayerStats->mfGetCurHitPoints()<=0)
{
color = GREY;
}
else
{
if (inParty[i])
{
color = WHITE;
}
else
{
color = YELLOW;
}
}
gprint_text(x, y, textbuf, color);
// draw the check mark
if (pPlayerStats->mfGetCurHitPoints()>0)
{
DrawBitmap(x+LIST_CHECK_X, y+2, iLocalCheck[inParty[i]], 0, 0, 20, 20);
}
y += INC_LIST_Y;
}
if (SiteList[iSite] != fERROR)
{
// clear the buffer
memset(&textbuf[0], 0, sizeof(textbuf));
sprintf(buffer,"%sTEXT\\%s.txt", InstallPath, advsite[SiteList[iSite]].name);
in = FileOpen(buffer, "r");
if(in == NULL)
{
sprintf(buffer,"%sTEXT\\usertext.txt", InstallPath );
in = FileOpen(buffer, "r");
}
if(in != NULL)
{
fread(textbuf, sizeof(textbuf), 1, in);
FileClose(in);
if(strlen(textbuf) < 850)
{
textbuf[2] = '0'; // change large font
textbuf[3] = '3'; // 12 point
}
else
{
textbuf[6] = '0'; // change small font
textbuf[7] = '2'; // 8 point
}
textbuf[6] = '3'; // change format string in local buffer
textbuf[7] = '9';
textbuf[8] = '5';
gprint_text(224, 281, textbuf, DKBROWN);
}
sprintf(textbuf,"UI\\ADVSCN\\%s.pcx", advsite[SiteList[iSite]].name);
iBitm = GetResourceStd (textbuf, FALSE);
if (iBitm != fERROR)
{
DrawBitmap (224, 52, iBitm, 0, 0, 400, 220 );
SetPurge(iBitm);
}
else
{
sprintf(textbuf,"UI\\ADVSCN\\userpic.pcx");
iBitm = GetResourceStd (textbuf, FALSE);
if (iBitm != fERROR)
{
DrawBitmap (224, 52, iBitm, 0, 0, 400, 220 );
SetPurge(iBitm);
}
}
}
else
{
strcpy(textbuf,STRMGR_GetStr(STR_BA_NOSITES));
gprint_text(224, 281, textbuf, DKBROWN);
}
DescribeAdvPrep();
}
/* ========================================================================
Function - DescribeAdvPrep
Description -
Returns -
======================================================================== */
static void DescribeAdvPrep(void)
{
del_region(AdvPrepIncTut,0);
if (fAdvTut && fTutorialSelected)
{
SysHideCursor();
init_gfont(FONT_SANS_8PT);
print_textf(0, 0, DKBROWN, STRMGR_GetStr(screennum));
if (GameSpecificGlobal_type == 5 || GameSpecificGlobal_type == 6)
{
SHORT x = GameSpecificGlobal_x + (GameSpecificGlobal_w/2) - 26;
SHORT y = GameSpecificGlobal_y + GameSpecificGlobal_h - 16 - 4;
SHORT iButton = fERROR;
iButton = GetResourceStd("UI\\MARBBTNA.PCX", FALSE);
DrawBitmap(x, y, iButton, 0, 0, 99, 99);
SetPurge(iButton);
iButton = fERROR;
char buf[80];
if (GameSpecificGlobal_type == 5)
strcpy(buf, STRMGR_GetStr(STR_GM_TUT_BUTS_MORE));
else
strcpy(buf, STRMGR_GetStr(STR_GM_TUT_BUTS_DONE));
print_textf(x+26, y+9, RED, buf);
add_region(x,y,52,16,(GameSpecificGlobal_type == 5)?D_KEY_MORE:D_KEY_DONE1,AdvPrepIncTut,0,0,0,STR_NULL);
}
SysShowCursor();
}
}
static void AdvPrepIncTut(LONG, LONG)
{
++screennum;
if (screennum >= screenend)
{
screennum = screenend;
fAdvTut = FALSE;
}
fUpdatePanels = TRUE;
}
/* ========================================================================
Function - AdvPrepDone
Description -
Returns -
======================================================================== */
void AdvPrepDone (LONG MenuCombo, LONG )
{
SHORT j,count=0;
SHORT HomeIndex, AwayIndex;
LONG who, me; // loop index, unit# of selection
LONG unit; // index for unit search loop
LONG lastGuy = -1; // lockstep link
LONG MenuId, ButtonId;
LONG index;
LONG iPartyLead;
BOOL fSend = FALSE;
#if defined(_WINDOWS)
fSend = IsMultiPlayer();
#endif
SPLIT_LONG(MenuCombo, MenuId, ButtonId);
// click the button
SetButtonHilight(D_ADVENTURE_PREP, ButtonId, TRUE);
fUpdatePanels = TRUE;
RunPanels();
RunMenus();
update_screen();
TickDelay(4);
SetButtonHilight(D_ADVENTURE_PREP, ButtonId, FALSE);
fUpdatePanels = TRUE;
RunPanels();
RunMenus();
update_screen();
/* -----------------------------------------------------------------
Handle right clicks help
----------------------------------------------------------------- */
if(mouse_button == 2)
{
//SystemHelp(STR_BA_HELP_DONE_TITLE, STR_BA_HELP_DONE_TITLE, -1, NULL, 0);
}
else
{
//++action_turn; [abc 8/18] removed
if (fLTAction == DURING_LTACTION)
{
ActiveRegent = realm[HomeRealm].mfGetRegent();
fLTAction = AFTER_LTACTION;
}
else // [abc 8/18] added
++action_turn[HomeRealm]; // [abc 8/18] added
// first, clean up the linked lists
for (who=0; who<LIST_SIZE; ++who)
{
BOOL did_break = FALSE;
if (Adventures[who] != fERROR)
{
// find this persons unit index
// Note: Lieutentents are also in this array.
me = regents[Adventures[who]].mfGetunit();
if (me == -1) /* invalid list */
continue;
if (inParty[who]) // he's going; take him out of map
{
LONG MyLeader = GetUnitLeader(me);
MakeUnitSingleStack(me, fSend);
// GWPif (units[me].Joined)
// GWP{
// GWP for (unit = 1; unit < MAX_UNITS; ++unit)
// GWP {
// GWP if (units[unit].NextUnit == me)
// GWP {
// GWP SetGameData(MP_UNITS, MPUNITS_NEXTUNIT,unit,units[me].NextUnit,fSend);
// GWP did_break = TRUE;
// GWP break;
// GWP }
// GWP }
// GWP}
// GWPelse
// GWP{
// GWP if (units[me].NextUnit > 0)
// GWP {
// GWP units[units[me].NextUnit].Joined = FALSE;
// GWP units[units[me].NextUnit].province = units[me].province;
// GWP }
// GWP}
// GWPunits[me].NextUnit = -1;
if (lastGuy < 0)
{
iPartyLead = me;
/* make sure I don't get lost coming home */
// GWP Don't change where I was.
// GWP units[me].DestProvince = units[me].province;
// GWP MakeUnitSingleStack already did this.
// GWP units[me].Joined = FALSE;
}
else
{
SetGameData(MP_UNITS, MPUNITS_NEXTUNIT, lastGuy, me, fSend);
/* we all follow the leader home */
// GWP Don't change where I was.
// GWP units[me].DestProvince = units[iPartyLead].DestProvince;
SetGameData(MP_UNITS, MPUNITS_JOINED, me, TRUE, fSend);
// Don't reorder the stack here, as then we would lose
// our original province data.
}
/* pull me out of the province I'm in */
// GWP Don't change my province. I'm going back at the end of the adventure.
// GWP units[me].province = NO_PROVINCE;
// GWP Make sure I return to where I started from.
// GWP Since only the leader of my stack had valid province data, update mine now.
units[me].province = units[MyLeader].province;
lastGuy = me;
++count;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SHORT Id = regents[Adventures[who]].mfGetid();
if (Id >= 1000 && Id < 3000)
{
SHORT const hPS = LoadStats(Id, fERROR);
DumbHandlePtr<PLAYER_STATS> const pPS(hPS);
LONG i;
LONG pr_spells, wiz_spells;
pr_spells = wiz_spells = 0;
for (i=1; i<=7; ++i)
pr_spells += pPS->mfCanMemorize(SPELL_INFO::PRIEST, SPELL_INFO::LEVEL(i))
- pPS->mfMemorized(SPELL_INFO::PRIEST, SPELL_INFO::LEVEL(i));
for (i=1; i<=9; ++i)
wiz_spells += pPS->mfCanMemorize(SPELL_INFO::WIZARD, SPELL_INFO::LEVEL(i))
- pPS->mfMemorized(SPELL_INFO::WIZARD, SPELL_INFO::LEVEL(i));
if (pr_spells > 0 || wiz_spells > 0)
{
fPreparingSpells = TRUE;
MagicPrep(who);
while (fPreparingSpells)
MenuLoop();
}
// One charge per adventure per sceptre.
InventoryItor itor(pPS->Inventory);
while (itor.mfFind(ITEM_SCEPTRE_OF_CUIRAECEN))
{
(*itor)->mfSetCharges(1);
}
// Setup Blood healing abilites for adventures.
itor = pPS->Inventory.begin();
if (itor.mfFind(ITEM_HEALING_MINOR))
{
(*itor)->mfSetCharges(1);
}
itor = pPS->Inventory.begin();
if (itor.mfFind(ITEM_HEALING_MAJOR))
{
(*itor)->mfSetCharges(2);
}
itor = pPS->Inventory.begin();
if (itor.mfFind(ITEM_HEALING_GREAT))
{
(*itor)->mfSetCharges(3);
}
itor = pPS->Inventory.begin();
if (itor.mfFind(ITEM_FEAR))
{
(*itor)->mfSetCharges(3);
}
itor = pPS->Inventory.begin();
if (itor.mfFind(ITEM_TRAVEL))
{
(*itor)->mfSetCharges(1);
}
itor = pPS->Inventory.begin();
if (itor.mfFind(ITEM_ENHANCED_SENSE))
{
// Anduiras'ns get 3 charges of detect evil.
if (ANDUIRAS == regents[Adventures[who]].mfGetBL_deriv())
{
(*itor)->mfSetCharges(3);
}
else
{
(*itor)->mfSetCharges(255); // infinite number. well as big as we can hold.
}
}
itor = pPS->Inventory.begin();
if (itor.mfFind(ITEM_PROTECTION_FROM_EVIL))
{
(*itor)->mfSetCharges(1);
}
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
if (count >= 4) // That's all we can carry!
break;
}
}
fPreparingSpells = FALSE;
iAdventureSiteIndex = SiteList[iSite];
iSiteChosen = advsite[iAdventureSiteIndex].iPlaces;
// let the scene manager know who's going, and where
SCENE_MGR::Aggressor = (REALM::REALM_TYPE) advsite[iAdventureSiteIndex].realm;
SCENE_MGR::Visitors = (REALM::REALM_TYPE) units[iPartyLead].Realm;
SCENE_MGR::HomeIndex = iPartyLead; // who is the home unit (w/camera)
SCENE_MGR::AwayIndex = -1; // who is the away unit
SCENE_MGR::PlacesIndex = iSiteChosen; // where we're going
SCENE_MGR::SceneType = SCENE_AI::ADVENTURE_SCENE; // type for next scene ai
SCENE_MGR::mfRequestNewScene(advsite[iAdventureSiteIndex].name, TYPE_PLAYERSTART1, FALSE); // load first scene
adv_dif = advsite[iAdventureSiteIndex].difficulty;
fShowProgressBar = TRUE;
InitDomainTurn(0);
fPractice = FALSE;
fFreezeDomainUI = FALSE;
sMenusUp = 0;
HidePanel(D_ADVENTURE_PREP);
pop_regions();
fUpdatePanels = TRUE;
}
}
/* ========================================================================
Function - AdvPrepCancel
Description -
Returns -
======================================================================== */
void AdvPrepCancel (LONG MenuCombo, LONG )
{
LONG MenuId, ButtonId;
SPLIT_LONG(MenuCombo, MenuId, ButtonId);
// click the button
SetButtonHilight(D_ADVENTURE_PREP, ButtonId, TRUE);
fUpdatePanels = TRUE;
RunPanels();
RunMenus();
update_screen();
TickDelay(4);
SetButtonHilight(D_ADVENTURE_PREP, ButtonId, FALSE);
fUpdatePanels = TRUE;
RunPanels();
RunMenus();
update_screen();
/* -----------------------------------------------------------------
Handle right clicks help
----------------------------------------------------------------- */
if(mouse_button == 2)
{
//SystemHelp(STR_BA_HELP_DONE_TITLE, STR_BA_HELP_DONE_TITLE, -1, NULL, 0);
}
else
{
// restore the state of the map level
RESTORE_REGION_STATE(regDOMAIN_TURN_MODE);
RESTORE_REGION_STATE(regACTION_MODE);
RESTORE_REGION_STATE(regMINIMIZED);
RESTORE_REGION_STATE(regMAXIMIZED);
RESTORE_REGION_STATE(regTAX_ROLLS);
RESTORE_REGION_STATE(regSWITCH_TO_ACTIONS);
RESTORE_REGION_STATE(regADJUST_TAXES);
dturn_mode = ACTN_MODE;
if (fLTAction == DURING_LTACTION)
{
ActiveRegent = realm[HomeRealm].mfGetRegent();
fLTAction = BEFORE_LTACTION;
}
DataAreaMode (ACTN_MODE, 0);
fPractice = FALSE;
fFreezeDomainUI = FALSE;
sMenusUp = 0;
HidePanel(D_ADVENTURE_PREP);
pop_regions();
fUpdatePanels = TRUE;
}
}
/* ========================================================================
Function - AdvPrepListSel
Description -
Returns -
======================================================================== */
void AdvPrepListSel (LONG MenuCombo, LONG )
{
SHORT i,index;
LONG MenuId, ButtonId;
SPLIT_LONG(MenuCombo, MenuId, ButtonId);
index = ButtonId - BA_LIST_01;
// site selection
if(index < 8)
{
if (SiteList[AdvSiteListboxFirst+index] != fERROR)
{
// enable go on adventure button
SetButtonLabelColor(MenuId, BA_DONE, BTN_LABEL_COLOR);
activate_region(BA_DONE, TRUE);
for(i=BA_LIST_01;i<=BA_LIST_08;++i)
SetButtonType(MenuId, i, BUTTON_REGION);
// SetButtonType(MenuId, ButtonId, BUTTON_COLORBEVEL);
iSite = AdvSiteListboxSel = AdvSiteListboxFirst+index;
}
else
{
// disable go on adventure button
SetButtonLabelColor(MenuId, BA_DONE, GREY);
activate_region(BA_DONE, FALSE);
}
}
// party member selection
else
{
index -= 8;
if (Adventures[PartyListboxFirst+index] != fERROR)
{
for(i=BA_LIST_09;i<=BA_LIST_16;++i)
SetButtonType(MenuId, i, BUTTON_REGION);
//SetButtonType(MenuId, ButtonId, BUTTON_COLORBEVEL);
PartyListboxSel = PartyListboxFirst+index;
if (mouse_button == 1)
{
// show character spells inventory
MagicPrep(PartyListboxSel);
}
else
if (mouse_button == 2)
{
// show character status
LONG const ThisRegentIndex = Adventures[PartyListboxSel];
if (ThisRegentIndex > 0 &&
ThisRegentIndex <= CHARACTER_COUNT)
{
SetStatusRealm((REALM::REALM_TYPE) regents[ThisRegentIndex].mfGetRealm());
LONG const hPlayerStats = LoadStats(regents[ThisRegentIndex].mfGetid(), fERROR);
ShowStatus(0, hPlayerStats);
}
}
}
}
fUpdatePanels = TRUE;
}
/* ========================================================================
Function - AdvPrepListScroll
Description - scroll button for the two listboxs
Returns -
======================================================================== */
void AdvPrepListScroll (LONG MenuCombo, LONG ButtonVal)
{
SHORT Index;
LONG MenuId, ButtonId;
SPLIT_LONG(MenuCombo, MenuId, ButtonId);
// click the button
SetButtonHilight(D_ADVENTURE_PREP, ButtonId, TRUE);
fUpdatePanels = TRUE;
RunPanels();
RunMenus();
update_screen();
TickDelay(4);
SetButtonHilight(D_ADVENTURE_PREP, ButtonId, FALSE);
switch (ButtonId)
{
case ADV_LIST1_UP:
// scroll the site list
if (AdvSiteListboxFirst)
AdvSiteListboxFirst--;
// keep the sel on the list
if (AdvSiteListboxSel > (AdvSiteListboxFirst + LISTBOX_SIZE - 1))
AdvSiteListboxSel = (AdvSiteListboxFirst + LISTBOX_SIZE - 1);
Index = AdvSiteListboxSel - AdvSiteListboxFirst + BA_LIST_01;
break;
case ADV_LIST1_DOWN:
// scroll the site list down
if (AdvSiteListboxFirst < (AdvSiteListboxCount - LISTBOX_SIZE))
++AdvSiteListboxFirst;
// keep the sel on the list
if (AdvSiteListboxSel < AdvSiteListboxFirst)
AdvSiteListboxSel = AdvSiteListboxFirst;
Index = AdvSiteListboxSel - AdvSiteListboxFirst + BA_LIST_01;
break;
case ADV_LIST2_UP:
// scroll the party list up
if (PartyListboxFirst)
PartyListboxFirst--;
// keep the sel on the list
if (PartyListboxSel > (PartyListboxFirst + LISTBOX_SIZE - 1))
PartyListboxSel = (PartyListboxFirst + LISTBOX_SIZE - 1);
Index = PartyListboxSel - PartyListboxFirst + BA_LIST_09;
break;
case ADV_LIST2_DOWN:
// scroll the party list down
if (PartyListboxFirst < (PartyListboxCount - LISTBOX_SIZE))
++PartyListboxFirst;
// keep the sel on the list
if (PartyListboxSel < PartyListboxFirst)
PartyListboxSel = PartyListboxFirst;
Index = PartyListboxSel - PartyListboxFirst + BA_LIST_09;
break;
default:
break;
}
// pass a fake click into the select code to update the selection
mouse_button = 0;
MenuCombo = BUILD_LONG(D_ADVENTURE_PREP,Index);
AdvPrepListSel (MenuCombo, 0);
}
/* ========================================================================
Function - TogglePartyCheck
Description -
Returns -
======================================================================== */
void TogglePartyCheck(LONG i, LONG)
{
SHORT j;
SHORT index = i + PartyListboxFirst;
SHORT count = 0;
for(j=0;j<LIST_SIZE;++j)
{
if (inParty[j])
++count;
}
if (i == 0 && inParty[0]) // can't undo first guy in list
{
AddSndObj(BIRTHRT_SND::SND_UI_NOT_PERMITTED,0,VOLUME_NINETY);
return;
}