/*      SCCS Id: @(#)botl.c     3.2     95/07/15        */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed.  See license for details. */

#include "hack.h"

#ifdef OVL0
extern const char *hu_stat[];   /* defined in eat.c */

const char *enc_stat[] = {
	"",
	"Burdened",
	"Stressed",
	"Strained",
	"Overtaxed",
	"Overloaded"
};

static void NDECL(bot1);
static void NDECL(bot2);
#endif /* OVL0 */

/* MAXCO must hold longest uncompressed status line, and must be larger
 * than COLNO
 *
 * longest practical second status line at the moment is
 *      Astral Plane $:12345 HP:700(700) Pw:111(111) AC:-127 Xp:30/123456789
 *      T:123456 Satiated Conf FoodPois Ill Blind Stun Hallu Overloaded
 * -- or somewhat over 130 characters
 */
#if COLNO <= 140
#define MAXCO 160
#else
#define MAXCO (COLNO+20)
#endif

#ifndef OVLB
STATIC_DCL int mrank_sz;
#else /* OVLB */
STATIC_OVL NEARDATA int mrank_sz = 0; /* loaded by max_rank_sz (from u_init) */
#endif /* OVLB */


STATIC_DCL const char *NDECL(rank);


#ifndef ROLE_PATCH	/* KMH -- These are now in roles[] */
struct rank_title {
#ifdef _DCC
    const char *m;              /* male title */
    const char *f;              /* female title, or 0 if same as male */
#else
    char const * const  m;      /* male title */
    char const * const  f;      /* female title, or 0 if same as male */
#endif
};
struct class_ranks {
    char                plclass, fill_;
    short               mplayer_class;
    struct rank_title   titles[9];
};

STATIC_DCL const struct rank_title *FDECL(rank_array, (CHAR_P));
#endif

#ifdef OVL1

#ifndef ROLE_PATCH	/* KMH -- These are now in roles[] */
/* 9 pairs of ranks for each class */

