#include <sys/types.h> #include <stdio.h> #include <string.h> #include <time.h> #include "merc.h" #include "interp.h" #include "tables.h" #include "rig.h" #include "rig_tables.h" /* * rig_weapon_lookup() * * Returns table number of Weapon table based on name */ int rig_weapon_lookup(const char *name) { int i; for (i = 0; rig_weapons_table[i].name != NULL; i++) { if (rig_weapons_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_weapons_table[i].name[0]) && !str_prefix (name, rig_weapons_table[i].name)) return i; } return -1; } /* * rig_armor_lookup() * * Returns table number of Armor table based on name */ int rig_armor_lookup(const char *name) { int i; for (i = 0; rig_armor_table[i].name != NULL; i++) { if (rig_armor_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_armor_table[i].name[0]) && !str_prefix (name, rig_armor_table[i].name)) return i; } return -1; } /* * rig_material_lookup() * * Returns table number of Material table based on name */ int rig_material_lookup(const char *name) { int i; for (i = 0; rig_material_table[i].name != NULL; i++) { if (rig_material_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_material_table[i].name[0]) && !str_prefix (name, rig_material_table[i].name)) return i; } return -1; } /* * rig_clothing_lookup() * * Returns table number of clothing table based on name */ int rig_clothing_lookup(const char *name) { int i; for (i = 0; rig_clothing_table[i].name != NULL; i++) { if (rig_clothing_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_clothing_table[i].name[0]) && !str_prefix (name, rig_clothing_table[i].name)) return i; } return -1; } /* * rig_clothing_exp_lookup() * * Returns table number of clothing_exp table based on name */ int rig_clothing_exp_lookup(const char *name) { int i; for (i = 0; rig_clothing_exp_table[i].name != NULL; i++) { if (rig_clothing_exp_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_clothing_exp_table[i].name[0]) && !str_prefix (name, rig_clothing_exp_table[i].name)) return i; } return -1; } /* * rig_wizscroll_lookup() * * Returns table number of wizscroll table based on name */ int rig_wizscroll_lookup(const char *name) { int i; for (i = 0; rig_wizscroll_table[i].name != NULL; i++) { if (rig_wizscroll_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_wizscroll_table[i].name[0]) && !str_prefix (name, rig_wizscroll_table[i].name)) return i; } return -1; } /* * rig_priscroll_lookup() * * Returns table number of priscroll table based on name */ int rig_priscroll_lookup(const char *name) { int i; for (i = 0; rig_priscroll_table[i].name != NULL; i++) { if (rig_priscroll_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_priscroll_table[i].name[0]) && !str_prefix (name, rig_priscroll_table[i].name)) return i; } return -1; } /* * rig_fighter_tome_lookup() * * Returns table number of fighter_tome table based on name */ int rig_fighter_tome_lookup(const char *name) { int i; for (i = 0; rig_fighter_tome_table[i].name != NULL; i++) { if (rig_fighter_tome_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_fighter_tome_table[i].name[0]) && !str_prefix (name, rig_fighter_tome_table[i].name)) return i; } return -1; } /* * rig_thief_tome_lookup() * * Returns table number of thief_tome table based on name */ int rig_thief_tome_lookup(const char *name) { int i; for (i = 0; rig_thief_tome_table[i].name != NULL; i++) { if (rig_thief_tome_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_thief_tome_table[i].name[0]) && !str_prefix (name, rig_thief_tome_table[i].name)) return i; } return -1; } /* * rig_potion_lookup() * * Returns table number of potions */ int rig_potion_lookup(const char *name) { int i; for (i = 0; rig_potion_table[i].name != NULL; i++) { if (rig_potion_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_potion_table[i].name[0]) && !str_prefix (name, rig_potion_table[i].name)) return i; } return -1; } /* * rig_potion_heal_lookup() * * Returns table number of potion_heals */ int rig_potion_heal_lookup(const char *name) { int i; for (i = 0; rig_potion_heal_table[i].name != NULL; i++) { if (rig_potion_heal_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_potion_heal_table[i].name[0]) && !str_prefix (name, rig_potion_heal_table[i].name)) return i; } return -1; } /* * rig_beer_lookup() * * Returns table number of beers */ int rig_beer_lookup(const char *name) { int i; for (i = 0; rig_beer_table[i].name != NULL; i++) { if (rig_beer_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_beer_table[i].name[0]) && !str_prefix (name, rig_beer_table[i].name)) return i; } return -1; } /* * rig_food_lookup() * * Returns table number of foods */ int rig_food_lookup(const char *name) { int i; for (i = 0; rig_food_table[i].name != NULL; i++) { if (rig_food_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (rig_food_table[i].name[0]) && !str_prefix (name, rig_food_table[i].name)) return i; } return -1; } /* * rig_weapon_max() * * Returns total # of weapons availible */ int rig_weapon_max(void) { int i, cnt = 0; for (i = 0; rig_weapons_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_armor_max() * * Returns total # of armor availible */ int rig_armor_max(void) { int i, cnt = 0; for (i = 0; rig_armor_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_material_max() * * Returns total # of material availible */ int rig_material_max(void) { int i, cnt = 0; for (i = 0; rig_material_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_clothing_max() * * Returns total # of clothing availible */ int rig_clothing_max(void) { int i, cnt = 0; for (i = 0; rig_clothing_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_clothing_exp_max() * * Returns total # of clothing_exp availible */ int rig_clothing_exp_max(void) { int i, cnt = 0; for (i = 0; rig_clothing_exp_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_wizscroll_max() * * Returns total # of wizscroll availible */ int rig_wizscroll_max(void) { int i, cnt = 0; for (i = 0; rig_wizscroll_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_priscroll_max() * * Returns total # of priscroll availible */ int rig_priscroll_max(void) { int i, cnt = 0; for (i = 0; rig_priscroll_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_fighter_tome_max() * * Returns total # of fighter_tome availible */ int rig_fighter_tome_max(void) { int i, cnt = 0; for (i = 0; rig_fighter_tome_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_thief_tome_max() * * Returns total # of thief_tome availible */ int rig_thief_tome_max(void) { int i, cnt = 0; for (i = 0; rig_thief_tome_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_potion_spell_max() * * Returns total # of priscroll availible */ int rig_potion_max(void) { int i, cnt = 0; for (i = 0; rig_potion_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_potion_heal_spell_max() * * Returns total # of priscroll availible */ int rig_potion_heal_max(void) { int i, cnt = 0; for (i = 0; rig_potion_heal_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_beer_spell_max() * * Returns total # of priscroll availible */ int rig_beer_max(void) { int i, cnt = 0; for (i = 0; rig_beer_table[i].name != NULL; i++) cnt++; return cnt; } /* * rig_food_spell_max() * * Returns total # of priscroll availible */ int rig_food_max(void) { int i, cnt = 0; for (i = 0; rig_food_table[i].name != NULL; i++) cnt++; return cnt; } /* * weapontype_lookup() * * Returns word of weapon skill type */ char * weapontype_lookup(int value0) { switch (value0) { case (WEAPON_EXOTIC): return "exotic"; break; case (WEAPON_SWORD): return "sword"; break; case (WEAPON_DAGGER): return "dagger"; break; case (WEAPON_SPEAR): return "staff"; break; case (WEAPON_MACE): return "mace"; break; case (WEAPON_AXE): return "axe"; break; case (WEAPON_FLAIL): return "flail"; break; case (WEAPON_WHIP): return "whip"; break; case (WEAPON_POLEARM): return "polearm"; break; default: return "unknown"; break; } return "unknown"; } /* * armortype_lookup() * Returns armor type */ char * armortype_lookup(int type) { switch(type) { default: return "unknown"; break; case ARMOR_NONE: return "none"; break; case ARMOR_LIGHT: return "light"; break; case ARMOR_MEDIUM: return "medium"; break; case ARMOR_HEAVY: return "heavy"; break; } return "unknown"; } /* * truefalse() * * Kinda easy here... */ char * truefalse(bool istrue) { if (istrue) return "true"; else return "false"; return "false"; }