// All purpose function to check is spot is free for travel into. bool is_blocked(location to_check) { short i,gr; ter_num_t ter; if(is_out()) { if(impassable(univ.out[to_check.x][to_check.y])) { return true; } if(to_check == univ.party.p_loc) return true; for(i = 0; i < univ.party.out_c.size(); i++) if((univ.party.out_c[i].exists)) if(univ.party.out_c[i].m_loc == to_check) return true; return false; } if((is_town()) || (is_combat())) { ter = univ.town->terrain(to_check.x,to_check.y); gr = univ.scenario.ter_types[ter].picture; // Terrain blocking? if(impassable(ter)) { return true; } // Keep away from marked specials during combat if((is_combat()) && univ.town.is_spot(to_check.x, to_check.y)) return true; if((is_combat()) && (univ.scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].trim_type == eTrimType::CITY)) return true; // TODO: Maybe replace eTrimType::CITY with a blockage == clear/special && is_special() check // Note: The purpose of the above check is to avoid portals. // Party there? if(is_town()) if(to_check == univ.town.p_loc) return true; if(is_combat()) for(i = 0; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ALIVE && to_check == univ.party[i].combat_pos) return true; // Monster there? if(univ.target_there(to_check, TARG_MONST)) return true; // Magic barrier? if(univ.town.is_force_barr(to_check.x,to_check.y)) return true; if(univ.town.is_force_cage(to_check.x,to_check.y)) return true; return false; } return true; }
// 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; }
bool combat_move_monster(short which,location destination) { if (monst_can_be_there(destination,which) == false) return false; else if (monst_check_special_terrain(destination,2,which) == false) return false; else { univ.town.monst[which].direction = set_direction(univ.town.monst[which].cur_loc, destination); univ.town.monst[which].cur_loc = destination; monst_inflict_fields(which); if (point_onscreen(destination,center) == true) { if (is_combat()) move_sound(combat_terrain[destination.x][destination.y], (short) univ.town.monst[which].ap); else move_sound(univ.town->terrain(destination.x,destination.y), (short) univ.town.monst[which].ap); } return true; } return false; }
short sight_obscurity(short x,short y) { ter_num_t what_terrain; short store; what_terrain = coord_to_ter(x,y); // TODO: This should not be hard-coded! // It appears to refer to mountain cave entrances, surface tower, and surface pit. (WHY?) if((what_terrain >= 237) && (what_terrain <= 242)) return 1; store = get_blockage(what_terrain); if(is_town()) { if(univ.town.is_special(x,y)) store++; } if((is_town()) || (is_combat())) { if(univ.town.is_web(x,y)) store += 2; if((univ.town.is_fire_barr(x,y)) || (univ.town.is_force_barr(x,y))) return 5; if(univ.town.is_crate(x,y) || univ.town.is_barrel(x,y) || univ.town.is_block(x,y)) store++; } return store; }
void apply_unseen_mask() { Rect base_rect = {9,9,53,45},to_rect,big_to = {13,13,337,265}; GrafPtr old_port; short i,j,k,l; ConstPatternParam c; bool need_bother = false; if (PSD[SDF_NO_FRILLS] > 0) return; if ((is_combat()) && (which_combat_type == 0)) return; if (!(is_out()) && (univ.town->lighting_type > 0)) return; for (i = 0; i < 11; i++) for (j = 0; j < 11; j++) if (unexplored_area[i + 1][j + 1] == 1) need_bother = true; if (need_bother == false) return; GetPort(&old_port); SetPort(terrain_screen_gworld); //p = *bw_pats[3]; //c = p; c = *bw_pats[3]; PenPat(c); PenMode(notPatOr); for (i = 0; i < 11; i++) for (j = 0; j < 11; j++) if (unexplored_area[i + 1][j + 1] == 1) { to_rect = base_rect; OffsetRect(&to_rect,-28 + i * 28,-36 + 36 * j); SectRect(&to_rect,&big_to,&to_rect); PaintRect(&to_rect); //PaintRoundRect(&to_rect,4,4); for (k = i - 2; k < i + 1; k++) for (l = j - 2; l < j + 1; l++) if ((k >= 0) && (l >= 0) && (k < 9) && (l < 9) && ((k != i - 1) || (l != j - 1))) terrain_there[k][l] = -1; } //p = *bw_pats[6]; //c = p; c = *bw_pats[6]; PenPat(c); PenMode(patCopy); SetPort(old_port); }
short light_radius() { short store = 1,i; short extra_levels[6] = {10,20,50,75,110,140}; if(((which_combat_type == 0) && (is_combat())) || (is_out()) || (univ.town->lighting_type == 0)) return 200; for(i = 0; i < 6; i++) if(univ.party.light_level > extra_levels[i]) store++; return store; }
// TODO: What on earth is this and why does it mangle the blockage? // NOTE: Seems to return 5 for "blocks sight", 1 for "obstructs missiles", 0 otherwise // So it should probably be called something like "get_opacity" instead. short get_blockage(ter_num_t terrain_type) { // little kludgy in here for pits if((terrain_type == 90) && (is_combat()) && (which_combat_type == 0)) return 5; if(univ.scenario.ter_types[terrain_type].blockage == eTerObstruct::BLOCK_MOVE_AND_SIGHT || univ.scenario.ter_types[terrain_type].blockage == eTerObstruct::BLOCK_SIGHT) return 5; else if(univ.scenario.ter_types[terrain_type].blockage == eTerObstruct::BLOCK_MOVE_AND_SHOOT) return 1; else { return 0; } }
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; }
short switch_target_to_adjacent(short which_m,short orig_target) { location monst_loc; short i,num_adj = 0; monst_loc = univ.town.monst[which_m].cur_loc; // First, take care of friendly monsters. if (univ.town.monst[which_m].attitude % 2 == 0) { if (orig_target >= 100) if ((univ.town.monst[orig_target - 100].active > 0) && (monst_adjacent(univ.town.monst[orig_target - 100].cur_loc,which_m) == true)) return orig_target; for (i = 0; i < univ.town->max_monst(); i++) if ((univ.town.monst[i].active > 0) && (univ.town.monst[i].attitude % 2 == 1) && (monst_adjacent(univ.town.monst[i].cur_loc,which_m) == true)) return i + 100; return orig_target; } // If we get here while in town, just need to check if switch to pc if ((is_town()) && (monst_adjacent(univ.town.p_loc,which_m) == true)) return 0; if (is_town()) return orig_target; // If target is already adjacent, we're done here. if ((is_combat()) && (orig_target < 6)) if ((univ.party[orig_target].main_status == 1) && (monst_adjacent(pc_pos[orig_target],which_m) == true)) return orig_target; if (orig_target >= 100) if ((univ.town.monst[orig_target - 100].active > 0) && (monst_adjacent(univ.town.monst[orig_target - 100].cur_loc,which_m) == true)) return orig_target; // Anyone unarmored? Heh heh heh... if (is_combat()) for (i = 0; i < 6; i++) if ((univ.party[i].main_status == 1) && (monst_adjacent(pc_pos[i],which_m) == true) && (get_encumberance(i) < 2)) return i; // Check for a nice, adjacent, friendly monster and maybe attack for (i = 0; i < univ.town->max_monst(); i++) if ((univ.town.monst[i].active > 0) && (univ.town.monst[i].attitude % 2 == 0) && (monst_adjacent(univ.town.monst[i].cur_loc,which_m) == true) && (get_ran(1,0,2) < 2)) return i + 100; // OK. Now if this monster has PCs adjacent, pick one at randomn and hack. Otherwise, // stick with orig. target. for (i = 0; i < 6; i++) if ((univ.party[i].main_status == 1) && (monst_adjacent(pc_pos[i],which_m) == true)) num_adj++; if (num_adj == 0) return orig_target; i = 0; num_adj = get_ran(1,1,num_adj); while ((num_adj > 1) || (univ.party[i].main_status != 1) || (monst_adjacent(pc_pos[i],which_m) == false)) { if ((univ.party[i].main_status == 1) && (monst_adjacent(pc_pos[i],which_m) == true)) num_adj--; i++; } return i; }
short monst_pick_target(short which_m) { cCreature *cur_monst; short targ_pc,targ_m; cur_monst = &univ.town.monst[which_m]; // First, any chance target is screwed? if (univ.town.monst[which_m].target >= 100) { if (((cur_monst->attitude % 2 == 1) && (univ.town.monst[univ.town.monst[which_m].target - 100].attitude == cur_monst->attitude)) || ((cur_monst->attitude % 2 == 0) && (univ.town.monst[univ.town.monst[which_m].target - 100].attitude % 2 == 0))) univ.town.monst[which_m].target = 6; else if (univ.town.monst[univ.town.monst[which_m].target - 100].active == 0) univ.town.monst[which_m].target = 6; } if (univ.town.monst[which_m].target < 6) if ((univ.party[univ.town.monst[which_m].target].main_status != 1) || (get_ran(1,0,3) == 1)) univ.town.monst[which_m].target = 6; if ((is_combat()) && (cur_monst->attitude % 2 == 1)) { if (spell_caster < 6) if ((get_ran(1,1,5) < 5) && (monst_can_see(which_m,pc_pos[spell_caster]) == true) && (univ.party[spell_caster].main_status == 1)) return spell_caster; if (missile_firer < 6) if ((get_ran(1,1,5) < 3) && (monst_can_see(which_m,pc_pos[missile_firer]) == true) && (univ.party[missile_firer].main_status == 1)) return missile_firer; if (univ.town.monst[which_m].target < 6) if ((monst_can_see(which_m,pc_pos[univ.town.monst[which_m].target]) == true) && (univ.party[univ.town.monst[which_m].target].main_status == 1)) return univ.town.monst[which_m].target; } // if (monst_target[which_m] >= 100) { // if ((can_see(cur_monst->m_loc,univ.town.monst[monst_target[which_m] - 100].m_loc,0) < 4) // && (univ.town.monst[monst_target[which_m] - 100].active > 0)) // return monst_target[which_m]; // } // Now pick a target pc and a target monst and see which is more attractive targ_pc = monst_pick_target_pc(which_m,cur_monst); targ_m = monst_pick_target_monst(cur_monst); if ((targ_pc != 6) && (targ_m == 6)) return targ_pc; if ((targ_pc == 6) && (targ_m != 6)) return targ_m; if ((targ_pc == 6) && (targ_m == 6)) return 6; if (is_town()) { if (cur_monst->attitude % 2 == 0) { return targ_m; } if ((targ_m == 6) && (cur_monst->attitude % 2 == 1)) return 0; if (dist(cur_monst->cur_loc,univ.town.monst[targ_m - 100].cur_loc) < dist(cur_monst->cur_loc,univ.town.p_loc)) return targ_m; else return 0; } // Otherwise we're in combat if ((dist(cur_monst->cur_loc,univ.town.monst[targ_m - 100].cur_loc) == dist(cur_monst->cur_loc,pc_pos[targ_pc])) && (get_ran(1,0,6) < 3)) return targ_m; else return targ_pc; if (dist(cur_monst->cur_loc,univ.town.monst[targ_m - 100].cur_loc) < dist(cur_monst->cur_loc,pc_pos[targ_pc])) return targ_m; else return targ_pc; }
void draw_party_symbol(location center) { rectangle source_rect; location target(4,4); short i = 0; if(!can_draw_pcs) return; if(!univ.party.is_alive()) return; if((is_town()) && (univ.town.p_loc.x > 70)) return; if(overall_mode == MODE_LOOK_TOWN || cartoon_happening) { target.x += univ.town.p_loc.x - center.x; target.y += univ.town.p_loc.y - center.y; } if((univ.party.in_boat < 0) && (univ.party.in_horse < 0)) { i = first_active_pc(); sf::Texture* from_gw; pic_num_t pic = univ.party[i].which_graphic; if(pic >= 1000) { bool isParty = pic >= 10000; pic_num_t need_pic = pic % 1000; if(univ.party.direction >= 4) need_pic++; graf_pos_ref(from_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty); } else if(pic >= 100) { // Note that we assume it's a 1x1 graphic. // PCs can't be larger than that, but we leave it to the scenario designer to avoid assigning larger graphics. pic_num_t need_pic = pic - 100; int mode = 0; if(univ.party.direction >= 4) mode++; source_rect = get_monster_template_rect(need_pic, mode, 0); int which_sheet = m_pic_index[need_pic].i / 20; from_gw = ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)).get(); } else { source_rect = calc_rect(2 * (pic / 8), pic % 8); if(univ.party.direction >= 4) source_rect.offset(28,0); from_gw = ResMgr::get<ImageRsrc>("pcs").get(); } ter_num_t ter = 0; if(is_out()) ter = univ.out[univ.party.p_loc.x][univ.party.p_loc.y]; else if(is_town() || is_combat()) ter = univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y); // now wedge in bed graphic if(is_town() && univ.scenario.ter_types[ter].special == eTerSpec::BED) draw_one_terrain_spot((short) target.x,(short) target.y,10000 + univ.scenario.ter_types[ter].flag1); else Draw_Some_Item(*from_gw, source_rect, terrain_screen_gworld, target, 1, 0); } else if(univ.party.in_boat >= 0) { if(univ.party.direction == DIR_N) i = 2; else if(univ.party.direction == DIR_S) i = 3; else i = univ.party.direction > DIR_S; Draw_Some_Item(*ResMgr::get<ImageRsrc>("vehicle"), calc_rect(i,0), terrain_screen_gworld, target, 1, 0); }else { i = univ.party.direction > 3; Draw_Some_Item(*ResMgr::get<ImageRsrc>("vehicle"), calc_rect(i + 2, 1), terrain_screen_gworld, target, 1, 0); } }
void draw_monsters() { short i,j = 0,k; short width,height; rectangle source_rect,to_rect; location where_draw,store_loc; ter_num_t ter; rectangle monst_rects[4][4] = { {{0,0,36,28}}, {{0,7,18,21},{18,7,36,21}}, {{9,0,27,14},{9,14,27,28}}, {{0,0,18,14},{0,14,18,28},{18,0,36,14},{18,14,36,28}} }; if(is_out()) for(i = 0; i < 10; i++) if(univ.party.out_c[i].exists) { if((point_onscreen(univ.party.p_loc, univ.party.out_c[i].m_loc)) && (can_see_light(univ.party.p_loc, univ.party.out_c[i].m_loc,sight_obscurity) < 5)) { where_draw.x = univ.party.out_c[i].m_loc.x - univ.party.p_loc.x + 4; where_draw.y = univ.party.out_c[i].m_loc.y - univ.party.p_loc.y + 4; for(j = 0; univ.party.out_c[i].what_monst.monst[j] == 0 && j < 7; j++); short picture_wanted; if(j == 7) univ.party.out_c[i].exists = false; // begin watch out else { picture_wanted = get_monst_picnum(univ.party.out_c[i].what_monst.monst[j]); } // end watch out if(univ.party.out_c[i].exists) { get_monst_dims(univ.party.out_c[i].what_monst.monst[j],&width,&height); if(picture_wanted >= 1000) { for(k = 0; k < width * height; k++) { sf::Texture* src_gw; graf_pos_ref(src_gw, source_rect) = spec_scen_g.find_graphic(picture_wanted % 1000 + ((univ.party.out_c[i].direction < 4) ? 0 : (width * height)) + k); to_rect = monst_rects[(width - 1) * 2 + height - 1][k]; to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y); rect_draw_some_item(*src_gw, source_rect, terrain_screen_gworld,to_rect, sf::BlendAlpha); } } if(picture_wanted < 1000) { for(k = 0; k < width * height; k++) { source_rect = get_monster_template_rect(picture_wanted,(univ.party.out_c[i].direction < 4) ? 0 : 1,k); to_rect = monst_rects[(width - 1) * 2 + height - 1][k]; to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y); int which_sheet = m_pic_index[picture_wanted].i / 20; sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)); rect_draw_some_item(monst_gworld, source_rect, terrain_screen_gworld,to_rect, sf::BlendAlpha); } } } } } if(is_town() || is_combat()) { for(i = 0; i < univ.town.monst.size(); i++) if(univ.town.monst[i].active != 0 && !univ.town.monst[i].invisible && univ.town.monst[i].status[eStatus::INVISIBLE] <= 0) if(point_onscreen(center,univ.town.monst[i].cur_loc) && party_can_see_monst(i)) { where_draw.x = univ.town.monst[i].cur_loc.x - center.x + 4; where_draw.y = univ.town.monst[i].cur_loc.y - center.y + 4; get_monst_dims(univ.town.monst[i].number,&width,&height); for(k = 0; k < width * height; k++) { store_loc = where_draw; store_loc.x += k % width; store_loc.y += k / width; ter = univ.town->terrain(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y); // in bed? if(store_loc.x >= 0 && store_loc.x < 9 && store_loc.y >= 0 && store_loc.y < 9 && (univ.scenario.ter_types[ter].special == eTerSpec::BED) && isHumanoid(univ.town.monst[i].m_type) && (univ.town.monst[i].active == 1 || univ.town.monst[i].target == 6) && width == 1 && height == 1) draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + univ.scenario.ter_types[ter].flag1); else if(univ.town.monst[i].picture_num >= 1000) { bool isParty = univ.town.monst[i].picture_num >= 10000; sf::Texture* src_gw; pic_num_t need_pic = (univ.town.monst[i].picture_num % 1000) + k; if(univ.town.monst[i].direction >= 4) need_pic += width * height; if(combat_posing_monster == i + 100) need_pic += (2 * width * height); graf_pos_ref(src_gw, source_rect) = spec_scen_g.find_graphic(need_pic, isParty); Draw_Some_Item(*src_gw, source_rect, terrain_screen_gworld, store_loc, 1, 0); } else { pic_num_t this_monst = univ.town.monst[i].picture_num; int pic_mode = (univ.town.monst[i].direction) < 4 ? 0 : 1; pic_mode += (combat_posing_monster == i + 100) ? 10 : 0; source_rect = get_monster_template_rect(this_monst, pic_mode, k); int which_sheet = m_pic_index[this_monst].i / 20; sf::Texture& monst_gworld = *ResMgr::get<ImageRsrc>("monst" + std::to_string(1 + which_sheet)); Draw_Some_Item(monst_gworld, source_rect, terrain_screen_gworld, store_loc, 1, 0); } } } } }
short can_see_light(location p1, location p2, std::function<short(short,short)> get_obscurity) { if(is_combat() && !combat_pt_in_light(p2)) return 6; else if(is_town() && !pt_in_light(p1,p2)) return 6; return can_see(p1, p2, get_obscurity); }
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); }