static const
struct class_ranks all_classes[] = {
  {                                     'A',0,  PM_ARCHEOLOGIST, {
	{"Digger",      0},
	{"Field Worker",0},
	{"Investigator",0},
	{"Exhumer",     0},
	{"Excavator",   0},
	{"Spelunker",   0},
	{"Speleologist",0},
	{"Collector",   0},
	{"Curator",     0}
  } },
  {                                     'B',0,  PM_BARBARIAN, {
	{"Plunderer",   "Plunderess"},
	{"Pillager",    0},
	{"Bandit",      0},
	{"Brigand",     0},
	{"Raider",      0},
	{"Reaver",      0},
	{"Slayer",      0},
	{"Chieftain",   "Chieftainess"},
	{"Conqueror",   "Conqueress"}
  } },
  {                                     'C',0,  PM_CAVEMAN, {
	{"Troglodyte",  0},
	{"Aborigine",   0},
	{"Wanderer",    0},
	{"Vagrant",     0},
	{"Wayfarer",    0},
	{"Roamer",      0},
	{"Nomad",       0},
	{"Rover",       0},
	{"Pioneer",     0}
  } },
  {                                     'D',0,  PM_DOPPELGANGER, {  
	{"Copier",          0},
	{"Duplicator",      0}, /* Used to be Copier */
	{"Modifier",        0}, /* Used to be Copier */
	{"Shifter",         0},
	{"Clone",           0}, /* Used to be Shifter */
	{"Reshaper",        0}, /*WAC Used to be Changer*/
	{"Manipulator",     0}, 
	{"Adept Changer",   0}, /* Used to be Adept Changer */
	{"Master of Forms", 0}
	                /*  WAC used to be Master Changer*/
  } },
  {                                     'E',0,  PM_ELF, {
	{"Edhel",       "Elleth"},
	{"Edhel",       "Elleth"},      /* elf-maid */
	{"Ohtar",       "Ohtie"},       /* warrior */
	{"Kano",                        /* commander (Q.) ['a] */
			"Kanie"}, /* educated guess, until further research- SAC */
	{"Arandur",               /* king's servant, minister (Q.) - guess */
			"Aranduriel"},  /* educated guess */
	{"Hir",         "Hiril"},       /* lord, lady (S.) ['ir] */
	{"Aredhel",     "Arwen"},       /* noble elf, maiden (S.) */
	{"Ernil",       "Elentariel"},  /* prince (S.), elf-maiden (Q.) */
	{"Elentar",     "Elentari"}     /* Star-king, -queen (Q.) */
  } },
  {                                     'F',0,  PM_FLAME_MAGE, {  
	{"Spark",         0},   /* WAC was Igniter */
	{"Igniter",       0},
	{"Broiler",       0},   /* WAC was Igniter */
	{"Combuster",     0},   /* WAC was Torcher */
	{"Torcher",       0},
	{"Scorcher",      0},   /* WAC was Torcher */
	{"Incinerator",   0},
	{"Disintegrator", 0},   /* WAC was Incinerator */
	{"Flame-Master",  0}
  } },
  {                                     'G',0,  PM_GNOME, {
	{"Gnome",               0},
	{"Gnome",               0},
	{"Gnome Warrior",       0},
	{"Gnome Knight",        0},
	{"Gnome Lord","Gnome Lady"},
	{"Gnome Lord","Gnome Lady"},
	{"Gnome Noble",         0},
	{"Gnome Noble",           0},
	{"Gnome King","Gnome Queen"}
  } },
  {                                     'H',0,  PM_HEALER, {
	{"Rhizotomist",  0},
	{"Empiric",     0},
	{"Embalmer",    0},
	{"Dresser",     0},
	{"Medici ossium",       0},
	{"Herbalist",   0},
	{"Magister",    0},
	{"Physician",   0},
	{"Chirurgeon",  0}
  } },
  {                                     'I',0,  PM_ICE_MAGE, {  
	{"Cooler",        0},   /* WAC was Chiller */
	{"Condenser",     0},   /* WAC was Chiller */
	{"Chiller",       0},
	{"Froster",       0},
	{"Permafroster",  0},   /* WAC was Froster */
	{"Icer",          0},   /* WAC was Froster */
	{"Freezer",       0},
	{"Sublimer",      0},   /* WAC was Freezer */
	{"Ice-Master",    0}
  } },
  {                                     'K',0,  PM_KNIGHT, {
	{"Gallant",     0},
	{"Esquire",     0},
	{"Bachelor",    0},
	{"Sergeant",    0},
	{"Knight",      0},
	{"Banneret",    0},
	{"Chevalier",   0},
	{"Seignieur",   0},
	{"Paladin",     0}
  } },
  {                                     'L',0,  PM_HUMAN_WEREWOLF, {  
	{"Infected",        0},
	{"Summoner",        0},
	{"Stalker",         0},
	{"Render",          0},
	{"Fiend",           0},
	{"Nightmare",       0},
	{"Devourer",        0},
	{"Greater Fiend",   0},
	{"Lycanthrope",     0}
  } },
  {                                     'M',0,  PM_MONK, {
	{"Initiate",           0},
	{"Beginner",           0},
	{"Abbot",              0},
	{"Master of Flowers",  0}, 
	{"Master of Wind",     0},
	{"Master of Dragons",  0},
	{"Master of Elements", 0},
	{"Master of Spirits",  0},
	{"Grand Master",       0}
  } },
  {                                     'N',0,  PM_NECROMANCER, {
	{"Gravedigger",      0},
	{"Embalmer",    0},
	{"Mortician", 0},
	{"Zombie Lord",    0},
	{"Ghoul Master",0},
	{"Necromancer", 0},
	{"Necromancer", 0},
	{"Undead Master",      0},
	{"Lich Lord",        0}
  } },
  {                                     'P',0,  PM_PRIEST, {
	{"Aspirant",    0},
	{"Acolyte",     0},
	{"Adept",       0},
	{"Priest",      "Priestess"},
	{"Curate",      0},
	{"Canon",       "Canoness"},
	{"Lama",        0},
	{"Patriarch",   "Matriarch"},
	{"High Priest", "High Priestess"}
  } },
  {                                     'R',0,  PM_ROGUE, {
	{"Footpad",     0},
	{"Cutpurse",    0},
	{"Rogue",       0},
	{"Pilferer",    0},
	{"Robber",      0},
	{"Burglar",     0},
	{"Filcher",     0},
	{"Magsman",     "Magswoman"},
	{"Thief",       0}
  } },
  {                                     'S',0,  PM_SAMURAI, {
	{"Hatamoto",    0},  /* Banner Knight */
	{"Ronin",       0},  /* no allegiance */
	{"Samurai",     0},  /* knight */
	{"Joshu",       0},  /* heads a castle */
	{"Ryoshu",      0},  /* has a territory */
	{"Kokushu",     0},  /* heads a province */
	{"Daimyo",      0},  /* a samurai lord */
	{"Kuge",        0},  /* Noble of the Court */
	{"Shogun",      0}   /* supreme commander, warlord */
  } },
#ifdef TOURIST
  {                                     'T',0,  PM_TOURIST, {
	{"Rambler",     0},
	{"Sightseer",   0},
	{"Excursionist",0},
	{"Peregrinator","Peregrinatrix"},
	{"Traveler",    0},
	{"Journeyer",   0},
	{"Voyager",     0},
	{"Explorer",    0},
	{"Adventurer",  0}
  } },
#endif
  {                                     'U',0,  PM_UNDEAD_SLAYER, {  
	{"Assistant",   0},
	{"Eliminator",    0},
	{"Eliminator",    0},
	{"Exterminator",        0},
	{"Exterminator",        0},
	{"Destroyer",   0},
	{"Vindicator",  0},
	{"Vindicator",  0},
	{"Undead Slayer",       0}
  } },
  {                                     'V',0,  PM_VALKYRIE, {
	{"Stripling",   0},
	{"Skirmisher",  0},
	{"Fighter",     0},
	{"Man-at-arms", "Woman-at-arms"},
	{"Warrior",     0},
	{"Swashbuckler",0},
	{"Hero",        "Heroine"},
	{"Champion",    0},
	{"Lord",        "Lady"}
  } },
  {                                     'W',0,  PM_WIZARD, {
	{"Evoker",      0},
	{"Conjurer",    0},
	{"Thaumaturge", 0},
	{"Magician",    0},
	{"Warlock", "Witch"},
	{"Enchanter",   "Enchantress"},
	{"Sorcerer",    "Sorceress"},
	{"Wizard",      0},
	{"Mage",        0}
  } },
};


