void edit_party_event_filter (short item_hit) { short which_pc; switch (item_hit) { case 1: dialog_not_toast = false; break; case 41: party.help_received[22] = 0; give_help(222,23,989); return; case 5: case 10: case 15: case 20: case 25: case 30: which_pc = (item_hit - 5) / 5; if (adven[which_pc].main_status != MAIN_STATUS_ABSENT) pick_pc_name(which_pc,989); put_party_stats(); break; case 7: case 12: case 17: case 22: case 27: case 32: which_pc = (item_hit - 7) / 5; pick_race_abil(&adven[which_pc],0,989); put_party_stats(); break; case 8: case 13: case 18: case 23: case 28: case 33: which_pc = (item_hit - 8) / 5; spend_xp(which_pc,0,989); put_party_stats(); break; case 35: case 36: case 37: case 38: case 39: case 40: which_pc = item_hit - 35; if (adven[which_pc].main_status <= MAIN_STATUS_ABSENT) break; if (adven[which_pc].main_status != MAIN_STATUS_ABSENT) pick_pc_graphic(which_pc,1,989); put_party_stats(); break; case 6: case 11: case 16: case 21: case 26: case 31: which_pc = (item_hit - 6) / 5; if (adven[which_pc].main_status != MAIN_STATUS_ABSENT) { if (FCD(1053,989) == 2) adven[which_pc].main_status = MAIN_STATUS_ABSENT; put_party_stats(); } else { give_help(56,0,989); create_pc(which_pc,989); put_party_stats(); cd_initial_draw(989); // extra redraw, just in case } break; // case 7: case 12: case 17: case 22: case 27: case 32: } }
bool handle_action(sf::Event event) { short i; location the_point; bool to_return = false; the_point = {event.mouseButton.x, event.mouseButton.y}; if(file_in_mem.empty()) return false; for(i = 0; i < 6; i++) if((the_point.in(pc_area_buttons[i][0])) && (univ.party[i].main_status != eMainStatus::ABSENT)) { do_button_action(0,i); current_active_pc = i; redraw_screen(); } for(i = 0; i < 5; i++) if((the_point.in(edit_rect[i])) && (univ.party[current_active_pc].main_status != eMainStatus::ABSENT)) { do_button_action(0,i + 10); switch(i) { case 0: display_pc(current_active_pc,10,nullptr); break; case 1: display_pc(current_active_pc,11,nullptr); break; case 2: pick_race_abil(&univ.party[current_active_pc],0); break; case 3: spend_xp(current_active_pc,2,nullptr); break; case 4: edit_xp(&univ.party[current_active_pc]); break; } } for(i = 0; i < 24; i++) if((the_point.in(item_string_rects[i][1])) && // drop item univ.party[current_active_pc].items[i].variety != eItemType::NO_ITEM) { flash_rect(item_string_rects[i][1]); univ.party[current_active_pc].take_item(i); } for(i = 0; i < 24; i++) if((the_point.in(item_string_rects[i][2])) && // identify item univ.party[current_active_pc].items[i].variety != eItemType::NO_ITEM) { flash_rect(item_string_rects[i][2]); univ.party[current_active_pc].items[i].ident = true; } return to_return; }
void handle_talk_event(POINT p) { short i,j,force_special = 0,get_pc,s1 = -1,s2 = -1,s3 = -1; char asked[4]; char place_string1[256] = ""; char place_string2[256] = ""; short a,b,c,d,ttype,which_talk_entry = -1; p.x -= 5; p.y -= 5; if (PtInRect(&talk_help_rect,p)) { if (play_sounds == true) play_sound(37); party.help_received[5] = 0; give_help(205,6,0); return; } for (i = 0; i < 9; i++) if ((PtInRect(&preset_words[i].word_rect,p)) && ((talk_end_forced == false) || (i == 6) || (i == 5))) { click_talk_rect((char *) old_str1,(char *) old_str2,preset_words[i].word_rect); switch (i) { case 0: case 1: case 2: case 7: case 8: force_special = i + 1; break; case 3: case 4: force_special = i + 1; break; case 5: // save if (strnum1 <= 0) { MessageBeep(MB_OK); return; } for (j = 0; j < 120; j++) if ((party.talk_save[j].personality == store_personality) && (party.talk_save[j].str1 == strnum1) && (party.talk_save[j].str2 == strnum2)) { ASB("This is already saved."); print_buf(); return; } for (j = 0; j < 120; j++) if (party.talk_save[j].personality <= 0) { give_help(57,0,0); play_sound(0); party.talk_save[j].personality = store_personality; party.talk_save[j].town_num = (unsigned char) c_town.town_num; party.talk_save[j].str1 = strnum1; party.talk_save[j].str2 = strnum2; ASB("Noted in journal."); j = 200; } if (j < 200) { MessageBeep(MB_OK); ASB("No more room in talking journal."); } print_buf(); return; break; case 6: // quit end_talk_mode(); if(talk_end_forced == 10){ // party is in inn talk_end_forced = true; // safety set for(j=0; j < 700; j++){ party.age++; // Specials countdowns if ((party.age % 500 == 0) && (get_ran(1,0,5) == 3) && (adven.hasAbil(ITEM_DISEASE_PARTY) == true)) { j = 900; adven.disease(2); } // Plants and magic shops if (party.age % 4000 == 0) refresh_store_items(); timed_special_happened = special_increase_age(0);//don't delay the trigger of the special, if there's a special if(timed_special_happened && PSD[SDF_COMPATIBILITY_SPECIALS_INTERRUPT_REST] == 1){ j = 900; add_string_to_buf(" Rest interrupted."); print_buf(); } } } return; break; default: for (j = 0; j < 4; j++) asked[j] = preset_words[i].word[j]; break; } i = 100; } if (i < 100) { for (i = 0; i < 50; i++) if ((PtInRect(&store_words[i].word_rect,p)) && (talk_end_forced == false)) { click_talk_rect((char *) old_str1,(char *) old_str2,store_words[i].word_rect); for (j = 0; j < 4; j++) asked[j] = store_words[i].word[j]; i = 100; } } if(strcmp(talk_edit_string,"") != 0){ for(j = 0; j < 4; j++) asked[j] = talk_edit_string[j]; talk_edit_string[0] = '\0'; i = 100; } if (i == 50) // no event return; if (force_special == 9) { get_text_response(1017,place_string1,0); asked[0] = place_string1[0]; asked[1] = place_string1[1]; asked[2] = place_string1[2]; asked[3] = place_string1[3]; } if ((asked[0] == 'n') && (asked[1] == 'a') &&(asked[2] == 'm') &&(asked[3] == 'e')) { force_special = 2; } if ((asked[0] == 'l') && (asked[1] == 'o') &&(asked[2] == 'o') &&(asked[3] == 'k')) { force_special = 1; } if (((asked[0] == 'j') && (asked[1] == 'o') &&(asked[2] == 'b')) || ((asked[0] == 'w') && (asked[1] == 'o') &&(asked[2] == 'r')&&(asked[3] == 'k')) ) { force_special = 3; } if((asked[0] == 'b') && (asked[1] == 'u') && (asked[2] == 'y')) force_special = 4; if((asked[0] == 'b') && (asked[1] == 'y') && (asked[2] == 'e')){ end_talk_mode(); return; } if (force_special > 0) { switch (force_special) { case 1: case 2: case 3: GetIndString(place_string1,120 + ((store_personality - 1) / 10), ((store_personality - 1) % 10) * 3 + 10 + force_special); sprintf((char *) place_string1,"%s",data_store3->talk_strs[store_personality % 10 + 10 * force_special]); oldstrnum1 = strnum1; oldstrnum2 = strnum2; strnum1 = store_personality % 10 + 10 * force_special; strnum2 = 0; strcpy((char *) one_back1,(char *) old_str1); strcpy((char *) one_back2,(char *) old_str2); strcpy((char *) old_str1,(char *) place_string1); strcpy((char *) old_str2,(char *) place_string2); place_talk_str((char *) place_string1,(char *) place_string2,0,dummy_rect); return; break; case 4: // buy button asked[0] = 'p';asked[1] = 'u';asked[2] = 'r';asked[3] = 'c'; if (scan_for_response(asked) >= 0) break; asked[0] = 's';asked[1] = 'a';asked[2] = 'l';asked[3] = 'e'; if (scan_for_response(asked) >= 0) break; asked[0] = 'h';asked[1] = 'e';asked[2] = 'a';asked[3] = 'l'; if (scan_for_response(asked) >= 0) break; asked[0] = 'i';asked[1] = 'd';asked[2] = 'e';asked[3] = 'n'; if (scan_for_response(asked) >= 0) break; asked[0] = 't';asked[1] = 'r';asked[2] = 'a';asked[3] = 'i'; if (scan_for_response(asked) >= 0) break; break; case 5: // sell button asked[0] = 's';asked[1] = 'e';asked[2] = 'l';asked[3] = 'l'; if (scan_for_response(asked) >= 0) break; break; case 8: // back 1 strnum1 = oldstrnum1; strnum2 = oldstrnum2; strcpy((char *) place_string1,(char *) one_back1); strcpy((char *) place_string2,(char *) one_back2); strcpy((char *) one_back1,(char *) old_str1); strcpy((char *) one_back2,(char *) old_str2); strcpy((char *) old_str1,(char *) place_string1); strcpy((char *) old_str2,(char *) place_string2); place_talk_str((char *) place_string1,(char *) place_string2,0,dummy_rect); return; break; } } which_talk_entry = scan_for_response(asked); if ((which_talk_entry < 0) || (which_talk_entry > 59)) { strcpy((char *) one_back1,(char *) old_str1); strcpy((char *) one_back2,(char *) old_str2); sprintf((char *) old_str2,""); sprintf((char *) old_str1,"%s",data_store3->talk_strs[store_personality % 10 + 160]); if (strlen((char *) old_str1) < 2) sprintf((char *) old_str1,"You get no response."); place_talk_str((char *) old_str1,(char *) old_str2,0,dummy_rect); strnum1 = -1; return; } ttype = talking.talk_nodes[which_talk_entry].type; a = talking.talk_nodes[which_talk_entry].extras[0]; b = talking.talk_nodes[which_talk_entry].extras[1]; c = talking.talk_nodes[which_talk_entry].extras[2]; d = talking.talk_nodes[which_talk_entry].extras[3]; sprintf(place_string1,"%s",data_store3->talk_strs[40 + which_talk_entry * 2]); sprintf(place_string2,"%s",data_store3->talk_strs[40 + which_talk_entry * 2 + 1]); oldstrnum1 = strnum1; oldstrnum2 = strnum2; strnum1 = 40 + which_talk_entry * 2; strnum2 = 40 + which_talk_entry * 2 + 1; switch(ttype) { case TALK_REGULAR: break; case TALK_DEP_ON_SDF: if (PSD[a][b] > c) { strnum1 = strnum2; strcpy(place_string1, place_string2); } sprintf(place_string2,""); strnum2 = 0; break; case TALK_SET_SDF: PSD[a][b] = 1; break; case TALK_INN: if (party.gold < a) { strnum1 = strnum2; strcpy(place_string1, place_string2); } else { talk_end_forced = true; party.gold -= a; put_pc_screen(); if(PSD[SDF_COMPATIBILITY_CHECK_TIMERS_WHILE_RESTING] == 1){ talk_end_forced = 10; adven.heal(30 * b); adven.restoreSP(25 * b); c_town.p_loc.x = c; c_town.p_loc.y = d; center = c_town.p_loc; } else{ adven.heal(30 * b); adven.restoreSP(25 * b); party.age += 700; c_town.p_loc.x = c; c_town.p_loc.y = d; center = c_town.p_loc; } } strnum2 = 0; sprintf(place_string2,""); break; case TALK_DEP_ON_TIME: if (day_reached((unsigned char) a,0) == true) { strnum1 = strnum2; strcpy(place_string1, place_string2); } sprintf(place_string2,""); strnum2 = 0; break; case TALK_DEP_ON_TIME_AND_EVENT: if (day_reached((unsigned char) a,(unsigned char) b) == true) { strnum1 = strnum2; strcpy(place_string1, place_string2); } sprintf(place_string2,""); strnum2 = 0; break; case TALK_DEP_ON_TOWN: if (c_town.town_num != a) { strnum1 = strnum2; strcpy(place_string1, place_string2); } sprintf(place_string2,""); strnum2 = 0; break; case TALK_BUY_ITEMS: c = minmax(1,30,(int)c); start_shop_mode(SHOP_MISC_SHOP,b, b + c - 1,a, place_string1); strnum1 = -1; return; case TALK_TRAINING: if ((get_pc = char_select_pc(1,0,"Train who?")) < 6) { strnum1 = -1; spend_xp(get_pc,1, 0); } sprintf(place_string1, "You conclude your training."); put_pc_screen(); return; case TALK_BUY_MAGE: case TALK_BUY_PRIEST: case TALK_BUY_ALCHEMY: c = minmax(1,30,(int)c); start_shop_mode(ttype + 1,b, b + c - 1,a, place_string1); strnum1 = -1; return; case TALK_BUY_HEALING: //healer start_shop_mode(SHOP_HEALER,0,0,a, place_string1); strnum1 = -1; return; break; case TALK_SELL_WEAPONS: // sell weap strnum1 = -1; stat_screen_mode = 3; put_item_screen(stat_window,1); give_help(42,43,0); break; case TALK_SELL_ARMOR: // sell armor strnum1 = -1; stat_screen_mode = 4; put_item_screen(stat_window,1); give_help(42,43,0); break; case TALK_SELL_ITEMS: // sell misc strnum1 = -1; stat_screen_mode = 5; put_item_screen(stat_window,1); give_help(42,43,0); break; case TALK_IDENTIFY: case TALK_ENCHANT: // ident, enchant strnum1 = -1; stat_screen_mode = (ttype == 16) ? 2 : 6; shop_identify_cost = a; put_item_screen(stat_window,1); give_help(ttype - 16 + 44,0,0); break; case TALK_BUY_INFO: if (party.gold < a) { strnum1 = strnum2; strcpy(place_string1, place_string2); } else { party.gold -= a; put_pc_screen(); } sprintf(place_string2,""); strnum2 = 0; break; case TALK_BUY_SDF: if ((sd_legit(b,c) == true) && (PSD[b][c] == d)) { sprintf(place_string1, "You've already learned that."); strnum1 = -1; } else if (party.gold < a) { strnum1 = strnum2; strcpy(place_string1, place_string2); } else { party.gold -= a; put_pc_screen(); if (sd_legit(b,c) == true) PSD[b][c] = d; else give_error("Invalid Stuff Done flag called in conversation.","",0); } strnum2 = 0; sprintf(place_string2,""); break; case TALK_BUY_SHIP: if (party.gold < a) { strnum1 = strnum2; strnum2 = 0; strcpy(place_string1, place_string2); sprintf(place_string2,""); break; } else { for (i = b; i <= b + c; i++) if ((i >= 0) && (i < 30) && (party.boats[i].property == true)) { party.gold -= a; put_pc_screen(); party.boats[i].property = false; sprintf(place_string2,""); strnum2 = 0; i = 1000; } if (i >= 1000) break; } sprintf(place_string1, "There are no boats left."); sprintf(place_string2,""); strnum1 = -1; strnum2 = -1; break; case TALK_BUY_HORSE: if (party.gold < a) { strnum1 = strnum2; strnum2 = 0; strcpy(place_string1, place_string2); sprintf(place_string2,""); break; } else { for (i = b; i <= b + c; i++) if ((i >= 0) && (i < 30) && (party.horses[i].property == true)) { party.gold -= a; put_pc_screen(); party.horses[i].property = false; sprintf(place_string2,""); strnum2 = 0; i = 1000; } if (i >= 1000) break; } sprintf(place_string1, "There are no horses left."); sprintf(place_string2,""); strnum1 = -1; strnum2 = -1; break; case TALK_BUY_SPEC_ITEM: if (party.spec_items[a] > 0) { sprintf(place_string1, "You already have it."); strnum1 = -1; } else if (party.gold < b) { strcpy(place_string1, place_string2); strnum1 = strnum2; } else { party.gold -= b; put_pc_screen(); party.spec_items[a] = 1; } strnum2 = 0; sprintf(place_string2,""); break; case TALK_BUY_JUNK: start_shop_mode(SHOP_MAGIC_SHOP_1 + b,0, 9,a, place_string1); strnum1 = -1; return; case TALK_BUY_TOWN_LOC: if (party.can_find_town[b] > 0) { } else if (party.gold < a) { strnum1 = strnum2; strcpy(place_string1, place_string2); } else { party.gold -= a; put_pc_screen(); party.can_find_town[b] = 1; } strnum2 = 0; sprintf(place_string2,""); break; case TALK_END_FORCE: talk_end_forced = true; break; case TALK_END_FIGHT: c_town.monst.dudes[store_m_num].attitude = 1; c_town.monst.dudes[store_m_num].mobile = 1; talk_end_forced = true; break; case TALK_END_ALARM: set_town_status(0); talk_end_forced = true; break; case TALK_END_DIE: c_town.monst.dudes[store_m_num].active = 0; // Special killing effects if (sd_legit(c_town.monst.dudes[store_m_num].monst_start.spec1,c_town.monst.dudes[store_m_num].monst_start.spec2) == true) party.stuff_done[c_town.monst.dudes[store_m_num].monst_start.spec1][c_town.monst.dudes[store_m_num].monst_start.spec2] = 1; talk_end_forced = true; break; case TALK_CALL_TOWN_SPEC: // town special run_special(SPEC_TALK,2,a,c_town.p_loc,&s1,&s2,&s3); // check s1 & s2 to see if we got diff str, and, if so, munch old strs if ((s1 >= 0) || (s2 >= 0)) { strnum1 = -1; strnum2 = -1; sprintf(place_string1,""); sprintf(place_string2,""); } get_strs(place_string1, place_string2,2,s1,s2); if (s1 >= 0) strnum1 = 2000 + s1; if (s2 >= 0) strnum2 = 2000 + s2; put_pc_screen(); put_item_screen(stat_window,0); break; case TALK_CALL_SCEN_SPEC: // scen special run_special(SPEC_TALK,0,a,c_town.p_loc,&s1,&s2,&s3); // check s1 & s2 to see if we got diff str, and, if so, munch old strs if ((s1 >= 0) || (s2 >= 0)) { strnum1 = -1; strnum2 = -1; sprintf(place_string1,""); sprintf(place_string2,""); } get_strs(place_string1, place_string2,0,s1,s2); if (s1 >= 0) strnum1 = 3000 + s1; if (s2 >= 0) strnum2 = 3000 + s2; put_pc_screen(); put_item_screen(stat_window,0); break; } strcpy(one_back1, old_str1); strcpy(one_back2, old_str2); strcpy(old_str1, place_string1); strcpy(old_str2, place_string2); place_talk_str(old_str1, old_str2,0,dummy_rect); }
//extern Rect pc_area_buttons[6][6] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later //extern Rect item_string_rects[24][4]; // 0 - name 1 - drop 2 - id 3 - bool handle_action(EventRecord event,short mode) //short mode; // ignore, { short i; Point the_point; short choice = 4; bool to_return = false; the_point = event.where; GlobalToLocal(&the_point); if (file_in_mem == false) return false; for (i = 0; i < 6; i++) if ((PtInRect(the_point,&pc_area_buttons[i][0]) == true) && (univ.party[i].main_status > 0)) { do_button_action(0,i); current_active_pc = i; display_party(6,1); draw_items(1); } for (i = 0; i < 5; i++) if ((PtInRect(the_point,&edit_rect[i][0]) == true) && (univ.party[current_active_pc].main_status > 0)) { do_button_action(0,i + 10); if (save_blocked == false) if ((choice = FCD(904,0)) == 1) return to_return; else save_blocked = true; switch(i) { case 0: display_pc(current_active_pc,0,0); break; case 1: display_pc(current_active_pc,1,0); break; case 2: pick_race_abil(&univ.party[current_active_pc],0,0); break; case 3: spend_xp(current_active_pc,1,0); break; case 4: edit_xp(&univ.party[current_active_pc]); break; } } for (i = 0; i < 24; i++) if ((PtInRect(the_point,&item_string_rects[i][1]) == true) && // drop item (univ.party[current_active_pc].items[i].variety > 0)) { // variety = 0 no item in slot/ non 0 item exists flash_rect(item_string_rects[i][1]); take_item(current_active_pc,i); draw_items(1); } for (i = 0; i < 24; i++) if ((PtInRect(the_point,&item_string_rects[i][2]) == true) && // identify item (univ.party[current_active_pc].items[i].variety > 0)) { flash_rect(item_string_rects[i][2]); univ.party[current_active_pc].items[i].ident = true; draw_items(1); } return to_return; }