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; }
// 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 monst_can_be_there(location loc,short m_num) { short i,j; location destination; // First clear monst away so it doesn't block itself univ.town.monst[m_num].cur_loc.x += 100; for(i = 0; i < univ.town.monst[m_num].x_width; i++) for(j = 0; j < univ.town.monst[m_num].y_width; j++) { destination.x = loc.x + i; destination.y = loc.y + j; if((is_blocked(destination)) || (loc_off_act_area(destination))) { univ.town.monst[m_num].cur_loc.x -= 100; return false; } } univ.town.monst[m_num].cur_loc.x -= 100; return true; }
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); } } }
location push_loc(location from_where,location to_where) { location loc_to_try; loc_to_try = to_where; loc_to_try.x = loc_to_try.x + (to_where.x - from_where.x); loc_to_try.y = loc_to_try.y + (to_where.y - from_where.y); if((univ.town->terrain(loc_to_try.x,loc_to_try.y) == 90) || ((univ.town->terrain(loc_to_try.x,loc_to_try.y) >= 50)&& (univ.town->terrain(loc_to_try.x,loc_to_try.y) <= 64)) || (univ.town->terrain(loc_to_try.x,loc_to_try.y) == 71) || ((univ.town->terrain(loc_to_try.x,loc_to_try.y) >= 74)&& (univ.town->terrain(loc_to_try.x,loc_to_try.y) <= 78)) ) { // Destroy crate loc_to_try.x = 0; return loc_to_try; } if(sight_obscurity(loc_to_try.x,loc_to_try.y) > 0 || univ.scenario.ter_types[univ.town->terrain(loc_to_try.x,loc_to_try.y)].blockage != eTerObstruct::CLEAR || (loc_off_act_area(loc_to_try)) || univ.target_there(loc_to_try)) return from_where; else return loc_to_try; }