STATIC_OVL const struct rank_title *
rank_array(pc)
char pc;
{
	register int i;

	for (i = 0; i < SIZE(all_classes); i++)
	    if (all_classes[i].plclass == pc) return all_classes[i].titles;
	return 0;
}
#endif	/* !ROLE_PATCH */


/* convert experience level (1..30) to rank index (0..8) */
int xlev_to_rank(xlev)
int xlev;
{
	return (xlev <= 2) ? 0 : (xlev <= 30) ? ((xlev + 2) / 4) : 8;
}

#if 0   /* not currently needed */
/* convert rank index (0..8) to experience level (1..30) */
int rank_to_xlev(rank)
int rank;
{
	return (rank <= 0) ? 1 : (rank <= 8) ? ((rank * 4) - 2) : 30;
}
#endif


#ifdef ROLE_PATCH
const char *
rank_of(lev, monnum, female)
	int lev;
	short monnum;
	boolean female;
{
	register struct Role *role;
	register int i;


	/* Find the role */
	for (role = (struct Role *) roles; role->name.m; role++)
		if (monnum == role->malenum || monnum == role->femalenum)
			break;
	if (!role->name.m)
		role = &urole;

	/* Find the rank */
	for (i = xlev_to_rank((int)lev); i >= 0; i--) {
		if (female && role->rank[i].f) return (role->rank[i].f);
		if (role->rank[i].m) return (role->rank[i].m);
	}

	/* Try the role name, instead */
	if (female && role->name.f) return (role->name.f);
	else if (role->name.m) return (role->name.m);
	return ("Player");
}


