Atrinik Server 2.5
Data Structures | Typedefs | Functions | Variables
server/readable.c File Reference
#include <global.h>
#include <book.h>

Go to the source code of this file.

Data Structures

struct  namebytype

Typedefs

typedef struct namebytype arttypename

Functions

int book_overflow (const char *buf1, const char *buf2, size_t booksize)
static void init_msgfile ()
static void init_mon_info ()
void init_readable ()
static void new_text_name (object *book, int msgtype)
static void add_author (object *op, int msgtype)
static void change_book (object *book, int msgtype)
objectget_random_mon ()
static char * mon_desc (object *mon, char *buf, size_t size)
static char * mon_info_msg (char *buf, size_t booksize)
static char * artifact_msg (int level, char *buf, size_t booksize)
static char * spellpath_msg (int level, char *buf, size_t booksize)
static char * msgfile_msg (size_t booksize)
void tailor_readable_ob (object *book, int msg_type)
void free_all_readable ()

Variables

static object ** monsters = NULL
static size_t num_monsters = 0
static char ** msgs = NULL
static size_t num_msgs = 0
static uint32 spellpathdef [NRSPELLPATHS]
static char * path_book_name []
static char * path_author []
static arttypename art_name_array []
static char * art_book_name []
static char * art_author []
static char * mon_book_name []
static char * mon_author []
static char * book_name []
static char * book_author []

Detailed Description

This file contains code relevant to allow randomly occurring messages in non-magical texts.

Author:
b.t. thomas@astro.psu.edu
Date:
December 1995

Definition in file readable.c.


Typedef Documentation

typedef struct namebytype arttypename

special structure, used only by art_name_array[]


Function Documentation

static void add_author ( object op,
int  msgtype 
) [static]

A lot like new_text_name(), but instead chooses an author and sets op->title to that value.

Parameters:
opThe book object.
msgtypeMessage type.

Definition at line 483 of file readable.c.

static char* artifact_msg ( int  level,
char *  buf,
size_t  booksize 
) [static]

Generate a message detailing the properties of 1-6 artifacts drawn sequentially from the artifact list.

Parameters:
levelLevel of the book
bufBuffer to contain the description.
booksizeLength of the book.
Returns:
'buf'.

Definition at line 602 of file readable.c.

int book_overflow ( const char *  buf1,
const char *  buf2,
size_t  booksize 
)

Checks if book will overflow.

Parameters:
buf1
buf2Buffers we plan on combining.
booksizeMaximum book size.
Returns:
1 if it will overflow, 0 otherwise.

Definition at line 312 of file readable.c.

static void change_book ( object book,
int  msgtype 
) [static]

Give a new, fancier name to generated objects of type BOOK and SPELLBOOK.

Will attempt to create consistent author/title and message content for BOOKs. Also, will alter books that match archive entries to the archival levels and archetypes.

Parameters:
bookThe book object to alter.
msgtypeMessage type to make.

Definition at line 525 of file readable.c.

void free_all_readable ( )

Cleanup routine for readable stuff.

Definition at line 882 of file readable.c.

object* get_random_mon ( )

Returns a random monster from all the monsters in the game.

Returns:
The monster object

Definition at line 541 of file readable.c.

static void init_mon_info ( ) [static]

Initialize array of monsters.

Definition at line 406 of file readable.c.

static void init_msgfile ( ) [static]

Reads the messages file into the list pointed to by first_msg.

Definition at line 325 of file readable.c.

void init_readable ( )

Initializes linked lists utilized by message functions in tailor_readable_ob().

This is the function called by the main routine to initialize all the readable information.

Definition at line 429 of file readable.c.

static char* mon_desc ( object mon,
char *  buf,
size_t  size 
) [static]

Returns a description of the monster.

Parameters:
monMonster to describe.
bufBuffer that will contain the description.
sizeSize of 'buf'.
Returns:
'buf'.

Definition at line 558 of file readable.c.

static char* mon_info_msg ( char *  buf,
size_t  booksize 
) [static]

Generate a message detailing the properties of randomly selected monsters.

Parameters:
bufBuffer that will contain the message.
booksizeSize (in characters) of the book we want.
Returns:
'buf'.

Definition at line 570 of file readable.c.

static char* msgfile_msg ( size_t  booksize) [static]

Generate a message drawn randomly from a file in lib/.

Parameters:
booksizeMaximum book size.
Returns:
Pointer to the generated message.

Definition at line 792 of file readable.c.

static void new_text_name ( object book,
int  msgtype 
) [static]

Only for objects of type BOOK. SPELLBOOK stuff is handled directly in change_book_name(). Names are based on text msgtype.

This sets book book->name based on msgtype given. What name is given is based on various criteria.

Parameters:
bookThe book object.
msgtypeMessage type.

Definition at line 446 of file readable.c.

static char* spellpath_msg ( int  level,
char *  buf,
size_t  booksize 
) [static]

Generate a message detailing the member incantations/prayers (and some of their properties) belonging to a random spellpath.

Parameters:
levelLevel of the book.
bufBuffer to write the description into.
booksizeLength of the book.
Returns:
'buf'.

Definition at line 728 of file readable.c.

void tailor_readable_ob ( object book,
int  msg_type 
)

The main routine. This chooses a random message to put in given readable object (type == BOOK) which will be referred hereafter as a 'book'. We use the book level to de- termine the value of the information we will insert. Higher values mean the book will (generally) have better/more info. See individual cases as to how this will be utilized. "Book" name/content length are based on the weight of the document. If the value of msg_type is negative, we will randomly choose the kind of message to generate.

Parameters:
bookThe object we are creating into.
msg_typeIf this is a positive value, we use it to determine the message type - otherwise a random value is used.
Author:
b.t. thomas@astro.psu.edu

Definition at line 830 of file readable.c.


Variable Documentation

char* art_author[] [static]
Initial value:
{
    "ancient things",
    "artifacts",
    "Havlor",
    "items",
    "lost artifacts",
    "the ancients",
    "useful things"
}

Used by artifact texts

Definition at line 182 of file readable.c.

char* art_book_name[] [static]
Initial value:
{
    "collection",
    "file",
    "files",
    "guide",
    "handbook",
    "index",
    "inventory",
    "list",
    "listing",
    "record",
    "record book"
}

Artifact book information

Definition at line 166 of file readable.c.

Initial value:
{
    {"Helmet", HELMET},
    {"Amulet", AMULET},
    {"Shield", SHIELD},
    {"Bracers", BRACERS},
    {"Boots", BOOTS},
    {"Cloak", CLOAK},
    {"Gloves", GLOVES},
    {"Girdle", GIRDLE},
    {"Ring", RING},
    {"Horn", HORN},
    {"Missile Weapon", BOW},
    {"Missile", ARROW},
    {"Hand Weapon", WEAPON},
    {"Artifact", SKILL},
    {"Food", FOOD},
    {"Body Armour", ARMOUR}
}

Artifact/item information

If it isn't listed here, then art_attr_msg will never generate a message for this type of artifact.

Definition at line 145 of file readable.c.

char* book_author[] [static]

Used by 'generic' books

Definition at line 258 of file readable.c.

char* book_name[] [static]
Initial value:
{
    "calendar",
    "datebook",
    "diary",
    "guidebook",
    "handbook",
    "ledger",
    "notes",
    "notebook",
    "octavo",
    "pamphlet",
    "practicum",
    "script",
    "transcript",
    "catalog",
    "compendium",
    "guide",
    "manual",
    "opus",
    "tome",
    "treatise",
    "volume",
    "work"
}

Generic book information.

Definition at line 231 of file readable.c.

char* mon_author[] [static]
Initial value:
{
    "beasts",
    "creatures",
    "dezidens",
    "dwellers",
    "evil nature",
    "life",
    "monsters",
    "nature",
    "new life",
    "residents",
    "the spawn",
    "the living",
    "things"
}

Used by monster bestiary texts

Definition at line 212 of file readable.c.

char* mon_book_name[] [static]
Initial value:
{
    "bestiary",
    "catalog",
    "compilation",
    "collection",
    "encyclopedia",
    "guide",
    "handbook",
    "list",
    "manual",
    "notes",
    "record",
    "register",
    "volume"
}

Monster book information

Definition at line 194 of file readable.c.

object** monsters = NULL [static]

Array of all the monsters.

Definition at line 52 of file readable.c.

char** msgs = NULL [static]

Array of the messages as read from the messages file.

Definition at line 59 of file readable.c.

size_t num_monsters = 0 [static]

Number of the monsters.

Definition at line 55 of file readable.c.

size_t num_msgs = 0 [static]

Number of msgs.

Definition at line 62 of file readable.c.

char* path_author[] [static]
Initial value:
{
    "aether",
    "astral byways",
    "connections",
    "the Grey Council",
    "deep pathways",
    "knowledge",
    "magic",
    "mystic ways",
    "pathways",
    "power",
    "spells",
    "transforms",
    "the mystic veil",
    "unknown spells",
    "cults",
    "joy",
    "lasting curse",
    "madness",
    "religions",
    "the dead",
    "the gods",
    "the heirophant",
    "the poor priest",
    "the priestess",
    "pain",
    "white"
}

Used by spellpath texts

Definition at line 110 of file readable.c.

char* path_book_name[] [static]
Initial value:
{
    "codex",
    "compendium",
    "exposition",
    "tables",
    "treatise",
    "devotional",
    "devout notes",
    "divine text",
    "divine work",
    "holy book",
    "holy record",
    "moral text",
    "sacred guide",
    "testament",
    "transcript"
}

Path book information

Definition at line 90 of file readable.c.

uint32 spellpathdef[NRSPELLPATHS] [static]