added worldarea -> will be responsible for world map rendering
[dboe.git] / dlgutils.c
blobd012f0f689d042c1225d2bec63f8b528cce2aeb7
3 #include <Windows.h>
4 #include "string.h"
5 #include "global.h"
7 #include "dlgutils.h"
8 #include "text.h"
9 #include "town.h"
10 #include "itemdata.h"
11 #include "locutils.h"
12 #include "fields.h"
13 #include "party.h"
14 #include "specials.h"
15 #include "fileio.h"
16 #include "graphics.h"
17 #include "townspec.h"
18 #include "items.h"
19 #include "exlsound.h"
20 #include "stdio.h"
21 #include "dlogtool.h"
22 #include "newgraph.h"
23 #include "infodlgs.h"
24 #include "graphutl.h"
26 #define NUM_HINTS 30
28 extern big_tr_type far t_d;
29 extern short stat_window,overall_mode,dialog_answer;
30 extern current_town_type far c_town;
31 extern party_record_type far party;
32 extern piles_of_stuff_dumping_type *data_store;
33 extern piles_of_stuff_dumping_type2 *data_store2;
34 extern talking_record_type far talking;
35 extern scenario_data_type far scenario;
37 extern Boolean in_startup_mode,play_sounds,sys_7_avail,give_intro_hint;
38 extern HWND mainPtr;
40 extern short display_mode,stat_screen_mode,current_pc;
41 extern long register_flag;
42 extern long ed_flag,ed_key;
43 extern Boolean registered,ed_reg,save_maps,give_delays;
44 extern pc_record_type far adven[6];
45 extern location center;
46 extern HWND text_sbar,item_sbar,shop_sbar;
47 extern Boolean modeless_exists[18];
48 extern HWND modeless_dialogs[18] ;
50 extern pascal Boolean cd_event_filter();
51 extern Boolean dialog_not_toast;
53 extern Boolean game_run_before;
55 extern HPALETTE hpal;
56 extern far PALETTEENTRY ape[256];
57 extern HDC main_dc,main_dc2,main_dc3;
58 extern Boolean cursor_shown;
59 extern piles_of_stuff_dumping_type3 *data_store3;
60 extern piles_of_stuff_dumping_type4 *data_store4;
63 HBITMAP pcs_gworld = NULL;
65 short sign_mode,person_graphic,store_person_graphic,store_sign_mode;
66 long num_talk_entries;
67 char null_string[256] = "";
68 short store_tip_page_on = 0;
70 // Talking vars
71 word_rect_type far store_words[50];
72 short store_pre_talk_mode,store_personality,store_personality_graphic,shop_identify_cost;
73 HBITMAP talk_gworld = NULL;
74 Boolean talk_end_forced;
75 char far old_str1[256];
76 char far old_str2[256];
77 char far one_back1[256];
78 char far one_back2[256];
79 extern word_rect_type preset_words[9];
80 RECT talk_area_rect = {5,5,284,420}, word_place_rect = {7,44,257,372},talk_help_rect = {254,5,272,21};
81 /**/
82 char title_string[50];
83 unsigned char store_monst_type;
84 short store_m_num;
85 RECT dummy_rect = {0,0,0,0};
86 hold_responses far store_resp[83];
87 short strnum1,strnum2,oldstrnum1,oldstrnum2;
88 short store_talk_face_pic,cur_town_talk_loaded = -1;
90 // Shopping vars
92 // 1 - 499 ... regular items
93 // 500 alchemy
94 // 600-620 ... food
95 // 700+ i - that healing
96 // 800 + - mage spells
97 // 900 + - priest spells
98 // n000 + i - magic store n item i
99 short far store_shop_items[30];
100 short far store_shop_costs[30];
101 // talk_area_rect and talk_help_rect used for this too
102 short store_shop_min,store_shop_max,store_pre_shop_mode,store_cost_mult;
103 char far store_store_name[256];
104 // 0 - whole area, 1 - active area 2 - graphic 3 - item name
105 // 4 - item cost 5 - item extra str 6 - item help button
106 extern RECT shopping_rects[8][7];
107 RECT bottom_help_rects[4] = {{6,356,250,368},{6,374,270,386},{6,386,250,398},{6,398,250,410}};
108 RECT shop_name_str = {6,44,200,56};
109 RECT shop_frame = {10,62,269,352};
110 RECT shop_done_rect = {212,388,275,411}; /**/
112 extern short store_shop_type;
114 char far *heal_types[] = {"Heal Damage","Cure Poison","Cure Disease","Cure Paralysis",
115 "Uncurse Items","Cure Stoned Character","Raise Dead","Resurrection","Cure Dumbfounding"};
116 short heal_costs[9] = {50,30,80,100,250,500,1000,3000,100};
117 long cost_mult[7] = {5,7,10,13,16,20,25};
118 short cur_display_mode;
120 short terrain_pic[256];
122 scen_header_type scen_headers[25];
124 short store_scen_page_on,store_num_scen;
127 shop_type:
128 0 - weapon shop
129 1 - armor shop
130 2 - misc shop
131 3 - healer
132 4 - food
133 5-9 - magic shop
134 10 - mage spells
135 11 - priest spells
136 12 alchemy
138 void start_shop_mode(short shop_type,short shop_min,short shop_max,short cost_adj,char *store_name)
140 RECT area_rect;
142 if (shop_max < shop_min)
143 shop_max = shop_min; ////
144 store_cost_mult = cost_adj;
145 if (store_cost_mult > 6)
146 store_cost_mult = 6;
147 store_shop_type = shop_type;
148 store_shop_min = shop_min;
149 store_shop_max = shop_max;
151 area_rect = talk_area_rect;
152 strcpy((char *) store_store_name,store_name);
154 OffsetRect(&area_rect, -1 * area_rect.left,-1 * area_rect.top);
155 if (talk_gworld == NULL)
156 talk_gworld = CreateCompatibleBitmap(main_dc,area_rect.right,area_rect.bottom);
158 store_pre_shop_mode = overall_mode;
159 overall_mode = 21;
160 stat_screen_mode = 1;
161 create_clip_region();
163 set_up_shop_array();
164 put_background();
166 draw_shop_graphics(0,area_rect);
168 put_item_screen(stat_window,0);
169 give_help(26,27,0);
172 void end_shop_mode()
174 RECT dummy_rect = {0,0,0,0};
176 ShowScrollBar(shop_sbar,SB_CTL,FALSE);
177 if (store_pre_shop_mode == 20) {
178 sprintf((char *)old_str1,"You conclude your business.");
179 sprintf((char *)old_str2,"");
180 sprintf((char *)one_back1,"You conclude your business.");
181 sprintf((char *)one_back2,"");
183 strnum1 = strnum2 = oldstrnum1 = oldstrnum2 = 0;
184 place_talk_str((char *)old_str1,"",0,dummy_rect);
186 else {
187 DisposeGWorld(talk_gworld);
188 talk_gworld = NULL;
191 overall_mode = store_pre_shop_mode;
192 create_clip_region();
193 if (overall_mode == 2)
194 overall_mode = 1;
195 if (overall_mode == 1) {
196 center = c_town.p_loc;
197 update_explored(center);
199 stat_screen_mode = 0;
200 put_item_screen(stat_window,0);
201 put_pc_screen();
202 refresh_screen(0);
205 void handle_shop_event(POINT p,Boolean right_button)
207 short i,j,get_pc,store_what_picked;
209 p.x -= 5;
210 p.y -= 5;
212 if (PtInRect(&talk_help_rect,p)) {
213 click_shop_rect(talk_help_rect);
214 party.help_received[26] = 0;
215 give_help(26,27,0);
216 return;
218 if (PtInRect(&shop_done_rect, p)) {
219 click_shop_rect(shop_done_rect);
220 end_shop_mode();
221 return;
224 for (i = 0; i < 8; i++) {
225 store_what_picked = i + GetScrollPos(shop_sbar,SB_CTL);
226 if ((PtInRect(&shopping_rects[i][1],p)) && (store_shop_items[store_what_picked] >= 0)) {
227 click_shop_rect(shopping_rects[i][1]);
228 handle_sale(store_shop_items[store_what_picked],store_shop_costs[store_what_picked]);
230 if ((PtInRect(&shopping_rects[i][6],p)) && (store_shop_items[store_what_picked] >= 0)
231 && (store_shop_type != 3) && (store_shop_type != 4)){
232 click_shop_rect(shopping_rects[i][6]);
233 handle_info_request(store_shop_items[store_what_picked]);
238 void handle_sale(short what_chosen,short cost)
240 item_record_type base_item;
241 short what_magic_shop,what_magic_shop_item,i,j;
242 RECT dummy_rect = {0,0,0,0};
244 switch (what_chosen / 100) {
245 case 0: case 1: case 2: case 3: case 4:
246 base_item = get_stored_item(what_chosen);
247 base_item.item_properties = base_item.item_properties | 1;
248 //cost = (base_item.charges == 0) ? base_item.value : base_item.value * base_item.charges;
249 switch (pc_ok_to_buy(current_pc,cost,base_item)) {
250 case 1: play_sound(-38); give_to_pc(current_pc,base_item,TRUE); break;
251 case 2: ASB("Can't carry any more items."); break;
252 case 3: ASB("Not enough cash."); break;
253 case 4: ASB("Item is too heavy."); break;
254 case 5: ASB("You own too many of this."); break;
256 break;
257 case 5:
258 base_item = store_alchemy(what_chosen - 500);
259 if (party.alchemy[base_item.item_level] == TRUE)
260 ASB("You already know that recipe.");
261 else if (take_gold(cost,FALSE) == FALSE)
262 ASB("Not enough gold.");
263 else {
264 play_sound(62);
265 ASB("You buy an alchemical recipe.");
266 party.alchemy[base_item.item_level] = TRUE;
268 break;
269 case 7:
270 what_chosen -= 700;
271 if (take_gold(cost,FALSE) == FALSE)
272 ASB("Not enough gold.");
273 else {
274 ASB("You pay the healer.");
275 play_sound(68);
276 switch (what_chosen) {
277 case 0:
278 adven[current_pc].cur_health = adven[current_pc].max_health;
279 break;
280 case 1:
281 adven[current_pc].status[2] = 0;
282 break;
283 case 2:
284 adven[current_pc].status[7] = 0; break;
285 case 3:
286 adven[current_pc].status[12] = 0; break;
287 case 4:
288 for (i = 0; i < 24; i++)
289 if ((adven[current_pc].equip[i] == TRUE) &&
290 (is_cursed(adven[current_pc].items[i])))
291 adven[current_pc].items[i].item_properties =
292 adven[current_pc].items[i].item_properties & 239;
293 break;
294 case 5: case 6: case 7:
295 adven[current_pc].main_status = 1; break;
296 case 8:
297 adven[current_pc].status[9] = 0; break;
300 break;
301 case 8:
302 base_item = store_mage_spells(what_chosen - 800 - 30);
303 if ((base_item.item_level < 0) || (base_item.item_level > 61)) {
304 SysBeep(50); ASB("Error 102: Report this!"); break;}
305 if (adven[current_pc].mage_spells[base_item.item_level] == TRUE)
306 ASB("You already have this spell.");
307 else if (take_gold(cost,FALSE) == FALSE)
308 ASB("Not enough gold.");
309 else {
310 play_sound(62);
311 ASB("You buy a spell.");
312 adven[current_pc].mage_spells[base_item.item_level] = TRUE;
313 give_help(41,0,0);
315 break;
316 case 9:
317 base_item = store_priest_spells(what_chosen - 900 - 30);
318 if ((base_item.item_level < 0) || (base_item.item_level > 61)) {
319 SysBeep(50); ASB("Error 101: Report this!"); break;}
320 if (adven[current_pc].priest_spells[base_item.item_level] == TRUE)
321 ASB("You already have this spell.");
322 else if (take_gold(cost,FALSE) == FALSE)
323 ASB("Not enough gold.");
324 else {
325 play_sound(62);
326 ASB("You buy a spell.");
327 adven[current_pc].priest_spells[base_item.item_level] = TRUE;
328 give_help(41,0,0);
330 break;
331 default:
332 what_magic_shop = (what_chosen / 1000) - 1;
333 what_magic_shop_item = what_chosen % 1000;
334 base_item = party.magic_store_items[what_magic_shop][what_magic_shop_item];
335 base_item.item_properties = base_item.item_properties | 1;
336 switch (pc_ok_to_buy(current_pc,cost,base_item)) {
337 case 1: play_sound(-38); give_to_pc(current_pc,base_item,TRUE);
338 party.magic_store_items[what_magic_shop][what_magic_shop_item].variety = 0;
339 break;
340 case 2: ASB("Can't carry any more items."); break;
341 case 3: ASB("Not enough cash."); break;
342 case 4: ASB("Item is too heavy."); break;
344 break;
346 set_up_shop_array();
348 if (overall_mode != 21) {
349 SysBeep(50);
350 ASB("Shop error 1. Report This!");
352 draw_shop_graphics(0,dummy_rect);
353 print_buf();
354 put_pc_screen();
355 put_item_screen(stat_window,0);
359 void handle_info_request(short what_chosen)
361 item_record_type base_item;
362 short what_magic_shop,what_magic_shop_item;
364 switch (what_chosen / 100) {
365 case 0: case 1: case 2: case 3: case 4:
366 base_item = get_stored_item(what_chosen);
367 base_item.item_properties = base_item.item_properties | 1;
368 display_pc_item(6,0, base_item,0);
369 break;
370 case 5:
371 display_help(0,0);
372 break;
373 case 8:
374 base_item = store_mage_spells(what_chosen - 800 - 30);
375 display_spells(0,base_item.item_level,0);
376 break;
377 case 9:
378 base_item = store_priest_spells(what_chosen - 900 - 30);
379 display_spells(1,base_item.item_level,0);
380 break;
381 default:
382 what_magic_shop = (what_chosen / 1000) - 1;
383 what_magic_shop_item = what_chosen % 1000;
384 base_item = party.magic_store_items[what_magic_shop][what_magic_shop_item];
385 base_item.item_properties = base_item.item_properties | 1;
386 display_pc_item(6,0, base_item,0);
387 break;
391 void set_up_shop_array()
393 short i,shop_pos = 0;
394 Boolean cursed_item = FALSE;
395 item_record_type store_i;
396 long store_l;
398 for (i = 0; i < 30; i++)
399 store_shop_items[i] = -1;
400 switch (store_shop_type) {
401 case 0: case 1: case 2:
402 for (i = store_shop_min; i < store_shop_max + 1; i++) {
403 store_shop_items[shop_pos] = i;
404 store_i = get_stored_item(store_shop_items[shop_pos]);
405 store_shop_costs[shop_pos] = (store_i.charges == 0) ?
406 store_i.value : store_i.value * store_i.charges;
407 shop_pos++;
409 break;
410 case 3:
411 if (adven[current_pc].cur_health < adven[current_pc].max_health) {
412 store_shop_items[shop_pos] = 700;
413 store_shop_costs[shop_pos] = heal_costs[0];
414 shop_pos++;
416 if (adven[current_pc].status[2] > 0) {
417 store_shop_items[shop_pos] = 701;
418 store_shop_costs[shop_pos] = heal_costs[1];
419 shop_pos++;
421 if (adven[current_pc].status[7] > 0) {
422 store_shop_items[shop_pos] = 702;
423 store_shop_costs[shop_pos] = heal_costs[2];
424 shop_pos++;
426 if (adven[current_pc].status[12] > 0) {
427 store_shop_items[shop_pos] = 703;
428 store_shop_costs[shop_pos] = heal_costs[3];
429 shop_pos++;
431 if (adven[current_pc].status[9] > 0) {
432 store_shop_items[shop_pos] = 708;
433 store_shop_costs[shop_pos] = heal_costs[8];
434 shop_pos++;
436 for (i = 0; i < 24; i++)
437 if ((adven[current_pc].equip[i] == TRUE) && (is_cursed(adven[current_pc].items[i]) == TRUE))
438 cursed_item = TRUE;
439 if (cursed_item) {
440 store_shop_items[shop_pos] = 704;
441 store_shop_costs[shop_pos] = heal_costs[4];
442 shop_pos++;
444 if (adven[current_pc].main_status == 4) {
445 store_shop_items[shop_pos] = 705;
446 store_shop_costs[shop_pos] = heal_costs[5];
447 shop_pos++;
449 if (adven[current_pc].main_status == 2){
450 store_shop_items[shop_pos] = 706;
451 store_shop_costs[shop_pos] = heal_costs[6];
452 shop_pos++;
454 if (adven[current_pc].main_status == 3){
455 store_shop_items[shop_pos] = 707;
456 store_shop_costs[shop_pos] = heal_costs[7];
457 shop_pos++;
459 break;
460 case 4:
461 //for (i = store_shop_min; i < store_shop_max + 1; i++) {
462 // store_shop_items[shop_pos] = 600 + i;
463 // store_shop_costs[shop_pos] = food_types[i].value;
464 // shop_pos++;
465 // }
466 break;
467 case 5: case 6: case 7: case 8: case 9:
468 for (i = 0; i < 10; i++)
469 if (party.magic_store_items[store_shop_type - 5][i].variety != 0) {
470 store_shop_items[shop_pos] = (store_shop_type - 4) * 1000 + i;
471 store_i = party.magic_store_items[store_shop_type - 5][i];
472 store_shop_costs[shop_pos] = (store_i.charges == 0) ?
473 store_i.value : store_i.value * store_i.charges;
474 shop_pos++;
476 break;
477 case 10:
478 for (i = store_shop_min; i < store_shop_max + 1; i++)
479 if (i == minmax(0,31,i)) {
480 store_i = store_mage_spells(i);
481 store_shop_costs[shop_pos] = store_i.value;
482 store_shop_items[shop_pos] = 800 + i + 30;
483 shop_pos++;
485 break;
486 case 11:
487 for (i = store_shop_min; i < store_shop_max + 1; i++)
488 if (i == minmax(0,31,i)) {
489 store_i = store_priest_spells(i);
490 store_shop_costs[shop_pos] = store_i.value;
491 store_shop_items[shop_pos] = 900 + i + 30;
492 shop_pos++;
494 break;
495 case 12:
496 for (i = store_shop_min; i < store_shop_max + 1; i++)
497 if (i == minmax(0,19,i)) {
498 store_i = store_alchemy(i);
499 store_shop_costs[shop_pos] = store_i.value;
500 store_shop_items[shop_pos] = 500 + i;
501 shop_pos++;
503 break;
505 for (i = 0; i < 30; i++)
506 if (store_shop_items[i] >= 0) {
507 store_l = store_shop_costs[i];
508 store_l = (store_l * cost_mult[store_cost_mult]) / 10;
509 store_shop_costs[i] = (short) store_l;
511 i = max(0,shop_pos - 8);
512 SetScrollRange(shop_sbar,SB_CTL,0,i,TRUE);
516 void start_talk_mode(short m_num,short personality,unsigned char monst_type,short store_face_pic)////
518 RECT area_rect;
519 char place_string1[256] = "";
520 char place_string2[256] = "";
521 short i,cash;
523 store_personality = personality;
525 store_monst_type = monst_type;
526 store_m_num = m_num;
527 store_talk_face_pic = store_face_pic; ////
528 area_rect = talk_area_rect;
529 OffsetRect(&area_rect, -1 * area_rect.left,-1 * area_rect.top);
530 talk_gworld = CreateCompatibleBitmap(main_dc,area_rect.right,area_rect.bottom);
532 // first make sure relevant talk strs are loaded in
533 if (personality / 10 != cur_town_talk_loaded)
534 load_town(personality / 10,1,0,NULL);
536 // load all possible responses
537 store_responses();
539 // Dredge up critter's name
540 sprintf((char *) title_string,"%s:",data_store3->talk_strs[personality % 10]);
542 store_pre_talk_mode = overall_mode;
543 overall_mode = 20;
544 create_clip_region();
545 talk_end_forced = FALSE;
546 stat_screen_mode = 1;
548 // Bring up and place first strings.
549 sprintf((char *) place_string1,"%s",data_store3->talk_strs[personality % 10 + 10]);
550 strnum1 = personality % 10 + 10;
551 strnum2 = 0;
552 strcpy((char *) old_str1,(char *) place_string1);
553 strcpy((char *) old_str2,(char *) place_string2);
554 strcpy((char *) one_back1,(char *) place_string1);
555 strcpy((char *) one_back2,(char *) place_string2);
556 place_talk_str((char *) place_string1,(char *) place_string2,0,dummy_rect);
558 put_item_screen(stat_window,0);
559 give_help(5,6,0);
563 void end_talk_mode()
565 DisposeGWorld(talk_gworld);
566 talk_gworld = NULL;
568 overall_mode = store_pre_talk_mode;
569 create_clip_region();
570 if (overall_mode == 2)
571 overall_mode = 1;
572 if (overall_mode == 1) {
573 center = c_town.p_loc;
574 update_explored(center);
576 stat_screen_mode = 0;
577 put_item_screen(stat_window,0);
578 put_pc_screen();
579 //refresh_screen(0);
580 redraw_screen(0);
583 void handle_talk_event(POINT p,Boolean right_button)
585 short i,j,force_special = 0,get_pc,s1 = -1,s2 = -1,s3 = -1;
586 char asked[4];
587 char place_string1[256] = "";
588 char place_string2[256] = "";
590 short a,b,c,d,per1,per2,ttype,which_talk_entry = -1;
591 char stra[10],strb[10];
593 long per1l,ttypel,al,bl,cl,dl,per2l;
595 p.x -= 5;
596 p.y -= 5;
598 if (PtInRect(&talk_help_rect,p)) {
599 party.help_received[5] = 0;
600 give_help(5,6,0);
601 return;
604 for (i = 0; i < 9; i++)
605 if ((PtInRect(&preset_words[i].word_rect,p)) && ((talk_end_forced == FALSE) || (i == 6) || (i == 5))) {
606 click_talk_rect((char *) old_str1,(char *) old_str2,preset_words[i].word_rect);
607 switch (i) {
608 case 0: case 1: case 2: case 7: case 8:
609 force_special = i + 1;
610 break;
611 case 3: case 4:
612 force_special = i + 1;
614 //asked[0] = 'p';asked[1] = 'u';asked[2] = 'r';asked[3] = 'c';
615 break;
616 case 5: // save
617 if (strnum1 <= 0) {
618 SysBeep(20);
619 return;
621 for (j = 0; j < 120; j++)
622 if ((party.talk_save[j].personality == store_personality) &&
623 (party.talk_save[j].str1 == strnum1) &&
624 (party.talk_save[j].str2 == strnum2)) {
625 ASB("This is already saved.");
626 print_buf();
627 return;
629 for (j = 0; j < 120; j++)
630 if (party.talk_save[j].personality <= 0) {
631 give_help(57,0,0);
632 play_sound(0);
633 party.talk_save[j].personality = store_personality;
634 party.talk_save[j].town_num = (unsigned char) c_town.town_num;
635 party.talk_save[j].str1 = strnum1;
636 party.talk_save[j].str2 = strnum2;
637 ASB("Noted in journal.");
638 j = 200;
640 if (j < 200) {
641 SysBeep(20);
642 ASB("No more room in talking journal.");
644 print_buf();
645 return;
646 break;
647 case 6: // quit
648 end_talk_mode();
649 return;
650 break;
651 default:
652 for (j = 0; j < 4; j++)
653 asked[j] = preset_words[i].word[j];
654 break;
656 i = 100;
658 if (i < 100) {
659 for (i = 0; i < 50; i++)
660 if ((PtInRect(&store_words[i].word_rect,p)) && (talk_end_forced == FALSE)) {
661 click_talk_rect((char *) old_str1,(char *) old_str2,store_words[i].word_rect);
662 for (j = 0; j < 4; j++)
663 asked[j] = store_words[i].word[j];
665 i = 100;
668 if (i == 50) // no event
669 return;
670 if (force_special == 9) {
671 get_text_response(1017,place_string1,0);
672 asked[0] = place_string1[0];
673 asked[1] = place_string1[1];
674 asked[2] = place_string1[2];
675 asked[3] = place_string1[3];
678 if ((asked[0] == 'n') && (asked[1] == 'a') &&(asked[2] == 'm') &&(asked[3] == 'a')) {
679 force_special = 2;
681 if ((asked[0] == 'l') && (asked[1] == 'o') &&(asked[2] == 'o') &&(asked[3] == 'k')) {
682 force_special = 1;
684 if (((asked[0] == 'j') && (asked[1] == 'o') &&(asked[2] == 'b')) ||
685 ((asked[0] == 'w') && (asked[1] == 'o') &&(asked[2] == 'r')&&(asked[3] == 'k')) ) {
686 force_special = 3;
689 if (force_special > 0) {
690 switch (force_special) {
691 case 1: case 2: case 3:
692 get_str(place_string1,120 + ((store_personality - 1) / 10),
693 ((store_personality - 1) % 10) * 3 + 10 + force_special);
694 sprintf((char *) place_string1,"%s",data_store3->talk_strs[store_personality % 10 + 10 * force_special]);
696 oldstrnum1 = strnum1; oldstrnum2 = strnum2;
697 strnum1 = store_personality % 10 + 10 * force_special;
698 strnum2 = 0;
699 strcpy((char *) one_back1,(char *) old_str1);
700 strcpy((char *) one_back2,(char *) old_str2);
701 strcpy((char *) old_str1,(char *) place_string1);
702 strcpy((char *) old_str2,(char *) place_string2);
703 place_talk_str((char *) place_string1,(char *) place_string2,0,dummy_rect);
704 return;
705 break;
706 case 4: // buy button
707 asked[0] = 'p';asked[1] = 'u';asked[2] = 'r';asked[3] = 'c';
708 if (scan_for_response(asked) >= 0)
709 break;
710 asked[0] = 's';asked[1] = 'a';asked[2] = 'l';asked[3] = 'e';
711 if (scan_for_response(asked) >= 0)
712 break;
713 asked[0] = 'h';asked[1] = 'e';asked[2] = 'a';asked[3] = 'l';
714 if (scan_for_response(asked) >= 0)
715 break;
716 asked[0] = 'i';asked[1] = 'd';asked[2] = 'e';asked[3] = 'n';
717 if (scan_for_response(asked) >= 0)
718 break;
719 asked[0] = 't';asked[1] = 'r';asked[2] = 'a';asked[3] = 'i';
720 if (scan_for_response(asked) >= 0)
721 break;
722 break;
723 case 5: // sell button
724 asked[0] = 's';asked[1] = 'e';asked[2] = 'l';asked[3] = 'l';
725 if (scan_for_response(asked) >= 0)
726 break;
727 break;
728 case 8: // back 1
729 strnum1 = oldstrnum1; strnum2 = oldstrnum2;
730 strcpy((char *) place_string1,(char *) one_back1);
731 strcpy((char *) place_string2,(char *) one_back2);
732 strcpy((char *) one_back1,(char *) old_str1);
733 strcpy((char *) one_back2,(char *) old_str2);
734 strcpy((char *) old_str1,(char *) place_string1);
735 strcpy((char *) old_str2,(char *) place_string2);
736 place_talk_str((char *) place_string1,(char *) place_string2,0,dummy_rect);
737 return;
738 break;
742 which_talk_entry = scan_for_response(asked);
743 if ((which_talk_entry < 0) || (which_talk_entry > 59)) {
744 strcpy((char *) one_back1,(char *) old_str1);
745 strcpy((char *) one_back2,(char *) old_str2);
746 sprintf((char *) old_str2,"");
747 sprintf((char *) old_str1,"%s",data_store3->talk_strs[store_personality % 10 + 160]);
748 if (strlen((char *) old_str1) < 2)
749 sprintf((char *) old_str1,"You get no response.");
750 place_talk_str((char *) old_str1,(char *) old_str2,0,dummy_rect);
751 strnum1 = -1;
752 return;
755 ttype = talking.talk_nodes[which_talk_entry].type;
756 a = talking.talk_nodes[which_talk_entry].extras[0];
757 b = talking.talk_nodes[which_talk_entry].extras[1];
758 c = talking.talk_nodes[which_talk_entry].extras[2];
759 d = talking.talk_nodes[which_talk_entry].extras[3];
761 sprintf((char *) place_string1,"%s",data_store3->talk_strs[40 + which_talk_entry * 2]);
762 sprintf((char *) place_string2,"%s",data_store3->talk_strs[40 + which_talk_entry * 2 + 1]);
764 oldstrnum1 = strnum1; oldstrnum2 = strnum2;
765 strnum1 = 40 + which_talk_entry * 2; strnum2 = 40 + which_talk_entry * 2 + 1;
767 switch(ttype) {
768 case 0:
769 break;
770 case 1:
771 if (PSD[a][b] > c) {
772 strnum1 = strnum2;
773 strcpy((char *) place_string1,(char *) place_string2);
775 sprintf((char *) place_string2,"");
776 strnum2 = 0;
777 break;
778 case 2:
779 PSD[a][b] = 1;
780 break;
781 case 3:
782 if (party.gold < a) {
783 strnum1 = strnum2;
784 strcpy((char *) place_string1,(char *) place_string2);
786 else {
787 talk_end_forced = TRUE;
788 party.gold -= a;
789 put_pc_screen();
790 heal_party(30 * b);
791 restore_sp_party(25 * b);
792 party.age += 700;
793 c_town.p_loc.x = c;
794 c_town.p_loc.y = d;
795 center = c_town.p_loc;
797 strnum2 = 0;
798 sprintf((char *) place_string2,"");
799 break;
800 case 4:
801 if (day_reached((unsigned char) a,0) == TRUE) {
802 strnum1 = strnum2;
803 strcpy((char *) place_string1,(char *) place_string2);
805 sprintf((char *) place_string2,"");
806 strnum2 = 0;
807 break;
808 case 5:
809 if (day_reached((unsigned char) a,(unsigned char) b) == TRUE) {
810 strnum1 = strnum2;
811 strcpy((char *) place_string1,(char *) place_string2);
813 sprintf((char *) place_string2,"");
814 strnum2 = 0;
815 break;
816 case 6:
817 if (c_town.town_num != a) {
818 strnum1 = strnum2;
819 strcpy((char *) place_string1,(char *) place_string2);
821 sprintf((char *) place_string2,"");
822 strnum2 = 0;
823 break;
824 case 7:
825 c = minmax(1,30,c);
826 start_shop_mode(2,b,
827 b + c - 1,a,(char *)place_string1);
828 strnum1 = -1;
829 return;
830 case 8:
831 if ((get_pc = char_select_pc(1,0,"Train who?")) < 6) {
832 strnum1 = -1;
833 spend_xp(get_pc,1, 0);
835 sprintf((char *) place_string1, "You conclude your training.");
836 return;
838 case 9: case 10: case 11:
839 c = minmax(1,30,c);
840 start_shop_mode(ttype + 1,b,
841 b + c - 1,a,(char *)place_string1);
842 strnum1 = -1;
843 return;
844 case 12: //healer
845 start_shop_mode(3,c_town.monst.dudes[store_m_num].monst_start.extra1,
846 c_town.monst.dudes[store_m_num].monst_start.extra2,a,(char *)place_string1);
847 strnum1 = -1;
848 return;
849 break;
850 case 13: // sell weap
851 strnum1 = -1;
852 stat_screen_mode = 3;
853 put_item_screen(stat_window,1);
854 give_help(42,43,0);
855 break;
856 case 14: // sell armor
857 strnum1 = -1;
858 stat_screen_mode = 4;
859 put_item_screen(stat_window,1);
860 give_help(42,43,0);
861 break;
862 case 15: // sell misc
863 strnum1 = -1;
864 stat_screen_mode = 5;
865 put_item_screen(stat_window,1);
866 give_help(42,43,0);
867 break;
868 case 16: case 17: // ident enchant
869 strnum1 = -1;
870 stat_screen_mode = (ttype == 16) ? 2 : 6;
871 shop_identify_cost = a;
872 put_item_screen(stat_window,1);
873 give_help(ttype - 16 + 44,0,0);
874 break;
875 case 18:
876 if (party.gold < a) {
877 strnum1 = strnum2;
878 strcpy((char *) place_string1,(char *) place_string2);
880 else {
881 party.gold -= a;
882 put_pc_screen();
885 sprintf((char *) place_string2,"");
886 strnum2 = 0;
887 break;
888 case 19:
889 if ((sd_legit(b,c) == TRUE) && (PSD[b][c] == d)) {
890 sprintf((char *) place_string1, "You've already learned that.");
891 strnum1 = -1;
893 else if (party.gold < a) {
894 strnum1 = strnum2;
895 strcpy((char *) place_string1,(char *) place_string2);
897 else {
898 party.gold -= a;
899 put_pc_screen();
900 if (sd_legit(b,c) == TRUE)
901 PSD[b][c] = d;
902 else give_error("Invalid Stuff Done flag called in conversation.","",0);
904 strnum2 = 0;
905 sprintf((char *) place_string2,"");
906 break;
907 case 20:
908 if (party.gold < a) {
909 strnum1 = strnum2;
910 strnum2 = 0;
911 strcpy((char *) place_string1,(char *) place_string2);
912 sprintf((char *) place_string2,"");
913 break;
915 else {
916 for (i = b; i <= b + c; i++)
917 if ((i >= 0) && (i < 30) && (party.boats[i].property == TRUE)) {
918 party.gold -= a;
919 put_pc_screen();
920 party.boats[i].property = FALSE;
921 sprintf((char *) place_string2,"");
922 strnum2 = 0;
923 i = 1000;
925 if (i >= 1000)
926 break;
928 sprintf((char *) place_string1, "There are no boats left.");
929 sprintf((char *) place_string2,"");
930 strnum1 = -1;
931 strnum2 = -1;
932 break;
933 case 21:
934 if (party.gold < a) {
935 strnum1 = strnum2;
936 strnum2 = 0;
937 strcpy((char *) place_string1,(char *) place_string2);
938 sprintf((char *) place_string2,"");
939 break;
941 else {
942 for (i = b; i <= b + c; i++)
943 if ((i >= 0) && (i < 30) && (party.horses[i].property == TRUE)) {
944 party.gold -= a;
945 put_pc_screen();
946 party.horses[i].property = FALSE;
947 sprintf((char *) place_string2,"");
948 strnum2 = 0;
949 i = 1000;
951 if (i >= 1000)
952 break;
954 sprintf((char *) place_string1, "There are no horses left.");
955 sprintf((char *) place_string2,"");
956 strnum1 = -1;
957 strnum2 = -1;
958 break;
959 case 22:
960 if (party.spec_items[a] > 0) {
961 sprintf((char *) place_string1, "You already have it.");
962 strnum1 = -1;
964 else if (party.gold < b) {
965 strcpy((char *) place_string1,(char *) place_string2);
966 strnum1 = strnum2;
968 else {
969 party.gold -= b;
970 put_pc_screen();
971 party.spec_items[a] = 1;
973 strnum2 = 0;
974 sprintf((char *) place_string2,"");
975 break;
976 case 23:
977 start_shop_mode(5 + b,0,
978 9,a,(char *)place_string1);
979 strnum1 = -1;
980 return;
981 case 24:
982 if (party.can_find_town[b] > 0) {
984 else if (party.gold < a) {
985 strnum1 = strnum2;
986 strcpy((char *) place_string1,(char *) place_string2);
988 else {
989 party.gold -= a;
990 put_pc_screen();
991 party.can_find_town[b] = 1;
993 strnum2 = 0;
994 sprintf((char *) place_string2,"");
995 break;
996 case 25:
997 talk_end_forced = TRUE;
998 break;
999 case 26:
1000 c_town.monst.dudes[store_m_num].attitude = 1;
1001 c_town.monst.dudes[store_m_num].mobile = 1;
1002 talk_end_forced = TRUE;
1003 break;
1004 case 27:
1005 make_town_hostile();
1006 talk_end_forced = TRUE;
1007 break;
1008 case 28:
1009 c_town.monst.dudes[store_m_num].active = 0;
1010 // Special killing effects
1011 if (sd_legit(c_town.monst.dudes[store_m_num].monst_start.spec1,c_town.monst.dudes[store_m_num].monst_start.spec2) == TRUE)
1012 party.stuff_done[c_town.monst.dudes[store_m_num].monst_start.spec1][c_town.monst.dudes[store_m_num].monst_start.spec2] = 1;
1013 talk_end_forced = TRUE;
1014 break;
1015 case 29: // town special
1016 run_special(7,2,a,c_town.p_loc,&s1,&s2,&s3);
1017 // check s1 & s2 to see if we got diff str, and, if so, munch old strs
1018 if ((s1 >= 0) || (s2 >= 0)) {
1019 strnum1 = -1;
1020 strnum2 = -1;
1021 sprintf((char *) place_string1,"");
1022 sprintf((char *) place_string2,"");
1024 get_strs((char *) place_string1,(char *) place_string2,2,s1,s2);
1025 //strnum1 = -1;
1026 //strnum2 = -1;
1027 if (s1 >= 0) strnum1 = 2000 + s1;
1028 if (s2 >= 0) strnum2 = 2000 + s2;
1029 put_pc_screen();
1030 put_item_screen(stat_window,0);
1031 break;
1032 case 30: // scen special
1033 run_special(7,0,a,c_town.p_loc,&s1,&s2,&s3);
1034 // check s1 & s2 to see if we got diff str, and, if so, munch old strs
1035 if ((s1 >= 0) || (s2 >= 0)) {
1036 strnum1 = -1;
1037 strnum2 = -1;
1038 sprintf((char *) place_string1,"");
1039 sprintf((char *) place_string2,"");
1041 get_strs((char *) place_string1,(char *) place_string2,0,s1,s2);
1042 //strnum1 = -1;
1043 //strnum2 = -1;
1044 if (s1 >= 0) strnum1 = 3000 + s1;
1045 if (s2 >= 0) strnum2 = 3000 + s2;
1046 put_pc_screen();
1047 put_item_screen(stat_window,0);
1048 break;
1054 strcpy((char *) one_back1,(char *) old_str1);
1055 strcpy((char *) one_back2,(char *) old_str2);
1056 strcpy((char *) old_str1,(char *) place_string1);
1057 strcpy((char *) old_str2,(char *) place_string2);
1058 place_talk_str((char *) old_str1,(char *) old_str2,0,dummy_rect);
1062 void handle_talk_spec(short ttype,char *place_string1,char *place_string2) ////
1064 short s1 = 1, s2 = 0,num_horns = 0, num_items = 0,i,j;
1065 item_record_type store_i;
1067 strnum1 = 1000 + s1;
1068 get_str(place_string1,15,s1);
1069 if (s2 > 0) {
1070 strnum2 = 1000 + s2;
1071 get_str(place_string2,15,s2);
1073 print_buf();
1074 put_pc_screen();
1079 void store_responses()
1084 void sign_event_filter (short item_hit)
1086 dialog_not_toast = FALSE;
1089 void do_sign(short town_num, short which_sign, short sign_type,location sign_loc)
1090 //town_num; // Will be 0 - 200 for town, 200 - 290 for outdoors
1091 //short sign_type; // terrain type
1094 short item_hit;
1095 char sign_text[256];
1096 location view_loc;
1098 view_loc = (is_out()) ? party.p_loc : c_town.p_loc;
1099 make_cursor_sword();
1101 cd_create_dialog(1014,mainPtr);
1103 store_sign_mode = sign_type;
1104 if (terrain_pic[sign_type] < 1000)
1105 csp(1014,3,terrain_pic[sign_type]);
1106 else csp(1014,3,94);
1108 if (town_num >= 200) {
1109 town_num -= 200;
1110 load_outdoors(town_num % scenario.out_width, town_num / scenario.out_width,party.i_w_c.x,party.i_w_c.y,
1111 1,which_sign + 100,(char *) sign_text);
1113 else {
1114 sprintf((char *) sign_text,"%s",data_store->town_strs[120 + which_sign]);
1116 csit(1014,2,(char *) sign_text);
1118 while (dialog_not_toast)
1119 ModalDialog();
1120 cd_kill_dialog(1014,0);
1125 void give_reg_info_event_filter (short item_hit)
1127 short i;
1128 char place_str[256];
1130 switch (item_hit) {
1131 case 1:
1132 dialog_not_toast = FALSE;
1133 break;
1137 void give_reg_info()
1139 long val_for_text;
1141 short i,item_hit;
1142 char place_str[256];
1145 make_cursor_sword();
1147 cd_create_dialog_parent_num(1073,0);
1149 while (dialog_not_toast)
1150 ModalDialog(); cd_kill_dialog(1073,0);
1157 void do_registration_event_filter (short item_hit)
1159 char get_text[256];
1160 long dummy;
1162 cd_get_text_edit_str(1075,(char *) get_text);
1163 dialog_answer = 0;
1164 sscanf((char *) get_text,"%d",&dialog_answer);
1165 dialog_not_toast = FALSE;
1168 void do_registration()
1171 short item_hit;
1172 char sign_text[256];
1173 location view_loc;
1175 make_cursor_sword();
1177 cd_create_dialog(1075,mainPtr);
1179 cdsin(1075,7,(short) register_flag);
1180 cd_set_edit_focus();
1182 while (dialog_not_toast)
1183 ModalDialog();
1184 cd_kill_dialog(1075,0);
1186 if (dialog_answer == 1)
1187 SysBeep(30);
1189 if (dialog_answer == (short) init_data(register_flag)) {
1190 play_sound(40);
1191 registered = TRUE;
1192 build_data_file(2);
1193 FCD(1078,0);
1194 //save_prefs();
1195 //check_pref_file();
1197 else {
1198 SysBeep(30);
1199 FCD(1077,0);
1206 Boolean prefs_event_filter (short item_hit)
1208 Boolean done_yet = FALSE,did_cancel = FALSE;
1209 short i;
1210 RECT windRECT;
1212 switch (item_hit) {
1213 case 1:
1214 done_yet = TRUE;
1215 dialog_not_toast = FALSE;
1216 break;
1218 case 2:
1219 done_yet = TRUE;
1220 dialog_not_toast = FALSE;
1221 did_cancel = TRUE;
1222 break;
1224 case 50: case 52: case 18: case 20: case 22: case 24: case 27: case 38: case 40: case 43: case 45:
1225 cd_set_led(1099,item_hit,1 - cd_get_led(1099,item_hit));
1226 break;
1228 case 29:
1229 cd_set_led(1099,29,1);
1230 break;
1232 case 32: case 34: case 36: case 47:
1233 cd_set_led(1099,32,(item_hit == 32) ? 1 : 0);
1234 cd_set_led(1099,34,(item_hit == 34) ? 1 : 0);
1235 cd_set_led(1099,36,(item_hit == 36) ? 1 : 0);
1236 cd_set_led(1099,47,(item_hit == 47) ? 1 : 0);
1237 break;
1240 default:
1241 cd_set_led(1099,4 + cur_display_mode,0);
1242 cur_display_mode = item_hit - 4;
1243 cd_set_led(1099,4 + cur_display_mode,1);
1244 break;
1246 if (done_yet== TRUE) {
1247 if (did_cancel == FALSE) {
1248 display_mode = cur_display_mode;
1249 party.stuff_done[306][0] = cd_get_led(1099,18);
1250 party.stuff_done[306][1] = cd_get_led(1099,20);
1251 play_sounds = 1 - party.stuff_done[306][1];
1252 party.stuff_done[306][2] = cd_get_led(1099,22);
1253 party.stuff_done[306][3] = cd_get_led(1099,24);
1254 party.stuff_done[306][4] = cd_get_led(1099,27);
1255 party.stuff_done[306][7] = cd_get_led(1099,38);
1256 party.stuff_done[306][8] = cd_get_led(1099,40);
1257 party.stuff_done[306][9] = cd_get_led(1099,43);
1258 party.stuff_done[296][0] = cd_get_led(1099,45);
1259 party.stuff_done[305][6] = cd_get_led(1099,50);
1260 party.stuff_done[305][5] = cd_get_led(1099,52);
1261 if (cd_get_led(1099,32) == 1)
1262 PSD[306][6] = 0;
1263 if (cd_get_led(1099,34) == 1)
1264 PSD[306][6] = 1;
1265 if (cd_get_led(1099,36) == 1)
1266 PSD[306][6] = 2;
1267 if (cd_get_led(1099,47) == 1)
1268 PSD[306][6] = 3;
1269 if (cd_get_led(1099,29) == 1)
1270 for (i = 0; i < 120; i++)
1271 party.help_received[i] = 0;
1272 if (display_mode < 5)
1273 max_window(mainPtr);
1274 else {
1275 GetWindowRect(GetDesktopWindow(),&windRECT);
1276 MoveWindow(mainPtr,(windRECT.right - (588 + 10)) / 2,
1277 (windRECT.bottom - (425 + 52)) / 2 ,
1278 588 + 10,425 + 52,TRUE);
1281 //play_sounds = 1 - party.stuff_done[306][1];
1282 save_maps = 1 - party.stuff_done[306][0];
1283 give_delays = party.stuff_done[306][2];
1284 build_data_file(2);
1287 return FALSE;
1290 void pick_preferences()
1292 short item_hit;
1294 cur_display_mode = display_mode;
1296 make_cursor_sword();
1298 cd_create_dialog(1099,mainPtr);
1300 cd_set_led(1099,4 + cur_display_mode,1);
1302 cd_set_led(1099,18,(party.stuff_done[306][0] != 0) ? 1 : 0);
1303 cd_set_led(1099,20,(play_sounds == FALSE) ? 1 : 0);
1304 cd_set_led(1099,22,(party.stuff_done[306][2] != 0) ? 1 : 0);
1305 cd_set_led(1099,24,(party.stuff_done[306][3] != 0) ? 1 : 0);
1306 cd_set_led(1099,27,(party.stuff_done[306][4] != 0) ? 1 : 0);
1307 cd_set_led(1099,38,(party.stuff_done[306][7] != 0) ? 1 : 0);
1308 cd_set_led(1099,40,(party.stuff_done[306][8] != 0) ? 1 : 0);
1309 cd_set_led(1099,43,(party.stuff_done[306][9] != 0) ? 1 : 0);
1310 cd_set_led(1099,45,(party.stuff_done[296][0] != 0) ? 1 : 0);
1311 cd_set_led(1099,50,(party.stuff_done[305][6] != 0) ? 1 : 0);
1312 cd_set_led(1099,52,(party.stuff_done[305][5] != 0) ? 1 : 0);
1313 cd_set_flag(1099,3,1);
1314 if (PSD[306][6] == 3)
1315 cd_set_led(1099,47,1);
1316 else cd_set_led(1099,32 + PSD[306][6] * 2,1);
1318 if (party.help_received[55] == 0) {
1319 cd_initial_draw(1099);
1320 give_help(55,0,1099);
1323 while (dialog_not_toast)
1324 ModalDialog();
1325 cd_kill_dialog(1099,0);
1326 adjust_window_mode();
1329 void put_party_stats()
1331 short i;
1332 char pc_str[256];
1335 for (i = 0; i < 6; i++) {
1336 if (adven[i].main_status > 0) {
1337 cd_set_item_text(989,5 + 5 * i,adven[i].name);
1338 cd_activate_item(989,7 + 5 * i,1);
1339 cd_activate_item(989,8 + 5 * i,1);
1340 cd_set_flag(989,6 + 5 * i,96);
1341 cd_activate_item(989,35 + i,1);
1342 cd_activate_item(989,42 + i,1);
1343 csp(989,42 + i,800 + adven[i].which_graphic);
1345 else {
1346 cd_set_item_text(989,5 + 5 * i,"Empty.");
1347 cd_activate_item(989,7 + 5 * i,0);
1348 cd_activate_item(989,8 + 5 * i,0);
1349 cd_set_flag(989,6 + 5 * i,98);
1350 cd_activate_item(989,35 + i,0);
1351 cd_activate_item(989,42 + i,0);
1357 void edit_party_event_filter (short item_hit)
1359 short i = 0,j = 0,which_pc;
1361 switch (item_hit) {
1362 case 1:
1363 dialog_not_toast = FALSE;
1364 break;
1366 case 41:
1367 party.help_received[22] = 0;
1368 give_help(222,23,989);
1369 return;
1371 case 5: case 10: case 15: case 20: case 25: case 30:
1372 which_pc = (item_hit - 5) / 5;
1373 if (adven[which_pc].main_status == 0) {
1374 //give_help(56,0,989);
1375 //create_pc(which_pc,989);
1376 //cd_initial_draw(989); // extra redraw, just in case
1378 else pick_pc_name(which_pc,989);
1379 put_party_stats();
1380 break;
1381 case 7: case 12: case 17: case 22: case 27: case 32:
1382 which_pc = (item_hit - 7) / 5;
1383 pick_race_abil(&adven[which_pc],0,989);
1384 put_party_stats();
1385 break;
1386 case 8: case 13: case 18: case 23: case 28: case 33:
1387 which_pc = (item_hit - 8) / 5;
1388 spend_xp(which_pc,0,989);
1389 put_party_stats();
1390 break;
1391 case 35: case 36: case 37: case 38: case 39: case 40:
1392 which_pc = item_hit - 35;
1394 if (adven[which_pc].main_status <= 0)
1395 break;
1396 if (adven[which_pc].main_status != 0)
1397 pick_pc_graphic(which_pc,1,989);
1398 put_party_stats();
1399 break;
1400 case 6: case 11: case 16: case 21: case 26: case 31:
1401 which_pc = (item_hit - 6) / 5;
1402 if (adven[which_pc].main_status != 0) {
1403 if (FCD(1053,989) == 2)
1404 adven[which_pc].main_status = 0;
1405 put_party_stats();
1407 else {
1408 give_help(56,0,989);
1409 create_pc(which_pc,989);
1410 put_party_stats();
1411 cd_initial_draw(989); // extra redraw, just in case
1413 break;
1414 // case 7: case 12: case 17: case 22: case 27: case 32:
1420 void edit_party(short can_create,short can_cancel)
1422 short item_hit;
1423 Boolean munch_pc_graphic = FALSE;
1425 make_cursor_sword();
1427 if (pcs_gworld == NULL) {
1428 munch_pc_graphic = TRUE;
1429 pcs_gworld = load_pict(902,main_dc);
1432 cd_create_dialog(989,mainPtr);
1434 put_party_stats();
1435 if (party.help_received[22] == 0) {
1436 cd_initial_draw(989);
1437 give_help(22,23,989);
1439 while (dialog_not_toast)
1440 ModalDialog();
1441 cd_kill_dialog(989,0);
1443 if (munch_pc_graphic == TRUE) {
1444 DisposeGWorld(pcs_gworld);
1445 pcs_gworld = NULL;
1448 if (adven[current_pc].main_status != 1)
1449 current_pc = first_active_pc();
1454 void tip_of_day_event_filter (short item_hit)
1456 short i;
1457 char place_str[256];
1459 switch (item_hit) {
1460 case 1:
1461 dialog_not_toast = FALSE;
1462 break;
1464 case 5:
1465 store_tip_page_on++;
1466 if (store_tip_page_on == NUM_HINTS)
1467 store_tip_page_on = 0;
1468 get_str(place_str,12,50 + store_tip_page_on);
1469 csit(958,3,(char *) place_str);
1470 break;
1472 case 7:
1473 give_intro_hint = 1 - give_intro_hint;
1474 cd_set_led(958,7,give_intro_hint);
1475 break;
1480 void tip_of_day()
1482 long val_for_text;
1484 short i,item_hit;
1485 char place_str[256];
1487 store_tip_page_on = get_ran(1,0,NUM_HINTS - 1);
1489 make_cursor_sword();
1491 cd_create_dialog_parent_num(958,0);
1493 get_str(place_str,12,50 + store_tip_page_on);
1494 csit(958,3,(char *) place_str);
1496 cd_set_led(958,7,give_intro_hint);
1498 while (dialog_not_toast)
1499 ModalDialog();
1501 cd_kill_dialog(958,0);
1502 build_data_file(2);
1506 void max_window(HWND window)
1508 RECT main_rect,wind_rect;
1509 short width,height;
1511 cursor_shown = TRUE;
1512 showcursor(TRUE);
1514 GetWindowRect(GetDesktopWindow(),&main_rect);
1515 GetWindowRect(window,&wind_rect);
1516 width = main_rect.right - main_rect.left;
1517 height = main_rect.bottom - main_rect.top;
1518 MoveWindow(window,0,0,width,height,TRUE);
1522 void put_scen_info()
1524 short i;
1525 char place_str[256];
1526 char *ratings[] = {"G","PG","R","NC-17"};
1527 char *difficulty[] = {"Low","Medium","High","Very High"};
1529 for (i = 0; i < 3; i++)
1530 if (scen_headers[store_scen_page_on * 3 + i].flag1 != 0) {
1531 cd_set_pict(947, 6 + i * 3,1600 + scen_headers[store_scen_page_on * 3 + i].intro_pic);
1532 sprintf((char *) place_str,
1533 "%s v%d.%d.%d - | Difficulty: %s, Rating: %s |%s |%s",
1534 data_store2->scen_header_strs[store_scen_page_on * 3 + i][0],
1535 (short) scen_headers[store_scen_page_on * 3 + i].ver[0],
1536 (short) scen_headers[store_scen_page_on * 3 + i].ver[1],
1537 (short) scen_headers[store_scen_page_on * 3 + i].ver[2],
1538 difficulty[scen_headers[store_scen_page_on * 3 + i].difficulty],
1539 ratings[scen_headers[store_scen_page_on * 3 + i].default_ground],
1540 data_store2->scen_header_strs[store_scen_page_on * 3 + i][1],
1541 data_store2->scen_header_strs[store_scen_page_on * 3 + i][2]);
1542 csit(947,7 + i * 3,(char *) place_str);
1543 cd_activate_item(947,8 + i * 3,1);
1545 else {
1546 cd_set_pict(947, 6 + i * 3,950);
1547 csit(947,7 + i * 3,"");
1548 cd_activate_item(947,8 + i * 3,0);
1552 void pick_a_scen_event_filter (short item_hit)
1554 short i;
1555 char place_str[256];
1557 switch (item_hit) {
1558 case 1:
1559 dialog_answer = -1;
1560 dialog_not_toast = FALSE;
1561 break;
1563 case 3: case 4:
1564 if (item_hit == 3) {
1565 if (store_scen_page_on == 0)
1566 store_scen_page_on = (store_num_scen - 1) / 3;
1567 else store_scen_page_on--;
1569 else {
1570 if (store_scen_page_on == (store_num_scen - 1) / 3)
1571 store_scen_page_on = 0;
1572 else store_scen_page_on++;
1574 put_scen_info();
1575 break;
1577 case 8: case 11: case 14:
1578 dialog_answer = ((item_hit - 8) / 3) + store_scen_page_on * 3;
1579 dialog_not_toast = FALSE;
1580 break;
1585 short pick_a_scen()
1587 long val_for_text;
1589 short i,item_hit;
1590 char place_str[256];
1592 build_scen_headers();
1594 store_num_scen = 0;
1595 for (i = 0; i < 25; i++)
1596 if (scen_headers[i].flag1 != 0)
1597 store_num_scen++;
1598 store_scen_page_on = 0;
1600 if (store_num_scen == 0) {
1601 FCD(868,0);
1602 return -1;
1604 make_cursor_sword();
1606 cd_create_dialog_parent_num(947,0);
1608 put_scen_info();
1610 if (store_num_scen <= 3) {
1611 cd_activate_item(947,3,0);
1612 cd_activate_item(947,4,0);
1614 while (dialog_not_toast)
1615 ModalDialog();
1616 cd_kill_dialog(947,0);
1617 return dialog_answer;
1621 void pick_prefab_scen_event_filter (short item_hit)
1623 short i;
1624 char place_str[256];
1626 switch (item_hit) {
1627 case 1:
1628 dialog_answer = -1;
1629 dialog_not_toast = FALSE;
1630 break;
1632 case 6: case 9: case 12:
1633 dialog_answer = ((item_hit - 6) / 3);
1634 dialog_not_toast = FALSE;
1635 break;
1640 short pick_prefab_scen()
1642 long val_for_text;
1644 short i,item_hit;
1645 char place_str[256];
1647 make_cursor_sword();
1649 cd_create_dialog_parent_num(869,0);
1650 cd_activate_item(869,2,0);
1652 while (dialog_not_toast)
1653 ModalDialog();
1654 cd_kill_dialog(869,0);
1655 return dialog_answer;
1658 void give_password_filter (short item_hit)
1660 char str[256];
1661 short i;
1663 switch (item_hit) {
1664 default:
1666 dialog_not_toast = FALSE;
1667 break;
1672 Boolean enter_password()
1673 // ignore parent in Mac version
1675 short town_strs_hit,i,store_dialog_answer;
1676 char temp_str[256],str2[256];
1678 cd_create_dialog_parent_num(823,0);
1680 cd_set_text_edit_str(823,"");
1682 while (dialog_not_toast)
1683 ModalDialog();
1685 cd_get_text_edit_str(823,(char *) temp_str);
1686 i = wd_to_pwd(temp_str);
1688 cd_kill_dialog(823,0);
1690 return check_p(i);
1693 short wd_to_pwd(char *str)
1695 char pwd[8] = "aaaaaa";
1696 short i;
1697 long val = 0,pow[6] = {1,10,100,1000,9999,99999};
1699 for (i = 0; i < 6; i++) {
1700 if (str[i] == 0)
1701 i = 6;
1702 else {
1703 if ((str[i] >= 65) && (str[i] <= 90))
1704 pwd[i] = str[i] + 32;
1705 else if ((str[i] >= 48) && (str[i] <= 57))
1706 pwd[i] = str[i] + 49;
1707 else if ((str[i] >= 97) && (str[i] <= 122))
1708 pwd[i] = str[i];
1711 for (i = 0; i < 6; i++)
1712 val = val + pow[i] * (long) (pwd[i] - 97);
1713 val = val % 30000;
1714 return (short) val;