STATIC_OVL const char *
rank()
{
	return(rank_of(u.ulevel, Role_switch, flags.female));
}


#else	/* !ROLE_PATCH */
const char *
rank_of(lev, pc, female)
int lev;
char pc;
boolean female;
{
	register int idx = xlev_to_rank((int)lev);
	const struct rank_title *ranks = rank_array(pc);

	if (ranks)
	    return( female && ranks[idx].f ? ranks[idx].f : ranks[idx].m );
	return(pl_character);
}

STATIC_OVL const char *
rank()
{
	return(rank_of(u.ulevel, u.role, flags.female));
}
#endif	/* !ROLE_PATCH */


int
title_to_mon(str, rank_indx, title_length)
const char *str;
int *rank_indx, *title_length;
{
#ifdef ROLE_PATCH
	register int i, j;


	/* Loop through each of the roles */
	for (i = 0; roles[i].name.m; i++)
		for (j = 0; j < 9; j++) {
			if (roles[i].rank[j].m && !strncmpi(str,
					roles[i].rank[j].m, strlen(roles[i].rank[j].m))) {
				if (rank_indx) *rank_indx = j;
				if (title_length) *title_length = strlen(roles[i].rank[j].m);
				return roles[i].malenum;
			}
			if (roles[i].rank[j].f && !strncmpi(str,
					roles[i].rank[j].f, strlen(roles[i].rank[j].f))) {
				if (rank_indx) *rank_indx = j;
				if (title_length) *title_length = strlen(roles[i].rank[j].f);
				return (roles[i].femalenum ? roles[i].femalenum : roles[i].malenum);
			}
		}
#else
	register int i, j;
	register const struct rank_title *ttl;

	for (i = 0; i < SIZE(all_classes); i++)
	    for (j = 0; j < 9; j++) {
		ttl = &all_classes[i].titles[j];
		if (!strncmpi(ttl->m, str, strlen(ttl->m))) {
		    if (rank_indx) *rank_indx = j;
		    if (title_length) *title_length = strlen(ttl->m);
		    return all_classes[i].mplayer_class;
		} else if (ttl->f && !strncmpi(ttl->f, str, strlen(ttl->f))) {
		    if (rank_indx) *rank_indx = j;
		    if (title_length) *title_length = strlen(ttl->f);
		    return all_classes[i].plclass == 'C' ? PM_CAVEWOMAN :
			   all_classes[i].plclass == 'P' ? PM_PRIESTESS :
			   all_classes[i].mplayer_class;
		}
	    }
#endif
	return NON_PM;
}

#endif /* OVL1 */
#ifdef OVLB

void
max_rank_sz()
{
	register int i, r, maxr = 0;


#ifdef ROLE_PATCH
	for (i = 0; i < 9; i++) {
		if (urole.rank[i].m && (r = strlen(urole.rank[i].m)) > maxr) maxr = r;
		if (urole.rank[i].f && (r = strlen(urole.rank[i].f)) > maxr) maxr = r;
	}
	mrank_sz = maxr;
	return;
#else
	const struct rank_title *ranks = rank_array(u.role);

	if (ranks) {
	    for (i = 0; i < 9; i++) {
		if ((r = strlen(ranks[i].m)) > maxr) maxr = r;
		if (ranks[i].f)
		    if ((r = strlen(ranks[i].f)) > maxr) maxr = r;
	    }
	    mrank_sz = maxr;
	} else
	    mrank_sz = strlen(pl_character);
#endif
}

