create a new shopkeeper in the given room */
| 625 | |
| 626 | /* create a new shopkeeper in the given room */ |
| 627 | staticfn int |
| 628 | shkinit(const struct shclass *shp, struct mkroom *sroom) |
| 629 | { |
| 630 | int sh; |
| 631 | coordxy sx, sy; |
| 632 | struct monst *shk; |
| 633 | struct eshk *eshkp; |
| 634 | |
| 635 | /* place the shopkeeper in the given room */ |
| 636 | sh = good_shopdoor(sroom, &sx, &sy); |
| 637 | if (sh < 0) { |
| 638 | #ifdef DEBUG |
| 639 | /* Said to happen sometimes, but I have never seen it. */ |
| 640 | /* Supposedly fixed by fdoor change in mklev.c */ |
| 641 | if (wizard) { |
| 642 | int j = sroom->doorct; |
| 643 | |
| 644 | impossible("Where is shopdoor?"); |
| 645 | pline("Room at (%d,%d),(%d,%d).", sroom->lx, sroom->ly, sroom->hx, |
| 646 | sroom->hy); |
| 647 | pline("doormax=%d doorct=%d fdoor=%d", gd.doorindex, sroom->doorct, |
| 648 | sh); |
| 649 | while (j--) { |
| 650 | pline("door [%d,%d]", svd.doors[sh].x, svd.doors[sh].y); |
| 651 | sh++; |
| 652 | } |
| 653 | display_nhwindow(WIN_MESSAGE, FALSE); |
| 654 | } |
| 655 | #endif |
| 656 | return -1; |
| 657 | } |
| 658 | |
| 659 | if (MON_AT(sx, sy)) |
| 660 | (void) rloc(m_at(sx, sy), RLOC_NOMSG); /* insurance */ |
| 661 | |
| 662 | /* now initialize the shopkeeper monster structure */ |
| 663 | if (!(shk = makemon(&mons[PM_SHOPKEEPER], sx, sy, MM_ESHK))) |
| 664 | return -1; |
| 665 | eshkp = ESHK(shk); /* makemon(...,MM_ESHK) allocates this */ |
| 666 | shk->isshk = shk->mpeaceful = 1; |
| 667 | set_malign(shk); |
| 668 | shk->msleeping = 0; |
| 669 | mon_learns_traps(shk, ALL_TRAPS); /* we know all the traps already */ |
| 670 | eshkp->shoproom = (schar) ((sroom - svr.rooms) + ROOMOFFSET); |
| 671 | sroom->resident = shk; |
| 672 | eshkp->shoptype = sroom->rtype; |
| 673 | assign_level(&eshkp->shoplevel, &u.uz); |
| 674 | eshkp->shd = svd.doors[sh]; |
| 675 | eshkp->shk.x = sx; |
| 676 | eshkp->shk.y = sy; |
| 677 | eshkp->robbed = eshkp->credit = eshkp->debit = eshkp->loan = 0L; |
| 678 | eshkp->following = eshkp->surcharge = eshkp->dismiss_kops = FALSE; |
| 679 | eshkp->billct = eshkp->visitct = 0; |
| 680 | eshkp->bill_p = (struct bill_x *) 0; |
| 681 | eshkp->customer[0] = '\0'; |
| 682 | mkmonmoney(shk, 1000L + 30L * (long) rnd(100)); /* initial capital */ |
| 683 | if (shp->shknms == shkrings) |
| 684 | (void) mongets(shk, TOUCHSTONE); |
no test coverage detected