version 1.12 | | version 1.13 |
---|
| | |
/* | | /* |
* static char *rcsid_readable_c = | | * static char *rcsid_readable_c = |
* "$Id: readable.c,v 1.12 2002/11/14 00:19:32 garbled Exp $"; | | * "$Id: readable.c,v 1.13 2003/09/13 05:01:30 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
}; | | }; |
| | |
| | |
| | |
static char *mage_book_name[] = | | |
{ | | |
"grimoire", /* Level 1 */ | | |
"grimoire", /* Level 2-3 */ | | |
"manual", /* Level 4-5 */ | | |
"tome", /* Level 6-7 */ | | |
"treatise" /* Level 8+ */ | | |
}; | | |
| | |
static char *priest_book_name[] = | | |
{ | | |
"hymnal", /* Level 1 */ | | |
"prayerbook", /* Level 2-3 */ | | |
"prayerbook", /* Level 4-5 */ | | |
"sacred text", /* Level 6-7 */ | | |
"testament" /* Level 8+ */ | | |
}; | | |
| | |
static int max_titles[6] = | | static int max_titles[6] = |
{ | | { |
((sizeof (light_book_name) / sizeof (char *)) + (sizeof (heavy_book_name) / sizeof (char *))) * (sizeof (book_author) / sizeof (char *)), | | ((sizeof (light_book_name) / sizeof (char *)) + (sizeof (heavy_book_name) / sizeof (char *))) * (sizeof (book_author) / sizeof (char *)), |
| | |
break; | | break; |
case 6: /*msg file */ | | case 6: /*msg file */ |
default: | | default: |
#if 0 | | |
nbr = sizeof (book_name) / sizeof (char *); | | |
strcpy (name, book_name[RANDOM () % nbr]); | | |
#endif | | |
if (book->weight > 2000) | | if (book->weight > 2000) |
{ /* based on weight */ | | { /* based on weight */ |
nbr = sizeof (heavy_book_name) / sizeof (char *); | | nbr = sizeof (heavy_book_name) / sizeof (char *); |
| | |
change_book (object *book, int msgtype) | | change_book (object *book, int msgtype) |
{ | | { |
int nbr = sizeof (book_descrpt) / sizeof (char *); | | int nbr = sizeof (book_descrpt) / sizeof (char *); |
char name[MAX_BUF]; | | |
| | |
switch (book->type) | | switch (book->type) |
{ | | { |
| | |
} | | } |
break; | | break; |
} | | } |
case SPELLBOOK: /* depends on mage/clerical */ | | |
if (!strcmp (book->arch->name, "cleric_book")) | | |
{ | | |
int level; | | |
level=spells[book->stats.sp].level/2; | | |
nbr = sizeof (priest_book_name) / sizeof (char *); | | |
if (level>(nbr-1)) level=nbr-1; | | |
strcpy (name, priest_book_name[level]); | | |
} | | |
else | | |
{ | | |
int level; | | |
| | |
level=spells[book->stats.sp].level/2; | | |
nbr = sizeof (mage_book_name) / sizeof (char *); | | |
if (level>(nbr-1)) level=nbr-1; | | |
strcpy (name, mage_book_name[level]); | | |
} | | |
if (book->name) | | |
free_string (book->name); | | |
book->name = add_string (name); | | |
break; | | |
default: | | default: |
LOG (llevError, "change_book_name() called w/ illegal obj type.\n"); | | LOG (llevError, "change_book_name() called w/ illegal obj type.\n"); |
return; | | return; |
| | |
static char retbuf[BOOK_BUF]; | | static char retbuf[BOOK_BUF]; |
char tmpbuf[BOOK_BUF]; | | char tmpbuf[BOOK_BUF]; |
int path = RANDOM () % NRSPELLPATHS, prayers = RANDOM () % 2; | | int path = RANDOM () % NRSPELLPATHS, prayers = RANDOM () % 2; |
int i = 0, did_first_sp = 0; | | int did_first_sp = 0; |
uint32 pnum = (path == -1) ? PATH_NULL : spellpathdef[path]; | | uint32 pnum = (path == -1) ? PATH_NULL : spellpathdef[path]; |
| | archetype *at; |
| | |
/* Preamble */ | | /* Preamble */ |
sprintf (retbuf, "Herein are detailed the names of %s\n", | | sprintf (retbuf, "Herein are detailed the names of %s\n", |
!(prayers) ? "incantations" : "prayers"); | | prayers ? "prayers": "incantations"); |
| | |
if (path == -1) | | if (path == -1) |
strcat (retbuf, "having no known spell path.\n"); | | strcat (retbuf, "having no known spell path.\n"); |
else | | else |
sprintf (retbuf, "%sbelonging to the path of %s:\n", retbuf, | | sprintf (retbuf, "%sbelonging to the path of %s:\n", retbuf, |
spellpathnames[path]); | | spellpathnames[path]); |
| | |
/* Now go through the entire list of spells. Add appropriate spells | | for (at=first_archetype; at != NULL; at=at->next) { |
* in our message buffer | | /* Determine if this is an appropriate spell. Must |
*/ | | * be of matching path, must be of appropriate type (prayer |
do | | * or not), and must be within the valid level range. |
{ | | */ |
if ((spells[i].books || prayers) && spells[i].cleric == prayers | | if (at->clone.type == SPELL && at->clone.path_attuned & pnum && |
&& (pnum & spells[i].path)) | | ((at->clone.stats.grace && prayers) || (at->clone.stats.sp && !prayers)) && |
{ | | (at->clone.level < (level * 8))) { |
/* book level determines max spell level to show | | strcpy (tmpbuf, at->clone.name); |
* thus higher level books are more comprehensive */ | | |
if (spells[i].level > (level * 8)) | | |
{ | | |
i++; | | |
continue; | | |
} | | |
strcpy (tmpbuf, spells[i].name); | | |
| | |
if (book_overflow (retbuf, tmpbuf, booksize)) | | if (book_overflow (retbuf, tmpbuf, booksize)) |
break; | | break; |
else | | else { |
{ | | |
if (did_first_sp) | | if (did_first_sp) |
strcat (retbuf, ",\n"); | | strcat (retbuf, ",\n"); |
did_first_sp = 1; | | did_first_sp = 1; |
strcat (retbuf, tmpbuf); | | strcat (retbuf, tmpbuf); |
} | | } |
} | | } |
i++; | | |
} | | } |
while (i < NROFREALSPELLS); | | |
| | |
/* Geez, no spells were generated. */ | | /* Geez, no spells were generated. */ |
if (!did_first_sp) | | if (!did_first_sp) { |
{ | | |
if (RANDOM () % 4) /* usually, lets make a recursive call... */ | | if (RANDOM () % 4) /* usually, lets make a recursive call... */ |
spellpath_msg (level, booksize); | | spellpath_msg (level, booksize); |
else /* give up, cause knowning no spells exist for path is info too. */ | | else /* give up, cause knowing no spells exist for path is info too. */ |
strcat (retbuf, "\n - no known spells exist -\n"); | | strcat (retbuf, "\n - no known spells exist -\n"); |
} | | } |
else | | else { |
{ | | |
#ifdef BOOK_MSG_DEBUG | | |
LOG (llevDebug, "\n spellpath_msg() created strng: %d\n", strlen (retbuf)); | | |
fprintf (logfile, " MADE THIS: path=%d pray=%d\n%s\n", path, prayers, retbuf); | | |
#endif | | |
strcat (retbuf, "\n"); | | strcat (retbuf, "\n"); |
} | | } |
return retbuf; | | return retbuf; |