#endif /* OVLB */
#ifdef OVL0

#ifdef SCORE_ON_BOTL
long
botl_score()
{
    int deepest = deepest_lev_reached(FALSE);
    long ugold = u.ugold + hidden_gold();

    if ((ugold -= u.ugold0) < 0L) ugold = 0L;
    return ugold + u.urexp + (long)(50 * (deepest - 1))
			  + (long)(deepest > 30 ? 10000 :
				   deepest > 20 ? 1000*(deepest - 20) : 0);
}
#endif

static void
bot1()
{
	char newbot1[MAXCO];
	register char *nb;
	register int i,j;

	Strcpy(newbot1, plname);
	if('a' <= newbot1[0] && newbot1[0] <= 'z') newbot1[0] += 'A'-'a';
	newbot1[10] = 0;
	Sprintf(nb = eos(newbot1)," the ");

	if (Upolyd) {
		char mbot[BUFSZ];
		int k = 0;

		Strcpy(mbot, mons[u.umonnum].mname);
		while(mbot[k] != 0) {
		    if ((k == 0 || (k > 0 && mbot[k-1] == ' ')) &&
					'a' <= mbot[k] && mbot[k] <= 'z')
			mbot[k] += 'A' - 'a';
		    k++;
		}
		Sprintf(nb = eos(nb), mbot);
	} else
		Sprintf(nb = eos(nb), rank());

	Sprintf(nb = eos(nb),"  ");
	i = mrank_sz + 15;
	j = (nb + 2) - newbot1; /* aka strlen(newbot1) but less computation */
	if((i - j) > 0)
		Sprintf(nb = eos(nb),"%*s", i-j, " ");  /* pad with spaces */
	if (ACURR(A_STR) > 18) {
		if (ACURR(A_STR) > 118)
		    Sprintf(nb = eos(nb),"St:%2d ",ACURR(A_STR)-100);
		else if (ACURR(A_STR) < 118)
		    Sprintf(nb = eos(nb), "St:18/%02d ",ACURR(A_STR)-18);
		else
		    Sprintf(nb = eos(nb),"St:18/** ");
	} else
		Sprintf(nb = eos(nb), "St:%-1d ",ACURR(A_STR));
	Sprintf(nb = eos(nb),
		"Dx:%-1d Co:%-1d In:%-1d Wi:%-1d Ch:%-1d",
		ACURR(A_DEX), ACURR(A_CON), ACURR(A_INT), ACURR(A_WIS), ACURR(A_CHA));
	Sprintf(nb = eos(nb), (u.ualign.type == A_CHAOTIC) ? "  Chaotic" :
			(u.ualign.type == A_NEUTRAL) ? "  Neutral" : "  Lawful");
#ifdef SCORE_ON_BOTL
	if (flags.showscore)
	    Sprintf(nb = eos(nb), " S:%ld", botl_score());
#endif
	curs(WIN_STATUS, 1, 0);
	putstr(WIN_STATUS, 0, newbot1);
}

