-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtownout.cpp
executable file
·2819 lines (2417 loc) · 79.6 KB
/
townout.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
#include "stdafx.h"
#include "global.h"
// Global variables
short dialog_answer;
// external global variables
extern short cen_x, cen_y;
extern Boolean dialog_not_toast;
extern scenario_data_type scenario;
extern zone_names_data_type zone_names;
extern town_record_type town;
extern big_tr_type t_d;
extern outdoor_record_type current_terrain;
extern scen_item_data_type scen_data;
extern short cur_town;
extern location cur_out;
extern short current_drawing_mode;
extern short town_type ;
extern Boolean editing_town;
extern short overall_mode;
extern char *attitude_types[4];
extern Boolean file_is_loaded;
extern short max_dim[3];
// local variables
creature_start_type store_placed_monst;
short store_which_placed_monst;
short extra_dialog_answer[4];
short str_do_delete[16];
short a,b,c;
short store_which_out_wand;
short store_out_wand_mode;
out_wandering_type store_out_wand;
location store_cur_loc;
short store_horse_page,store_boat_page;
short store_which_dlog; // used for get_num
short store_which_str;
short store_dlog_min;
short store_dlog_max;
short store_which_part;
short store_max_x;
short store_max_y;
item_storage_shortcut_type store_storage;
short cur_shortcut;
// function prototype
void put_placed_monst_in_dlog();
Boolean get_placed_monst_in_dlog();
void put_placed_item_in_dlog();
Boolean get_placed_item_in_dlog();
void put_out_wand_in_dlog();
Boolean get_out_wand_in_dlog();
Boolean save_town_details();
void put_town_details_in_dlog();
Boolean save_town_wand();
void put_town_wand_in_dlog();
Boolean save_out_strs();
void put_out_strs_in_dlog();
Boolean save_town_strs();
void put_town_strs_in_dlog();
void put_item_placement_in_dlog();
Boolean save_item_placement();
void put_add_town_in_dlog();
Boolean save_add_town();
void put_make_scen_1_in_dlog();
short edit_make_scen_1(char *filename,char *title,short *start_on_surface);
void put_make_scen_2_in_dlog();
short edit_make_scen_2(short *val_array);
Boolean save_scen_details();
void put_scen_details_in_dlog();
extern in_town_on_ter_script_type copied_ter_script;
void put_placed_terrain_script_in_dlog();
Boolean get_placed_terrain_script_in_dlog();
short which_script;
short store_which_placed_script;
in_town_on_ter_script_type store_placed_script;
short which_item;
short store_which_placed_item;
item_type store_placed_item;
short which_town_group;
extern zone_names_data_type zone_names;
char *aaa;
char *BOACreatureTimeFlags[11] = {
"always here (unless town dead)","here at day d unless town dead",
"disappear at day d","here if event not done by day d",
"gone if event not done by day d","here if event happened",
"gone if event happened","here on day 0-2 of every 9 days",
"here on day 3-5 of every 9 days","here on day 6-8 of every 9 days",
"here if and only if town dead"};
void monst_replaceall()
{
char temp_str[256];
short i;
cd_create_dialog_parent_num(843,0);
CDSN(843,63,0);
CDSN(843,64,0);
while (dialog_not_toast)
ModalDialog();
cd_kill_dialog(843,0);
}
void monst_replaceall_event_filter (short item_hit)
{
short i;
short dummy;
short town_size = max_dim[scenario.town_size[cur_town]];
char str[14];
switch (item_hit) {
case 2:
if (cre(CDGN(843,63),-1,255,"Find value error: Creature Type. |Town creatures must have a type number between 0 and 255 inclusive. | (-1 means no monster).","",843) == TRUE)
break;
if (cre(CDGN(843,64),-1,255,"Replace value error: Creature Type. |Town creatures must have a type number between 0 and 255 inclusive. |(-1 means no monster).","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].number == CDGN(843,63))
town.creatures[i].number = CDGN(843,64);
}
break;
case 3:
if (cre(CDGN(843,63),-1,499,"Find value error: Extra Item 1. |Town creatures must have extra item numbers between 0 and 499.","(-1 means no item.)",843) == TRUE)
break;
if (cre(CDGN(843,64),-1,499,"Replace value error: Extra Item 1. |Town creatures must have extra item numbers between 0 and 499.","(-1 means no item.)",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].extra_item == CDGN(843,63))
town.creatures[i].extra_item = CDGN(843,64);
}
break;
case 4:
if (cre(CDGN(843,63),-1,499,"Find value error: Extra Item 2. |Town creatures must have extra item numbers between 0 and 499.","(-1 means no item.)",843) == TRUE)
break;
if (cre(CDGN(843,64),-1,499,"Replace value error: Extra Item 2. |Town creatures must have extra item numbers between 0 and 499.","(-1 means no item.)",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].extra_item_2 == CDGN(843,63))
town.creatures[i].extra_item_2 = CDGN(843,64);
}
break;
case 5:
short l;
CDGT(843,63,(char *) str);
str[14] = 0;
for (i = 0; i < 80; i++) {
for (l = 0; l < 14; l++) {
if (str[l] = town.creatures[i].char_script[l])
CDGT(843,64,town.creatures[i].char_script);
}
}
break;
case 6:
if (cre(CDGN(843,63),0,10,"Find value error: Creature Appearance Type. |Town creatures must have Creature Appearance Type numbers between 0 and 10.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,10,"Replace value error: Creature Appearance Type. |Town creatures must have Creature Appearance Type numbers between 0 and 10.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].time_flag == CDGN(843,63))
town.creatures[i].time_flag = CDGN(843,64);
}
break;
case 7:
if (cre(CDGN(843,63),0,3,"Find value error: Facing. |Town creatures must have a facing number between 0 and 3.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,3,"Replace value error: Facing. |Town creatures must have a facing number between 0 and 3.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].facing == CDGN(843,63))
town.creatures[i].facing = CDGN(843,64);
}
break;
case 8:
if (cre(CDGN(843,63),2,5,"Find value error: Start Attitude. |Town creatures must have an attitude number between 2 and 5.","",843) == TRUE)
break;
if (cre(CDGN(843,64),2,5,"Replace value error: Start Attitude. |Town creatures must have an attitude number between 2 and 5.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].start_attitude == CDGN(843,63))
town.creatures[i].start_attitude = CDGN(843,64);
}
break;
case 9:
if (cre(CDGN(843,63),0,town_size,"Find value error: Start Loc X. |Town creatures must have a Start Loc X number between 0 and (Town width - 1).","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,town_size,"Replace value error: Start Loc X. |Town creatures must have a Start Loc X number between 0 and (Town width - 1).","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].start_loc.x == CDGN(843,63))
town.creatures[i].start_loc.x = CDGN(843,64);
}
break;
case 10:
if (cre(CDGN(843,63),0,town_size,"Find value error: Start Loc Y. |Town creatures must have a Start Loc Y number between 0 and (Town width - 1).","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,town_size,"Replace value error: Start Loc Y. |Town creatures must have a Start Loc Y number between 0 and (Town width - 1).","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].start_loc.y == CDGN(843,63))
town.creatures[i].start_loc.y = CDGN(843,64);
}
break;
case 11:
if (cre(CDGN(843,63),0,100,"Find value error: Extra Item Chance 1. |Town creatures must have a Extra Item Chance 1 number between 0 and 100.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,100,"Replace value error: Extra Item Chance 1. |Town creatures must have a Extra Item Chance 1 number between 0 and 100.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].extra_item_chance_1 == CDGN(843,63))
town.creatures[i].extra_item_chance_1 = CDGN(843,64);
}
break;
case 12:
if (cre(CDGN(843,63),0,100,"Find value error: Extra Item Chance 2. |Town creatures must have a Extra Item Chance 2 number between 0 and 100.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,100,"Replace value error: Extra Item Chance 2. |Town creatures must have a Extra Item Chance 2 number between 0 and 100.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].extra_item_chance_2 == CDGN(843,63))
town.creatures[i].extra_item_chance_2 = CDGN(843,64);
}
break;
case 13:
if (cre(CDGN(843,63),0,3999,"Find value error: Personality. |Town creatures must have a personality between 0 and 3,999.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,3999,"Replace value error: Personality. |Town creatures must have a personality between 0 and 3,999.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].personality == CDGN(843,63))
town.creatures[i].personality = CDGN(843,64);
}
break;
case 14:
if (cre(CDGN(843,63),0,19999,"Find value error: Character Id. |Town creatures must have a Character Id between 0 and 19,999.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,19999,"Replace value error: Character Id. |Town creatures must have a Character Id between 0 and 19,999.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].character_id == CDGN(843,63))
town.creatures[i].character_id = CDGN(843,64);
}
break;
case 15:
if (cre(CDGN(843,63),0,19,"Find value error: Hidden Class. |Town creatures must have hidden class numbers between 0 and 19.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,19,"Replace value error: Hidden Class. |Town creatures must have hidden class numbers between 0 and 19.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].hidden_class == CDGN(843,63))
town.creatures[i].hidden_class = CDGN(843,64);
}
break;
case 16:
if (cre(CDGN(843,63),0,3,"Find value error: Act at Distance. |Town creatures must have numbers between 0 and 3 for this variable.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,3,"Replace value error: Act at Distance. |Town creatures must have numbers between 0 and 3 for this variable.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].act_at_distance == CDGN(843,63))
town.creatures[i].act_at_distance = CDGN(843,64);
}
break;
case 17:
if (cre(CDGN(843,63),0,1,"Find value error: Unique NPC. |Town creatures must have numbers between 0 and 1 for this variable.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,1,"Replace value error: Unique NPC. |Town creatures must have numbers between 0 and 1 for this variable.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].unique_char == CDGN(843,63))
town.creatures[i].unique_char = CDGN(843,64);
}
break;
case 18:
if (cre(CDGN(843,63),0,32767,"Find value error: Appear Day. |Town creatures must have numbers between 0 and 32,767 for this variable.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,32767,"Replace value error: Appear Day. |Town creatures must have numbers between 0 and 32,767 for this variable.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].creature_time == CDGN(843,63))
town.creatures[i].creature_time = CDGN(843,64);
}
break;
case 19:
if (cre(CDGN(843,63),0,9,"Find value error: Linked Event. |Town creatures must have numbers between 0 and 9 for this variable.","",843) == TRUE)
break;
if (cre(CDGN(843,64),0,9,"Replace value error: Linked Event. |Town creatures must have numbers between 0 and 9 for this variable.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].attached_event == CDGN(843,63))
town.creatures[i].attached_event = CDGN(843,64);
}
break;
case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29:
if (cre(CDGN(843,63),-32767,32767,"Find value error: Memory Cell #. |Town creatures must have numbers between -32,767 and +32,767 for this variable.","",843) == TRUE)
break;
if (cre(CDGN(843,64),-32767,32767,"Replace value error: Memory Cell #. |Town creatures must have numbers between -32,767 and +32,767 for this variable.","",843) == TRUE)
break;
for (i = 0; i < 80; i++) {
if (town.creatures[i].memory_cells[item_hit - 20] == CDGN(843,63))
town.creatures[i].memory_cells[item_hit - 20] = CDGN(843,64);
}
break;
case 62:
dialog_not_toast = FALSE;
break;
case 65: // Choose creature type: Find
i = choose_text_res(-1,0,255,town.creatures[i].number,843,"Choose Which Creature Type: 0 - 255");
if ((i >= 0) && (i < 256)) {
CDSN(843,63,i);
csit(843,75,scen_data.scen_creatures[i].name);
}
break;
case 66: // Choose creature type: Replace
i = choose_text_res(-1,0,255,town.creatures[i].number,843,"Choose Which Creature Type: 0 - 255");
if ((i >= 0) && (i < 256)) {
CDSN(843,64,i);
csit(843,76,scen_data.scen_creatures[i].name);
}
break;
case 67: case 69: // Choose item type: Find
i = choose_text_res(-2,0,NUM_SCEN_ITEMS - 1,town.creatures[i].extra_item,843,"Extra Item 1, which item: 0 - 499?");
if ((i >= 0) && (i < NUM_SCEN_ITEMS)) {
CDSN(843,63,i);
csit(843,75,scen_data.scen_items[i].full_name);
}
break;
case 68: case 70: // Choose item type: Replace
i = choose_text_res(-2,0,NUM_SCEN_ITEMS - 1,town.creatures[i].extra_item,843,"Extra Item 1, which item: 0 - 499?");
if ((i >= 0) && (i < NUM_SCEN_ITEMS)) {
CDSN(843,64,i);
csit(843,76,scen_data.scen_items[i].full_name);
}
break;
case 71: // Choose name of a char script already placed in this town: Find
i = choose_text_res(-10,0,79,0,843,"Which Character Script Name?");
CDST(843,63,town.creatures[i].char_script);
break;
case 72: // Choose name of a char script already placed in this town: Replace
i = choose_text_res(-10,0,79,0,843,"Which Character Script Name?");
CDST(843,64,town.creatures[i].char_script);
break;
case 73: // // Choose time type: Find
i = choose_text_res(4,1,11,town.creatures[i].time_flag,843,"Choose Time Type:");
if ((i > 0) && (i < 12)) {
CDSN(843,63,i - 1);
csit(843,75,BOACreatureTimeFlags[i - 1]);
}
break;
case 74: // // Choose time type: Replace
i = choose_text_res(4,1,11,town.creatures[i].time_flag,843,"Choose Time Type:");
if ((i > 0) && (i < 12)) {
CDSN(843,64,i - 1);
csit(843,76,BOACreatureTimeFlags[i - 1]);
}
break;
case 77: // Update creature type names
i = CDGN(843,63);
csit(843,75,scen_data.scen_creatures[i].name);
i = CDGN(843,64);
csit(843,76,scen_data.scen_creatures[i].name);
break;
case 78: case 79: // Update extra item 1 and extra item 2 names
i = CDGN(843,63);
csit(843,75,scen_data.scen_items[i].full_name);
i = CDGN(843,64);
csit(843,76,scen_data.scen_items[i].full_name);
break;
case 80: // Update creature script names
i = CDGN(843,63);
CDST(843,75,town.creatures[i].char_script);
i = CDGN(843,64);
CDST(843,76,town.creatures[i].char_script);
break;
case 81: // Update creature appearance type names
i = CDGN(843,63);
csit(843,75,BOACreatureTimeFlags[i]);
i = CDGN(843,64);
csit(843,76,BOACreatureTimeFlags[i]);
break;
default:
break;
}
}
void edit_placed_item(short which_item)
{
short i;
store_placed_item = town.preset_items[which_item];
store_which_placed_item = which_item;
cd_create_dialog_parent_num(842,0);
cdsin(842,4,store_which_placed_item);
put_placed_item_in_dlog();
while (dialog_not_toast)
ModalDialog();
cd_kill_dialog(842,0);
set_string("Select/edit placed object","Select object to edit");
set_cursor(7);
overall_mode = 40;
}
void put_placed_item_in_dlog()
{
char str[256];
short i;
cdsin(842,4,store_which_placed_item);
csit(842,5,scen_data.scen_items[store_placed_item.which_item].full_name);
CDSN(842,15,store_placed_item.item_shift.x);
CDSN(842,16,store_placed_item.item_shift.y);
CDSN(842,17,store_placed_item.charges);
if (store_placed_item.properties & 1)
cd_set_led(842,18,1);
else
cd_set_led(842,18,0);
if (store_placed_item.properties & 2)
cd_set_led(842,19,1);
else
cd_set_led(842,19,0);
if (store_placed_item.properties & 4)
cd_set_led(842,20,1);
else
cd_set_led(842,20,0);
if (store_placed_item.properties & 8)
cd_set_led(842,21,1);
else
cd_set_led(842,21,0);
if (store_placed_item.properties & 16)
cd_set_led(842,22,1);
else
cd_set_led(842,22,0);
cdsin(842,29,store_placed_item.item_loc.x);
cdsin(842,31,store_placed_item.item_loc.y);
CDSN(842,35,store_placed_item.which_item);
cdsin(842,38,store_placed_item.properties);
CDSN(842,45,store_which_placed_item);
}
void edit_placed_item_event_filter (short item_hit)
{
short i;
switch (item_hit) {
case 23:
if (store_which_placed_item == 0)
store_which_placed_item = 143;
else
store_which_placed_item--;
store_placed_item = town.preset_items[store_which_placed_item];
put_placed_item_in_dlog();
break;
case 24:
if (store_which_placed_item == 143)
store_which_placed_item = 0;
else
store_which_placed_item++;
store_placed_item = town.preset_items[store_which_placed_item];
put_placed_item_in_dlog();
break;
case 25: // Save: save this item record, but don't exit the dialog.
if (get_placed_item_in_dlog() == FALSE) {
set_string("Item Save attempt failed","");
break;
}
else
set_string("Item Record Saved.","");
break;
case 26: // Cancel
dialog_not_toast = FALSE;
break;
case 27: // OK: save and exit.
if (get_placed_item_in_dlog() == FALSE)
break;
dialog_not_toast = FALSE;
break;
case 34: // Delete this item
store_placed_item.clear_item_type();
put_placed_item_in_dlog();
break;
case 37:
i = choose_text_res(-2,0,NUM_SCEN_ITEMS - 1,store_placed_item.which_item,842,"Which item?");
if (i >= 0)
store_placed_item.which_item = i;
put_placed_item_in_dlog();
break;
case 46:
if (store_which_placed_item < 0)
store_which_placed_item = 0;
if (store_which_placed_item > 143)
store_which_placed_item = 143;
else
store_which_placed_item = CDGN(842,45);
store_placed_item = town.preset_items[store_which_placed_item];
put_placed_item_in_dlog();
break;
default:
cd_flip_led(842,18,item_hit);
cd_flip_led(842,19,item_hit);
cd_flip_led(842,20,item_hit);
cd_flip_led(842,21,item_hit);
cd_flip_led(842,22,item_hit);
break;
}
}
Boolean get_placed_item_in_dlog()
{
char str[256];
short i;
short item_identified = cd_get_led(842,18);
short item_property = cd_get_led(842,19);
short item_contained = cd_get_led(842,20);
short item_cursed = cd_get_led(842,21);
short item_onceperday = cd_get_led(842,22);
store_placed_item.item_shift.x = CDGN(842,15);
store_placed_item.item_shift.y = CDGN(842,16);
store_placed_item.charges = CDGN(842,17);
store_placed_item.properties=
item_identified +
2 * item_property +
4 * item_contained +
8 * item_cursed +
16 * item_onceperday;
store_placed_item.which_item = CDGN(842,35);
town.preset_items[store_which_placed_item] = store_placed_item;
return TRUE;
}
void edit_placed_script(short which_script)
{
short i;
store_placed_script = town.ter_scripts[which_script];
store_which_placed_script = which_script;
cd_create_dialog_parent_num(838,0);
cdsin(838,4,store_which_placed_script);
put_placed_terrain_script_in_dlog();
while (dialog_not_toast)
ModalDialog();
cd_kill_dialog(838,0);
set_string("Select/edit placed object","Select object to edit");
set_cursor(7);
overall_mode = 40;
}
void put_placed_terrain_script_in_dlog()
{
char str[256];
short i;
cdsin(838,4,store_which_placed_script);
CDST(838,6,store_placed_script.script_name);
for (i = 0; i < 10; i++)
CDSN(838,18 + i,store_placed_script.memory_cells[i]);
cdsin(838,34,store_placed_script.exists);
cdsin(838,36,store_placed_script.loc.x);
cdsin(838,38,store_placed_script.loc.y);
}
void edit_placed_script_event_filter (short item_hit)
{
short i;
switch (item_hit) {
case 28:
if (store_which_placed_script == 0)
store_which_placed_script = 99;
else
store_which_placed_script--;
store_placed_script = town.ter_scripts[store_which_placed_script];
put_placed_terrain_script_in_dlog();
break;
case 29:
if (store_which_placed_script == 99)
store_which_placed_script = 0;
else
store_which_placed_script++;
store_placed_script = town.ter_scripts[store_which_placed_script];
put_placed_terrain_script_in_dlog();
break;
case 30: // Save: save this script record, but don't exit the dialog.
if (get_placed_terrain_script_in_dlog() == FALSE) {
set_string("Save script attempt failed","");
break;
}
else
set_string("Script save succeeded.","");
break;
case 31: // Cancel
dialog_not_toast = FALSE;
break;
case 32: // OK: save and exit.
if (get_placed_terrain_script_in_dlog() == FALSE)
break;
dialog_not_toast = FALSE;
break;
case 41: // Delete this script
store_placed_script.clear_in_town_on_ter_script_type();
put_placed_terrain_script_in_dlog();
break;
case 42: // Show a menu of all scripts already placed in this town.
i = choose_text_res(-9,0,99,0,838,"Which Terrain Script Name?");
CDST(838,6,town.ter_scripts[i].script_name);
break;
default:
break;
}
}
Boolean get_placed_terrain_script_in_dlog()
{
char str[256];
short i;
CDGT(838,6,str);
if (string_not_clean(str,SCRIPT_NAME_LEN,1,"This terrain script",838))
return FALSE;
CDGT(838,6,store_placed_script.script_name);
for (i = 0; i < 10; i++)
store_placed_script.memory_cells[i] = CDGN(838,18 + i);
town.ter_scripts[store_which_placed_script] = store_placed_script;
return TRUE;
}
void edit_placed_monst(short which_m)
{
short i;
store_placed_monst = town.creatures[which_m];
store_which_placed_monst = which_m;
cd_create_dialog_parent_num(837,0);
cdsin(837,37,which_m + 6);
put_placed_monst_in_dlog();
for (i = 0; i < 4; i++)
cd_add_label(837,27 + i,attitude_types[i],57);
while (dialog_not_toast)
ModalDialog();
cd_kill_dialog(837,0);
set_string("Select/edit placed object","Select object to edit");
set_cursor(7);
overall_mode = 40;
}
void put_placed_monst_in_dlog()
{
char str[256];
short i;
CDST(837,2,store_placed_monst.char_script);
CDSN(837,3,store_placed_monst.extra_item_chance_1);
CDSN(837,4,store_placed_monst.extra_item);
CDSN(837,5,store_placed_monst.extra_item_chance_2);
CDSN(837,6,store_placed_monst.extra_item_2);
CDSN(837,7,store_placed_monst.personality);
CDSN(837,8,store_placed_monst.character_id);
CDSN(837,9,store_placed_monst.hidden_class);
CDSN(837,10,store_placed_monst.act_at_distance);
CDSN(837,11,store_placed_monst.unique_char);
CDSN(837,12,store_placed_monst.number);
CDSN(837,13,store_placed_monst.creature_time);
CDSN(837,14,store_placed_monst.attached_event);
for (i = 0; i < 10; i++)
CDSN(837,15 + i,store_placed_monst.memory_cells[i]);
cd_set_led_range(837,27,30,store_placed_monst.start_attitude - 2);
cdsin(837,37,store_which_placed_monst);
csit(837,38,scen_data.scen_creatures[store_placed_monst.number].name);
get_str(str,4,store_placed_monst.time_flag + 1);
csit(837,39,(char *) str);
csit(837,51,scen_data.scen_items[store_placed_monst.extra_item].full_name);
csit(837,52,scen_data.scen_items[store_placed_monst.extra_item_2].full_name);
}
void edit_placed_monst_event_filter (short item_hit)
{
short i;
switch (item_hit) {
case 31:
if (get_placed_monst_in_dlog() == FALSE)
break;
dialog_not_toast = FALSE;
break;
case 32:
dialog_not_toast = FALSE;
break;
case 33: // choose m type
if (get_placed_monst_in_dlog() == FALSE)
break;
i = choose_text_res(-1,0,255,store_placed_monst.number,837,"Choose Which Creature Type: 0 - 255");
if ((i >= 0) && (i < 256)) {
store_placed_monst.number = i;
put_placed_monst_in_dlog();
}
break;
case 34:
i = choose_text_res(-2,0,NUM_SCEN_ITEMS - 1,store_placed_monst.extra_item,837,"Which item?");
if (i >= 0)
store_placed_monst.extra_item = i;
put_placed_monst_in_dlog();
break;
case 35:
i = choose_text_res(-2,0,NUM_SCEN_ITEMS - 1,store_placed_monst.extra_item_2,837,"Which item?");
if (i >= 0)
store_placed_monst.extra_item_2 = i;
put_placed_monst_in_dlog();
break;
case 36: // choose time type
if (get_placed_monst_in_dlog() == FALSE)
break;
i = choose_text_res(4,1,11,store_placed_monst.time_flag + 1,837,"Choose Time Type:");
if (i >= 0) {
store_placed_monst.time_flag = i - 1;
put_placed_monst_in_dlog();
}
break;
case 69:
if (store_which_placed_monst == 79)
store_which_placed_monst = 0;
else
store_which_placed_monst++;
store_placed_monst = town.creatures[store_which_placed_monst];
put_placed_monst_in_dlog();
break;
case 70:
if (store_which_placed_monst == 0)
store_which_placed_monst = 79;
else
store_which_placed_monst--;
store_placed_monst = town.creatures[store_which_placed_monst];
put_placed_monst_in_dlog();
break;
case 71: // delete this record
store_placed_monst.clear_creature_start_type();
put_placed_monst_in_dlog();
break;
case 72: // Save: save this Creature record, but don't exit the dialog.
if (get_placed_monst_in_dlog() == FALSE) {
set_string("Save Creature attempt failed","");
break;
}
else
set_string("Creature save succeeded.","");
break;
case 73: // Update display of names
csit(837,38,scen_data.scen_creatures[CDGN(837,12)].name);
csit(837,51,scen_data.scen_items[CDGN(837,4)].full_name);
csit(837,52,scen_data.scen_items[CDGN(837,5)].full_name);
break;
case 74: // Choose name of a char script already placed in this town.
i = choose_text_res(-10,0,79,0,837,"Which Character Script Name?");
CDST(837,2,town.creatures[i].char_script);
break;
default:
break;
}
}
Boolean get_placed_monst_in_dlog()
{
char str[256];
short i;
// check for errors
CDGT(837,2,str);
if (string_not_clean(str,SCRIPT_NAME_LEN,1,"This creature's script",837))
return FALSE;
CDGT(837,2,store_placed_monst.char_script);
store_placed_monst.extra_item_chance_1 = CDGN(837,3);
store_placed_monst.extra_item = CDGN(837,4);
store_placed_monst.extra_item_chance_2 = CDGN(837,5);
store_placed_monst.extra_item_2 = CDGN(837,6);
store_placed_monst.personality = CDGN(837,7);
store_placed_monst.character_id = CDGN(837,8);
store_placed_monst.hidden_class = CDGN(837,9);
store_placed_monst.act_at_distance = CDGN(837,10);
store_placed_monst.unique_char = CDGN(837,11);
store_placed_monst.creature_time = CDGN(837,13);
store_placed_monst.attached_event = CDGN(837,14);
for (i = 0; i < 10; i++)
store_placed_monst.memory_cells[i] = CDGN(837,15 + i);
store_placed_monst.start_attitude = cd_get_led_range(837,27,30) + 2;
town.creatures[store_which_placed_monst] = store_placed_monst;
return TRUE;
}
void edit_sign(short which_sign)
{
char new_text[256];
if (editing_town)
get_str_dlog(town.sign_text[which_sign],"What should this sign say?",new_text);
else get_str_dlog(current_terrain.sign_text[which_sign],"What should this sign say?",new_text);
if (editing_town)
strcpy(town.sign_text[which_sign],new_text);
else strcpy(current_terrain.sign_text[which_sign],new_text);
}
void get_a_number_event_filter (short item_hit)
{
short x;
char *str;
switch (item_hit) {
case 3:
dialog_answer = CDGN(store_which_dlog,2);
if (store_which_dlog == 855) {
if (cre(dialog_answer,0,scenario.num_towns - 1,"Town number must be from 0 to (Number of scenario towns - 1).","",857) == TRUE)
break;
}
dialog_answer = minmax(store_dlog_min,store_dlog_max,dialog_answer);
dialog_not_toast = FALSE;
break;
case 4:
dialog_answer = -1;
dialog_not_toast = FALSE;
break;
case 7:
if ((store_which_dlog != 855) && (store_which_dlog != 856))
break;
else {
x = choose_text_res(-7,0,scenario.num_towns - 1,CDGN(store_which_dlog,2),store_which_dlog,"Which Town?");
if (x >= 0) {
CDSN(store_which_dlog,2,x);
csit(store_which_dlog,9,zone_names.town_names[x]);
}
}
break;
case 10:
if ((store_which_dlog != 855) && (store_which_dlog != 856))
break;
else {
x = CDGN(store_which_dlog,2);
csit(store_which_dlog,9,zone_names.town_names[x]);
}
break;
}
}
// which_dlog is the number of a dialog box that takes a number in text edit field 2
// gets a number and returns it. returns -1 if canceled
short get_a_number(short which_dlog,short default_value,short min,short max)
{
char temp_str[256],str2[256];
short x;
store_which_dlog = which_dlog;
store_dlog_min = min;
store_dlog_max = max;
cd_create_dialog_parent_num(store_which_dlog,0);
CDSN(store_which_dlog,2,default_value);
if ((which_dlog == 855) || (which_dlog == 856) ){
cd_get_item_text(which_dlog,6,(char *) temp_str);
sprintf((char *) str2,"%s (0 - %d)",(char *) temp_str, (int)(scenario.num_towns - 1));
csit(which_dlog,6,(char *) str2);
x = CDGN(store_which_dlog,2);
csit(store_which_dlog,9,zone_names.town_names[x]);
}
while (dialog_not_toast)
ModalDialog();
cd_kill_dialog(store_which_dlog,0);
return dialog_answer;
}
void change_ter_event_filter (short item_hit)
{
short i;
a = CDGN(857,2);
b = CDGN(857,3);
c = CDGN(857,4);
switch (item_hit) {
case 5:
if (current_drawing_mode == 0) {
if (cre(a,0,255,"Both floor types must be from 0 to 255.","",857) == TRUE) break;
if (cre(b,0,255,"Both floor types must be from 0 to 255.","",857) == TRUE) break;
}
else {
if (cre(a,0,511,"Both terrain types must be from 0 to 511.","",857) == TRUE) break;
if (cre(b,0,511,"Both terrain types must be from 0 to 511.","",857) == TRUE) break;
}
if (cre(c,0,100,"The Chance must be from 0 to 100.","",857) == TRUE) break;
dialog_not_toast = FALSE;
break;
case 6:
dialog_not_toast = FALSE;
break;
case 9: case 10:
i = CDGN(857,item_hit - 7);
if (current_drawing_mode == 0) {
i = choose_text_res(-6,0,255,i,857,"Which Floor? (0:255)");
csit(857,item_hit + 5,scen_data.scen_floors[i].floor_name);
}
else {
i = choose_text_res(-4,0,511,i,857,"Which Terrain? (0:511)");
csit(857,item_hit + 5,scen_data.scen_ter_types[i].ter_name);
}
if (i >= 0)
CDSN(857,item_hit - 7,i);
break;
}
}
void change_ter(short *change_from,short *change_to,short *chance)
// ignore parent in Mac version
{
cd_create_dialog_parent_num(857,0);