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 pc_record_type::dropItem(short item_num, location where_drop) { short choice, how_many = 0; item_record_type item_store; bool take_given_item = true; location loc; item_store = items[item_num]; if ((equip[item_num] == true) && (items[item_num].isCursed())) add_string_to_buf("Drop: Item is cursed. "); else switch (overall_mode) { case 0: choice = fancy_choice_dialog(1093,0); if (choice == 1) return; add_string_to_buf("Drop: OK"); if ((item_store.type_flag > 0) && (item_store.charges > 1)) { how_many = get_num_of_items(item_store.charges); if (how_many == item_store.charges) takeItem(item_num); else items[item_num].charges -= how_many; } else takeItem(item_num); break; case 5: case 15: loc = where_drop; if ((item_store.type_flag > 0) && (item_store.charges > 1)) { how_many = get_num_of_items(item_store.charges); if (how_many <= 0) return; if (how_many < item_store.charges) take_given_item = false; item_store.charges = how_many; } if (is_container(loc) == true) item_store.item_properties = item_store.item_properties | 8; if (place_item(item_store,loc,false) == false) { add_string_to_buf("Drop: Too many items on ground"); item_store.item_properties = item_store.item_properties & 247; // not contained } else { if (item_store.isContained()) add_string_to_buf("Drop: Item put away"); else add_string_to_buf("Drop: OK"); items[item_num].charges -= how_many; if (take_given_item) takeItem(item_num); } break; } }
void pc_record_type::combineThings() { int i,j,test; for (i = 0; i < 24; i++) { if ((items[i].variety > ITEM_TYPE_NO_ITEM) && (items[i].type_flag > 0) && (items[i].isIdent())) { for (j = i + 1; j < 24; j++) if ((items[j].variety > ITEM_TYPE_NO_ITEM) && (items[j].type_flag == items[i].type_flag) && (items[j].isIdent())) { add_string_to_buf("(items combined)"); test = items[i].charges + items[j].charges; if (test > 125) { items[i].charges = 125; ASB("(Can have at most 125 of any item."); } else items[i].charges += items[j].charges; if (equip[j] == true) { equip[i] = true; equip[j] = false; } takeItem(30 + j); } } if ((items[i].variety > ITEM_TYPE_NO_ITEM) && (items[i].charges < 0)) items[i].charges = 1; } }
void record_monst(cCreature *which_m) { short r1; char str[60]; r1 = get_ran(1,1,100); r1 = (r1 * 7) / 10; if ((which_m->x_width > 1) || (which_m->y_width > 1)) { ASB("Capture Soul: Monster is too big."); } else if ((r1 > charm_odds[which_m->level / 2]) || (which_m->spec_skill == 12) || (which_m->m_type == 3)) { monst_spell_note(which_m->number,10); play_sound(68); } else { monst_spell_note(which_m->number,24); r1 = get_ran(1,0,3); if (univ.party.imprisoned_monst[r1] == 0) univ.party.imprisoned_monst[r1] = which_m->number; else { r1 = get_ran(1,0,3); univ.party.imprisoned_monst[r1] = which_m->number; } ASB("Capture Soul: Success!"); sprintf((char *)str," Caught in slot %d.",r1 + 1); add_string_to_buf((char *)str); play_sound(53); } }
void pc_record_type::takeItem(short which_item) //short pc_num,which_item; // if which_item > 30, don't update stat win, item is which_item - 30 { int i; bool do_print = true; if (which_item >= 30) { do_print = false; which_item -= 30; } if ((weap_poisoned == which_item) && (status[STATUS_POISONED_WEAPON] > 0)) { add_string_to_buf(" Poison lost. "); status[STATUS_POISONED_WEAPON] = 0; } if ((weap_poisoned > which_item) && (status[STATUS_POISONED_WEAPON] > 0)) weap_poisoned--; for (i = which_item; i < 23; i++) { items[i] = items[i + 1]; equip[i] = equip[i + 1]; } items[23] = return_dummy_item(); equip[23] = false; if ((stat_window == getNum()) && (do_print)) put_item_screen(stat_window,1); }
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::drainXP(short how_much) { if (!isAlive()) return; experience = max(experience - how_much, 0); sprintf (c_line, " %s drained.", name); add_string_to_buf(c_line); }
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); }
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::giveThing(short item_num) { short who_to,how_many = 0; item_record_type item_store; bool take_given_item = true; short pc_num = getNum(); if ((equip[item_num] == true) && (items[item_num].isCursed())) add_string_to_buf("Give: Item is cursed. "); else { item_store = items[item_num]; who_to = char_select_pc(1,1,"Give item to who?"); if ((overall_mode == MODE_COMBAT) && (adjacent(pc_pos[pc_num],pc_pos[who_to]) == false)) { add_string_to_buf("Give: Must be adjacent."); who_to = 6; } if ((who_to < 6) && (who_to != pc_num) && ((overall_mode != MODE_COMBAT) || (adjacent(pc_pos[pc_num],pc_pos[who_to]) == true))) { if ((item_store.type_flag > 0) && (item_store.charges > 1)) { how_many = get_num_of_items(item_store.charges); if (how_many == 0) return; if (how_many < item_store.charges) take_given_item = false; items[item_num].charges -= how_many; item_store.charges = how_many; } if (adven[who_to].giveToPC(item_store,0) == true) { if (take_given_item) takeItem(item_num); } else { if (adven[who_to].hasSpace() == 24) ASB("Can't give: PC has max. # of items."); else ASB("Can't give: PC carrying too much."); if (how_many > 0) items[item_num].charges += how_many; } } } }
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); }
// returns true if placement was successful bool summon_monster(m_num_t which,location where,short duration,short given_attitude) //which; // if in town, this is caster loc., if in combat, this is where to try // to put monster { location loc; short which_m,spot; if ((is_town()) || (monsters_going)) { // Ooooh ... mondo kludge. Need to find caster's attitude to give it to monst. which_m = monst_there(where); // if (pc_there(where) < 6) // which_att = 2; // else if (which_m == 90) // which_att = 1; // else which_att = univ.town.monst[which_m].attitude; loc = find_clear_spot(where,0); if (loc.x == 0) return false; } else { // pc may be summoning using item, in which case where will be pc's space, so fix if (pc_there(where) < 6) { where = find_clear_spot(where,0); if (where.x == 0) return false; } if ((univ.town.is_barrel(where.x,where.y)) || (univ.town.is_crate(where.x,where.y))) return false; loc = where; } spot = place_monster(which,loc); if (spot >= univ.town->max_monst()) { if (duration < 100) add_string_to_buf(" Too many monsters."); //ASB(" Monster fails to summon monster."); return false; } //play_sound(61); // if (duration < 100) univ.town.monst[spot].attitude = given_attitude; // else univ.town.monst[spot].attitude = which_att; if (which > 0) {//monster here for good univ.town.monst[spot].summoned = duration; monst_spell_note(which,21); } else univ.town.monst[spot].summoned = 0; return true; }
bool pc_record_type::giveToPC(item_record_type item, bool print_result) { short free_space; char announce_string[60]; if (item.variety == ITEM_TYPE_NO_ITEM) return true; if (item.variety == ITEM_TYPE_GOLD) { party.gold += item.item_level; ASB("You get some gold."); return true; } if (item.variety == ITEM_TYPE_FOOD) { party.food += item.item_level; ASB("You get some food."); return true; } if (item_weight(item) > amountCanCarry() - amountCarried()) { if (print_result == true) { MessageBeep(MB_OK); ASB("Item too heavy to carry."); } return false; } if (((free_space = hasSpace()) == 24) || (!isAlive())) return false; else { item.item_properties = item.item_properties & 253; // not property item.item_properties = item.item_properties & 247; // not contained items[free_space] = item; if (print_result == 1) { if (stat_window == getNum()) put_item_screen(stat_window,0); } if (in_startup_mode == false) { if (item.isIdent() == false) sprintf((char *) announce_string," %s gets %s.",name,item.name); else sprintf((char *) announce_string," %s gets %s.",name,item.full_name); if (print_result) add_string_to_buf((char *)announce_string); } combineThings(); sortItems(); return true; } return false; }
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); }
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; }
bool monst_check_special_terrain(location where_check,short mode,short which_monst) //mode; // 1 - town 2 - combat { ter_num_t ter = 0; short r1,i,guts = 0; bool can_enter = true,mage = false; location from_loc,to_loc; bool do_look = false; // If becomes true, terrain changed, so need to update what party sees cCreature *which_m; short ter_abil; unsigned short ter_flag; from_loc = univ.town.monst[which_monst].cur_loc; switch (mode) { case 1: ter = univ.town->terrain(where_check.x,where_check.y); break; case 2: ter = combat_terrain[where_check.x][where_check.y]; break; } //// which_m = &univ.town.monst[which_monst]; ter_abil = scenario.ter_types[ter].special; ter_flag = scenario.ter_types[ter].flag3.u; if ((mode > 0) && (ter_abil == TER_SPEC_CONVEYOR)) { if ( ((ter_flag == DIR_N) && (where_check.y > from_loc.y)) || ((ter_flag == DIR_E) && (where_check.x < from_loc.x)) || ((ter_flag == DIR_S) && (where_check.y < from_loc.y)) || ((ter_flag == DIR_W) && (where_check.x > from_loc.x)) ) { return false; } } // begin determining guts, which determines how enthused the monst is about entering // nasty barriers if ((which_m->mu > 0) || (which_m->cl > 0)) mage = true; if (which_m->spec_skill == 13) guts = 20; else guts = get_ran(1,1,(which_m->level / 2)); guts += which_m->health / 20; if (mage == true) guts = guts / 2; if (which_m->attitude == 0) guts = guts / 2; if ((univ.town.is_antimagic(where_check.x,where_check.y)) && (mage == true)) return false; if ((univ.town.is_fire_wall(where_check.x,where_check.y)) && (which_m->spec_skill != 22)) { if (guts < 3) return false; } if (univ.town.is_force_wall(where_check.x,where_check.y)) { if (guts < 4) return false; } if ((univ.town.is_ice_wall(where_check.x,where_check.y)) && (which_m->spec_skill != 23)) { if (guts < 5) return false; } if (univ.town.is_sleep_cloud(where_check.x,where_check.y)) { if (guts < 8) return false; } if (univ.town.is_blade_wall(where_check.x,where_check.y)) { if (guts < 8) return false; } if (univ.town.is_quickfire(where_check.x,where_check.y)) { if (guts < 8) return false; } if (univ.town.is_scloud(where_check.x,where_check.y)) { if (guts < 4) return false; } if ((univ.town.is_web(where_check.x,where_check.y)) && (which_m->m_type != 12)) { if (guts < 3) return false; } if (univ.town.is_fire_barr(where_check.x,where_check.y)) { if ((which_m->attitude % 2 == 1) && (get_ran(1,1,100) < (which_m->mu * 10 + which_m->cl * 4))) { play_sound(60); add_string_to_buf("Monster breaks barrier."); univ.town.set_fire_barr(where_check.x,where_check.y,false); } else { if (guts < 6) return false; r1 = get_ran(1,0,10); if ((r1 < 8) || (monster_placid(which_monst))) can_enter = false; } } if (univ.town.is_force_barr(where_check.x,where_check.y)) { /// Not in big towns if ((which_m->attitude % 2 == 1) && (get_ran(1,1,100) < (which_m->mu * 10 + which_m->cl * 4)) && (!univ.town->strong_barriers)) { play_sound(60); add_string_to_buf("Monster breaks barrier."); univ.town.set_force_barr(where_check.x,where_check.y,false); } else can_enter = false; } if (univ.town.is_crate(where_check.x,where_check.y)) { if (monster_placid(which_monst)) can_enter = false; else { to_loc = push_loc(from_loc,where_check); univ.town.set_crate((short) where_check.x,(short) where_check.y,false); if (to_loc.x > 0) univ.town.set_crate((short) to_loc.x,(short) to_loc.y, true); for (i = 0; i < NUM_TOWN_ITEMS; i++) if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) && (univ.town.items[i].contained)) univ.town.items[i].item_loc = to_loc; } } if (univ.town.is_barrel(where_check.x,where_check.y)) { if (monster_placid(which_monst)) can_enter = false; else { to_loc = push_loc(from_loc,where_check); univ.town.set_barrel((short) where_check.x,(short) where_check.y,false); if (to_loc.x > 0) univ.town.set_barrel((short) to_loc.x,(short) to_loc.y,true); for (i = 0; i < NUM_TOWN_ITEMS; i++) if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) && (univ.town.items[i].contained)) univ.town.items[i].item_loc = to_loc; } } if (monster_placid(which_monst) && // monsters don't hop into bed when things are calm (scenario.ter_types[ter].special == TER_SPEC_BED)) can_enter = false; if (mode == 1 && univ.town.is_spot(where_check.x, where_check.y)) can_enter = false; if (ter == 90) { if ((is_combat()) && (which_combat_type == 0)) { univ.town.monst[which_monst].active = 0; add_string_to_buf("Monster escaped! "); } return false; } switch (ter_abil) { // changing ter case TER_SPEC_CHANGE_WHEN_STEP_ON: can_enter = false; if (!(monster_placid(which_monst))) { univ.town->terrain(where_check.x,where_check.y) = scenario.ter_types[ter].flag1.u; combat_terrain[where_check.x][where_check.y] = scenario.ter_types[ter].flag1.u; do_look = true; if (point_onscreen(center,where_check)) play_sound(scenario.ter_types[ter].flag2.u); } break; case TER_SPEC_BLOCKED_TO_MONSTERS: case TER_SPEC_TOWN_ENTRANCE: case TER_SPEC_WATERFALL: can_enter = false; break; case TER_SPEC_DAMAGING: // TODO: Update this to check other cases if (ter_flag == DAMAGE_FIRE && univ.town.monst[which_monst].immunities & 8) return true; else return false; break; } // Action may change terrain, so update what's been seen if (do_look == true) { if (is_town()) update_explored(univ.town.p_loc); if (is_combat()) for (i = 0; i < 6; i++) if (univ.party[i].main_status == 1) update_explored(pc_pos[i]); } return can_enter; }
void do_monsters() { short i,j,r1,target; location l1,l2; bool acted_yet = false; if (overall_mode == MODE_TOWN) for (i = 0; i < univ.town->max_monst(); i++) if ((univ.town.monst[i].active != 0) && (univ.town.monst[i].status[11] <= 0) && (univ.town.monst[i].status[12] <= 0)) { // have to pick targets if (univ.town.monst[i].active == 1) target = 6; else { target = monst_pick_target(i); // will return 0 if target party target = switch_target_to_adjacent(i,target); if (target == 0) { if (dist(univ.town.monst[i].cur_loc,univ.town.p_loc) > 8) target = 6; else target = select_active_pc(); } if ((univ.town.monst[i].attitude % 2 != 1) && (target < 6)) target = 6; } univ.town.monst[i].target = target; // sprintf((char *)debug," t: %d targets %d.",i,monst_target[i]); // add_string_to_buf((char *) debug); if ((univ.town.monst[i].active == 2) || ((univ.town.monst[i].active != 0) && (univ.town.monst[i].attitude % 2 != 1))) { acted_yet = false; if (((univ.town.monst[i].attitude == 0) || (univ.town.monst[i].target == 6)) && (univ.town.hostile == 0)) { if (univ.town.monst[i].mobility == 1) { // OK, it doesn't see the party or // isn't nasty, and the town isn't totally hostile. if ((univ.town.monst[i].attitude % 2 != 1) || (get_ran(1,0,1) == 0)) { acted_yet = rand_move(i); } else acted_yet = seek_party(i,univ.town.monst[i].cur_loc,univ.town.p_loc); } } if ((univ.town.monst[i].attitude > 0) || (univ.town.hostile == 1)) { if ((univ.town.monst[i].mobility == 1) && (univ.town.monst[i].target != 6)) { l1 = univ.town.monst[i].cur_loc; l2 = (univ.town.monst[i].target <= 6) ? univ.town.p_loc : univ.town.monst[target - 100].cur_loc; if ((univ.town.monst[i].morale < 0) && (univ.town.monst[i].spec_skill != 13) && (univ.town.monst[i].m_type != 8)) { acted_yet = flee_party(i,l1,l2); if (get_ran(1,0,10) < 6) univ.town.monst[i].morale++; } else if (monst_hate_spot(i,&l2) == true) acted_yet = seek_party(i,l1,l2); else if (((univ.town.monst[i].mu == 0) && (univ.town.monst[i].mu == 0)) || (can_see(l1,l2,0) > 3)) acted_yet = seek_party(i,l1,l2); } } } // Make hostile monsters active if ((univ.town.monst[i].active == 1) && (univ.town.monst[i].attitude % 2 == 1) && (dist(univ.town.monst[i].cur_loc,univ.town.p_loc) <= 8)) { r1 = get_ran(1,1,100); r1 += (PSD[SDF_PARTY_STEALTHY] > 0) ? 46 : 0; r1 += can_see(univ.town.monst[i].cur_loc,univ.town.p_loc,0) * 10; if (r1 < 50) { univ.town.monst[i].active = 2; add_string_to_buf("Monster saw you!"); // play go active sound switch (univ.town.monst[i].m_type) { case 0: case 3: case 4: case 5: case 6: case 9: play_sound(18); break; default: play_sound(46); break; } } for (j = 0; j < univ.town->max_monst(); j++) if ((univ.town.monst[j].active == 2) && ((dist(univ.town.monst[i].cur_loc,univ.town.monst[j].cur_loc) <= 5) == true)) univ.town.monst[i].active = 2; } } if (overall_mode == MODE_OUTDOORS) { for (i = 0; i < 10; i++) if (univ.party.out_c[i].exists == true) { acted_yet = false; l1 = univ.party.out_c[i].m_loc; l2 = univ.party.p_loc; r1 = get_ran(1,1,6); if (r1 == 3) acted_yet = rand_move(i); else acted_yet = seek_party(i,l1,l2); } } }
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(); } }
//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 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(); } }
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); }
void pc_record_type::equipItem(short item_num) { short num_equipped_of_this_type = 0; short num_hands_occupied = 0; short i; short equip_item_type = 0; //the next check didn't allow food to be equipped in combat mode... leftover from Exile 1-2-3 ? /*if ((overall_mode == MODE_COMBAT) && (items[item_num].variety == ITEM_TYPE_FOOD)) add_string_to_buf("Equip: Not in combat"); else {*/ // unequip if (equip[item_num] == true) { if ((equip[item_num] == true) && (items[item_num].isCursed())) add_string_to_buf("Equip: Item is cursed. "); else { equip[item_num] = false; add_string_to_buf("Equip: Unequipped"); if ((weap_poisoned == item_num) && (status[STATUS_POISONED_WEAPON] > 0)) { add_string_to_buf(" Poison lost. "); status[STATUS_POISONED_WEAPON] = 0; } } } else { // equip if (equippable[items[item_num].variety] == false) add_string_to_buf("Equip: Can't equip this item."); else { for (i = 0; i < 24; i++) if (equip[i] == true) { if (items[i].variety == items[item_num].variety) num_equipped_of_this_type++; num_hands_occupied = num_hands_occupied + num_hands_to_use[items[i].variety]; } equip_item_type = excluding_types[items[item_num].variety]; // Now if missile is already equipped, no more missiles if (equip_item_type > 0) { for (i = 0; i < 24; i++) if ((equip[i] == true) && (excluding_types[items[i].variety] == equip_item_type)) { add_string_to_buf("Equip: You have something of"); add_string_to_buf(" this type equipped."); return; } } if ((is_combat()) && (items[item_num].variety == ITEM_TYPE_ARMOR)) add_string_to_buf("Equip: Not armor in combat"); else if ((2 - num_hands_occupied) < num_hands_to_use[items[item_num].variety]) add_string_to_buf("Equip: Not enough free hands"); else if (num_that_can_equip[items[item_num].variety] <= num_equipped_of_this_type) add_string_to_buf("Equip: Can't equip another"); else { equip[item_num] = true; add_string_to_buf("Equip: OK"); } } } //} if (stat_window == getNum()) put_item_screen(stat_window,1); }
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); }
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; }