/* * do_post: * Put a trading post room and stuff on the screen */ void do_post() { struct coord tp; int i; struct room *rp; struct object *op; struct linked_list *ll; free_list(lvl_obj); /* throw old items away */ for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) { rp->r_goldval = 0; /* no gold */ rp->r_nexits = 0; /* no exits */ rp->r_flags = ISGONE; /* kill all rooms */ } rp = &rooms[0]; /* point to only room */ rp->r_flags = 0; /* this room NOT gone */ rp->r_max.x = 40; rp->r_max.y = 10; /* 10 * 40 room */ rp->r_pos.x = (COLS - rp->r_max.x) / 2; /* center horizontal */ rp->r_pos.y = 1; /* 2nd line */ draw_room(rp); /* draw the only room */ i = roll(4, 10); /* 10 to 40 items */ for (; i > 0; i--) { /* place all the items */ ll = new_thing(FALSE, ANYTHING); /* get something */ attach(lvl_obj, ll); op = OBJPTR(ll); setoflg(op, ISPOST); /* object in trading post */ tp = *rnd_pos(rp); op->o_pos = tp; mvaddch(tp.y, tp.x, op->o_type); } trader = 0; wmove(cw, 12, 0); waddstr(cw, "Welcome to Friendly Fiend's Flea Market\n\r"); waddstr(cw, "=======================================\n\r"); waddstr(cw, "$: Prices object that you stand upon.\n\r"); waddstr(cw, "#: Buys the object that you stand upon.\n\r"); waddstr(cw, "%: Trades in something in your pack for gold.\n\r"); trans_line(); }
void give_pack(THING *tp) { if (level >= max_level && rnd(100) < monsters[tp->t_type-'A'].m_carry) attach(tp->t_pack, new_thing()); }
do_rooms() { register int i; register struct room *rp; register struct linked_list *item; register struct thing *tp; register int left_out; coord top; coord bsze; coord mp; /* * bsze is the maximum room size */ bsze.x = cols()/3; bsze.y = lines()/3; /* * Clear things for a new level */ for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) rp->r_goldval = rp->r_nexits = rp->r_flags = 0; /* * Put the gone rooms, if any, on the level */ left_out = rnd(4); for (i = 0; i < left_out; i++) rooms[rnd_room()].r_flags |= ISGONE; /* * dig and populate all the rooms on the level */ for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++) { /* * Find upper left corner of box that this room goes in */ top.x = (i%3)*bsze.x + 1; top.y = i/3*bsze.y; if (rp->r_flags & ISGONE) { /* * Place a gone room. Make certain that there is a blank line * for passage drawing. */ do { rp->r_pos.x = top.x + rnd(bsze.x-2) + 1; rp->r_pos.y = top.y + rnd(bsze.y-2) + 1; rp->r_max.x = -cols(); rp->r_max.x = -lines(); } until(rp->r_pos.y > 0 && rp->r_pos.y < lines()-1); continue; } if (rnd(10) < level-1) rp->r_flags |= ISDARK; /* * Find a place and size for a random room */ do { rp->r_max.x = rnd(bsze.x - 4) + 4; rp->r_max.y = rnd(bsze.y - 4) + 4; rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x); rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y); } until (rp->r_pos.y != 0); /* * Put the gold in */ if (rnd(100) < 50 && (!amulet || level >= max_level)) { rp->r_goldval = GOLDCALC; rnd_pos(rp, &rp->r_gold); if (roomin(&rp->r_gold) != rp) endwin(), abort(); } draw_room(rp); /* * Put the monster in */ if (rnd(100) < (rp->r_goldval > 0 ? 80 : 25)) { item = new_item(sizeof *tp); tp = (struct thing *) ldata(item); do { rnd_pos(rp, &mp); } until(mvwinch(stdscr, mp.y, mp.x) == FLOOR); new_monster(item, randmonster(FALSE), &mp); /* * See if we want to give it a treasure to carry around. */ if (rnd(100) < monsters[tp->t_type-'A'].m_carry) attach(tp->t_pack, new_thing()); } }
do_rooms() { int i; struct room *rp; struct linked_list *item; struct thing *tp; int left_out; coord top; coord bsze; coord mp; /* * bsze is the maximum room size */ bsze.x = COLS / 3; bsze.y = (LINES - 2) / 3; /* * Clear things for a new level */ for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) rp->r_nexits = rp->r_flags = rp->r_fires = 0; /* * Put the gone rooms, if any, on the level */ left_out = rnd(4); for (i = 0; i < left_out; i++) rooms[rnd_room()].r_flags |= ISGONE; /* * dig and populate all the rooms on the level */ for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++) { bool has_gold = FALSE; /* * Find upper left corner of box that this room goes in */ top.x = (i % 3) * bsze.x; top.y = i / 3 * bsze.y + 1; if (rp->r_flags & ISGONE) { /* * Place a gone room. Make certain that there is a * blank line for passage drawing. */ do { rp->r_pos.x = top.x + rnd(bsze.x - 2) + 1; rp->r_pos.y = top.y + rnd(bsze.y - 2) + 1; rp->r_max.x = -COLS; rp->r_max.x = -LINES; } while (rp->r_pos.y < 1 || rp->r_pos.y > LINES - 3); continue; } if (rnd(80) < level - 15) rp->r_flags |= ISDARK; /* * Find a place and size for a random room */ do { rp->r_max.x = rnd(bsze.x - 4) + 4; rp->r_max.y = rnd(bsze.y - 4) + 4; rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x); rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y); } while (rp->r_pos.y == 0); /* Draw the room */ draw_room(rp); /* * Put the gold in */ if (rnd(100) < 50 && (!has_artifact || level >= max_level)) { struct linked_list *item; struct object *cur; coord tp; has_gold = TRUE; /* This room has gold in it */ item = spec_item(GOLD, NULL, NULL, NULL); cur = OBJPTR(item); /* Put it somewhere */ rnd_pos(rp, &tp); cur->o_pos = tp; /* Put the gold into the level list of items */ add_obj(item, tp.y, tp.x); if (roomin(&tp) != rp) { endwin(); abort(); } } /* * Put the monster in */ if (rnd(100) < (has_gold ? 80 : 40)) { short which; int i, count; item = new_item(sizeof *tp); tp = THINGPTR(item); do { rnd_pos(rp, &mp); } while (mvwinch(stdscr, mp.y, mp.x) != FLOOR); which = randmonster(NOWANDER, NOGRAB); new_monster(item, which, &mp, NOMAXSTATS); /* * See if we want to give it a treasure to carry * around. */ if (rnd(100) < monsters[tp->t_index].m_carry) attach(tp->t_pack, new_thing()); /* * If it has a fire, mark it */ if (on(*tp, HASFIRE)) { rp->r_flags |= HASFIRE; rp->r_fires++; } /* * If it carries gold, give it some */ if (on(*tp, CARRYGOLD)) { struct object *cur; item = spec_item(GOLD, NULL, NULL, NULL); cur = OBJPTR(item); cur->o_count = GOLDCALC + GOLDCALC + GOLDCALC; cur->o_pos = tp->t_pos; attach(tp->t_pack, item); } i = rnd(7); if (on(*tp, ISSWARM) && i < 5) count = roll(2, 4); else if (on(*tp, ISFLOCK) && i < 5) count = roll(1, 4); else count = 0; for (i = 1; i <= count; i++) { coord *mpos; if ((mpos = place_mons(mp.y, mp.x)) != NULL) { struct linked_list *nitem; nitem = new_item(sizeof(struct thing)); new_monster(nitem, which, mpos, NOMAXSTATS); /* * If the monster is on a trap, trap * it */ if (isatrap(mvinch(mpos->y, mpos->x))) be_trapped(THINGPTR(nitem), mp); if (on(*tp, ISFRIENDLY)) turn_on(*(THINGPTR(nitem)), ISFRIENDLY); else turn_off(*(THINGPTR(nitem)), ISFRIENDLY); } } if (count > 0) { int boost = rnd(3) + 1; if (on(*tp, LOWCAST) || on(*tp, MEDCAST) || on(*tp, HIGHCAST)) turn_on(*tp, CANCAST); tp->t_stats.s_hpt += 3 * boost; tp->t_stats.s_arm -= 2 * boost; tp->t_stats.s_lvl += 2 * boost; tp->t_stats.s_str += 2 * boost; tp->t_stats.s_intel += 2 * boost; tp->t_stats.s_exp += 4 * boost * monsters[which].m_add_exp; } } } }