void mission_start::place_priest_diary(game *g, mission *miss) { point place; int city_id = g->cur_om->closest_city( g->om_location() ); place = g->cur_om->random_house_in_city(city_id); miss->target = place; for (int x = place.x - 2; x <= place.x + 2; x++) { for (int y = place.y - 2; y <= place.y + 2; y++) g->cur_om->seen(x, y, 0) = true; } tinymap compmap(&(g->itypes), &(g->mapitems), &(g->traps)); compmap.load(g, place.x * 2, place.y * 2, 0, false); point comppoint; std::vector<point> valid; for (int x = 0; x < SEEX * 2; x++) { for (int y = 0; y < SEEY * 2; y++) { if (compmap.furn(x, y) == f_bed || compmap.furn(x, y) == f_dresser || compmap.furn(x, y) == f_indoor_plant || compmap.furn(x, y) == f_cupboard) { valid.push_back( point(x, y) ); } } } if (valid.empty()) comppoint = point( rng(6, SEEX * 2 - 7), rng(6, SEEY * 2 - 7) ); else comppoint = valid[rng(0, valid.size() - 1)]; compmap.spawn_item(comppoint.x, comppoint.y, "priest_diary", 0); compmap.save(g->cur_om, int(g->turn), place.x * 2, place.y * 2, 0); }
void mission_start::place_deposit_box(game *g, mission *miss) { npc *p = g->find_npc(miss->npc_id); p->attitude = NPCATT_FOLLOW;//npc joins you int dist = 0; point site = g->cur_om->find_closest(g->om_location(), ot_bank_north, 1, dist, false); if (site.x == -1 && site.y == -1 ) site = g->cur_om->find_closest(g->om_location(), ot_bank_south, 1, dist, false); if (site.x == -1 && site.y == -1) site = g->cur_om->find_closest(g->om_location(), ot_bank_east, 1, dist, false); if (site.x == -1 && site.y == -1) site = g->cur_om->find_closest(g->om_location(), ot_bank_west, 1, dist, false); if (site.x == -1 && site.y == -1) site = g->cur_om->find_closest(g->om_location(), ot_office_tower_1, 1, dist, false); miss->target = site; for (int x = site.x - 2; x <= site.x + 2; x++) { for (int y = site.y - 2; y <= site.y + 2; y++) g->cur_om->seen(x, y, 0) = true; } tinymap compmap(&(g->itypes), &(g->mapitems), &(g->traps)); compmap.load(g, site.x * 2, site.y * 2, 0, false); point comppoint; std::vector<point> valid; for (int x = 0; x < SEEX * 2; x++) { for (int y = 0; y < SEEY * 2; y++) { if (compmap.ter(x, y) == t_floor) { bool okay = false; for (int x2 = x - 1; x2 <= x + 1 && !okay; x2++) { for (int y2 = y - 1; y2 <= y + 1 && !okay; y2++) { if (compmap.ter(x2, y2) == t_wall_metal_h|| compmap.ter(x2, y2) == t_wall_metal_v) { okay = true; valid.push_back( point(x, y) ); } } } } } } if (valid.empty()) comppoint = point( rng(6, SEEX * 2 - 7), rng(6, SEEY * 2 - 7) ); else comppoint = valid[rng(0, valid.size() - 1)]; compmap.spawn_item(comppoint.x, comppoint.y, "safe_box", 0); compmap.save(g->cur_om, int(g->turn), site.x * 2, site.y * 2, 0); }
void mission_start::place_npc_software(game *g, mission *miss) { npc* dev = g->find_npc(miss->npc_id); if (dev == NULL) { debugmsg("Couldn't find NPC! %d", miss->npc_id); return; } g->u.i_add( item(g->itypes["usb_drive"], 0) ); g->add_msg("%s gave you a USB drive.", dev->name.c_str()); oter_id ter = ot_house_north; switch (dev->myclass) { case NC_HACKER: miss->item_id = "software_hacking"; break; case NC_DOCTOR: miss->item_id = "software_medical"; ter = ot_s_pharm_north; miss->follow_up = MISSION_GET_ZOMBIE_BLOOD_ANAL; break; case NC_SCIENTIST: miss->item_id = "software_math"; break; default: miss->item_id = "software_useless"; } int dist = 0; point place; if (ter == ot_house_north) { int city_id = g->cur_om->closest_city( g->om_location() ); place = g->cur_om->random_house_in_city(city_id); } else place = g->cur_om->find_closest(g->om_location(), ter, 4, dist, false); miss->target = place; // Make it seen on our map for (int x = place.x - 6; x <= place.x + 6; x++) { for (int y = place.y - 6; y <= place.y + 6; y++) g->cur_om->seen(x, y, 0) = true; } tinymap compmap(&(g->itypes), &(g->mapitems), &(g->traps)); compmap.load(g, place.x * 2, place.y * 2, 0, false); point comppoint; switch (g->cur_om->ter(place.x, place.y, 0)) { case ot_house_north: case ot_house_east: case ot_house_west: case ot_house_south: { std::vector<point> valid; for (int x = 0; x < SEEX * 2; x++) { for (int y = 0; y < SEEY * 2; y++) { if (compmap.ter(x, y) == t_floor) { bool okay = false; for (int x2 = x - 1; x2 <= x + 1 && !okay; x2++) { for (int y2 = y - 1; y2 <= y + 1 && !okay; y2++) { if (compmap.ter(x2, y2) == t_bed || compmap.ter(x2, y2) == t_dresser) { okay = true; valid.push_back( point(x, y) ); } } } } } } if (valid.empty()) comppoint = point( rng(6, SEEX * 2 - 7), rng(6, SEEY * 2 - 7) ); else comppoint = valid[rng(0, valid.size() - 1)]; } break; case ot_s_pharm_north: { bool found = false; for (int x = SEEX * 2 - 1; x > 0 && !found; x--) { for (int y = SEEY * 2 - 1; y > 0 && !found; y--) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } break; case ot_s_pharm_east: { bool found = false; for (int x = 0; x < SEEX * 2 && !found; x++) { for (int y = SEEY * 2 - 1; y > 0 && !found; y--) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } break; case ot_s_pharm_south: { bool found = false; for (int x = 0; x < SEEX * 2 && !found; x++) { for (int y = 0; y < SEEY * 2 && !found; y++) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } break; case ot_s_pharm_west: { bool found = false; for (int x = SEEX * 2 - 1; x > 0 && !found; x--) { for (int y = 0; y < SEEY * 2 && !found; y++) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } break; } std::stringstream compname; compname << dev->name << "'s Terminal"; compmap.ter_set(comppoint.x, comppoint.y, t_console); computer *tmpcomp = compmap.add_computer(comppoint.x, comppoint.y, compname.str(), 0); tmpcomp->mission_id = miss->uid; tmpcomp->add_option("Download Software", COMPACT_DOWNLOAD_SOFTWARE, 0); compmap.save(g->cur_om, int(g->turn), place.x * 2, place.y * 2, 0); }