void pc_record_type::dumbfound(short how_much) { short r1; if (!isAlive()) return; r1 = get_ran(1,0,90); if (hasAbilEquip(ITEM_WILL) < 24) { add_string_to_buf(" Ring of Will glows."); r1 -= 10; } if (r1 < level) how_much -= 2; if (how_much <= 0) { sprintf (c_line, " %s saved.", name); add_string_to_buf(c_line); return; } status[STATUS_DUMB] = min(status[STATUS_DUMB] + how_much, 8); sprintf (c_line, " %s dumbfounded.", name); add_string_to_buf(c_line); one_sound(67); put_pc_screen(); adjust_spell_menus(); give_help(28,0,0); }
void pc_record_type::disease(short how_much) { short r1, tlevel; if (!isAlive()) return; r1 = get_ran(1,0,100); if (r1 < level * 2) how_much -= 2; if (how_much <= 0) { sprintf (c_line, " %s saved.", name); add_string_to_buf(c_line); return; } if ((tlevel = getProtLevel(ITEM_PROTECT_FROM_DISEASE)) > 0) how_much -= tlevel / 2; if ((traits[TRAIT_FRAIL] == true) && (how_much > 1)) how_much++; if ((traits[TRAIT_FRAIL] == true) && (how_much == 1) && (get_ran(1,0,1) == 0)) how_much++; status[STATUS_DISEASE] = min(status[STATUS_DISEASE] + how_much,8); sprintf (c_line, " %s diseased.", name); add_string_to_buf(c_line); one_sound(66); put_pc_screen(); give_help(29,0,0); }
void end_talk_mode() { DeleteObject(talk_gworld); talk_gworld = NULL; if((PSD [SDF_ASK_ABOUT_TEXT_BOX] == 1) && (talk_edit_box != NULL)){ DestroyWindow(talk_edit_box); talk_edit_box = NULL; } overall_mode = store_pre_talk_mode; create_clip_region(); if (overall_mode == MODE_TALK_TOWN) overall_mode = MODE_TOWN; if (overall_mode == MODE_TOWN) { center = c_town.p_loc; update_explored(center); } stat_screen_mode = 0; put_item_screen(stat_window,0); put_pc_screen(); redraw_screen(0); }
void end_shop_mode() { RECT dummy_rect = {0,0,0,0}; if(PSD[SDF_ASK_ABOUT_TEXT_BOX] == 1) ShowWindow(talk_edit_box, SW_SHOW); ShowScrollBar(shop_sbar,SB_CTL,false); if (store_pre_shop_mode == 20) { sprintf(old_str1,"You conclude your business."); sprintf(old_str2,""); sprintf(one_back1,"You conclude your business."); sprintf(one_back2,""); strnum1 = strnum2 = oldstrnum1 = oldstrnum2 = 0; place_talk_str((char *)old_str1,"",0,dummy_rect); } else { DeleteObject(talk_gworld); talk_gworld = NULL; } overall_mode = store_pre_shop_mode; create_clip_region(); if (overall_mode == MODE_TALK_TOWN) overall_mode = MODE_TOWN; if (overall_mode == MODE_TOWN) { center = c_town.p_loc; update_explored(center); } stat_screen_mode = 0; put_item_screen(stat_window,0); put_pc_screen(); refresh_screen(0); }
void pc_record_type::curse(short how_much) { if (!isAlive()) return; status[STATUS_BLESS_CURSE] = max(status[STATUS_BLESS_CURSE] - how_much, -8); sprintf (c_line, " %s cursed.", name); add_string_to_buf(c_line); put_pc_screen(); give_help(59,0,0); }
void pc_record_type::web(short how_much) { if (!isAlive()) return; status[STATUS_WEBS] = min(status[STATUS_WEBS] + how_much,8); sprintf ((char *) c_line, " %s webbed.",(char *) name); add_string_to_buf((char *) c_line); one_sound(17); put_pc_screen(); give_help(31,0,0); }
void pc_record_type::slow(short how_much) { if (!isAlive()) return; status[STATUS_HASTE_SLOW] = minmax(-8,8,status[STATUS_HASTE_SLOW] - how_much); if (how_much < 0) sprintf ((char *) c_line, " %s hasted.",(char *) name); else sprintf ((char *) c_line, " %s slowed.",(char *) name); add_string_to_buf((char *) c_line); put_pc_screen(); if (how_much < 0) give_help(35,0,0); }
void pc_record_type::acid(short how_much) { if (!isAlive()) return; if (hasAbilEquip(ITEM_ACID_PROTECTION) < 24) { sprintf (c_line, " %s resists acid.", name); add_string_to_buf(c_line); return; } status[STATUS_ACID] += how_much; sprintf (c_line, " %s covered with acid!",(char *) name); add_string_to_buf(c_line); one_sound(42); put_pc_screen(); }
void pc_record_type::sleep(short how_much,short what_type,short adjust) // higher adjust, less chance of saving { short r1, tlevel; if (!isAlive()) return; if (how_much == 0) return; if ((what_type == STATUS_ASLEEP) || (what_type == STATUS_PARALYZED)) { //// if ((tlevel = getProtLevel(ITEM_WILL)) > 0) how_much -= tlevel / 2; if ((tlevel = getProtLevel(ITEM_FREE_ACTION)) > 0) how_much -= (what_type == STATUS_ASLEEP) ? tlevel : tlevel * 300; } r1 = get_ran(1,0,100) + adjust; if (r1 < 30 + level * 2) how_much = -1; if ((what_type == STATUS_ASLEEP) && ((traits[TRAIT_HIGHLY_ALERT] > 0) || (status[STATUS_ASLEEP] < 0))) how_much = -1; if (how_much <= 0) { sprintf (c_line, " %s resisted.", name); add_string_to_buf( c_line); return; } if (isAlive()) { status[what_type] = how_much; if (what_type == STATUS_ASLEEP) sprintf (c_line, " %s falls asleep.", name); else sprintf (c_line, " %s paralyzed.", name); if (what_type == STATUS_ASLEEP) play_sound(96); else play_sound(90); add_string_to_buf(c_line); pc_moves[getNum()] = 0; } put_pc_screen(); if (what_type == STATUS_ASLEEP) give_help(30,0,0); else give_help(32,0,0); }
bool pc_record_type::runTrap(short trap_type, short trap_level, short diff) { short r1,skill,i,num_hits = 1,i_level; short trap_odds[30] = {5,30,35,42,48, 55,63,69,75,77, 78,80,82,84,86, 88,90,92,94,96,98,99,99,99,99,99,99,99,99,99}; num_hits += trap_level; if (trap_type == TRAP_RANDOM) trap_type = get_ran(1,1,4); /// ??? => no trap after all ;) if (trap_type == 6) return true; i = statAdj(SKILL_DEXTERITY); if ((i_level = getProtLevel(ITEM_THIEVING)) > 0) i += i_level / 2; skill = minmax(0, 20, skills[SKILL_DISARM_TRAPS] + skills[SKILL_LUCK] / 2 + 1 - c_town.difficulty + 2 * i); r1 = get_ran(1,0,100) + diff; // Nimble? if (traits[TRAIT_NIMBLE] == true) r1 -= 6; if (r1 < trap_odds[skill]) { add_string_to_buf(" Trap disarmed. "); return true; } else add_string_to_buf(" Disarm failed. "); switch (trap_type) { case TRAP_BLADE: for (i = 0; i < num_hits; i++) { add_string_to_buf(" A knife flies out! "); damage(get_ran(2 + c_town.difficulty / 14,1,10),DAMAGE_WEAPON,-1); } break; case TRAP_DART: add_string_to_buf(" A dart flies out. "); poison((3 + c_town.difficulty / 14) + (trap_level * 2)); break; case TRAP_GAS: add_string_to_buf(" Poison gas pours out. "); adven.poison((2 + c_town.difficulty / 14) + trap_level * 2); break; case TRAP_EXPLOSION: for (i = 0; i < num_hits; i++) { add_string_to_buf(" There is an explosion. "); adven.damage(get_ran(3 + c_town.difficulty / 13,1,8), DAMAGE_FIRE); } break; case TRAP_SLEEP_RAY: add_string_to_buf(" A purple ray flies out. "); sleep((200 + c_town.difficulty * 100) + (trap_level * 400),12,50); break; case TRAP_DRAIN_XP: add_string_to_buf(" You feel weak. "); experience = max(0, experience - (40 + trap_level * 30)); break; case TRAP_ALERT: add_string_to_buf(" An alarm goes off!!! "); set_town_status(0); break; case TRAP_FLAMES: add_string_to_buf(" Flames shoot from the walls. "); adven.damage(get_ran(10 + trap_level * 5,1,8),DAMAGE_FIRE); break; case TRAP_DUMBFOUND: add_string_to_buf(" You feel disoriented. "); adven.dumbfound(2 + trap_level * 2); break; case TRAP_DISEASE: add_string_to_buf(" You prick your finger. "); disease((3 + c_town.difficulty / 14) + (trap_level * 2)); break; case TRAP_DISEASE_ALL: add_string_to_buf(" A foul substance sprays out."); adven.disease((2 + c_town.difficulty / 14) + (trap_level * 2)); break; default: add_string_to_buf(" (ERROR: Unknown type of trap!)"); break; } put_pc_screen(); put_item_screen(stat_window,0); return true; }
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); }
void pc_record_type::giveXP(short amt) { short adjust,add_hp; short xp_percent[30] = {150,120,100,90,80,70,60,50,50,50, 45,40,40,40,40,35,30,25,23,20, 15,15,15,15,15,15,15,15,15,15}; if (!isAlive()) return; if (level > 49) { level = 50; return; } if (amt > 200) { // debug MessageBeep(MB_OK); ASB("Oops! Too much xp!"); ASB("Report this!"); return; } if (amt < 0) { // debug MessageBeep(MB_OK); ASB("Oops! Negative xp!"); ASB("Report this!"); return; } if (level >= 40) adjust = 15; else adjust = xp_percent[level / 2]; if ((amt > 0) && (level > 7)) { if (get_ran(1,0,100) < xp_percent[level / 2]) amt--; } if (amt <= 0) return; experience += (max(((amt * adjust) / 100), 0) * 100) / 100; party.total_xp_gained += (max(((amt * adjust) / 100), 0) * 100) / 100; if (experience < 0) { MessageBeep(MB_OK); ASB("Oops! Xp became negative somehow!"); ASB("Report this!"); experience = level * (get_tnl(this)) - 1; return; } if (experience > 15000) { experience = 15000; return; } while (experience >= (level * (get_tnl(this)))) { play_sound(7); level++; sprintf (c_line, " %s is level %d! ", name, level); add_string_to_buf(c_line); skill_pts += (level < 20) ? 5 : 4; add_hp = (level < 26) ? get_ran(1,2,6) + skill_bonus[skills[SKILL_STRENGTH]] : max (skill_bonus[skills[SKILL_STRENGTH]],0); if (add_hp < 0) add_hp = 0; max_health += add_hp; if (max_health > 250) max_health = 250; cur_health += add_hp; if (cur_health > 250) cur_health = 250; put_pc_screen(); } }
void handle_sale(short what_chosen,short cost) { item_record_type base_item; short what_magic_shop,what_magic_shop_item,i; RECT dummy_rect = {0,0,0,0}; switch (what_chosen / 100) { case 0: case 1: case 2: case 3: case 4: base_item = get_stored_item(what_chosen); base_item.item_properties = base_item.item_properties | 1; //cost = (base_item.charges == 0) ? base_item.value : base_item.value * base_item.charges; switch (adven[current_pc].okToBuy(cost,base_item)) { case 1: play_sound(-38); adven[current_pc].giveToPC(base_item,true); break; case 2: ASB("Can't carry any more items."); break; case 3: ASB("Not enough cash."); break; case 4: ASB("Item is too heavy."); break; case 5: ASB("You own too many of this."); break; } break; case 5: base_item = store_alchemy(what_chosen - 500); if (party.alchemy[base_item.item_level] == true) ASB("You already know that recipe."); else if (party.takeGold(cost, false) == false) ASB("Not enough gold."); else { play_sound(62); ASB("You buy an alchemical recipe."); party.alchemy[base_item.item_level] = true; } break; case 7: what_chosen -= 700; if (party.takeGold(cost, false) == false) ASB("Not enough gold."); else { ASB("You pay the healer."); play_sound(68); switch (what_chosen) { case 0: adven[current_pc].cur_health = adven[current_pc].max_health; break; case 1: adven[current_pc].status[STATUS_POISON] = 0; break; case 2: adven[current_pc].status[STATUS_DISEASE] = 0; break; case 3: adven[current_pc].status[STATUS_PARALYZED] = 0; break; case 4: for (i = 0; i < 24; i++) if ((adven[current_pc].equip[i] == true) && (adven[current_pc].items[i].isCursed())) adven[current_pc].items[i].item_properties = adven[current_pc].items[i].item_properties & 239; break; case 5: case 6: case 7: adven[current_pc].main_status = MAIN_STATUS_ALIVE; break; case 8: adven[current_pc].status[STATUS_DUMB] = 0; break; } } break; case 8: base_item = store_mage_spells(what_chosen - 800 - 30); if ((base_item.item_level < 0) || (base_item.item_level > 61)) { MessageBeep(MB_OK); ASB("Error 102: Report this!"); break;} if (adven[current_pc].mage_spells[base_item.item_level] == true) ASB("You already have this spell."); else if (party.takeGold(cost, false) == false) ASB("Not enough gold."); else { play_sound(62); ASB("You buy a spell."); adven[current_pc].mage_spells[base_item.item_level] = true; give_help(41,0,0); } break; case 9: base_item = store_priest_spells(what_chosen - 900 - 30); if ((base_item.item_level < 0) || (base_item.item_level > 61)) { MessageBeep(MB_OK); ASB("Error 101: Report this!"); break;} if (adven[current_pc].priest_spells[base_item.item_level] == true) ASB("You already have this spell."); else if (party.takeGold(cost, false) == false) ASB("Not enough gold."); else { play_sound(62); ASB("You buy a spell."); adven[current_pc].priest_spells[base_item.item_level] = true; give_help(41,0,0); } break; default: what_magic_shop = (what_chosen / 1000) - 1; what_magic_shop_item = what_chosen % 1000; base_item = party.magic_store_items[what_magic_shop][what_magic_shop_item]; base_item.item_properties = base_item.item_properties | 1; switch (adven[current_pc].okToBuy(cost,base_item)) { case 1: play_sound(-38); adven[current_pc].giveToPC(base_item,true); party.magic_store_items[what_magic_shop][what_magic_shop_item].variety = ITEM_TYPE_NO_ITEM; break; case 2: ASB("Can't carry any more items."); break; case 3: ASB("Not enough cash."); break; case 4: ASB("Item is too heavy."); break; } break; } set_up_shop_array(); if (overall_mode != MODE_SHOPPING) { MessageBeep(MB_OK); ASB("Shop error 1. Report This!"); } draw_shop_graphics(0,dummy_rect); print_buf(); put_pc_screen(); put_item_screen(stat_window,0); }
void handle_menu_choice(eMenu item_hit) { std::string dialogToShow; sf::Event dummyEvent = {sf::Event::KeyPressed}; short i, choice; switch(item_hit) { case eMenu::NONE: break; case eMenu::FILE_OPEN: do_load(); break; case eMenu::FILE_SAVE: do_save(0); break; case eMenu::FILE_SAVE_AS: do_save(1); break; case eMenu::FILE_NEW: if(overall_mode != MODE_STARTUP) { std::string choice = cChoiceDlog("restart-game",{"okay","cancel"}).show(); if(choice == "cancel") return; for(i = 0; i < 6; i++) univ.party[i].main_status = eMainStatus::ABSENT; party_in_memory = false; reload_startup(); overall_mode = MODE_STARTUP; draw_startup(0); } start_new_game(); draw_startup(0); menu_activate(); break; case eMenu::FILE_ABORT: if(overall_mode != MODE_STARTUP) { std::string choice = cChoiceDlog("abort-game",{"okay","cancel"}).show(); if (choice=="cancel") return; reload_startup(); overall_mode = MODE_STARTUP; } party_in_memory = false; draw_startup(0); menu_activate(); break; case eMenu::PREFS: pick_preferences(); break; case eMenu::QUIT: if(overall_mode == MODE_STARTUP) { if(party_in_memory) { std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { fs::path file = nav_put_party(); if(!file.empty()) break; save_party(file, univ); } } All_Done = true; break; } if(overall_mode > MODE_TOWN) { std::string choice = cChoiceDlog("quit-confirm-nosave",{"quit","cancel"}).show(); if(choice == "cancel") return; } else { std::string choice = cChoiceDlog("quit-confirm-save",{"quit","save","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { if(univ.file.empty()) { univ.file = nav_put_party(); if(univ.file.empty()) break; } save_party(univ.file, univ); } } All_Done = true; break; case eMenu::OPTIONS_PC_GRAPHIC: choice = char_select_pc(1,"New graphic for who?"); if(choice < 6) pick_pc_graphic(choice,1,nullptr); draw_terrain(); break; case eMenu::OPTIONS_DELETE_PC: if(!prime_time()) { ASB("Finish what you're doing first."); print_buf(); } else { choice = char_select_pc(1,"Delete who?"); if(choice < 6) { std::string confirm = cChoiceDlog("delete-pc-confirm",{"yes","no"}).show(); if(confirm == "yes") kill_pc(univ.party[choice],eMainStatus::ABSENT); } draw_terrain(); } break; case eMenu::OPTIONS_RENAME_PC: choice = char_select_pc(1,"Rename who?"); if(choice < 6) pick_pc_name(choice,nullptr); put_pc_screen(); put_item_screen(stat_window); break; case eMenu::OPTIONS_NEW_PC: if(!(is_town())) { add_string_to_buf("Add PC: Town mode only."); print_buf(); break; } for(i = 0; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ABSENT) i = 20; if(i == 6) { ASB("Add PC: You already have 6 PCs."); print_buf(); break; } if(univ.town->has_tavern) { give_help(56,0); create_pc(6,nullptr); } else { add_string_to_buf("Add PC: You cannot add new characters in this town. Try in the town you started in.", 2); } print_buf(); put_pc_screen(); put_item_screen(stat_window); break; case eMenu::OPTIONS_JOURNAL: journal(); break; case eMenu::OPTIONS_TALK_NOTES: if(overall_mode == MODE_TALKING) { ASB("Talking notes: Can't read while talking."); print_buf(); return; } talk_notes(); break; case eMenu::OPTIONS_ENCOUNTER_NOTES: adventure_notes(); break; case eMenu::OPTIONS_STATS: if(overall_mode != MODE_STARTUP) print_party_stats(); break; case eMenu::HELP_OUT: dialogToShow = "help-outdoor"; break; case eMenu::HELP_TOWN: dialogToShow = "help-town"; break; case eMenu::HELP_COMBAT: dialogToShow = "help-combat"; break; case eMenu::HELP_BARRIER: dialogToShow = "help-fields"; break; case eMenu::HELP_HINTS: dialogToShow = "help-hints"; break; case eMenu::HELP_SPELLS: dialogToShow = "help-magic"; break; case eMenu::ABOUT: dialogToShow = "about-boe"; break; case eMenu::LIBRARY_MAGE: display_spells(eSkill::MAGE_SPELLS,100,0); break; case eMenu::LIBRARY_PRIEST: display_spells(eSkill::PRIEST_SPELLS,100,0); break; case eMenu::LIBRARY_SKILLS: display_skills(eSkill::INVALID,0); break; case eMenu::LIBRARY_ALCHEMY: // TODO: Create a dedicated dialog for alchemy info display_alchemy(); break; case eMenu::LIBRARY_TIPS: tip_of_day(); break; case eMenu::LIBRARY_INTRO: dialogToShow = "welcome"; break; case eMenu::ACTIONS_ALCHEMY: dummyEvent.key.code = sf::Keyboard::A; dummyEvent.key.shift = true; handle_keystroke(dummyEvent); break; case eMenu::ACTIONS_WAIT: dummyEvent.key.code = sf::Keyboard::W; handle_keystroke(dummyEvent); break; case eMenu::ACTIONS_AUTOMAP: if(!prime_time()) { ASB("Finish what you're doing first."); print_buf(); } else { give_help(62,0); display_map(); } make_cursor_sword(); break; case eMenu::HELP_TOC: if(fs::is_directory(progDir/"doc")) launchURL("file://" + (progDir/"doc/game/Contents.html").string()); else launchURL("https://blades.calref.net/doc/game/Contents.html"); break; case eMenu::ABOUT_MAGE: case eMenu::ABOUT_PRIEST: give_help(209,0); break; case eMenu::ABOUT_MONSTERS: give_help(212,0); break; } if(!dialogToShow.empty()) { cChoiceDlog dlog(dialogToShow); dlog.show(); } }
Boolean handle_menu (short item, HMENU) { short choice,i; POINT x = {1001,0},pass_point; Boolean to_return = false; switch (item) { case 1: // File Menu if (in_startup_mode == true) startup_load(); else do_load(); break; case 2: do_save(0); break; case 3: if (in_startup_mode == true) save_file(1); else do_save(1); break; case 4: if (in_startup_mode == false) { choice = FCD(1091,0); if (choice == 1) return false; for (i = 0; i < 6; i++) adven[i].main_status = MAIN_STATUS_ABSENT; party_in_memory = false; reload_startup(); in_startup_mode = true; draw_startup(0); } start_new_game(); draw_startup(0); break; case 6: pick_preferences(); break; case 7: pick_compatibility(); break; case 8: // Quit if (in_startup_mode == true) { to_return = All_Done = true; break; } if (overall_mode > MODE_TOWN) { choice = FCD(1067,0); if (choice == 1) return All_Done; } else { choice = FCD(1066,0); if (choice == 3) break; if (choice == 1) save_file(0); } to_return = All_Done = true; break; // Options menu case 21: choice = char_select_pc(0,0,"New graphic for who?"); if (choice < 6) pick_pc_graphic(choice,1,0); initiate_redraw(); break; case 22: choice = select_pc(0,0); if (choice < 6) pick_pc_name(choice,0); put_pc_screen(); put_item_screen(stat_window,0); break; case 23: if (!(is_town())) { add_string_to_buf("Add PC: Town mode only."); print_buf(); break; } for (i = 0; i < NUM_OF_PCS; i++) if (adven[i].main_status == MAIN_STATUS_ABSENT) i = 20; if (i == INVALID_PC) { ASB("Add PC: You already have 6 PCs."); print_buf(); } if (c_town.town_num == scenario.which_town_start) { give_help(56,0,0); create_pc(6,0); } else { add_string_to_buf("Add PC: You can only make new"); add_string_to_buf(" characters in the town you "); add_string_to_buf(" started in."); } print_buf(); put_pc_screen(); put_item_screen(stat_window,0); break; case 24: if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else { choice = char_select_pc(0,0,"Delete who?"); if (choice < 6) { if ((i = FCD(1053,0)) == 2) adven[choice].kill(0); } initiate_redraw(); } break; case 27: if (overall_mode == MODE_TALKING) { ASB("Talking notes: Can't read while talking."); print_buf(); return to_return; } talk_notes(); break; case 28: adventure_notes(); break; case 29: if (in_startup_mode == false) print_party_stats(); break; // Help menu case 41: FCD(1079,0); break; case 42: FCD(1080,0); break; case 43: FCD(1081,0); break; case 44: FCD(1072,0); break; // magic barriers case 46: FCD(1084,0); break; case 47: FCD(1088,0); break; // Library case 61: display_spells(0,100,0); break; case 62: display_spells(1,100,0); break; case 63: display_skills(100,0); break; case 64: display_help(0,0); break; case 65: tip_of_day(); break; case 67: FCD(986,0); break; // Actions case 81: if (overall_mode != MODE_TOWN) { ASB("Alchemy: In town mode only."); print_buf(); break; } pass_point.x = 1000; pass_point.y = 405; to_return = handle_action(pass_point,(WPARAM) 0,(LPARAM)-1); break; case 82: to_return = handle_action(x,(WPARAM) 0,(LPARAM)-1); break; case 84: if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else { give_help(62,0,0); display_map(); } SetCursor(sword_curs); break; // Mage is 399 case 399: give_help(209,0,0); party.help_received[9] = false; break; // Priest is 499 case 499: give_help(209,0,0); party.help_received[9] = false; break; // Monsters is 599 case 599: give_help(212,0,0); break; case 100: // Index WinHelp(mainPtr,"Blades of Exile.hlp",HELP_CONTENTS,0L); break; case 200: // About FCD(1062,0); break; default: if ((item >= 400) && (item < 500)) { // mage spell if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else handle_menu_spell(item - 400,0); break; } if ((item >= 500) && (item < 600)) { // priest spell if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else handle_menu_spell(item - 500,1); break; } if ((item >= 600) && (item < 700)) { // monster spell display_monst(item - 600,(creature_data_type *) NULL,1); break; } break; } if (in_startup_mode == true) menu_activate(0); else menu_activate(1); return to_return; }
//short trap_type; // 0 - random 1 - blade 2 - dart 3 - gas 4 - boom 5 - paralyze 6 - no // 7 - level drain 8 - alert 9 - big flames 10 - dumbfound 11 - disease 1 // 12 - disease all bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) { short r1,skill,i,num_hits = 1; short trap_odds[30] = {5,30,35,42,48, 55,63,69,75,77, 78,80,82,84,86, 88,90,92,94,96,98,99,99,99,99,99,99,99,99,99}; num_hits += trap_level; if(trap_type == TRAP_RANDOM) trap_type = (eTrapType) get_ran(1,1,4); if(trap_type == TRAP_FALSE_ALARM) return true; cPlayer& disarmer = univ.party[pc_num]; if(pc_num < 6) { i = disarmer.stat_adj(eSkill::DEXTERITY); i += disarmer.get_prot_level(eItemAbil::THIEVING) / 2; skill = minmax(0,20,disarmer.skill(eSkill::DISARM_TRAPS) + + disarmer.skill(eSkill::LUCK) / 2 + 1 - univ.town.difficulty + 2 * i); r1 = get_ran(1,1,100) + diff; // Nimble? if(disarmer.traits[eTrait::NIMBLE]) r1 -= 6; if(r1 < trap_odds[skill]) { add_string_to_buf(" Trap disarmed."); return true; } else add_string_to_buf(" Disarm failed."); } switch(trap_type) { case TRAP_BLADE: for(i = 0; i < num_hits; i++) { add_string_to_buf(" A knife flies out!"); r1 = get_ran(2 + univ.town.difficulty / 14,1,10); damage_pc(disarmer,r1,eDamageType::WEAPON,eRace::UNKNOWN,0); } break; case TRAP_DART: add_string_to_buf(" A dart flies out."); r1 = 3 + univ.town.difficulty / 14; r1 = r1 + trap_level * 2; disarmer.poison(r1); break; case TRAP_GAS: add_string_to_buf(" Poison gas pours out."); r1 = 2 + univ.town.difficulty / 14; r1 = r1 + trap_level * 2; univ.party.poison(r1); break; case TRAP_EXPLOSION: for(i = 0; i < num_hits; i++) { add_string_to_buf(" There is an explosion."); r1 = get_ran(3 + univ.town.difficulty / 13,1,8); hit_party(r1,eDamageType::FIRE); } break; case TRAP_SLEEP_RAY: add_string_to_buf(" A purple ray flies out."); r1 = 200 + univ.town.difficulty * 100; r1 = r1 + trap_level * 400; // TODO: It says sleep ray but is actually paralysis ray? disarmer.sleep(eStatus::PARALYZED, r1, 50); break; case TRAP_DRAIN_XP: add_string_to_buf(" You feel weak."); r1 = 40; r1 = r1 + trap_level * 30; disarmer.experience = max(0,disarmer.experience - r1); break; case TRAP_ALERT: add_string_to_buf(" An alarm goes off!!!"); make_town_hostile(); break; case TRAP_FLAMES: add_string_to_buf(" Flames shoot from the walls."); r1 = get_ran(10 + trap_level * 5,1,8); hit_party(r1,eDamageType::FIRE); break; case TRAP_DUMBFOUND: add_string_to_buf(" You feel disoriented."); univ.party.dumbfound(2 + trap_level * 2); adjust_spell_menus(); break; case TRAP_DISEASE: add_string_to_buf(" You prick your finger."); r1 = 3 + univ.town.difficulty / 14; r1 = r1 + trap_level * 2; disarmer.disease(r1); break; case TRAP_DISEASE_ALL: add_string_to_buf(" A foul substance sprays out."); r1 = 2 + univ.town.difficulty / 14; r1 = r1 + trap_level * 2; univ.party.disease(r1); break; case TRAP_CUSTOM: univ.party.force_ptr(15, trap_level); break; default: add_string_to_buf("ERROR: Invalid trap type."); // should never be reached } put_pc_screen(); put_item_screen(stat_window); return false; }
void pc_record_type::kill(short type) { short i = 24; bool dummy, no_save = false, no_luck = false; location item_loc; if (type >= 20) { type -= 10; no_save = true; } if(type >= 10) { type -= 10; no_luck = true; } if(no_save == false){ if (type != 4) i = hasAbilEquip(ITEM_LIFE_SAVING); //check if has life saving items else i = hasAbilEquip(ITEM_PROTECT_FROM_PETRIFY); //check if has protection vs petrification items } short which_pc = getNum(); if ((no_luck == false) && (type != 0) && (skills[SKILL_LUCK] > 0) && (get_ran(1,0,100) < hit_chance[skills[SKILL_LUCK]])) { add_string_to_buf(" But you luck out! "); cur_health = 0; } else if ((i == 24) || (type == 0)) { if (combat_active_pc == which_pc) combat_active_pc = 6; for (i = 0; i < 24; i++) equip[i] = false; item_loc = (overall_mode >= MODE_COMBAT) ? pc_pos[which_pc] : c_town.p_loc; if (type == 2) make_sfx(item_loc.x,item_loc.y,3); else if (type == 3) make_sfx(item_loc.x,item_loc.y,6); if (overall_mode != MODE_OUTDOORS) for (i = 0; i < 24; i++) if (items[i].variety != ITEM_TYPE_NO_ITEM) { dummy = place_item(items[i],item_loc,true); items[i].variety = ITEM_TYPE_NO_ITEM; } if ((type == 2) || (type == 3)) play_sound(21); if(type == 4){ play_sound(43); sprintf (create_line, " %s is turned to stone. ",(char *) name); add_string_to_buf(create_line); } main_status = type; pc_moves[which_pc] = 0; } else { if (type == 4) { sprintf (create_line, " %s is immune to petrification. ",(char *) name); add_string_to_buf(create_line); //inform of what has happened } else{ add_string_to_buf(" Life saved! "); takeItem(i); heal(200); } } current_pc = first_active_pc(); if (current_pc > 5) { for (i = 0; i < NUM_OF_PCS; i++) if (adven[i].status > 0) current_pc = i; } put_pc_screen(); set_stat_window(current_pc); }