added worldarea -> will be responsible for world map rendering
[dboe.git] / infodlgs.c
blob9a3f0253d3f0ae59c5b3d1e567a45eca46e6ae85
3 #include <Windows.h>
4 #include "stdio.h"
6 #include "global.h"
8 #include "graphics.h"
9 #include "newgraph.h"
10 #include "items.h"
11 #include "string.h"
12 #include "monster.h"
13 #include "dlogtool.h"
14 #include "party.h"
15 #include "fields.h"
16 #include "locutils.h"
17 #include "text.h"
18 #include "exlsound.h"
19 #include "infodlgs.h"
20 #include "fileio.h"
22 short mage_spell_pos = 0,priest_spell_pos = 0,skill_pos = 0;
23 pc_record_type *store_pc;
24 creature_data_type *store_m;
25 short store_trait_mode,store_item_pc,store_pc_num;
26 item_record_type store_i;
28 extern short spell_w_cast[2][62];
29 extern short spell_level[62];
30 extern short skill_cost[20];
31 extern short skill_max[20];
32 extern short skill_g_cost[20];
33 extern pc_record_type far adven[6];
34 extern short which_pc_displayed;
35 extern party_record_type far party;
36 extern short far mage_range[66];
37 extern short far priest_range[66];
38 extern short spell_cost[2][62];
39 extern Boolean in_startup_mode,give_intro_hint;
40 extern pascal Boolean cd_event_filter();
41 extern Boolean dialog_not_toast;
42 extern HWND mainPtr;
43 extern short on_monst_menu[256],cur_town_talk_loaded;
44 extern big_tr_type far t_d;
45 extern location tinraya_portculli[12];
46 extern char far scen_strs2[110][256];
47 extern scenario_data_type far scenario;
48 extern piles_of_stuff_dumping_type3 *data_store3;
49 extern piles_of_stuff_dumping_type4 *data_store4;
50 extern piles_of_stuff_dumping_type5 *data_store5;
52 Boolean full_roster = FALSE;
54 extern short far dest_personalities[40];
55 extern location far dest_locs[40];
57 extern short dest_personalities[40];
58 location source_locs[6] = {{2,9},{0,6},{3,6},{3,4},{6,2},{0,0}};
59 extern location dest_locs[40] ;
61 // Displaying string vars
62 short store_str1a;
63 short store_str1b;
64 short store_str2a;
65 short store_str2b;
66 short store_which_string_dlog;
67 short store_page_on,store_num_i;
68 short store_str_label_1,store_str_label_2,store_str_label_1b,store_str_label_2b;
70 // Misc dialog vars
71 short store_display_mode,store_displayed_item,position,cur_entry,num_entries,store_help_mode;
72 creature_data_type hold_m;
74 void put_spell_info()
76 char store_text[256];
77 short pos,res,ran;
80 pos = (store_display_mode == 0) ? mage_spell_pos : priest_spell_pos;
81 res = (store_display_mode == 0) ? 7 : 8;
82 ran = (store_display_mode == 0) ? mage_range[pos] : priest_range[pos];
84 get_str (store_text, res, pos * 2 + 1);
85 cd_set_item_text(1096,4,(char *) store_text);
87 if (spell_cost[store_display_mode][pos] > 0)
88 sprintf((char *) store_text, "%d/%d",spell_level[pos],spell_cost[store_display_mode][pos]);
89 else sprintf((char *) store_text, "%d/?",spell_level[pos]);
90 cd_set_item_text(1096,5,(char *) store_text);
92 if (ran == 0) {
93 cd_set_item_text(1096,6,"");
95 else cd_set_item_num(1096,6,ran);
96 get_str (store_text, res, pos * 2 + 2);
98 cd_set_item_text(1096,7,(char *) store_text);
99 get_str (store_text, 11, 1 + spell_w_cast[store_display_mode][pos]);
100 cd_set_item_text(1096,11,(char *) store_text);
104 Boolean display_spells_event_filter (short item_hit)
106 short store;
107 switch (item_hit) {
108 case 1: case 8:
109 dialog_not_toast = FALSE;
110 break;
112 case 9: case 10:
113 store = (store_display_mode == 0) ? mage_spell_pos : priest_spell_pos;
114 if (item_hit == 9) {
115 store = (store == 0) ? 61 : store - 1;
117 else {
118 store = (store + 1) % 62;
120 if (store_display_mode == 0)
121 mage_spell_pos = store;
122 else priest_spell_pos = store;
123 put_spell_info();
124 break;
127 return FALSE;
129 void display_spells(short mode,short force_spell,short parent_num)
130 //short mode; // 0 - mage 1 - priest
131 //short force_spell; // if 100, ignore
133 short buy_val,i,store,item_hit;
134 char get_text[256];
136 store_display_mode = mode;
137 if (force_spell < 100) {
138 if (mode == 0)
139 mage_spell_pos = force_spell;
140 else priest_spell_pos = force_spell;
143 make_cursor_sword();
145 cd_create_dialog_parent_num(1096,parent_num);
147 cd_set_pict(1096,18,714 + mode);
148 put_spell_info();
149 if (mode == 0)
150 csit(1096,3,"Mage Spells");
151 else csit(1096,3,"Priest Spells");
152 while (dialog_not_toast)
153 ModalDialog();
155 cd_kill_dialog(1096,0);
159 void put_skill_info()
161 char store_text[256];
162 short pos;
164 pos = skill_pos;
166 get_str(store_text,9,pos * 2 + 1);
167 cd_set_item_text(1097,3,(char *) store_text);
168 cd_set_item_num(1097,4,skill_cost[pos]);
169 cd_set_item_num(1097,5,skill_g_cost[pos]);
170 cd_set_item_num(1097,6,skill_max[pos]);
172 get_str (store_text, 9, pos * 2 + 2);
173 cd_set_item_text(1097,7,(char *) store_text);
174 get_str (store_text, 12, 1 + pos);
175 cd_set_item_text(1097,8,(char *) store_text);
179 Boolean display_skills_event_filter (short item_hit)
181 switch (item_hit) {
182 case 1: case 11:
183 dialog_not_toast = FALSE;
184 break;
186 case 10: case 9:
187 if (item_hit == 9) {
188 skill_pos = (skill_pos == 0) ? 18 : skill_pos - 1;
190 else {
191 skill_pos = (skill_pos + 1) % 19;
193 put_skill_info();
194 break;
196 return FALSE;
199 void display_skills(short force_skill,short parent)
201 long val_for_text;
203 short buy_val,i,store,item_hit;
205 if (force_skill < 100)
206 skill_pos = force_skill;
207 if (skill_pos < 0)
208 skill_pos = 0;
210 make_cursor_sword();
212 cd_create_dialog_parent_num(1097,parent);
214 put_skill_info();
215 while (dialog_not_toast)
216 ModalDialog(); cd_kill_dialog(1097,0);
220 void put_pc_graphics()
222 short item_hit,what_talk_field,i;
224 for (i = 3; i < 65; i++) {
225 if (((store_trait_mode == 0) && (adven[which_pc_displayed].mage_spells[i - 3] == TRUE)) ||
226 ((store_trait_mode == 1) && (adven[which_pc_displayed].priest_spells[i - 3] == TRUE)))
227 cd_set_led(991,i,2);
228 else cd_set_led(991,i,0);
231 cd_set_item_text(991,69,adven[which_pc_displayed].name);
233 Boolean display_pc_event_filter (short item_hit)
235 short pc_num;
237 pc_num = which_pc_displayed;
238 switch (item_hit) {
239 case 1: case 65:
240 dialog_not_toast = FALSE;
241 break;
243 case 66:
244 do {
245 pc_num = (pc_num == 0) ? 5 : pc_num - 1;
246 } while (adven[pc_num].main_status == 0);
247 which_pc_displayed = pc_num;
248 put_pc_graphics();
249 break;
250 case 67:
251 do {
252 pc_num = (pc_num == 5) ? 0 : pc_num + 1;
253 } while (adven[pc_num].main_status == 0);
254 which_pc_displayed = pc_num;
255 put_pc_graphics();
256 break;
258 case 100:
259 break;
262 return FALSE;
265 void display_pc(short pc_num,short mode,short parent)
267 short i,item_hit;
268 char label_str[256];
270 if (adven[pc_num].main_status == 0) {
271 for (pc_num = 0; pc_num < 6; pc_num++)
272 if (adven[pc_num].main_status == 1)
273 break;
275 which_pc_displayed = pc_num;
276 store_trait_mode = mode;
278 make_cursor_sword();
280 cd_create_dialog_parent_num(991,parent);
282 for (i = 3; i < 65; i++) {
283 get_str(label_str,(mode == 0) ? 7 : 8,(i - 3) * 2 + 1);
284 cd_add_label(991,i,(char *)label_str,46);
286 put_pc_graphics();
288 cd_set_pict(991,2,714 + mode);
289 while (dialog_not_toast)
290 ModalDialog(); cd_kill_dialog(991,0);
293 void put_item_info(short pc,short item)
295 char store_text[256];
296 char desc_str[256];
297 short pos,i;
298 item_record_type s_i;
299 char *item_types[] = {"","1-Handed weapon","2-Handed weapon","","Bow","Arrows","Thrown missile",
300 "Potion/Magic Item","Scroll/Magic Item","Wand","Tool","","Shield","Armor","Helm",
301 "Gloves","Shield","Boots","Ring","Necklace",
302 "Weapon Poison","Gem, Stone, Etc.","Pants","Crossbow","Bolts","Missile Weapon"};
305 s_i = store_i;
307 csp(998,1,950);
308 if (s_i.graphic_num >= 150)
309 csp(998,1,s_i.graphic_num - 150 + 2000);
310 else csp(998,1,1800 + s_i.graphic_num);
312 // id? magic?
313 if ((is_magic(store_i) == TRUE) && (is_ident(store_i) == TRUE))
314 cd_set_led(998,17,1);
315 else cd_set_led(998,17,0);
316 if (is_ident(store_i) == TRUE)
317 cd_set_led(998,16,1);
318 else cd_set_led(998,16,0);
319 cd_set_item_text(998,4, item_types[s_i.variety]);
321 // Clear fields
322 for (i = 5; i < 13; i++) {
323 cd_set_item_text(998,i, "");
327 if (is_ident(s_i) == FALSE) {
328 cd_set_item_text(998,3, s_i.name);
329 return;
332 cd_set_item_text(998,3, s_i.full_name);
333 i = item_weight(s_i);
334 cd_set_item_num(998,20,i);
336 cd_set_item_num(998,5,(s_i.charges > 0) ? s_i.value * s_i.charges : s_i.value);
338 if (s_i.ability > 0) {////
339 get_str(desc_str,23,s_i.ability + 1);
340 cd_set_item_text(998,12,(char *) desc_str);
342 if (s_i.charges > 0)
343 cd_set_item_num(998,10,s_i.charges);
344 if (s_i.protection > 0)
345 cd_set_item_num(998,8,s_i.protection);
347 switch (s_i.variety) {
348 case 1: case 2:
349 cd_set_item_num(998,6,s_i.item_level);
350 cd_set_item_num(998,7,s_i.bonus);
352 switch (s_i.type) {
353 case 1:sprintf((char *) store_text, "Edged weapon");
354 break;
355 case 2:sprintf((char *) store_text, "Bashing weapon");
356 break;
357 case 3:sprintf((char *) store_text, "Pole weapon");
358 break;
360 if (s_i.ability == 0)
361 cd_set_item_text(998,12,store_text);
362 break;
363 case 4: case 23:
364 cd_set_item_num(998,6,s_i.item_level);
365 cd_set_item_num(998,7,s_i.bonus);
366 break;
367 case 5: case 6: case 24: case 25:
368 cd_set_item_num(998,6,s_i.item_level);
369 cd_set_item_num(998,7,s_i.bonus);
370 break;
371 case 7: case 18:
372 cd_set_item_num(998,11,s_i.item_level);
373 break;
374 case 12: case 13: case 14: case 15: case 16: case 17:
375 cd_set_item_num(998,7,s_i.bonus + s_i.protection);
376 cd_set_item_num(998,8,s_i.item_level);
377 cd_set_item_num(998,9,s_i.awkward);
378 break;
379 case 20:
380 cd_set_item_num(998,11,s_i.item_level);
381 break;
386 Boolean display_pc_item_event_filter (short item_hit)
388 short item,pc_num;
390 item = store_displayed_item;
391 pc_num = store_item_pc;
393 switch (item_hit) {
394 case 1: case 13:
395 dialog_not_toast = FALSE;
396 break;
398 case 14:
399 do {
400 item = (item == 0) ? 23 : item - 1;
401 } while (adven[pc_num].items[item].variety == 0);
402 store_displayed_item = item;
403 store_i = adven[pc_num].items[item];
404 put_item_info(pc_num,item);
405 break;
406 case 15:
407 do {
408 item = (item == 23) ? 0 : item + 1;
409 } while (adven[pc_num].items[item].variety == 0);
410 store_displayed_item = item;
411 store_i = adven[pc_num].items[item];
412 put_item_info(pc_num,item);
413 break;
415 case 100:
416 break;
419 return FALSE;
422 void display_pc_item(short pc_num,short item,item_record_type si,short parent)
424 short item_hit;
426 store_item_pc = pc_num;
427 if (pc_num == 6)
428 store_i = si;
429 else store_i = adven[pc_num].items[item];
430 store_displayed_item = item;
431 make_cursor_sword();
433 if (cd_create_dialog_parent_num(998,parent) < 0)
434 return;
436 if (store_item_pc >= 6) {
437 cd_activate_item(998,14,0);
438 cd_activate_item(998,15,0);
440 cd_add_label(998,3,"Name:",1026);
441 cd_add_label(998,4,"Type:",1026);
442 cd_add_label(998,5,"Value:",1020);
443 cd_add_label(998,6,"Damage:",1026);
444 cd_add_label(998,7,"Bonus:",1024);
445 cd_add_label(998,8,"Defend:",1025);
446 cd_add_label(998,9,"Encumb.:",1029);
447 cd_add_label(998,10,"Uses:",1019);
448 cd_add_label(998,11,"Item Level:",1037);
449 cd_add_label(998,12,"Ability:",1026);
450 cd_add_label(998,16,"ID?",1013);
451 cd_add_label(998,17,"Magic?",1022);
452 cd_add_label(998,20 ,"Weight",1022);
454 put_item_info(pc_num,item);
455 while (dialog_not_toast)
456 ModalDialog(); cd_kill_dialog(998,0);
461 void put_monst_info()
463 char store_text[256];
464 char str[256];
465 short abil,i;
467 if ( store_m->m_d.spec_skill == 11)
468 cd_set_pict(999,4,400);
469 else if (store_m->m_d.picture_num < 1000)
470 cd_set_pict(999,4,400 + store_m->m_d.picture_num);
471 else cd_set_pict(999,4,2000 + (store_m->m_d.picture_num % 1000));
473 get_m_name((char *) store_text,store_m->number);
474 cd_set_item_text(999,5,store_text);
475 // Clear fields
476 for (i = 6; i < 20; i++) {
477 cd_set_item_text(999,i,"");
480 abil = store_m->m_d.spec_skill;
481 get_str(str,20,abil + 1);
482 cd_set_item_text(999,19,(char *) str);
483 get_str(str,20,store_m->m_d.radiate_1 + 50);
484 cd_set_item_text(999,31,(char *) str);
486 for (i = 0; i < 3; i++)
487 if (store_m->m_d.a[i] > 0) {
488 sprintf((char *) store_text," %dd%d ",
489 store_m->m_d.a[i] / 100 + 1, store_m->m_d.a[i] % 100);
491 cd_set_item_text(999,13 + i,store_text);
493 cd_set_item_num(999,6,store_m->m_d.level);
494 cd_set_item_num(999,7,store_m->m_d.health);
495 cd_set_item_num(999,8,store_m->m_d.mp);
496 cd_set_item_num(999,9,store_m->m_d.armor);
497 cd_set_item_num(999,10,store_m->m_d.skill);
498 cd_set_item_num(999,11,store_m->m_d.morale);
499 cd_set_item_num(999,12,store_m->m_d.speed);
500 cd_set_item_num(999,16,store_m->m_d.mu);
501 cd_set_item_num(999,17,store_m->m_d.cl);
502 cd_set_item_num(999,18,store_m->m_d.poison);
503 // 2140 - lit 2141 - dark
504 // immunities
505 for (i = 0; i < 8; i++)
506 if (store_m->m_d.immunities & (char)(s_pow(2,i)))
507 cd_set_led(999,20 + i,1);
508 else cd_set_led(999,20 + i,0);
514 Boolean display_monst_event_filter (short item_hit)
516 short i,dummy = 0;
518 switch (item_hit) {
519 case 1: case 3:
520 dialog_not_toast = FALSE;
521 break;
523 case 28:
524 if (position == 0) {
525 for (i = 255; on_monst_menu[i] < 0 && i > 0; i--)
526 dummy++;
527 position = i;
529 else position--;
531 if (on_monst_menu[position] < 0)
532 position = 0;
533 store_m->number = (unsigned char)on_monst_menu[position];
534 store_m->m_d = return_monster_template((unsigned char)on_monst_menu[position]);
535 put_monst_info();
536 break;
537 case 29:
538 position++;
539 if (on_monst_menu[position] < 0)
540 position = 0;
541 store_m->number = (unsigned char)on_monst_menu[position];
542 store_m->m_d = return_monster_template((unsigned char)on_monst_menu[position]);
543 put_monst_info();
544 break;
546 case 100:
547 break;
551 return FALSE;
554 void display_monst(short array_pos,creature_data_type *which_m,short mode)
555 //creature_data_type *which_m; // if NULL, show full roster
556 //short mode; // if 1, full roster, else use monster from storwhich_me_m
559 short item_hit;
561 position = array_pos;
562 full_roster = FALSE;
563 if (mode == 1) {
564 full_roster = TRUE;
565 store_m = &hold_m;
566 store_m->number = on_monst_menu[array_pos];
567 store_m->m_d = return_monster_template((unsigned char)on_monst_menu[array_pos]);
569 else {
570 hold_m = *which_m;
571 store_m = which_m;
574 make_cursor_sword();
576 cd_create_dialog(999,mainPtr);
578 if (full_roster == FALSE) {
579 cd_activate_item(999,28,0);
580 cd_activate_item(999,29,0);
582 cd_add_label(999,5,"Name",1026);
583 cd_add_label(999,6,"Level",1021);
584 cd_add_label(999,7,"Health",1024);
585 cd_add_label(999,8,"Magic Pts.",1032);
586 cd_add_label(999,9,"Armor",1023);
587 cd_add_label(999,10,"Skill",1018);
588 cd_add_label(999,11,"Morale",1023);
589 cd_add_label(999,12,"Speed",1019);
590 cd_add_label(999,13,"Att #1",1026);
591 cd_add_label(999,14,"Att #2",1023);
592 cd_add_label(999,15,"Att #3",1022);
593 cd_add_label(999,16,"Mage L.",1034);
594 cd_add_label(999,17,"Priest L.",1030);
595 cd_add_label(999,18,"Poison",1023);
596 cd_add_label(999,19,"Ability 1",1029);
597 cd_add_label(999,31,"Ability 2",1029);
598 cd_add_label(999,20,"Magic Resistant",45);
599 cd_add_label(999,21,"Immune To Magic",45);
600 cd_add_label(999,22,"Fire Resistant",45);
601 cd_add_label(999,23,"Immune To Fire",45);
602 cd_add_label(999,24,"Cold Resistant",45);
603 cd_add_label(999,25,"Immune To Cold",45);
604 cd_add_label(999,26,"Poison Resistant",45);
605 cd_add_label(999,27,"Immune To Poison",45);
606 put_monst_info();
607 while (dialog_not_toast)
608 ModalDialog(); cd_kill_dialog(999,0);
612 Boolean display_help_event_filter (short item_hit)
614 char get_text[256];
616 switch (item_hit) {
617 case 1: case 3:
618 dialog_not_toast = FALSE;
619 break;
621 case 4: case 5:
622 if (item_hit == 4)
623 cur_entry = (cur_entry == 3) ? num_entries + 2 : cur_entry - 1;
624 else cur_entry = (cur_entry == num_entries + 2) ? 3 : cur_entry + 1;
625 get_str (get_text, 25 + store_help_mode, cur_entry);
626 cd_set_item_text(997,7,(char *) get_text);
627 break;
630 return FALSE;
633 void display_help(short mode,short parent)
635 char get_text[256];
636 long get_val;
637 short item_hit;
639 store_help_mode = mode;
640 cur_entry = 3;
642 make_cursor_sword();
644 cd_create_dialog_parent_num(997,parent);
646 get_str (get_text, 25 + mode, 1);
647 csit( 997,6,(char *) get_text);
648 GetIndString (get_text, 25 + mode, 2);
649 StringToNum(get_text,&get_val);
650 num_entries = (short) get_val;
651 get_str (get_text, 25 + mode, cur_entry);
652 csit( 997,7,(char *) get_text);
654 while (dialog_not_toast)
655 ModalDialog(); cd_kill_dialog(997,0);
661 Boolean display_alchemy_event_filter (short item_hit)
663 switch (item_hit) {
664 case 1: case 3:
665 dialog_not_toast = FALSE;
666 break;
669 return FALSE;
672 void display_alchemy()
674 short i,item_hit;
675 char *alch_names[] = {"Weak Curing Potion (1)","Weak Healing Potion (1)","Weak Poison (1)",
676 "Weak Speed Potion (3)","Medium Poison (3)",
677 "Medium Heal Potion (4)","Strong Curing (5)","Medium Speed Potion (5)",
678 "Graymold Salve (7)","Weak Energy Potion (9)",
679 "Potion of Clarity (9)","Strong Poison (10)","Strong Heal Potion (12)","Killer Poison (12)",
680 "Resurrection Balm (9)","Medium Energy Ptn. (14)","Knowledge Brew (19)",
681 "Strong Strength (10)","Bliss (16)","Strong Power (20)"
684 make_cursor_sword();
686 cd_create_dialog_parent_num(996,1019);
689 for (i = 0; i < 20; i++) {
690 cd_add_label(996,i + 4,alch_names[i],1083);
691 if (party.alchemy[i] > 0)
692 cd_set_led(996,i + 4,1);
693 else cd_set_led(996,i + 4,0);
696 while (dialog_not_toast)
697 ModalDialog(); cd_kill_dialog(996,0);
698 dialog_not_toast = TRUE;
703 void display_traits_graphics()
705 short i,store;
706 char str[256];
708 for (i = 0; i < 3; i++) {
709 cd_set_led(1013,4 + i,(store_pc->race == i) ? 1 : 0);
711 for (i = 0; i < 10; i++) {
712 cd_set_led(1013,7 + i,(store_pc->traits[i] > 0) ? 1 : 0);
714 for (i = 0; i < 5; i++) {
715 cd_set_led(1013,36 + i,(store_pc->traits[10 + i] > 0) ? 1 : 0);
718 store = get_tnl(store_pc);
719 cdsin(1013,18,store);
722 void pick_race_abil_event_filter(short item_hit)
724 char abil_str[256];
725 pc_record_type *pc;
727 pc = store_pc;
728 switch (item_hit) {
729 case 3:
730 dialog_not_toast = FALSE;
731 break;
732 case 4: case 5: case 6:
733 if (store_trait_mode == 0)
734 pc->race = item_hit - 4;
735 display_traits_graphics();
736 get_str(abil_str,5,12 + item_hit);
737 csit(1013,19,(char *) abil_str);
738 break;
739 case 36: case 37: case 38: case 39: case 40:
740 if (store_trait_mode != 1)
741 pc->traits[item_hit - 36 + 10] = (pc->traits[item_hit - 36 + 10] == TRUE) ? FALSE : TRUE;
742 display_traits_graphics();
743 get_str(abil_str,5,item_hit - 36 + 11);
744 csit(1013,19,(char *) abil_str);
745 break;
746 default:
747 if (item_hit >= 100)
748 return;
749 if (store_trait_mode != 1)
750 pc->traits[item_hit - 7] = (pc->traits[item_hit - 7] == TRUE) ? FALSE : TRUE;
751 display_traits_graphics();
752 get_str(abil_str,5,item_hit - 6);
753 csit(1013,19,(char *) abil_str);
754 break;
759 void pick_race_abil(pc_record_type *pc,short mode,short parent_num)
760 //mode; // 0 - edit 1 - just display 2 - can't change race
762 char *start_str1 = "Click on button by name for description.";
763 char *start_str2 = "Click on advantage button to add/remove.";
764 short item_hit;
766 store_trait_mode = mode;
767 store_pc = pc;
768 make_cursor_sword();
770 cd_create_dialog_parent_num(1013,parent_num);
772 display_traits_graphics();
773 if (mode == 1)
774 csit(1013,19,start_str1);
775 else csit(1013,19,start_str2);
777 while (dialog_not_toast)
778 ModalDialog(); cd_kill_dialog(1013,0);
779 dialog_not_toast = TRUE;
782 void display_pc_info()
784 short i,store;
785 char str[256];
786 short pc;
787 char to_draw[60];
789 short weap1 = 24,weap2 = 24,hit_adj = 0, dam_adj = 0,skill_item;
791 pc = store_pc_num;
793 store = pc_carry_weight(pc);
794 i = amount_pc_can_carry(pc);
795 sprintf ((char *) to_draw, "%s is carrying %d stones out of %d.",adven[pc].name,store,i);
796 csit(1019,69,(char *) to_draw);
798 sprintf((char *) str,"%d out of %d.",
799 adven[pc].cur_health,adven[pc].max_health);
800 csit(1019,65,(char *) str);
801 sprintf((char *) str,"%d out of %d.",
802 adven[pc].cur_sp,adven[pc].max_sp);
803 csit(1019,67,(char *) str);
805 for (i = 0; i < 19; i++) {
806 cdsin(1019,18 + i * 2,adven[pc].skills[i]);
808 store = total_encumberance(pc);
809 cdsin(1019,62,store);
810 csit(1019,9,adven[pc].name);
811 cdsin(1019,11,adven[pc].level);
812 cdsin(1019,13,adven[pc].experience);
813 cdsin(1019,71,adven[pc].skill_pts);
814 store = adven[pc].level * get_tnl(&adven[pc]);
815 cdsin(1019,15,store);
816 csp(1019,7,800 + adven[pc].which_graphic);
818 // Fight bonuses
819 for (i = 0; i < 24; i++)
820 if (((adven[pc].items[i].variety == 1) || (adven[pc].items[i].variety == 2)) &&
821 (adven[pc].equip[i] == TRUE)) {
822 if (weap1 == 24)
823 weap1 = i;
824 else weap2 = i;
827 hit_adj = stat_adj(pc,1) * 5 - (total_encumberance(pc)) * 5
828 + (5 * minmax(-8,8,adven[pc].status[1]));
829 if ((adven[pc].traits[2] == FALSE) && (weap2 < 24))
830 hit_adj -= 25;
832 dam_adj = stat_adj(pc,0) + minmax(-8,8,adven[pc].status[1]);
833 if ((skill_item = text_pc_has_abil_equip(pc,101)) < 24) {
834 hit_adj += 5 * (adven[pc].items[skill_item].item_level + 1);
835 dam_adj += adven[pc].items[skill_item].item_level;
837 if ((skill_item = text_pc_has_abil_equip(pc,96)) < 24) {
838 dam_adj += 2;
839 hit_adj += 1;
841 if ((skill_item = text_pc_has_abil_equip(pc,97)) < 24) {
842 hit_adj += 5;
843 dam_adj += 3;
846 csit(1019,56,"No weapon.");
847 csit(1019,57,"");
848 csit(1019,59,"No weapon.");
849 csit(1019,60,"");
850 if (weap1 < 24) {
851 if (is_ident(adven[pc].items[weap1]) == FALSE)
852 csit(1019,56,"Not identified.");
853 else {
854 if (hit_adj + 5 * adven[pc].items[weap1].bonus < 0)
855 sprintf(to_draw,"Penalty to hit: %%%d",hit_adj + 5 * adven[pc].items[weap1].bonus);
856 else sprintf(to_draw,"Bonus to hit: +%%%d",hit_adj + 5 * adven[pc].items[weap1].bonus);
857 csit(1019,56,to_draw);
858 sprintf(to_draw,"Damage: (1-%d) + %d",adven[pc].items[weap1].item_level
859 ,dam_adj + adven[pc].items[weap1].bonus);
860 csit(1019,57,to_draw);
864 if (weap2 < 24) {
865 if (is_ident(adven[pc].items[weap2]) == FALSE)
866 csit(1019,59,"Not identified.");
867 else {
868 if (hit_adj + 5 * adven[pc].items[weap2].bonus < 0)
869 sprintf(to_draw,"Penalty to hit: %%%d",hit_adj + 5 * adven[pc].items[weap2].bonus);
870 else sprintf(to_draw,"Bonus to hit: +%%%d",hit_adj + 5 * adven[pc].items[weap2].bonus);
871 csit(1019,59,to_draw);
872 sprintf(to_draw,"Damage: (1-%d) + %d",adven[pc].items[weap2].item_level
873 ,dam_adj + adven[pc].items[weap2].bonus);
874 csit(1019,60,to_draw);
881 void give_pc_info_event_filter(short item_hit)
883 char abil_str[256];
884 short pc;
886 pc = store_pc_num;
887 switch (item_hit) {
888 case 1:
889 dialog_not_toast = FALSE;
890 break;
891 case 2:
893 store_pc_num = (store_pc_num == 0) ? 5 : store_pc_num - 1;
894 while (adven[store_pc_num].main_status != 1);
895 display_pc_info();
896 break;
897 case 3:
899 store_pc_num = (store_pc_num + 1) % 6;
900 while (adven[store_pc_num].main_status != 1);
901 display_pc_info();
902 break;
903 case 4:
904 display_pc(pc,0,1019);
905 break;
906 case 5:
907 display_pc(pc,1,1019);
908 break;
909 case 6:
910 pick_race_abil(&adven[pc],1,1019);
911 break;
912 case 68:
913 display_alchemy();
914 break;
919 void give_pc_info(short pc_num)
921 short item_hit ,i;
922 char str[256];
924 store_pc_num = pc_num;
925 make_cursor_sword();
927 cd_create_dialog_parent_num(1019,0);
929 for (i = 0; i < 19; i++) {
930 get_str(str,9,1 + i * 2);
931 csit(1019,17 + i * 2,(char *) str);
933 display_pc_info();
934 while (dialog_not_toast)
935 ModalDialog(); cd_kill_dialog(1019,0);
938 void adventure_notes_event_filter (short item_hit)
940 short i;
941 char place_str[256];
943 switch (item_hit) {
944 case 1:
945 dialog_not_toast = FALSE;
946 break;
948 case 7: case 8:
949 if (item_hit == 7) {
950 if (store_page_on == 0)
951 store_page_on = (store_num_i - 1) / 3;
952 else store_page_on--;
954 else {
955 if (store_page_on == (store_num_i - 1) / 3)
956 store_page_on = 0;
957 else store_page_on++;
960 break;
961 case 10: case 9: case 11:
962 party.special_notes_str[(store_page_on * 3) + item_hit - 9][0] = -1;
963 break;
965 for (i = 0; i < 3; i++) {
966 if (party.special_notes_str[i][0] > 0) {
967 switch (party.special_notes_str[i][0] / 1000) {
968 case 0: if (party.special_notes_str[i][0] % 1000 < 160)
969 strcpy((char *) place_str,data_store5->scen_strs[party.special_notes_str[i][0] % 1000]);
970 else strcpy((char *) place_str,scen_strs2[(party.special_notes_str[i][0] % 1000) - 160]);
971 break;
972 case 1:
973 load_outdoors(party.special_notes_str[i][1] % scenario.out_width,
974 party.special_notes_str[i][1] / scenario.out_width,
975 0,0,1,party.special_notes_str[i][0] % 1000,(char *)place_str);
976 break;
977 case 2: load_town(party.special_notes_str[i][1],2,party.special_notes_str[i][0],(char *)place_str); break;
980 get_str(place_str,party.special_notes_str[i][0],party.special_notes_str[i][1]);
981 csit(961,3 + i,(char *) place_str);
982 cd_activate_item(961,9 + i,1);
984 else cd_activate_item(961,9 + i,0);
986 for (i = store_page_on * 3; i < (store_page_on * 3) + 3; i++) {
987 if (party.special_notes_str[i][0] > 0) {
988 switch (party.special_notes_str[i][0] / 1000) {
989 case 0: if (party.special_notes_str[i][0] % 1000 < 160)
990 strcpy((char *) place_str,data_store5->scen_strs[party.special_notes_str[i][0] % 1000]);
991 else strcpy((char *) place_str,scen_strs2[(party.special_notes_str[i][0] % 1000) - 160]);
992 break;
993 case 1:
994 load_outdoors(party.special_notes_str[i][1] % scenario.out_width,
995 party.special_notes_str[i][1] / scenario.out_width,
996 0,0,1,party.special_notes_str[i][0] % 1000,(char *)place_str);
997 break;
998 case 2: load_town(party.special_notes_str[i][1],2,party.special_notes_str[i][0] % 1000,(char *)place_str); break;
1002 csit(961,3 + (i - store_page_on * 3),(char *) place_str);
1003 cd_activate_item(961,9 + (i - store_page_on * 3),1);
1005 else {
1006 csit(961,3 + (i - store_page_on * 3),"");
1007 cd_activate_item(961,9 + (i - store_page_on * 3),0);
1012 void adventure_notes()
1014 long val_for_text;
1016 short i,item_hit;
1017 char place_str[256];
1019 store_num_i = 0;
1020 for (i = 0; i < 140; i++)
1021 if (party.special_notes_str[i][0] > 0)
1022 store_num_i = i + 1;
1023 store_page_on = 0;
1024 if (store_num_i == 0) {
1025 ASB("Nothing in your journal.");
1026 print_buf();
1027 return;
1030 make_cursor_sword();
1032 cd_create_dialog_parent_num(961,0);
1034 for (i = 0; i < 3; i++) {
1035 if (party.special_notes_str[i][0] > 0) {
1036 switch (party.special_notes_str[i][0] / 1000) {
1037 case 0:
1038 if (party.special_notes_str[i][0] % 1000 < 160)
1039 strcpy((char *) place_str,data_store5->scen_strs[party.special_notes_str[i][0] % 1000]);
1040 else strcpy((char *) place_str,scen_strs2[(party.special_notes_str[i][0] % 1000) - 160]);
1041 break;
1042 case 1:
1043 load_outdoors(party.special_notes_str[i][1] % scenario.out_width,
1044 party.special_notes_str[i][1] / scenario.out_width,
1045 0,0,1,party.special_notes_str[i][0] % 1000,(char *)place_str);
1046 break;
1047 case 2: load_town(party.special_notes_str[i][1],2,party.special_notes_str[i][0] % 1000,(char *)place_str); break;
1050 csit(961,3 + i,(char *) place_str);
1051 cd_activate_item(961,9 + i,1);
1053 else cd_activate_item(961,9 + i,0);
1055 if (store_num_i <= 3) {
1056 cd_activate_item(961,7,0);
1057 cd_activate_item(961,8,0);
1059 while (dialog_not_toast)
1060 ModalDialog();
1061 cd_kill_dialog(961,0);
1065 void put_talk()
1067 short personality;
1068 char place_str[256];
1070 csit(960,3,"");
1071 csit(960,5,"");
1072 csit(960,7,"");
1073 csit(960,9,"");
1074 if ((personality = party.talk_save[store_page_on].personality) >= 0) {
1075 if (personality / 10 != cur_town_talk_loaded)
1076 load_town(personality / 10,1,0,NULL);
1078 load_town(party.talk_save[store_page_on].town_num,2,0,(char *) place_str);
1079 csit(960,9,(char *) place_str);
1081 //get_str(place_str,120 + ((personality - 1) / 10),((personality - 1) % 10) + 1);
1082 csit(960,7,data_store3->talk_strs[personality % 10]);
1084 if (party.talk_save[store_page_on].str1 >= 1000) {
1085 if (party.talk_save[store_page_on].str1 >= 3000) {
1086 if (party.talk_save[store_page_on].str1 - 3000 < 160)
1087 csit(960,3,data_store5->scen_strs[party.talk_save[store_page_on].str1 - 3000 ]);
1088 else csit(960,3,scen_strs2[party.talk_save[store_page_on].str1 - 3000 - 160]);
1091 else {
1092 load_town(party.talk_save[store_page_on].town_num,2,
1093 party.talk_save[store_page_on].str1 - 2000 ,(char *) place_str);
1094 csit(960,3,(char *) place_str);
1097 else if ((party.talk_save[store_page_on].str1 > 0) &&
1098 (party.talk_save[store_page_on].str1 < 170))
1099 csit(960,3,data_store3->talk_strs[party.talk_save[store_page_on].str1]);
1101 if (party.talk_save[store_page_on].str2 >= 1000) {
1102 if (party.talk_save[store_page_on].str2 >= 3000) {
1103 if (party.talk_save[store_page_on].str2 - 3000 < 160)
1104 csit(960,5,data_store5->scen_strs[party.talk_save[store_page_on].str2 - 3000 ]);
1105 else csit(960,5,scen_strs2[party.talk_save[store_page_on].str2 - 3000 - 160]);
1108 else {
1109 load_town(party.talk_save[store_page_on].town_num,2,
1110 party.talk_save[store_page_on].str2 - 2000 + 20,(char *) place_str);
1111 csit(960,5,(char *) place_str);
1114 else if ((party.talk_save[store_page_on].str2 > 0) &&
1115 (party.talk_save[store_page_on].str2 < 170))
1116 csit(960,5,data_store3->talk_strs[party.talk_save[store_page_on].str2]);
1120 void talk_notes_event_filter (short item_hit)
1122 short i;
1123 char place_str[256];
1124 switch (item_hit) {
1125 case 1:
1126 dialog_not_toast = FALSE;
1127 break;
1129 case 10: case 11:
1130 if (item_hit == 10) {
1131 if (store_page_on == 0)
1132 store_page_on = store_num_i - 1;
1133 else store_page_on--;
1135 else {
1136 if (store_page_on == store_num_i - 1)
1137 store_page_on = 0;
1138 else store_page_on++;
1141 break;
1142 case 12:
1143 party.talk_save[store_page_on].personality = -1;
1144 break;
1146 put_talk();
1149 void talk_notes()
1151 long val_for_text;
1153 short i,item_hit;
1154 char place_str[256];
1156 store_num_i = 0;
1157 for (i = 0; i < 120; i++)
1158 if (party.talk_save[i].personality != -1)
1159 store_num_i = i + 1;
1160 store_page_on = 0;
1161 if (store_num_i == 0) {
1162 ASB("Nothing in your talk journal.");
1163 print_buf();
1164 return;
1167 make_cursor_sword();
1169 cd_create_dialog_parent_num(960,0);
1171 put_talk();
1172 if (store_num_i == 1) {
1173 cd_activate_item(960,10,0);
1174 cd_activate_item(960,11,0);
1177 while (dialog_not_toast)
1178 ModalDialog();
1179 cd_kill_dialog(960,0);
1185 // Only call these when main window is in foreground!
1186 void display_enc_string(short val1,short val2,short sound)
1189 void display_2_enc_string(short val1,short val2,short val3,short val4,short sound)
1193 // Call call this anywhere, but don't forget parent!!!
1194 void give_help(short help1,short help2,short parent_num)
1196 Boolean help_forced = FALSE;
1197 char str1[256],str2[256];
1199 if (help1 >= 200) {
1200 help_forced = TRUE;
1201 help1 -= 200;
1203 if ((PSD[306][4] > 0) && (help_forced == FALSE))
1204 return;
1205 if (party.help_received[help1] > 0)
1206 return;
1207 //if (help1 >= 20)
1208 party.help_received[help1] = 1;
1209 get_str(str1,10,help1);
1210 if (help2 > 0)
1211 get_str(str2,10,help2);
1212 if (help2 == 0)
1213 display_strings((char *)str1, "",-1,-1,-1,-1,"Instant Help",57,724, parent_num);
1214 else display_strings((char *)str1,(char *)str2,-1,-1,-1,-1,"Instant Help",57,724, parent_num);
1218 void put_spec_item_info (short which_i)
1220 char item_name[256];
1222 display_strings(data_store5->scen_strs[60 + 1 + which_i * 2],"",
1223 -1,-1,-1,-1,
1224 data_store5->scen_strs[60 + which_i * 2],57,1600 + scenario.intro_pic,0);
1227 void display_strings_event_filter (short item_hit)
1229 short i;
1230 Boolean had1 = FALSE, had2 = FALSE;
1232 switch (item_hit) {
1233 case 1:
1234 dialog_not_toast = FALSE;
1235 break;
1236 case 2:
1237 play_sound(0);
1238 for (i = 0; i < 140; i++)
1239 if ((store_str_label_1 == party.special_notes_str[i][0]) &&
1240 (store_str_label_1b == party.special_notes_str[i][1]))
1241 had1 = TRUE;
1242 if (had1 == FALSE) {
1243 //give_help(58,0,store_which_string_dlog);
1244 for (i = 0; i < 140; i++)
1245 if (party.special_notes_str[i][0] <= 0) {
1246 party.special_notes_str[i][0] = store_str_label_1;
1247 party.special_notes_str[i][1] = store_str_label_1b;
1248 //party.special_notes_str[i][1] = store_str1b;
1249 ASB("Info added to Encounter Notes.");
1250 i = 140;
1254 for (i = 0; i < 140; i++)
1255 if ((store_str_label_2 == party.special_notes_str[i][0]) &&
1256 (store_str_label_2b == party.special_notes_str[i][1]))
1257 had2 = TRUE;
1258 if (had2 == FALSE) {
1259 for (i = 0; i < 140; i++)
1260 if (party.special_notes_str[i][0] <= 0) {
1261 party.special_notes_str[i][0] = store_str_label_2;
1262 party.special_notes_str[i][1] = store_str_label_2b;
1263 //party.special_notes_str[i][1] = store_str2b;
1264 i = 140;
1268 break;
1272 // str_label_1 & str_label_2 uysed for saving button for journal
1273 // 1000 + x scen 2000 + x out 3000 + x town
1274 void display_strings(char *text1, char *text2,short str_label_1,short str_label_2,short str_label_1b,
1275 short str_label_2b,
1276 char *title,short sound_num,short graphic_num,short parent_num)
1279 short item_hit;
1280 char sign_text[256];
1281 location view_loc;
1282 Boolean sound_done = FALSE;
1284 make_cursor_sword();
1286 store_str_label_1 = str_label_1;
1287 store_str_label_2 = str_label_2;
1288 store_str_label_1b = str_label_1b;
1289 store_str_label_2b = str_label_2b;
1291 store_which_string_dlog = 970;
1292 if (strlen(title) > 0)
1293 store_which_string_dlog += 2;
1294 if ((text2 != NULL) && (text2[0] != 0))
1295 store_which_string_dlog++;
1296 cd_create_dialog_parent_num(store_which_string_dlog,parent_num);
1298 csp(store_which_string_dlog,store_which_string_dlog,graphic_num);
1300 csit(store_which_string_dlog,4,(char *) text1);
1301 if (text2 != NULL) {
1302 csit(store_which_string_dlog,5,(char *) text2);
1304 if (strlen(title) > 0)
1305 csit(store_which_string_dlog,6,title);
1306 csp(store_which_string_dlog,3,graphic_num);
1307 if (sound_num >= 0)
1308 play_sound(sound_num);
1310 if ((str_label_1 < 0) && (str_label_2 < 0))
1311 cd_activate_item(store_which_string_dlog,2,0);
1312 while (dialog_not_toast)
1313 ModalDialog(); //cd_kill_dialog(store_which_string_dlog,0);
1314 final_process_dialog(store_which_string_dlog);
1317 void give_error(char *text1, char *text2,short parent_num)
1319 display_strings(text1,text2,-1,-1,-1,-1,"Error!",57,716,parent_num);
1322 void display_strings_with_nums(short a1,short a2, short b1, short b2,
1323 char *title,short sound_num,short graphic_num,short parent_num)
1325 char str1[256] = "", str2[256] = "";
1327 if ((a1 > 0) && (a2 > 0))
1328 get_str(str1,a1,a2);
1329 if ((b1 > 0) && (b2 > 0))
1330 get_str(str2,b1,b2);
1331 display_strings((char *) str1,(char *) str2,-1,-1,-1,-1,
1332 title, sound_num, graphic_num, parent_num);