-
Notifications
You must be signed in to change notification settings - Fork 0
/
ACTNMENU.SAV
9277 lines (8204 loc) · 290 KB
/
ACTNMENU.SAV
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: ACTNMENU.CPP
Authors: Alan Clark, Lan Zhou, & Michael Branham
========================================================================
Contains the following internal functions:
Contains the following general functions:
======================================================================= */
/* ------------------------------------------------------------------------
Includes
------------------------------------------------------------------------ */
#ifdef _WINDOWS
#include <windows.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include "system.h"
#include "actnmenu.hxx"
#include "charsel.hxx"
#include "sound.hxx"
#include "units.hxx"
#include "realm.hxx"
//#include "rlmspell.hxx"
#include "gamemap.hxx"
#include "mapai.hxx"
#include "menu.h"
#include "request.h"
#include "playstat.hxx"
#include "regents.hxx"
#include "game.h"
#include "actions.hxx"
#include "strmgr.h"
#include "strenum.h"
#include "report.hxx"
#include "multimap.hxx"
#include "thingtyp.h"
#include "multiui.hxx"
#include "menu.h"
#include "panel.h"
#ifdef _WINDOWS
#include "winsys\mulplay.hxx"
#endif
/* ------------------------------------------------------------------------
Notes
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Defines and Compile Flags
------------------------------------------------------------------------ */
#define D20TOPERCENT(a) ((mundane_descriptions)?(105-((a)*5)):(a))
#define PERCENTCHAR ((mundane_descriptions)?'%':0)
#define RULE_LAW 0
#define RULE_GUILD 1
#define RULE_TEMPLE 2
#define RULE_SOURCE 3
#define RULE_PROV 4
#define DKBLUE 60
#define BLUE 64
#define DKRED 112
#define MDRED 120
#define MDGREEN 188
#define DKBROWN 128
#define MDBROWN 136
#define ORANGE 142
#define DKTAN 209
#define MDTAN 213
#define LTTAN 223
#define COPPER_GRAD 224
#define BEFORE_LTACTION 0
#define DURING_LTACTION 1
#define AFTER_LTACTION 2
#define LARGE 0
#define SMALL 1
#define REGENTNAME 160
#define NUMDIPSUBJ 11
/* ------------------------------------------------------------------------
Macros
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Prototypes
------------------------------------------------------------------------ */
void CleanupAfterActnMenu (void);
static void DeleteActnMenuRegions (void);
void DoneHoldAction(LONG, LONG);
void CancelHoldAction(LONG, LONG);
void DispSuccess (void);
void MapAIPlayerResponseWaitSync (void);
void UpdateHoldingFlag (void);
void SuspendTimeLimit (void);
void InitActionGlobals (void);
extern "C" void ResumeTimeLimit (void);
LONG HoldingValue (LONG iHold);
BOOL ForeignUnitsHere (PROVINCE prov, REALM::REALM_TYPE _realm);
#ifdef _LOGCOMMENT
extern "C" void RandomLogComment ( char * szString );
extern "C" void RandomLogPrefix ( char * szString );
#endif
extern "C" {
void SetRedrawMainMapLevel (void);
}
/* ------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------ */
SHORT usedFreeAction = 0; // extra actions you've used this turn
SHORT usedFreeForge = 0; // number of LL's you've forged as free actions
SHORT usedFreeMagic = 0; // number of Realm Spells cast as free actions
SHORT usedFreeAgitate = 0; // if priest
SHORT usedFreeSpy = 0; // if thief
static LONG startProvCount = 1;
static LONG startProvCount1 = 1;
static LONG startProvCount2 = 1;
static SHORT iCurAction = 0;
static BOOL musterSkl = 0;
static BOOL firstRollFlag = 0;
SHORT oldAction = 1;
static BOOL checkGoldReg = 0;
LONG fAllowCancelButton = TRUE;
LONG fAllowRollButton = FALSE;
LONG fAllowDoneButton = TRUE;
LONG fAllowRollButton_others = FALSE;
LONG fAllowDoneButton_others = TRUE;
BOOL fPlayerNeverDeclaredWar = TRUE;
static LONG GoldBar = -2;
static LONG GoldGained = 0;
static LONG RegencePoint = -2;
static LONG iSelectedRealm = REALM::NO_COUNTRY;
static UBYTE modGoldBars = 0;
UBYTE modRegency=0;
static BOOL NoFlag = FALSE;
LONG modOpponent = 0;
static LONG modLevel = 0;
static LONG reportFlag = 0;
static LONG iNewScreen = 0;
static LONG iCancel = 1;
static LONG additionalamt = 0;
static LONG startPlace = 0;
static PROVINCE iSelectedProvince = NO_PROVINCE;
static LONG iSelectedOneHolding = 99;
static LONG iSelectedUnit = 0;
LONG fOtherDipMP = FALSE; //---- Multiplayer diplomacy sync flag
//---- should be true when called from mapai.cpp
//---- Sync point #5 should be done
extern USHORT TargetPlace;
extern SHORT iProvMap;
extern BOOL fTutorialSelected;
extern BOOL fMenuClosed;
extern LONG fControlMode;
extern USHORT StartPlace;
DEFINE_STATIC_VECTOR_DATA_S(LONG,iSelection,NUMDIPSUBJ);
DEFINE_VECTOR_CLASS(LONG, iSelection);
DEFINE_STATIC_VECTOR_DATA_S(LONG,iSelectedMulUnits,20);
DEFINE_VECTOR_CLASS(LONG,iSelectedMulUnits);
DEFINE_STATIC_VECTOR_DATA_S(UBYTE,iSelectedMulProvince,16);
DEFINE_VECTOR_CLASS(UBYTE, iSelectedMulProvince);
DEFINE_MATRIX_DATA_S(UBYTE,iSelectedHolding,PROVINCE_COUNT,4);
DEFINE_MATRIX_CLASS_S(UBYTE, iSelectedHolding,PROVINCE_COUNT,4);
DEFINE_VECTOR_DATA_S(UBYTE,iLieutenants,9)={0, 0, 0, 0, 0, 0, 0, 0, 0};
DEFINE_VECTOR_CLASS(UBYTE, iLieutenants);
DEFINE_STATIC_VECTOR_DATA(LONG,HoldingType) = {RULE_LAW,RULE_GUILD,RULE_TEMPLE,RULE_SOURCE};
DEFINE_VECTOR_CLASS(LONG, HoldingType);
DEFINE_VECTOR_DATA(LONG,InfoReqType) = {LAW1_ICON,GUILD1_ICON,TEMPLE1_ICON,SOURCE1_ICON,CASTLE1_ICON,WIZTOWER_ICON, 0};
DEFINE_VECTOR_CLASS(LONG,InfoReqType);
DEFINE_STATIC_VECTOR_DATA(GAME_STRING,gsHoldType) = {STR_ACTNMENU_CAPS_LAW,STR_ACTNMENU_CAPS_GUILD,STR_ACTNMENU_CAPS_TEMPLE,STR_ACTNMENU_CAPS_SOURCE,STR_ACTNMENU_CAPS_PROVINCE};
DEFINE_VECTOR_CLASS(GAME_STRING, gsHoldType);
DEFINE_VECTOR_DATA(GAME_STRING,gsAllHold) = {STR_ACTNMENU_LAW,STR_ACTNMENU_GUILD,STR_ACTNMENU_TEMPLE,STR_ACTNMENU_SOURCE,STR_ACTNMENU_CASTLE,STR_ACTNMENU_WIZTOWER,STR_NULL};
DEFINE_VECTOR_CLASS(GAME_STRING, gsAllHold);
DEFINE_STATIC_VECTOR_DATA(GAME_STRING,gsLoyaltyUC) = {STR_ACTNMENU_LOYALTY_REBEL,STR_ACTNMENU_LOYALTY_POOR,STR_ACTNMENU_LOYALTY_AVERAGE,STR_ACTNMENU_LOYALTY_HIGH};
DEFINE_VECTOR_CLASS(GAME_STRING, gsLoyaltyUC);
DEFINE_VECTOR_DATA(MAP_ICON,MonsterUnits)={G_INF_UNIT_ICON, G_CAV_UNIT_ICON, N_INF_UNIT_ICON, C_SKL_UNIT_ICON};
DEFINE_VECTOR_CLASS(MAP_ICON, MonsterUnits);
DEFINE_VECTOR_DATA(UBYTE,LevelUnitReqt) = {0, 1,3,2,1,2,1,0,4,3,0,0,0,0,0, 2,3,4, 4,4, 2,2,3, 0,0, 0,0,0,0,0};
DEFINE_VECTOR_CLASS(UBYTE, LevelUnitReqt);
DEFINE_VECTOR_DATA(UBYTE,UnitMusterCost) = {0, 2,4,2,1,2,0,2,6,4,4,4,3,4,6, 4,4,8, 4,4, 1,1,4, 2,3, 4,4,4,4,8};
DEFINE_VECTOR_CLASS(UBYTE, UnitMusterCost);
static LONG iThisRoll;
static LONG iWhichRoll = 99;
static LONG lAskedTargetWhichRoll = 99;
static LONG xRollLocation;
static LONG yRollLocation;
static UBYTE fRollResult[128];
static UBYTE success_roll;
DEFINE_STATIC_VECTOR_DATA(UBYTE,expertHolding)={1, 6, 4, 5, 1};
DEFINE_VECTOR_CLASS(UBYTE, expertHolding);
DEFINE_STATIC_VECTOR_DATA(UBYTE,expertise) = {
/*NO_ACTION*/ 0, // no one
/*ADVENTURE*/ 0,
/*AGITATE*/ 4, // priest
/*BUILD_ROAD*/ 0,
/*CONTEST*/ 8, // as holding type
/*CREATE_HOLDING*/ 8, // as holding type
/*DECLARE_WAR*/ 0,
/*DIPLOMACY*/ 9, // any
/*ESPIONAGE*/ 6, // thief
/*FORGE_LEY_LINE*/ 5, // wizard
/*FORTIFY*/ 1, // fighter
/*HOLD_ACTION*/ 0,
/*INVESTITURE*/ 0,
/*LIEUTANANT*/ 0,
/*LT_ACTION*/ 0,
/*MUSTER*/ 0,
/*REALM_SPELL*/ 10, // wizard & priest
/*RULE*/ 8, // as holding type
/*TRADE_ROUTE*/ 6, // thief
};
DEFINE_VECTOR_CLASS(UBYTE, expertise);
DEFINE_VECTOR_DATA(SHORT,UnitTypeID) = {
/* NO_MAP_ICON */ 0,
/* A_INF_UNIT_ICON */ INFANTRY,
/* A_EIN_UNIT_ICON */ ELITE_INFANTRY,
/* A_BOW_UNIT_ICON */ ARCHER,
/* A_IRR_UNIT_ICON */ IRREGULAR,
/* A_PIK_UNIT_ICON */ PIKEMAN,
/* A_LVY_UNIT_ICON */ LEVY,
/* A_SCT_UNIT_ICON */ SCOUT,
/* A_KNT_UNIT_ICON */ KNIGHT,
/* A_CAV_UNIT_ICON */ LIGHT_CAVALRY,
/* M_INF_UNIT_ICON */ MERC_INFANTRY,
/* M_BOW_UNIT_ICON */ MERC_ARCHER,
/* M_IRR_UNIT_ICON */ MERC_IRREGULAR,
/* M_PIK_UNIT_ICON */ MERC_PIKEMAN,
/* M_CAV_UNIT_ICON */ MERC_CAVALRY,
/* E_INF_UNIT_ICON */ ELF_INFANTRY,
/* E_BOW_UNIT_ICON */ ELF_ARCHER,
/* E_CAV_UNIT_ICON */ ELF_CAVALRY,
/* D_INF_UNIT_ICON */ DWARF_INFANTRY,
/* D_BOW_UNIT_ICON */ DWARF_ARCHER,
/* G_INF_UNIT_ICON */ GOBLIN_INFANTRY,
/* G_BOW_UNIT_ICON */ GOBLIN_ARCHER,
/* G_CAV_UNIT_ICON */ GOBLIN_CAVALRY,
/* N_INF_UNIT_ICON */ GNOLL_1,
/* N_IRR_UNIT_ICON */ GNOLL_IRREGULAR,
/* C_HPY_UNIT_ICON */ T_HARPY,
/* C_SKL_UNIT_ICON */ T_SKELETON,
/* C_SPD_UNIT_ICON */ T_GIANT_SPIDER,
/* C_HEL_UNIT_ICON */ T_HELL_HOUND,
/* C_WYV_UNIT_ICON */ T_WYVERN_1,
};
DEFINE_VECTOR_CLASS(SHORT, UnitTypeID);
extern SHORT iDRollFIc;
extern int reqSound;
extern BOOL fSmallMap;
extern LONG TutorialActionNumber;
extern LONG TutorialScreenNumber;
extern BOOL mundane_descriptions;
static void DoDealMenu(LONG iRealm);
#if 0
// Diplomacy structs
typedef struct
{
unsigned int iWhoFrom : 6;
unsigned int iAlliance : 2;
unsigned int iReqGold : 5;
unsigned int iReqProv : 8;
unsigned int iReqHold : 10;
unsigned int iReqTrib : 5;
unsigned int iOffProv : 8;
unsigned int iOffHold : 10;
unsigned int iOffTrib : 5;
unsigned int iOffGold : 5;
unsigned int iOffRegy : 5;
} DIP_DATA;
typedef struct
{
LONG data1;
LONG data2;
LONG data3;
} DIP_DATA1;
typedef struct
{
union
{
DIP_DATA d1;
DIP_DATA1 d2;
};
} DIPLOMACY_DATA;
#endif
DIPLOMACY_DATA dData;
void SetCurAction(SHORT iAction)
{
iCurAction = iAction;
return;
}
/* ========================================================================
Function -
Description - Vassal of another realm?
Returns -
======================================================================== */
static BOOL CheckVassal ( REALM::REALM_TYPE rlm )
{
REALM::REALM_TYPE i;
for (i=REALM::FIRST_REALM; i < LAND_REALM_COUNT; i = (REALM::REALM_TYPE)(i + 1))
{
if ( ISVASSAL(rlm, i) )
{
return TRUE;
}
}
return FALSE;
}
/* ========================================================================
Function -
Description - reconstruct the map
Returns -
======================================================================== */
void ReconstructMap (void)
{
LONG j;
LONG fLowMemory_ = fLowMemory;
LONG fRestrictAni_ = fRestrictAni;
LONG fLowResTextures_ = fLowResTextures;
LONG fLowResAni_ = fLowResAni;
LONG fMedResTextures_ = fMedResTextures;
LONG fMedResAni_ = fMedResAni;
fLowMemory = FALSE;
fRestrictAni = FALSE;
fLowResTextures = FALSE;
fLowResAni = FALSE;
fMedResTextures = FALSE;
fMedResAni = FALSE;
if (iLgMap != fERROR)
{
DisposBlock(iLgMap);
iLgMap = fERROR;
}
run_timers(); // cdb 11/27 // ABC don't put in inner loops
//---- Always small map in multiplayer otherwise we go out of sync
#ifdef _WINDOWS
if ( IsMultiPlayer() )
{
iLgMap = GetResourceStd("MAP\\SMMAP.PCX", FALSE);
fLgMap = SMALL;
}
else
#endif
{
if (fSmallMap)
{
iLgMap = GetResourceStd("MAP\\SMMAP.PCX", FALSE);
fLgMap = SMALL;
}
else
{
iLgMap = GetResourceStd("MAP\\LGMAP.PCX", FALSE);
if (iLgMap == fERROR)
{
// Try for the smaller map.
iLgMap = GetResourceStd("MAP\\SMMAP.PCX", FALSE);
fLgMap = SMALL;
}
else
{
fLgMap = LARGE;
}
}
}
if (iProvMap == fERROR)
iProvMap = GetResourceStd("MAP\\PROVMAP.PCX", FALSE);
SetModifyResource(iLgMap);
for (j=FIRST_PROVINCE; j<PROVINCE_COUNT; ++j)
DrawRoads((PROVINCE)j);
DrawBorders(0, 0, 0, 0, ((BITMPTR)BLKPTR(iLgMap))->w, ((BITMPTR)BLKPTR(iLgMap))->h, FULL_SCALE);
fLowMemory = fLowMemory_; // DON'T REMOVE THIS
fRestrictAni = fRestrictAni_; // DON'T REMOVE THIS
fLowResTextures = fLowResTextures_; // DON'T REMOVE THIS
fLowResAni = fLowResAni_; // DON'T REMOVE THIS
fMedResTextures = fMedResTextures_; // DON'T REMOVE THIS
fMedResAni = fMedResAni_; // DON'T REMOVE THIS
}
/* ========================================================================
Function -
Description -
Returns -
======================================================================== */
void NextPrev (LONG val, LONG);
void DrawLittleButton (LONG x, LONG y, LONG w, LONG h, LONG pushFlag);
BOOL DoPageProvince(LONG *startCount, LONG provCount, LONG countToPrint, LONG counter, LONG x, LONG y)
{
BOOL rv = FALSE;
if(*startCount < 1)
*startCount = 1;
if(provCount > countToPrint &&
(((counter%countToPrint) == 0) || (counter == provCount)))
{
if(*startCount > 1)
{
DrawLittleButton(x+10, y+1, 50, 8, FALSE);
add_region(x+10, y+1, 50, 8, 0, NextPrev,-countToPrint,(LONG)startCount,0, -1);
print_textf(x+10+25, y+6, DKBROWN, STRMGR_GetStr(STR_ACTNMENU_PREV_PAGE));
rv = TRUE;
}
if(*startCount <= (provCount - countToPrint))
{
DrawLittleButton(x+65, y+1, 50, 8, FALSE);
add_region(x+65, y+1, 50, 8, 0, NextPrev,countToPrint,(LONG)startCount,0, -1);
print_textf(x+65+25, y+6, DKBROWN, STRMGR_GetStr(STR_ACTNMENU_NEXT_PAGE));
rv = TRUE;
}
}
return rv;
}
/* ========================================================================
Function -
Description -
Returns -
======================================================================== */
void DrawLittleButton (LONG x, LONG y, LONG w, LONG h, LONG pushFlag)
{
LONG Color1, Color2, Color3;
if (pushFlag)
{
Color1 = COPPER_GRAD;
Color2 = COPPER_GRAD - 10;
Color3 = LTTAN - 4;
}
else
{
Color1 = COPPER_GRAD - 10;
Color2 = COPPER_GRAD;
Color3 = LTTAN;
}
color_rect(x, y, w+1, h, Color3);
color_rect(x-2, y-2, 1, h+4, Color1);
color_rect(x-1, y-1, 1, h+2, Color1);
color_rect(x-1, y-1, w+2, 0, Color1);
color_rect(x-1, y-2, w+3, 0, Color1);
color_rect(x+w+2, y-2, 1, h+4, Color2);
color_rect(x+w+1, y-1, 1, h+2, Color2);
color_rect(x, y+h+1, w+2, 0, Color2);
color_rect(x-1, y+h+2, w+3, 0, Color2);
}
/* ========================================================================
Function - Functions to determine success
Description -
Returns -
======================================================================== */
#define CHECK_ONLY 1
#define CHECK_AND_UPDATE 2
#define CHECK_QUITE 3
static BOOL ProcessGoldAndReg (LONG mode)
{
LONG j;
checkGoldReg = 1;
if (((GoldBar-GoldGained)*10) > realm[HomeRealm].mfGetTreasury())
{
if(mode != CHECK_QUITE)
AddSndObj((BIRTHRT_SND)SND_UI_NOT_ENOUGH_GOLD,0,VOLUME_NINETY);
return FALSE;
}
if (RegencePoint > realm[HomeRealm].mfGetRegency())
{
if(mode != CHECK_QUITE)
AddSndObj((BIRTHRT_SND)SND_UI_NOT_ENOUGH_REGENCY,0,VOLUME_NINETY);
return FALSE;
}
if (mode == CHECK_AND_UPDATE )
{
realm[HomeRealm].mfAddRegency(-RegencePoint);
// if(((iCurAction == REALM_SPELL && iSelectedOneHolding == ITEM_SPELL_ALCHEMY) ||
// iCurAction == DIPLOMACY )
// && GoldGained > 0)
// Handle the Diplomacy case upon success.
if ((iCurAction == REALM_SPELL & iSelectedOneHolding == ITEM_SPELL_ALCHEMY)
&& GoldGained > 0)
{
realm[HomeRealm].mfAddTreasury(GoldGained * 10);
GoldGained = 0;
}
realm[HomeRealm].mfAddTreasury(-(GoldBar * 10));
// YOU HAVE TO SEND THIS IN MULTIPLAYER
#ifdef _LOGCOMMENT
{
char temp[100];
sprintf ( temp, "ProcessGoldAndRegency - HomeRealm:%s regency:%04d",realm[HomeRealm].mfGetName(),realm[HomeRealm].mfGetRegency());
RandomLogComment ( temp );
}
#endif
SetGameData(MP_REALM, MPRLM_TREASURY, HomeRealm, realm[HomeRealm].mfGetTreasury(), TRUE);
SetGameData(MP_REALM, MPRLM_REGENCY, HomeRealm, realm[HomeRealm].mfGetRegency(), TRUE);
}
return TRUE;
}
/* ========================================================================
Function - Functions to determine success
Description -
Returns -
======================================================================== */
void CancelRoll (void)
{
fAllowCancelButton = FALSE;
fAllowRollButton = TRUE;
fAllowDoneButton = FALSE;
iWhichRoll = 99;
lAskedTargetWhichRoll = 99;
}
/* ========================================================================
Function - Functions to determine success
Description -
Returns -
======================================================================== */
static UBYTE RollSuccess (UBYTE Chance, LONG x, LONG y, LONG lPrint)
{
++iThisRoll;
if (iThisRoll >= 128)
fatal_error("ERROR - index of fRollResult exceeded 127 in ACTNMENU\n");
if (fLTAction == DURING_LTACTION && iSelectedRealm > 0 && iSelectedRealm < REALM::REALM_COUNT)
{
CLASS_ENUM const class1 = regents[iSelectedRealm].mfGetClass1();
CLASS_ENUM const class2 = regents[iSelectedRealm].mfGetClass2();
UBYTE const expert = expertise[iCurAction];
if ( expert!=class1
&& expert!=class2
&& expert!=9
&& expert!=8
&& (!(expert==10&&(class1==PRIEST||class1==WIZARD||class2==PRIEST||class2==WIZARD))))
{
Chance += 3;
}
if(expert == 8)
{
if(expertHolding[iSelectedOneHolding]!=class1
&& expertHolding[iSelectedOneHolding]!=class2)
Chance += 3;
}
}
if (fRollResult[iThisRoll] == 1)
{
if(iCurAction==REALM_SPELL && iSelectedOneHolding == ITEM_SPELL_SCRY)
return 3;
if(lPrint)
{
print_textf(x+1, y+6, DKBROWN,STRMGR_GetStr(STR_ACTNMENU_F02_WON));
print_textf(x, y+5, MDGREEN, STRMGR_GetStr(STR_ACTNMENU_WON));
}
fAllowRollButton = FALSE;
fAllowCancelButton = FALSE;
if(iCurAction == ESPIONAGE)
return 3;
return 0;
}
if (fRollResult[iThisRoll] == 2)
{
if(iCurAction==REALM_SPELL && iSelectedOneHolding == ITEM_SPELL_SCRY)
return 3;
if(lPrint)
{
print_textf(x+1, y+6, DKBROWN, STRMGR_GetStr(STR_ACTNMENU_F02_LOST));
print_textf(x, y+5, RED, STRMGR_GetStr(STR_ACTNMENU_LOST));
}
fAllowRollButton = FALSE;
fAllowCancelButton = FALSE;
return 0;
}
if (iThisRoll == iWhichRoll) // time to do the roll
{
xRollLocation = x;
yRollLocation = y;
DispSuccess();
success_roll = random(20)+1;
if (success_roll >= Chance || fTutorialSelected)
{
fRollResult[iThisRoll] = 1; // succeed
if(iCurAction != ESPIONAGE || iSelectedOneHolding != 1)
{
if (iThisRoll == 0)
AddSndObj((BIRTHRT_SND)SND_UI_DELAY_SUCCEEDED,0,VOLUME_NINETY);
else
AddSndObj((BIRTHRT_SND)SND_UI_SUCCEEDED,0,VOLUME_NINETY);
}
}
else
{
fRollResult[iThisRoll] = 2; // fail
if (iThisRoll == 0)
AddSndObj((BIRTHRT_SND)SND_UI_DELAY_DID_NOT_SUCCEED,0,VOLUME_NINETY);
else
AddSndObj((BIRTHRT_SND)SND_UI_DID_NOT_SUCCEED,0,VOLUME_NINETY);
}
//printf("ROLL SUCCESS - Chance:%d roll:%d result:%d\n",Chance,success_roll,fRollResult[iThisRoll]);
return fRollResult[iThisRoll];
}
return 0;
}
/* ======================================================================== */
static void DispSuccess (void)
{
static LONG waittime = 0;
// check for start conditions
if (iWhichRoll>iThisRoll || xRollLocation==0 || yRollLocation==0)
{
lAskedTargetWhichRoll = 99;
return;
}
// draw graphics each time
DrawBitmap((SHORT)(xRollLocation+15-90), (SHORT)(yRollLocation+5-24), iDRollFIc, 0, 0, 999, 999);
// do sound once
//if(iWhichRoll==0)
// AddSndObj((BIRTHRT_SND)SND_UI_DICE1,0,VOLUME_NINETY);
if(iWhichRoll==0 && firstRollFlag==0)
{
waittime = get_time()+27;
AddSndObj((BIRTHRT_SND)SND_UI_DICE1,0,VOLUME_NINETY);
firstRollFlag=1;
}
// wait to advance
if (waittime>get_time())
{
lAskedTargetWhichRoll = 99;
fAllowDoneButton = FALSE;
return;
}
waittime = get_time()+18;
++iWhichRoll; // advance
fAllowDoneButton = TRUE;
lAskedTargetWhichRoll = iWhichRoll;
}
/* ========================================================================
Function - Various utility functions
Description -
Returns -
======================================================================== */
void SelectRealm (LONG realm_, LONG)
{
if (mouse_button == 2)
{
if (iCurAction == LIEUTANANT)
ShowStatus(-realm_, 0);
else if (iCurAction == LIEUTENANT_ACTION)
ShowStatus(regents[realm_].mfGetid(), 0);
else if (iCurAction == DIPLOMACY)
ShowStatus(-regents[realm[realm_].mfGetRegent()].mfGetid(), 0);
}
else
{
fAllowRollButton -= (iSelectedRealm!=0);
// set new or toggle off
iSelectedRealm = (iSelectedRealm == realm_) ? 0 : realm_;
fAllowRollButton += (iSelectedRealm!=0);
fAllowRollButton -= (iSelectedProvince!=0);
// clear a bunch of stuff
checkGoldReg = 0;
iSelectedProvince = NO_PROVINCE;
iSelectedOneHolding = 99;
iSelectedUnit = 0;
modRegency = modGoldBars = modLevel = 0;
for (LONG i=0; i<16; ++i)
iSelectedMulProvince[i] = 0;
for (i=0; i<20; ++i)
iSelectedMulUnits[i] = 0;
for (i=0; i<9; ++i)
iSelection[i] = 0;
if (iCurAction==DIPLOMACY)
{
for (i=0; i<PROVINCE_COUNT; ++i)
iSelectedHolding[i][3] = 0;
startProvCount = 1;
}
iNewScreen = 0;
}
}
/* ======================================================================== */
void SelectProvince (LONG prov, LONG)
{
LONG i, j;
checkGoldReg = 0;
fAllowRollButton -= (iSelectedProvince!=0);
iSelectedProvince = (iSelectedProvince == prov) ? NO_PROVINCE : (PROVINCE)prov;
fAllowRollButton += (iSelectedProvince!=0);
modRegency = modGoldBars=modLevel = 0;
if (iCurAction!=REALM_SPELL && iCurAction!=TRADE_ROUTE && iCurAction != FORGE_LEY_LINE)
{
for(i=0; i<PROVINCE_COUNT; ++i)
for(j=0; j<4; ++j)
{
fAllowRollButton -= (iSelectedHolding[i][j]!=0);
iSelectedHolding[i][j] = 0;
}
}
iSelectedOneHolding = 99; // 99 means no holding
iSelectedUnit = 0;
for(i=0; i<16; ++i)
iSelectedMulProvince[i]=0;
for(i=0; i<20; ++i)
iSelectedMulUnits[i]=0;
}
/* ======================================================================== */
void Selection (LONG prov, LONG index)
{
LONG i, j;
checkGoldReg = 0;
fAllowRollButton -= (iSelection[index]!=0);
iSelection[index] = (iSelection[index] == prov) ? 0 : prov;
fAllowRollButton += (iSelection[index]!=0);
if(iSelection[index]!=0 && index != 5 && index != 8) // for Diplomacy choosing holding
iNewScreen = 0;
if(iSelection[index]==5 || iSelection[index]==8)
iSelection[index-2]=0;
if(iSelection[index]==3 || iSelection[index]==6)
startProvCount = 1;
}
/* ======================================================================== */
void SelectMulProvince (LONG prov, LONG level)
{
LONG count=0, i, rate;
LONG baseLevel;
switch ((ITEMTYPE)iSelectedOneHolding)
{
case ITEM_SPELL_DEATH_PLAGUE:
case ITEM_SPELL_WARDING:
baseLevel = 5;
rate = 2;
break;
case ITEM_SPELL_DEMAGOGUE:
case ITEM_SPELL_HONEST_DEALING:
baseLevel = 3;
rate = 2;
break;
case ITEM_SPELL_MASS_DESTRUCTION:
baseLevel = 1;
rate = 3;
break;
case ITEM_SPELL_BLESS_LAND:
case ITEM_SPELL_BLIGHT:
baseLevel = 1;
rate = 2;
break;
case ITEM_SPELL_BLESS_ARMY:
baseLevel = 1;
rate = 1;
default:
baseLevel = 0;
rate = 1;
break;
}
if(iSelectedMulProvince[prov] == 1)
{
checkGoldReg = 0;
fAllowRollButton --;
additionalamt--;
iSelectedMulProvince[prov] = 0;
}
else
{
for (i = 0; i<16; ++i)
{
if ((ITEMTYPE)iSelectedOneHolding == ITEM_SPELL_DEMAGOGUE && i == 8)
continue;
if(iSelectedMulProvince[i]==1)
++count;
}
additionalamt = count;
if (count < (level-baseLevel)/rate)
{
checkGoldReg = 0;
iSelectedMulProvince[prov]=1;
++fAllowRollButton ;
++additionalamt;
}
}
modRegency = modGoldBars = 0;
}
/* ======================================================================== */
/* ======================================================================== */
static void SelectHolding (LONG prov, LONG typ)
{
// general SelectHolding code, used by RULE
checkGoldReg = 0;
fAllowRollButton -= (iSelectedHolding[prov][typ]!=0);
iSelectedHolding[prov][typ] = !iSelectedHolding[prov][typ];
fAllowRollButton += (iSelectedHolding[prov][typ]!=0);
if (!iSelectedHolding[prov][typ])
iNewScreen = 0;
// specific code for DIPLOMACY only
if (iCurAction == DIPLOMACY)
{
if (prov < 9)
iSelection[prov] = 0;
if (prov == 5 || prov == 8)
iSelection[prov-2] = 0;
startProvCount = 1;
}
modRegency = modGoldBars = 0;
}
/* ======================================================================== */
void SelectOneHolding (LONG typ, LONG)
{
checkGoldReg = 0;
fAllowRollButton -= (iSelectedOneHolding!=99);
iSelectedOneHolding = (iSelectedOneHolding==typ)?99:typ;
fAllowRollButton += (iSelectedOneHolding!=99);
iSelectedUnit = 0;
for(LONG i=0; i<16; ++i)
iSelectedMulProvince[i]=0;
for(i=0; i<20; ++i)
iSelectedMulUnits[i]=0;
modRegency = modGoldBars = modLevel =0;
}
/* ======================================================================== */
void SelectUnit (LONG typ, LONG)
{
checkGoldReg = 0;
fAllowRollButton -= (iSelectedUnit!=0);
iSelectedUnit = (iSelectedUnit==typ)?0:typ;
fAllowRollButton += (iSelectedUnit!=0);
for(LONG i=0; i<16; ++i)
iSelectedMulProvince[i]=0;
modRegency = modGoldBars = modLevel =0;
}
/* ======================================================================== */
void SelectMulUnits (LONG unitid, LONG index)
{
LONG count=0, i;
if(iSelectedMulUnits[index] != 0)
{
checkGoldReg = 0;
fAllowRollButton --;
iSelectedMulUnits[index] = 0;
}
else
{
for(i = 0; i<20; ++i)
{
if(iSelectedMulUnits[i]!= 0)
++count;
}
if(count < modLevel-1)
{
checkGoldReg = 0;
iSelectedMulUnits[index]=unitid;
++fAllowRollButton ;
}
}
count = 0;
for(i = 0; i<20; ++i)
{
if(iSelectedMulUnits[i]!= 0)
++count;
}
if(count == 0)
iSelectedUnit = 0;
modRegency = modGoldBars = 0;
}
/* ======================================================================== */
void IncNum (LONG lpNum, LONG)
{
checkGoldReg = 0;
UBYTE * pNum = (UBYTE*)lpNum;
*pNum = *pNum + 1;
}
/* ======================================================================== */
void DecNum (LONG lpNum, LONG)
{
checkGoldReg = 0;
UBYTE * pNum = (UBYTE*)lpNum;
*pNum = *pNum - 1;
}
/* ======================================================================== */
void IncNumWithSign (LONG, LONG)
{
checkGoldReg = 0;
modLevel += 1;
}
/* ======================================================================== */
void DecNumWithSign (LONG, LONG)
{
checkGoldReg = 0;