void place_outd_wand_monst(location where,cOutdoors::cWandering group,short forced) { short i = 0,j = 0; location l; while (i < 10) { //// if ((univ.party.out_c[i].exists == false) || ((i == 9) && (forced > 0))) { if ((sd_legit(group.end_spec1,group.end_spec2) == true) && (PSD[group.end_spec1][group.end_spec2] > 0)) return; univ.party.out_c[i].exists = true; univ.party.out_c[i].direction = 0; univ.party.out_c[i].what_monst = group; univ.party.out_c[i].which_sector = univ.party.i_w_c; univ.party.out_c[i].m_loc = where; if (univ.party.out_c[i].which_sector.x == 1) univ.party.out_c[i].m_loc.x += 48; if (univ.party.out_c[i].which_sector.y == 1) univ.party.out_c[i].m_loc.y += 48; l = univ.party.out_c[i].m_loc; while ((forced == true) && (is_blocked(l)) && (j < 50)) { l = univ.party.out_c[i].m_loc; l.x += get_ran(1,0,2) - 1; l.y += get_ran(1,0,2) - 1; j++; } univ.party.out_c[i].m_loc = l; i = 50; } i++; } }
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); }
short monst_pick_target_pc(short m_num,cCreature *which_m)//// { short num_tries = 0,r1,store_targ = 6; if (which_m->attitude % 2 == 0) return 6; if (is_town()) return 0; // First pick any visible, nearby PC r1 = get_ran(1,0,5); while ((num_tries < 6) && ((univ.party[r1].main_status != 1) || (monst_can_see(m_num,pc_pos[r1]) == false))) { r1 = get_ran(1,0,5); num_tries++; } if (num_tries < 6) store_targ = r1; // Then, see if target can be replaced with someone nice and close r1 = get_ran(1,0,5); while ((num_tries < 6) && ((univ.party[r1].main_status != 1) || (dist(which_m->cur_loc,pc_pos[r1]) > 4) || (monst_can_see(m_num,pc_pos[r1]) == false))) { r1 = get_ran(1,0,5); num_tries++; } if (num_tries < 6) return r1; else return store_targ; }
void play_ambient_sound(){ // TODO: Maybe add a system for in-town ambient sounds if(overall_mode == MODE_TOWN) { for(int i = 0; i < univ.town.monst.size(); i++) { if(party_can_see_monst(i)) check_if_monst_seen(univ.town.monst[i].number, univ.town.monst[i].cur_loc); } return; } static const short drip[2] = {78,79}, bird[3] = {76,77,91}; if(overall_mode != MODE_OUTDOORS) return; // ambient sounds are outdoors only at the moment if(get_ran(1,1,100) > 10) return; // 10% chance per move of playing a sound short sound_to_play; switch(univ.out->ambient_sound){ case AMBIENT_DRIP: sound_to_play = get_ran(1,0,1); play_sound(-drip[sound_to_play]); break; case AMBIENT_BIRD: sound_to_play = get_ran(1,0,2); play_sound(-bird[sound_to_play]); break; case AMBIENT_CUSTOM: sound_to_play = univ.out->out_sound; play_sound(-sound_to_play); break; case AMBIENT_NONE: break; // obviously, do nothing } }
bool seek_party(short i,location l1,location l2) { bool acted_yet = false; short m,n; if ((l1.x > l2.x) && (l1.y > l2.y)) acted_yet = try_move(i,l1,-1,-1); if ((l1.x < l2.x) & (l1.y < l2.y) & (acted_yet == false)) acted_yet = try_move(i,l1,1,1); if ((l1.x > l2.x) & (l1.y < l2.y) & (acted_yet == false)) acted_yet = try_move(i,l1,-1,1); if ((l1.x < l2.x) & (l1.y > l2.y) & (acted_yet == false)) acted_yet = try_move(i,l1,1,-1); if ((l1.x > l2.x) & (acted_yet == false)) acted_yet = try_move(i,l1,-1,0); if ((l1.x < l2.x) & (acted_yet == false)) acted_yet = try_move(i,l1,1,0); if ( (l1.y < l2.y) & (acted_yet == false)) acted_yet = try_move(i,l1,0,1); if ( (l1.y > l2.y) & (acted_yet == false)) acted_yet = try_move(i,l1,0,-1); if (acted_yet == false) { futzing++; m = get_ran(1,0,2) - 1; n = get_ran(1,0,2) - 1; acted_yet = try_move(i,l1,m,n); } return acted_yet; }
// Looks at all spaces within 2, looking for a spot which is clear of nastiness and beings // returns {0,0} if none found // THIS MAKES NO ADJUSTMENTS FOR BIG MONSTERS!!! location find_clear_spot(location from_where,short mode) //mode; // 0 - normal 1 - prefer adjacent space { location loc,store_loc; short num_tries = 0,r1; while (num_tries < 75) { num_tries++; loc = from_where; r1 = get_ran(1,-2,2); loc.x = loc.x + r1; r1 = get_ran(1,-2,2); loc.y = loc.y + r1; if ((loc_off_act_area(loc) == false) && (is_blocked(loc) == false) && (can_see(from_where,loc,1) == 0) && (!(is_combat()) || (pc_there(loc) == 6)) && (!(is_town()) || (loc != univ.town.p_loc)) && (!(univ.town.misc_i(loc.x,loc.y) & 248)) && // check for crate, barrel, barrier, quickfire (!(univ.town.explored(loc.x,loc.y) & 254))) { // check for fields, clouds if ((mode == 0) || ((mode == 1) && (adjacent(from_where,loc) == true))) return loc; else store_loc = loc; } } return store_loc; }
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); } }
// returns 6 if no short select_active_pc() { short r1, num_tries = 0; r1 = get_ran(1,0,5); while ((univ.party[r1].main_status != 1) && (num_tries++ < 50)) r1 = get_ran(1,0,5); return r1; }
location random_shift(location start) { location store; store = start; store.x = store.x + get_ran(1,0,2) - 1; store.y = store.y + get_ran(1,0,2) - 1; return store; }
short get_encumberance(short pc_num) { short store = 0,i,what_val; for (i = 0; i < 24; i++) if (univ.party[pc_num].equip[i] == true) { what_val = univ.party[pc_num].items[i].awkward; if ((what_val == 1) && (get_ran(1,0,130) < hit_chance[univ.party[pc_num].skills[8]])) what_val--; if ((what_val > 1) && (get_ran(1,0,70) < hit_chance[univ.party[pc_num].skills[8]])) what_val--; store += what_val; } return store; }
void add_explosion(location dest,short val_to_place,short place_type,short boom_type,short x_adj,short y_adj) { short i; if (PSD[SDF_NO_FRILLS] > 0) return; if (boom_anim_active == false) return; // lose redundant explosions for (i = 0; i < 30; i++) if ((store_booms[i].boom_type >= 0) && (dest == store_booms[i].dest) && (place_type == 0)) { if (val_to_place > 0) store_booms[i].val_to_place = val_to_place; return; } for (i = 0; i < 30; i++) if (store_booms[i].boom_type < 0) { have_boom = true; store_booms[i].offset = (i == 0) ? 0 : -1 * get_ran(1,0,2); store_booms[i].dest = dest; store_booms[i].val_to_place = val_to_place; store_booms[i].place_type = place_type; store_booms[i].boom_type = boom_type; store_booms[i].x_adj =x_adj; store_booms[i].y_adj =y_adj; return; } }
bool cCreature::is_shielded() const { if(status[eStatus::MARTYRS_SHIELD] > 0) return true; if(abil[eMonstAbil::MARTYRS_SHIELD].active && get_ran(1,1,1000) <= abil[eMonstAbil::MARTYRS_SHIELD].special.extra1) return true; return false; }
bool cCurTown::set_quickfire(short x, short y, bool b){ if(x > record()->max_dim() || y > record()->max_dim()) return false; if(b){ // If certain things are on space, there's no room for quickfire. ter_num_t ter = record()->terrain(x,y); if(univ.scenario.ter_types[ter].blockage == eTerObstruct::BLOCK_SIGHT) return false; // TODO: Isn't it a little odd that BLOCK_MOVE_AND_SHOOT isn't included here? if(univ.scenario.ter_types[ter].blockage == eTerObstruct::BLOCK_MOVE_AND_SIGHT) return false; if(is_antimagic(x,y) && get_ran(1,0,1) == 0) return false; if(is_force_barr(x,y) || is_fire_barr(x,y)) return false; quickfire_present = true; set_force_wall(x,y,false); set_fire_wall(x,y,false); set_antimagic(x,y,false); set_scloud(x,y,false); set_ice_wall(x,y,false); set_blade_wall(x,y,false); set_sleep_cloud(x,y,false); set_web(x,y,false); set_crate(x,y,false); set_barrel(x,y,false); set_force_barr(x,y,false); set_fire_barr(x,y,false); fields[x][y] |= FIELD_QUICKFIRE; } else fields[x][y] &= ~FIELD_QUICKFIRE; return true; }
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 create_wand_monst() { short r1,r2,r3,i = 0,num_tries = 0; location p_loc; r1 = get_ran(1,0,3); if (overall_mode == MODE_OUTDOORS) if (!univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].wandering[r1].isNull()) { r2 = get_ran(1,0,3); while ((point_onscreen(univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].wandering_locs[r2], global_to_local(univ.party.p_loc))) && (num_tries++ < 100)) r2 = get_ran(1,0,3); if (!is_blocked(univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].wandering_locs[r2])) place_outd_wand_monst(univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].wandering_locs[r2], univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].wandering[r1],0); } else // won't place wandering is more than 50 monsters if ((!univ.town->wandering[r1].isNull()) && (univ.town.countMonsters() <= 50) && (univ.party.m_killed[univ.town.num] < univ.town->max_num_monst)) { r2 = get_ran(1,0,3); while (point_onscreen(univ.town->wandering_locs[r2],univ.town.p_loc) && !loc_off_act_area(univ.town->wandering_locs[r2]) && (num_tries++ < 100)) r2 = get_ran(1,0,3); for (i = 0; i < 4; i++) { if (univ.town->wandering[r1].monst[i] != 0) { // place a monster p_loc = univ.town->wandering_locs[r2]; p_loc.x += get_ran(1,0,4) - 2; p_loc.y += get_ran(1,0,4) - 2; if (!is_blocked(p_loc)) place_monster(univ.town->wandering[r1].monst[i],p_loc); } p_loc = univ.town->wandering_locs[r2]; p_loc.x += get_ran(1,0,4) - 2; p_loc.y += get_ran(1,0,4) - 2; r3 = get_ran(1,0,3); if ((r3 >= 2) && (!is_blocked(p_loc))) // place extra monsters? place_monster(univ.town->wandering[r1].monst[3],p_loc); } } }
m_num_t get_summon_monster(short summon_class) { short i,j; for (i = 0; i < 200; i++) { j = get_ran(1,0,255); if (scenario.scen_monsters[j].summon_type == summon_class) { return j; } } ASB(" Summon failed."); return 0; }
// For charm, amount is the resulting attitude of the charmed monster; if 0, attitude is 2. void cCreature::sleep(eStatus which_status,int amount,int penalty) { if(which_status != eStatus::CHARM && amount < 0) { status[which_status] -= amount; if(which_status != eStatus::ASLEEP) status[which_status] = max(0, status[which_status]); return; } if((which_status == eStatus::ASLEEP) && (m_type == eRace::UNDEAD || m_type == eRace::SKELETAL || m_type == eRace::SLIME || m_type == eRace::STONE || m_type == eRace::PLANT)) return; short r1 = get_ran(1,1,100); if(magic_res > 0) { r1 *= 100; r1 /= magic_res; } else r1 = 200; r1 += penalty; if(which_status == eStatus::FORCECAGE && (mu > 0 || cl > 0)) r1 += 5; if(which_status == eStatus::ASLEEP) r1 -= 25; if(which_status == eStatus::PARALYZED) r1 -= 15; if(which_status == eStatus::ASLEEP && abil[eMonstAbil::FIELD].active && abil[eMonstAbil::FIELD].gen.fld == eFieldType::CLOUD_SLEEP) return; if(r1 > charm_odds[level / 2]) { //one_sound(68); spell_note(10); } else { if(which_status == eStatus::CHARM) { if(amount == 0 || amount > 3) amount = 2; attitude = amount; spell_note(23); } else if(which_status == eStatus::FORCECAGE) { status[eStatus::FORCECAGE] = amount; spell_note(52); } else { status[which_status] = amount; if(which_status == eStatus::ASLEEP && (amount >= 0)) spell_note(28); if(which_status == eStatus::PARALYZED && (amount >= 0)) spell_note(30); if(amount < 0) spell_note(40); } //one_sound(53); } }
int cCreature::magic_adjust(int how_much) { if(how_much <= 0) return how_much; if(abil[eMonstAbil::ABSORB_SPELLS].active && get_ran(1,1,1000) <= abil[eMonstAbil::ABSORB_SPELLS].special.extra1) { int gain = abil[eMonstAbil::ABSORB_SPELLS].special.extra2; if(32767 - health > gain) health = 32767; else health += gain; return 0; } // TODO: Magic resistance status effect? how_much *= magic_res; how_much /= 100; return how_much; }
// Sees if party has seen a monster of this sort, gives special messages as necessary void check_if_monst_seen(unsigned short m_num, location at) { // Give special messages if necessary if(m_num < 10000 && !univ.party.m_seen.count(m_num)) { univ.party.m_seen.insert(m_num); play_see_monster_str(m_num, at); } // Make the monster vocalize if applicable snd_num_t sound = -1; if(m_num >= 10000) sound = univ.party.summons[m_num - 10000].ambient_sound; else sound = univ.scenario.scen_monsters[m_num].ambient_sound; if(sound > 0 && get_ran(1,1,100) < 10) play_sound(-sound); }
void incidental_noises(bool on_surface){ short sound_to_play; if(on_surface){ if(get_ran(1,1,100) < 40){ sound_to_play = get_ran(1,1,3); switch(sound_to_play){ case 1: play_sound(76); break; case 2: play_sound(77); break; case 3: play_sound(91); break; } } }else{ if(get_ran(1,1,100) < 40){ sound_to_play = get_ran(1,1,2); switch(sound_to_play){ case 1: play_sound(78); break; case 2: play_sound(79); break; } } } // Dog: 80 // Cat: 81 // Sheep: 82 // Cow: 83 // Chicken: 92 }
void forced_place_monster(m_num_t which,location where) { bool free_spot = false; short i = 0,r1; while ((free_spot == false) && (i < univ.town->max_monst())) { if (univ.town.monst[i].active == 0) free_spot = true; i++; } do r1 = get_ran(1,0,59); while ((univ.town.monst[r1].spec1 != 0) || (univ.town.monst[r1].spec2 != 0)); if (free_spot == false) univ.town.monst[r1].active = 0; place_monster(which,where); }
bool rand_move(char i) { bool acted_yet = false; short j; location store_loc; // first, if outdoor, just roam. if (is_out()) { store_loc = random_shift(univ.party.out_c[i].m_loc); return outdoor_move_monster(i,store_loc); } if (univ.town.monst[i].targ_loc == univ.town.monst[i].cur_loc) univ.town.monst[i].targ_loc.x = 0; // FIrst, try to move to monst_targs. If it don't work, then we'll shift. if (univ.town.monst[i].targ_loc.x > 0) acted_yet = seek_party(i,univ.town.monst[i].cur_loc,univ.town.monst[i].targ_loc); if (acted_yet == false) { univ.town.monst[i].targ_loc.x = 0; for (j = 0; j < 3; j++) { store_loc = univ.town.monst[i].cur_loc; store_loc.x += get_ran(1,0,24) - 12; store_loc.y += get_ran(1,0,24) - 12; if ((loc_off_act_area(store_loc) == false) && (can_see(univ.town.monst[i].cur_loc,store_loc,0) < 5)) { univ.town.monst[i].targ_loc = store_loc; j = 3; } } if (univ.town.monst[i].targ_loc.x == 0) { // maybe pick a wand loc, else juist pick a loc j = get_ran(1,0,3); store_loc = univ.town->wandering_locs[j]; if ((loc_off_act_area(store_loc) == false) && (get_ran(1,0,1) == 1)) univ.town.monst[i].targ_loc = store_loc; else { store_loc = univ.town.monst[i].cur_loc; store_loc.x += get_ran(1,0,20) - 10; store_loc.y += get_ran(1,0,20) - 10; if (loc_off_act_area(store_loc) == false) univ.town.monst[i].targ_loc = store_loc; } } if (univ.town.monst[i].targ_loc.x > 0) acted_yet = seek_party(i,univ.town.monst[i].cur_loc,univ.town.monst[i].targ_loc); } return acted_yet; }
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); }
short monst_pick_target_monst(cCreature *which_m) { short min_dist = 1000,i,cur_targ = 6; for (i = 0; i < univ.town->max_monst(); i++) { if ((univ.town.monst[i].active > 0) && // alive (((which_m->attitude % 2 == 1) && (univ.town.monst[i].attitude % 2 == 0)) || ((which_m->attitude % 2 == 0) && (univ.town.monst[i].attitude % 2 == 1)) || ((which_m->attitude % 2 == 1) && (univ.town.monst[i].attitude != which_m->attitude))) && // they hate each other ((dist(which_m->cur_loc,univ.town.monst[i].cur_loc) < min_dist) || ((dist(which_m->cur_loc,univ.town.monst[i].cur_loc) == min_dist) && (get_ran(1,0,7) < 4))) && (monst_can_see(i,univ.town.monst[i].cur_loc) == true) ) { min_dist = dist(which_m->cur_loc,univ.town.monst[i].cur_loc); cur_targ = i + 100; } } return cur_targ; }
void tip_of_day() { char place_str[256]; store_tip_page_on = get_ran(1,0,NUM_HINTS - 1); SetCursor(sword_curs); cd_create_dialog_parent_num(958,0); GetIndString(place_str,12,50 + store_tip_page_on); csit(958,3, place_str); cd_set_led(958,7,give_intro_hint); while (dialog_not_toast) ModalDialog(); cd_kill_dialog(958,0); build_data_file(2); }
void charm_monst(cCreature *which_m,short penalty,short which_status,short amount) // Also used for sleep and paralyze, which_statys is 0 means charm { short r1; if ((which_status == 11) && ((which_m->m_type == 8) || (which_m->m_type == 10) || (which_m->m_type == 11))) return; r1 = get_ran(1,1,100); if (which_m->immunities & 1) r1 = r1 * 2; if (which_m->immunities & 2) r1 = 200; r1 += penalty; if (which_status == 11) r1 -= 25; if (which_status == 12) r1 -= 15; if ((which_status == 11) && (which_m->spec_skill == 32)) return; if (r1 > charm_odds[which_m->level / 2]) { //one_sound(68); monst_spell_note(which_m->number,10); } else { if (which_status == 0) { which_m->attitude = 2; monst_spell_note(which_m->number,23); } else { which_m->status[which_status] = amount; if (which_status == 11) monst_spell_note(which_m->number,28); if (which_status == 12) monst_spell_note(which_m->number,30); } //one_sound(53); } }
bool cCurTown::set_force_barr(short x, short y, bool b){ if(x > record()->max_dim() || y > record()->max_dim()) return false; if(b){ // If certain things are on the space, there's no room for a barrier. if(is_fire_barr(x,y) || is_barrel(x,y) || is_quickfire(x,y) || is_crate(x,y)) return false; if(is_antimagic(x,y) && get_ran(1,0,2) < 2) return false; // Cancel out fields set_web(x,y,false); set_force_wall(x,y,false); set_fire_wall(x,y,false); set_antimagic(x,y,false); set_scloud(x,y,false); set_ice_wall(x,y,false); set_blade_wall(x,y,false); set_sleep_cloud(x,y,false); fields[x][y] |= BARRIER_FORCE; } else fields[x][y] &= ~BARRIER_FORCE; return true; }
void move_sound(ter_num_t ter,short step){ static bool on_swamp = false; short pic; eTerSpec spec; pic = univ.scenario.ter_types[ter].picture; spec = univ.scenario.ter_types[ter].special; eStepSnd snd = univ.scenario.ter_types[ter].step_sound; // if on swamp don't play squish sound : BoE legacy behavior, can be removed safely if(snd == eStepSnd::SPLASH && !flying() && univ.party.in_boat < 0){ if(on_swamp && get_ran(1,1,100) >= 10) return; on_swamp = true; } else on_swamp = false; if(!monsters_going && (overall_mode < MODE_COMBAT) && (univ.party.in_boat >= 0)) { if(spec == eTerSpec::TOWN_ENTRANCE) return; play_sound(48); //play boat sound } else if(!monsters_going && (overall_mode < MODE_COMBAT) && (univ.party.in_horse >= 0)) { play_sound(85); //so play horse sound } else switch(univ.scenario.ter_types[ter].step_sound){ case eStepSnd::SQUISH: play_sound(55); break; case eStepSnd::CRUNCH: play_sound(47); break; case eStepSnd::NONE: break; case eStepSnd::SPLASH: play_sound(17); break; case eStepSnd::STEP: if(step % 2 == 0) //footsteps alternate sound play_sound(49); else play_sound(50); } }
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); }
Boolean handle_menu (short item, HMENU) { short i,j,k; Boolean to_return = FALSE; item_record_type store_i; if ((file_in_mem == FALSE) && ((item == 1) || (item == 3) || (item >= 40)) && (item != 200) && (item != 100)) { display_strings(20,5,0,0,"Editing party",57,707,0); item = -1; } switch (item) { case -1: break; case 1: save_file(0); break; case 2: if (verify_restore_quit(1) == TRUE) load_file(); update_item_menu(item_menus_lock); break; case 3: save_file(1); break; case 4: All_Done = verify_restore_quit(0); break; case 41: edit_gold_or_food(0); redraw_screen(); break; case 42: edit_gold_or_food(1); redraw_screen(); break; case 44: if (party.stuff_done[304][0] > 0) { FCD(909,0); break; } FCD(901,0); leave_town(); break; case 45: if (party.stuff_done[304][0] == 0) { FCD(911,0); break; } FCD(910,0); c_town.p_loc.x = party.stuff_done[304][1]; c_town.p_loc.y = party.stuff_done[304][2]; party.stuff_done[304][0] = 0; for (i = 0; i < 6; i++) if (adven[i].main_status >= 10) adven[i].main_status -= 10; redraw_screen(); break; case 48: display_strings(20,20,0,0,"Editing party",57,707,0); for (i = 0; i < 4; i++) party.creature_save[i].which_town = 200; break; case 51: // damage display_strings(20,1,0,0,"Editing party",57,715,0); for (i = 0; i < 6; i++) adven[i].cur_health = adven[i].max_health; redraw_screen(); break; case 52: // spell pts display_strings(20,2,0,0,"Editing party",57,715,0); for (i = 0; i < 6; i++) adven[i].cur_sp = adven[i].max_sp; redraw_screen(); break; case 53: // raise dead display_strings(20,3,0,0,"Editing party",57,715,0); for (i = 0; i < 6; i++) if ((adven[i].main_status == 2) || (adven[i].main_status == 3) || (adven[i].main_status == 4)) adven[i].main_status = 1; redraw_screen(); break; case 54: // conditions display_strings(20,4,0,0,"Editing party",57,715,0); for (i = 0; i < 6; i++) { adven[i].status[2] = 0; if (adven[i].status[3] < 0) adven[i].status[3] = 0; adven[i].status[6] = 0; adven[i].status[7] = 0; adven[i].status[9] = 0; adven[i].status[11] = 0; adven[i].status[12] = 0; adven[i].status[13] = 0; } redraw_screen(); break; case 55: if (party_in_scen == FALSE) { display_strings(20,25,0,0,"Editing party",57,715,0); break; } if (FCD(912,0) != 1) break; remove_party_from_scen(); party.stuff_done[304][0] = 0; redraw_screen(); break; case 62: display_alchemy(); break; case 63: // all property display_strings(20,6,0,0,"Editing party",57,707,0); for (i = 0; i < 30; i++) { party.boats[i].property = FALSE; party.horses[i].property = FALSE; } break; case 70: // edit day edit_day(); break; case 71: // out maps if (party_in_scen == FALSE) { display_strings(20,25,0,0,"Editing party",57,715,0); break; } display_strings(20,13,0,0,"Editing party",57,715,0); for (i = 0; i < 96; i++) for (j = 0; j < 96; j++) out_e[i][j] = 1; for (i = 0; i < 100; i++) for (j = 0; j < 6; j++) for (k = 0; k < 48; k++) o_maps.outdoor_maps[i][j][k] = 255; break; case 72: // town maps if (party_in_scen == FALSE) { display_strings(20,25,0,0,"Editing party",57,715,0); break; } display_strings(20,14,0,0,"Editing party",57,715,0); for (i = 0; i < 64; i++) for (j = 0; j < 64; j++) c_town.explored[i][j] = 1; for (i = 0; i < 200; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++) town_maps.town_maps[i][j][k] = 255; break; case 100: // index WinHelp(mainPtr,"Blades of Exile.hlp",HELP_CONTENTS,0L); break; case 200: // about FCD(1062,0); break; default: item -= 600; store_i = scen_item_list.scen_items[item]; if(store_i.variety == 3){ party.gold += get_ran(1,1,20); redraw_screen(); break; } if(store_i.variety == 11){ party.food += get_ran(1,1,20); redraw_screen(); break; } give_to_pc(current_active_pc,store_i,FALSE); draw_items(1); break; } return to_return; }