static void
bot2()
{
	char  newbot2[MAXCO];
	register char *nb;
	register int con = ACURR(A_CON), wis = ACURR(A_WIS),
		     intl = ACURR(A_INT);
	int hp, hpmax, cbon, mbon, temp;
	int cap = near_capacity();


	/* STEPHEN WHITE'S NEW CODE */

	     if (u.ulevel > 7) temp = 7 + ((u.ulevel - 7) / 2);
	else if (u.ulevel > 14) temp = 10 + ((u.ulevel - 14) / 3);
	else if (u.ulevel > 21) temp = 12 + ((u.ulevel - 21) / 4);
	else if (u.ulevel > 24) temp = 13;
	else temp = u.ulevel;

	if (con == 3) cbon = -3 * temp;
	else if (con == 4) cbon = -2 * temp;
	else if (con == 5) cbon = -2 * temp;
	else if (con == 6) cbon = -1 * temp;
	else if (con == 7) cbon = -1 * temp;
	else if (con < 15) cbon = 0 * temp;  
	else if (con == 15) cbon = 1 * temp;
	else if (con == 16) cbon = 2 * temp;
	else if (con == 17) cbon = 3 * temp;
	else if (con == 18) cbon = 4 * temp;
	else if (con == 19) cbon = 5 * temp;
	else if (con == 20) cbon = 5 * temp;
	else if (con == 21) cbon = 6 * temp;
	else if (con == 22) cbon = 6 * temp; 
	else if (con == 23) cbon = 7 * temp; 
	else if (con == 24) cbon = 7 * temp; 
	else cbon = 8 * temp;
	
	if (wis < 4) mbon = -3 * temp;
	else if (wis < 6) mbon = -2 * temp;
	else if (wis < 8) mbon = -1 * temp;
	else if (wis < 14) mbon = 0 * temp;
	else if (wis == 14) mbon = 1 * temp;
	else if (wis == 15) mbon = 2 * temp;
	else if (wis == 16) mbon = 2 * temp;
	else if (wis == 17) mbon = 3 * temp;
	else if (wis == 18) mbon = 3 * temp;
	else if (wis == 19) mbon = 4 * temp;
	else if (wis == 20) mbon = 4 * temp;
	else if (wis == 21) mbon = 5 * temp;
	else if (wis == 22) mbon = 5 * temp; 
	else if (wis == 23) mbon = 6 * temp; 
	else if (wis == 24) mbon = 6 * temp; 
	else mbon = 7 * temp;
	
	if (intl < 4) mbon += -2 * temp;
	else if (intl < 6) mbon += -1 * temp;
	else if (intl < 17) mbon += 0 * temp;
	else if (intl == 17) mbon += 1 * temp;
	else if (intl == 18) mbon += 1 * temp; 
	else if (intl == 19) mbon += 2 * temp;
	else if (intl == 20) mbon += 2 * temp;
	else if (intl == 21) mbon += 3 * temp;
	else if (intl == 22) mbon += 3 * temp;
	else if (intl == 23) mbon += 4 * temp; 
	else if (intl == 24) mbon += 4 * temp;
	else mbon += 5 * temp;
	
	u.uhpmax = u.uhpbase + cbon;
	if (u.uhpmax < 1) u.uhpmax = 1;
	if (u.uhp > u.uhpmax) u.uhp = u.uhpmax;
	
	u.uenmax = u.uenbase + mbon;
	if (u.uenmax < 0) u.uenmax = 0;
	if (u.uen > u.uenmax) u.uen = u.uenmax;


	hp = Upolyd ? u.mh : u.uhp;
	hpmax = Upolyd ? u.mhmax : u.uhpmax;

	/* TODO:        Add in dungeon name */
	if(Is_knox(&u.uz)) Sprintf(newbot2, "%s ", dungeons[u.uz.dnum].dname);
	else if(In_quest(&u.uz)) Sprintf(newbot2, "Home %d ", dunlev(&u.uz));
	else
/*	if(strcmp(hu_stat[u.uhs], "        ")) {*/
		if(In_endgame(&u.uz))                
			Sprintf(newbot2,
					Is_astralevel(&u.uz) ? "Astral Plane " : "End Game ");
		else  Sprintf(newbot2, "Dlvl:%-2d ", depth(&u.uz));

	if(hp < 0) hp = 0;
/*          
	Sprintf(newbot2,"AC:%-2d ",u.uac);
  
	Sprintf(nb = eos(newbot2),
		"HP:%d(%d)  Pw:%d(%d) ",
		hp, hpmax, u.uen, u.uenmax);
*/
	Sprintf(nb = eos(newbot2),
	       "%c:%-2ld HP:%d(%d) Pw:%d(%d) AC:%-2d", oc_syms[GOLD_CLASS],
	       u.ugold, hp, hpmax, u.uen, u.uenmax, u.uac);
	nb = eos(newbot2);

/* WAC pulled old code from 3.2.2 source
	if (Upolyd)
		Sprintf(nb = eos(nb), " HD:%d", mons[u.umonnum].mlevel);
	Sprintf(nb = eos(nb), " Level:%u  Xp:%-1ld(%-1ld)", u.ulevel,u.uexp,newuexp(u.ulevel));
*/
	if (Upolyd)
		Sprintf(nb = eos(nb), " HD:%d", mons[u.umonnum].mlevel);
#ifdef EXP_ON_BOTL
	else if(flags.showexp)
		Sprintf(nb = eos(nb), " Xp:%u/%-1ld", u.ulevel,u.uexp);
#endif
	else
		Sprintf(nb = eos(nb), " Exp:%u", u.ulevel);

#ifdef SHOW_WEIGHT
	if (flags.showweight)
		Sprintf(nb = eos(nb), "  Wt:%ld/%ld", (long)(inv_weight()+weight_cap()),
				(long)weight_cap());
#endif

	if(flags.time)
	        Sprintf(nb = eos(nb), "  T:%ld ", moves);
	        
        if(strcmp(hu_stat[u.uhs], "        ")) {
		Sprintf(nb = eos(nb), " ");
		Strcat(newbot2, hu_stat[u.uhs]);
	}

/* WAC further Up
#ifdef SCORE_ON_BOTL
	if (flags.showscore)
                Sprintf(nb,"%c:%-2ld  Score:%ld", oc_syms[GOLD_CLASS],
                   u.ugold, botl_score());
#endif
*/
	/* KMH -- changed to Lev */
	if (Levitation)    Sprintf(nb = eos(nb), " Lev");
	if(Confusion)      Sprintf(nb = eos(nb), " Conf");
	if(Sick) {
		if (u.usick_type & SICK_VOMITABLE)
			   Sprintf(nb = eos(nb), " FoodPois");
		if (u.usick_type & SICK_NONVOMITABLE)
			   Sprintf(nb = eos(nb), " Ill");
	}
	if(Blind)          Sprintf(nb = eos(nb), " Blind");
	if(Stunned)        Sprintf(nb = eos(nb), " Stun");
	if(Hallucination)  Sprintf(nb = eos(nb), " Hallu");
	if(Slimed)         Sprintf(nb = eos(nb), " Slime");
	if(cap > UNENCUMBERED)
		Sprintf(nb = eos(nb), " %s", enc_stat[cap]);
	curs(WIN_STATUS, 1, 1);
	putstr(WIN_STATUS, 0, newbot2);
	return;
}

/* WAC -- Shorten bot1 to fit in len spaces.
 * Currently only used by wintty
 * Longest string past Str: is
 * ". Str:18/** Dx:11 Co:13 In:12 Wi:14 Ch:14 Neutral" or 49 Chars long.
 */
#ifdef TTY_GRAPHICS
const char*
shorten_bot1(str, len)
const char *str;
int len;
{
    static char cbuf[BUFSZ];

    register const char *bp0 = str;
    register char *bp1 = cbuf;
    int k = 0;

    do {
            *bp1++ = *bp0;
            k++;
    } while(*bp0++ && k < (len - 49));
    
    cbuf[k] = '.';
    bp1++;
    
    bp0 = index(str, ':') - 3;
    do {
            *bp1++ = *bp0;
    } while(*bp0++);
    return cbuf;
}
#endif /* TTY_GRAPHICS */

void
bot()
{
	bot1();
	bot2();
	flags.botl = flags.botlx = 0;
}

#endif /* OVL0 */

/*botl.c*/
