MCPcopy Create free account
hub / github.com/NetHack/NetHack / shkname

Function shkname

src/shknam.c:855–897  ·  view source on GitHub ↗

shopkeeper's name, without any visibility constraint; if hallucinating, will yield some other shopkeeper's name (not necessarily one residing in the current game's dungeon, or who keeps same type of shop) */

Source from the content-addressed store, hash-verified

853 will yield some other shopkeeper's name (not necessarily one residing
854 in the current game's dungeon, or who keeps same type of shop) */
855char *
856shkname(struct monst *mtmp)
857{
858 char *nam;
859 unsigned save_isshk = mtmp->isshk;
860
861 mtmp->isshk = 0; /* don't want mon_nam() calling shkname() */
862 /* get a modifiable name buffer along with fallback result */
863 nam = noit_mon_nam(mtmp);
864 mtmp->isshk = save_isshk;
865
866 if (!mtmp->isshk) {
867 impossible("shkname: \"%s\" is not a shopkeeper.", nam);
868 } else if (!has_eshk(mtmp)) {
869 panic("shkname: shopkeeper \"%s\" lacks 'eshk' data.", nam);
870 } else {
871 const char *shknm = ESHK(mtmp)->shknam;
872
873 if (Hallucination && !program_state.gameover) {
874 const char *const *nlp;
875 int num;
876
877 /* count the number of non-unique shop types;
878 pick one randomly, ignoring shop generation probabilities;
879 pick a name at random from that shop type's list */
880 for (num = 0; num < SIZE(shtypes); num++)
881 if (shtypes[num].prob == 0)
882 break;
883 if (num > 0) {
884 nlp = shtypes[rn2(num)].shknms;
885 for (num = 0; nlp[num]; num++)
886 continue;
887 if (num > 0)
888 shknm = nlp[rn2(num)];
889 }
890 }
891 /* strip prefix if present */
892 if (!letter(*shknm))
893 ++shknm;
894 Strcpy(nam, shknm);
895 }
896 return nam;
897}
898
899boolean
900shkname_is_pname(struct monst *mtmp)

Callers 15

ready_weaponFunction · 0.85
end.cFile · 0.85
do_mgivennameFunction · 0.85
do_name.cFile · 0.85
bury_objsFunction · 0.85
ShknamFunction · 0.85
clone_monFunction · 0.85
fracture_rockFunction · 0.85
container_impact_dmgFunction · 0.85
impact_dropFunction · 0.85
rob_shopFunction · 0.85
u_entered_shopFunction · 0.85

Calls 5

noit_mon_namFunction · 0.85
rn2Function · 0.85
letterFunction · 0.85
impossibleFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected