io.h
src/io.h · 12.5 KB
From the archive cotn-2.5.tar.gz
Download the archive « Back to the archive contents
VARIABLE_FUNCTION_STRING: Functions returning strings.
VARIABLE_CONSTANT_STRING: Constant strings.
VARIABLE_FUNCTION_NUMBER: Functions returning numbers.
VARIABLE_CONSTANT_NUMBER: Constant numbers.
/******************************************************************************
You have to add the following prototypes to an appropriate header file:
void io_parse args( ( CHAR_DATA *ch, char *in_ptr, char *out_ptr ) );
void io_display args( ( CHAR_DATA *ch, char text[] ) );
void io_main args( ( CHAR_DATA *ch ) );
int io_calculate args( ( CHAR_DATA *ch, char *calculation ) );
******************************************************************************/
typedef enum
{
VARIABLE_FUNCTION_STRING,
VARIABLE_CONSTANT_STRING,
VARIABLE_FUNCTION_NUMBER,
VARIABLE_CONSTANT_NUMBER
} VARIABLE_TYPE;
typedef enum
{
STATE_NONE,
STATE_LEFT_SIGN,
STATE_LEFT,
STATE_DONE_LEFT,
STATE_OPERATOR,
STATE_RIGHT_SIGN,
STATE_RIGHT
} STATE_TYPE;
typedef union
{
char* text;
int number;
} replace_type;
typedef struct
{
const char * variable;
const VARIABLE_TYPE type;
replace_type replace;
} var_type;
/*********************************************************/
/* FUNCTION PROTOTYPES */
/*********************************************************/
static int main_calc ( CHAR_DATA *ch, char calc_string[] );
bool string_var ( char *var_ptr, char **out_ptr );
bool number_var ( char *var_ptr, char *out_ptr );
static void setup_variables ( CHAR_DATA *ch );
/*********************************************************/
/* VARIABLE FUNCTIONS */
/*********************************************************/
CHAR_DATA *you = NULL;
OBJ_DATA *wpn = NULL;
/*********************************************************************/
/**************************** PURE STRING ****************************/
/*********************************************************************/
char *get_name( void ) { return ( you->name ); }
// char *get_firstname( void ) { return ( you->forename ); }
// char *get_surname( void ) { return ( you->surname ); }
/*
char *get_fullname( void )
{
static char buf [MAX_INPUT_LENGTH];
strcpy( buf, you->forename );
strcat( buf, " " );
strcat( buf, you->surname );
return ( buf );
}
*/
char *get_he_she( void ) { return ( IS_FEMALE(you) ? "she" : "he" ); }
char *get_him_her( void ) { return ( IS_FEMALE(you) ? "her" : "him" ); }
char *get_his_her( void ) { return ( IS_FEMALE(you) ? "her" : "his" ); }
char *obj_where_text( OBJ_DATA *obj )
{
static char buf [MAX_INPUT_LENGTH];
extern char * const male_where_name[];
extern char * const female_where_name[];
if ( !obj ) return "";
if ( obj->in_obj )
{
sprintf( buf, "inside his %s", short_obj_desc(you,obj->in_obj,FALSE) );
return buf;
}
if ( obj->carried_by == you )
{
if ( obj->wear_loc >= WEAR_LIGHT && obj->wear_loc < MAX_WEAR )
{
if ( IS_FEMALE(you) )
sprintf( buf, female_where_name[obj->wear_loc], "X", "her" );
else
sprintf( buf, male_where_name[obj->wear_loc], "X", "his" );
return &buf[2];
}
}
return "";
}
/*********************************************************************/
/**************************** PURE NUMBER ****************************/
/*********************************************************************/
int get_class( void ) { return ( you->class ); }
// int get_dot_mode( void ) { return (!IS_NPC(you) && IS_SET(you->act, PLR_DOT)); }
/*********************************************************************/
/********************** BOTH STRING AND NUMBER ***********************/
/*********************************************************************/
int get_wpn( void ) { return ( !!wpn ); }
char *get_wpn_text( void )
{ return ( wpn ? short_obj_desc(you,wpn,FALSE) : "fist" ); }
int wpn_diff( void ) { return ( wpn ? wpn->value[1] : 0 ); }
char *wpn_diff_text( void ) { return ( number_text(wpn_diff()) ); }
int wpn_dam( void ) { return ( wpn ? wpn->value[2] : 0 ); }
char *wpn_dam_text( void ) { return ( number_text(wpn_dam()) ); }
int wpn_where( void ) { return ( wpn ? wpn->wear_loc : -1 ); }
char *wpn_where_text( void ) { return ( obj_where_text( wpn ) ); }
// int get_generation( void )
// { return ( is_affected(you,gsn_potency) ? (you->vampgen_a + 1) : you->vampgen_a ); }
char *get_generation_text( void )
{
switch ( you->vampgen_a )
{
default: return "bugged";
case 15: return "15th";
case 14: return "14th";
case 13: return "13th";
case 12: return "12th";
case 11: return "11th";
case 10: return "10th";
case 9: return "9th";
case 8: return "8th";
case 7: return "7th";
case 6: return "6th";
case 5: return "5th";
case 4: return "4th";
case 3: return "3rd";
case 2: return "2nd";
case 1: return "1st";
}
}
int get_max_disc( void )
{
switch ( you->vampgen_a )
{
case 15: return 3;
case 14: return 4;
default: return 5;
case 7: return 6;
case 6: return 7;
case 5: return 8;
case 4: return 9;
case 3: return 10;
case 2: return 10;
case 1: return 10;
}
}
char *get_max_disc_text( void )
{
switch ( you->vampgen_a )
{
case 15: return "three";
case 14: return "four";
default: return "five";
case 7: return "six";
case 6: return "seven";
case 5: return "eight";
case 4: return "nine";
case 3: return "ten";
case 2: return "ten";
case 1: return "ten";
}
}
/*
int get_sect( void ) { return ( find_sectname( you ) ); }
char *get_sect_text( void )
{
return ( strlen(you->side) < 2 ? "None" : you->side );
}
int get_clan( void ) { return ( find_clanname( you ) ); }
char *get_clan_text( void )
{
return ( strlen(you->clan) < 2 ? "Caitiff" : you->clan );
}
int get_clandisc1( void )
{ return ( IS_NPC(you) ? -1 : you->pcdata->cland[0] ); }
char *get_clandisc1_text( void )
{ return ( get_clandisc1() < 0 ? "None" : disc_name(get_clandisc1()) ); }
int get_clandisc2( void )
{ return ( IS_NPC(you) ? -1 : you->pcdata->cland[1] ); }
char *get_clandisc2_text( void )
{ return ( get_clandisc2() < 0 ? "None" : disc_name(get_clandisc2()) ); }
int get_clandisc3( void )
{ return ( IS_NPC(you) ? -1 : you->pcdata->cland[2] ); }
char *get_clandisc3_text( void )
{ return ( get_clandisc3() < 0 ? "None" : disc_name(get_clandisc3()) ); }
int get_conscience( void )
{ return ( you->virtues[1] ); }
char *get_conscience_text( void )
{
switch ( you->virtues[1] )
{
default: return "bugged";
case 1: return "Chaste";
case 2: return "Moral";
case 3: return "Just";
case 4: return "Charitable";
case 5: return "Remorseful";
}
}
int get_selfcontrol( void )
{ return ( you->virtues[2] ); }
char *get_selfcontrol_text( void )
{
switch ( you->virtues[2] )
{
default: return "bugged";
case 1: return "Calm";
case 2: return "Temperate";
case 3: return "Disciplined";
case 4: return "Hardened";
case 5: return "Total self-mastery";
}
}
int get_courage( void )
{ return ( you->virtues[3] ); }
char *get_courage_text( void )
{
switch ( you->virtues[3] )
{
default: return "bugged";
case 1: return "Bold";
case 2: return "Dauntless";
case 3: return "Steadfast";
case 4: return "Gallant";
case 5: return "Valorous";
}
}
char *get_attribute_str_text(void) { return number_text(you->stats[STAT_STR]); }
int get_attribute_str(void) { return you->stats[STAT_STR]; }
char *get_attribute_dex_text(void) { return number_text(you->stats[STAT_DEX]); }
int get_attribute_dex(void) { return you->stats[STAT_DEX]; }
char *get_attribute_sta_text(void) { return number_text(you->stats[STAT_STA]); }
int get_attribute_sta(void) { return you->stats[STAT_STA]; }
char *get_attribute_cha_text(void) { return number_text(you->stats[STAT_CHA]); }
int get_attribute_cha(void) { return you->stats[STAT_CHA]; }
char *get_attribute_man_text(void) { return number_text(you->stats[STAT_MAN]); }
int get_attribute_man(void) { return you->stats[STAT_MAN]; }
char *get_attribute_app_text(void) { return number_text(you->stats[STAT_APP]); }
int get_attribute_app(void) { return you->stats[STAT_APP]; }
char *get_attribute_per_text(void) { return number_text(you->stats[STAT_PER]); }
int get_attribute_per(void) { return you->stats[STAT_PER]; }
char *get_attribute_int_text(void) { return number_text(you->stats[STAT_INT]); }
int get_attribute_int(void) { return you->stats[STAT_INT]; }
char *get_attribute_wit_text(void) { return number_text(you->stats[STAT_WIT]); }
int get_attribute_wit(void) { return you->stats[STAT_WIT]; }
*/
/*********************************************************/
#define STRING_FUNCTION(f) VARIABLE_FUNCTION_STRING, (char *) (f)
#define STRING_CONSTANT(f) VARIABLE_CONSTANT_STRING, (f)
#define NUMBER_FUNCTION(f) VARIABLE_FUNCTION_NUMBER, (void *) (f)
#define NUMBER_CONSTANT(f) VARIABLE_CONSTANT_NUMBER, (void *) (f)
#define END_OF_LIST VARIABLE_CONSTANT_NUMBER, NULL
int get_disc_animalism( void ) { return get_disc( you, VAM_ANIM ); }
char *get_disc_animalism_text( void )
{ return number_text(get_disc_animalism()); }
int get_disc_auspex( void ) { return get_disc( you, VAM_AUSP ); }
char *get_disc_auspex_text( void )
{ return number_text(get_disc_auspex()); }
int get_disc_celerity( void ) { return get_disc( you, VAM_CELE ); }
char *get_disc_celerity_text( void )
{ return number_text(get_disc_celerity()); }
int get_disc_chimerstry( void ) { return get_disc( you, VAM_CHIM ); }
char *get_disc_chimerstry_text( void )
{ return number_text(get_disc_chimerstry()); }
int get_disc_daimoinon( void ) { return get_disc( you, VAM_DAIM ); }
char *get_disc_daimoinon_text( void )
{ return number_text(get_disc_daimoinon()); }
int get_disc_dominate( void ) { return get_disc( you, VAM_DOMI ); }
char *get_disc_dominate_text( void )
{ return number_text(get_disc_dominate()); }
int get_disc_fortitude( void ) { return get_disc( you, VAM_FORT ); }
char *get_disc_fortitude_text( void )
{ return number_text(get_disc_fortitude()); }
int get_disc_melpominee( void ) { return get_disc( you, VAM_MELP ); }
char *get_disc_melpominee_text( void )
{ return number_text(get_disc_melpominee()); }
int get_disc_necromancy( void ) { return get_disc( you, VAM_NECR ); }
char *get_disc_necromancy_text( void )
{ return number_text(get_disc_necromancy()); }
int get_disc_obeah( void ) { return get_disc( you, VAM_OBEA ); }
char *get_disc_obeah_text( void )
{ return number_text(get_disc_obeah()); }
int get_disc_obfuscate( void ) { return get_disc( you, VAM_OBFU ); }
char *get_disc_obfuscate_text( void )
{ return number_text(get_disc_obfuscate()); }
int get_disc_obtenebration( void ) { return get_disc( you, VAM_OBTE);}
char *get_disc_obtenebration_text( void )
{ return number_text(get_disc_obtenebration()); }
int get_disc_potence( void ) { return get_disc( you, VAM_POTE ); }
char *get_disc_potence_text( void )
{ return number_text(get_disc_potence()); }
int get_disc_presence( void ) { return get_disc( you, VAM_PRES ); }
char *get_disc_presence_text( void )
{ return number_text(get_disc_presence()); }
int get_disc_protean( void ) { return get_disc( you, VAM_PROT ); }
char *get_disc_protean_text( void )
{ return number_text(get_disc_protean()); }
int get_disc_quietus( void ) { return get_disc( you, VAM_QUIE ); }
char *get_disc_quietus_text( void )
{ return number_text(get_disc_quietus()); }
int get_disc_serpentis( void ) { return get_disc( you, VAM_SERP ); }
char *get_disc_serpentis_text( void )
{ return number_text(get_disc_serpentis()); }
int get_disc_thanatosis( void ) { return get_disc( you, VAM_THAN ); }
char *get_disc_thanatosis_text( void )
{ return number_text(get_disc_thanatosis()); }
int get_disc_thaumaturgy( void ) { return get_disc( you, VAM_THAU ); }
char *get_disc_thaumaturgy_text( void )
{ return number_text(get_disc_thaumaturgy()); }
int get_disc_vicissitude( void ) { return get_disc( you, VAM_VICI ); }
char *get_disc_vicissitude_text( void )
{ return number_text(get_disc_vicissitude()); }