#include <sys/types.h>
#include <stdio.h>
#include <time.h>
#include "merc.h"
#include "tables.h"

/* for position */
const struct position_type position_table[] = {
  {"dead", "dead"},
  {"mortally wounded", "mort"},
  {"incapacitated", "incap"},
  {"stunned", "stun"},
  {"sleeping", "sleep"},
  {"resting", "rest"},
  {"sitting", "sit"},
  {"fighting", "fight"},
  {"standing", "stand"},
  {"tethered", "tether"}, 
  {"mounted", "mount"}, 
  {"feigning_death","feign"},
  {"chopping", "chop"},
  {"milling", "mill"},
  {"carving", "carve"},
  {NULL, NULL}
};

/* for sex */
const struct sex_type sex_table[] = {
  {"none"}, {"male"}, {"female"}, {"either"}, {NULL}
};

/* for sizes */
const struct size_type size_table[] = {
  {"tiny"},
  {"small"}, {"medium"}, {"large"}, {"huge",}, {"giant"}, {NULL}
};

/* various flag tables */
const struct flag_type act_flags[] = {
  {"npc", A, FALSE},
  {"sentinel", B, TRUE},
  {"scavenger", C, TRUE},
  {"no_scent", E, TRUE},
  {"aggressive", F, TRUE},
  {"stay_area", G, TRUE},
  {"wimpy", H, TRUE},
  {"pet", I, TRUE},
  {"train", J, TRUE},
  {"hunt", M, TRUE},
  {"remember", N, TRUE},
  {"smart_hunt", X, TRUE},
  {"practice", K, TRUE},
  {"halt", L, TRUE},
  {"undead", O, TRUE},
  {"cleric", Q, TRUE},
  {"mage", R, TRUE},
  {"thief", S, TRUE},
  {"warrior", T, TRUE},
  {"bounty", U, TRUE},
  {"nopurge", V, TRUE},
  {"outdoors", W, TRUE},
  {"indoors", Y, TRUE},
  {"mount", Z, TRUE},
  {"healer", aa, TRUE},
  {"gain", bb, TRUE},
  {"looter", cc, TRUE},
  {"changer", dd, TRUE}, {"tame", ee, TRUE}, //{"croupier", ff, TRUE},
//  {"aggressive_to_all", gg, TRUE},
  {NULL, 0, FALSE}
};

// Adeon 7/1/03 -- Act flag 2 expansion
const struct flag_type act_flags2[] = {
  {"blockexit", A, TRUE}, 
  {"nosink", B, TRUE}, 
  {"illusion", C, TRUE},
  {"nomove", D, TRUE},
  {"familiar", E, FALSE},
  {"puppet", F, FALSE},
  {"puppeteer", G, FALSE},
  {"monk", H, TRUE},
  {"necromancer", I, TRUE},
  {"questmaster", J, TRUE},
  {"questmob", K, FALSE},
  {"aggie_evil", L, TRUE},
  {"aggie_neutral", M, TRUE},
  {"aggie_good", N, TRUE},
  {"transformer", O, FALSE},
  {"croupier", P, TRUE},
  {"mageskills",ACT_MAGE_SKILLS,TRUE},
  {"nokill",ACT_NO_KILL,TRUE},
  {"noalign",ACT_NO_ALIGN,TRUE},
  {"trapmob",ACT_TRAPMOB,FALSE},
  {"noblock",ACT_NO_BLOCK,TRUE},
  {"staysector",ACT_STAY_SECTOR,TRUE},
  {"warped",ACT_WARPED,TRUE},
  {"imaginary", ACT_IMAGINARY, TRUE},
  {"switched", ACT_SWITCHED, FALSE},
  {"all_skills", ACT_ALL_SKILLS, TRUE},
  {"always_mirrored", ACT_ALWAYS_MIRRORED,TRUE},
  {NULL, 0, FALSE}
};
const struct flag_type plr_flags[] = {
  {"npc", A, FALSE},
  {"autoassist", C, FALSE},
  {"autoexit", D, FALSE},
  {"autoloot", E, FALSE},
  {"autosac", F, FALSE},
  {"autogold", G, FALSE},
  {"autosplit", H, FALSE},
  {"holylight", N, FALSE},
  {"can_loot", P, FALSE},
  {"nosummon", Q, FALSE},
  {"nofollow", R, FALSE},
  {"permit", U, TRUE},
  {"log", W, FALSE},
  {"deny", X, FALSE},
  {"freeze", Y, FALSE},
  {"thief", Z, FALSE}, {"killer", aa, FALSE}, {NULL, 0, 0}
};
const struct flag_type recruit_flags[] = {
  {"pskeeper", RECRUIT_KEEPER, TRUE}, {NULL, 0, 0}
};
const struct flag_type affect_flags[] = {
  {"blind", A, TRUE},
  {"invisible", B, TRUE},
  {"detect_evil", C, TRUE},
  {"detect_invis", D, TRUE},
  {"detect_magic", E, TRUE},
  {"detect_hidden", F, TRUE},
  {"detect_good", G, TRUE},
  {"sanctuary", H, TRUE},
  {"faerie_fire", I, TRUE},
  {"infrared", J, TRUE},
  {"curse", K, TRUE},
  {"poison", M, TRUE},
  {"protect_evil", N, TRUE},
  {"protect_good", O, TRUE},
  {"sneak", P, TRUE},
  {"hide", Q, TRUE},
  {"sleep", R, TRUE},
  {"charm", S, TRUE},
  {"flying", T, TRUE},
  {"pass_door", U, TRUE},
  {"haste", V, TRUE},
  {"calm", W, TRUE},
  {"plague", X, TRUE},
  {"weaken", Y, TRUE},
  {"dark_vision", Z, TRUE},
  {"berserk", aa, TRUE},
  {"swim", bb, TRUE},
  {"regeneration", cc, TRUE},
  {"slow", dd, TRUE}, {"aqua_breathe", ee, TRUE}, {NULL, 0, 0}
};
const struct flag_type off_flags[] = {
  {"area_attack", A, TRUE},
  {"backstab", B, TRUE},
  {"bash", C, TRUE},
  {"berserk", D, TRUE},
  {"disarm", E, TRUE},
  {"dodge", F, TRUE},
  {"fade", G, TRUE},
  {"fast", H, TRUE},
  {"kick", I, TRUE},
  {"dirt_kick", J, TRUE},
  {"parry", K, TRUE},
  {"rescue", L, TRUE},
  {"tail", M, TRUE},
  {"trip", N, TRUE},
  {"crush", O, TRUE},
  {"assist_all", P, TRUE},
  {"assist_align", Q, TRUE},
  {"assist_race", R, TRUE},
  {"assist_players", S, TRUE},
  {"assist_guard", T, TRUE},
  {"assist_vnum", U, TRUE},
  {"charge", V, TRUE},
  {"sweep", W, TRUE},
  {"throwing", X, TRUE}, 
  {"trample", Y, TRUE}, 
  {"uppercut", OFF_UPPERCUT, TRUE},
  {"counter", OFF_COUNTER, TRUE},
  {"assist_exact_align",ASSIST_EXACT_ALIGN,TRUE},
  {"kai", OFF_KAI, TRUE},
  {"hellbreath", OFF_HELLBREATH, TRUE},
  {"stun", OFF_STUN, TRUE},
  {NULL, 0, 0}
};
const struct flag_type imm_flags[] = {
  {"summon", A, TRUE},
  {"charm", B, TRUE},
  {"magic", C, TRUE},
  {"weapon", D, TRUE},
  {"bash", E, TRUE},
  {"pierce", F, TRUE},
  {"slash", G, TRUE},
  {"fire", H, TRUE},
  {"cold", I, TRUE},
  {"lightning", J, TRUE},
  {"acid", K, TRUE},
  {"poison", L, TRUE},
  {"negative", M, TRUE},
  {"holy", N, TRUE},
  {"energy", O, TRUE},
  {"mental", P, TRUE},
  {"disease", Q, TRUE},
  {"drowning", R, TRUE},
  {"light", S, TRUE},
  {"sound", T, TRUE},
  {"entangle", U, TRUE},
  {"wood", X, TRUE},
  {"silver", Y, TRUE},
  {"iron", Z, TRUE}, 
  {"levels", aa, TRUE}, 
  {"blind", bb, TRUE},
  {"sleep", cc, TRUE},
  {"arrows", dd, TRUE},
  {"wind", ee, TRUE},
  {NULL, 0, 0}
};
const struct flag_type form_flags[] = {
  {"edible", FORM_EDIBLE, TRUE},
  {"poison", FORM_POISON, TRUE},
  {"magical", FORM_MAGICAL, TRUE},
  {"instant_decay", FORM_INSTANT_DECAY, TRUE},
  {"other", FORM_OTHER, TRUE},
  {"animal", FORM_ANIMAL, TRUE},
  {"sentient", FORM_SENTIENT, TRUE},
  {"undead", FORM_UNDEAD, TRUE},
  {"construct", FORM_CONSTRUCT, TRUE},
  {"mist", FORM_MIST, TRUE},
  {"intangible", FORM_INTANGIBLE, TRUE},
  {"biped", FORM_BIPED, TRUE},
  {"centaur", FORM_CENTAUR, TRUE},
  {"insect", FORM_INSECT, TRUE},
  {"spider", FORM_SPIDER, TRUE},
  {"crustacean", FORM_CRUSTACEAN, TRUE},
  {"worm", FORM_WORM, TRUE},
  {"blob", FORM_BLOB, TRUE},
  {"mammal", FORM_MAMMAL, TRUE},
  {"bird", FORM_BIRD, TRUE},
  {"reptile", FORM_REPTILE, TRUE},
  {"snake", FORM_SNAKE, TRUE},
  {"dragon", FORM_DRAGON, TRUE},
  {"amphibian", FORM_AMPHIBIAN, TRUE},
  {"fish", FORM_FISH, TRUE},
  {"cold_blood", FORM_COLD_BLOOD, TRUE}, {NULL, 0, 0}
};
const struct flag_type part_flags[] = {
  {"head", PART_HEAD, TRUE},
  {"arms", PART_ARMS, TRUE},
  {"legs", PART_LEGS, TRUE},
  {"heart", PART_HEART, TRUE},
  {"brains", PART_BRAINS, TRUE},
  {"guts", PART_GUTS, TRUE},
  {"hands", PART_HANDS, TRUE},
  {"feet", PART_FEET, TRUE},
  {"fingers", PART_FINGERS, TRUE},
  {"ear", PART_EAR, TRUE},
  {"eye", PART_EYE, TRUE},
  {"long_tongue", PART_LONG_TONGUE, TRUE},
  {"eyestalks", PART_EYESTALKS, TRUE},
  {"tentacles", PART_TENTACLES, TRUE},
  {"fins", PART_FINS, TRUE},
  {"wings", PART_WINGS, TRUE},
  {"tail", PART_TAIL, TRUE},
  {"claws", PART_CLAWS, TRUE},
  {"fangs", PART_FANGS, TRUE},
  {"horns", PART_HORNS, TRUE},
  {"scales", PART_SCALES, TRUE},
  {"tusks", PART_TUSKS, TRUE},
  {"feathers", PART_FEATHERS, TRUE},
  {"eye", PART_EYE, TRUE}, {NULL, 0, 0}
};
const struct flag_type comm_flags[] = {
  {"quiet", COMM_QUIET, TRUE},
  {"deaf", COMM_DEAF, TRUE},
  {"nowiz", COMM_NOWIZ, TRUE},
  {"noclangossip", COMM_NOAUCTION, TRUE},
  {"nogossip", COMM_NOGOSSIP, TRUE},
  {"noquestion", COMM_NOQUESTION, TRUE},
  {"nomusic", COMM_NOMUSIC, TRUE},
  {"noclan", COMM_NOCLAN, TRUE},
  {"noooc", COMM_NOOOC, TRUE},
  {"shoutsoff", COMM_SHOUTSOFF, TRUE},
  {"true_trust", COMM_TRUE_TRUST, TRUE},
  {"compact", COMM_COMPACT, TRUE},
  {"brief", COMM_BRIEF, TRUE},
  {"prompt", COMM_PROMPT, TRUE},
  {"combine", COMM_COMBINE, TRUE},
  {"telnet_ga", COMM_TELNET_GA, TRUE},
  {"show_affects", COMM_SHOW_AFFECTS, TRUE},
  {"nograts", COMM_NOGRATS, TRUE},
  {"noemote", COMM_NOEMOTE, FALSE},
  {"noshout", COMM_NOSHOUT, FALSE},
  {"notell", COMM_NOTELL, FALSE},
  {"nochannels", COMM_NOCHANNELS, FALSE},
  {"snoop_proof", COMM_SNOOP_PROOF, FALSE},
  {"afk", COMM_AFK, TRUE},
  {"noadmin", COMM_NOADMIN, TRUE},
  {"hearclan", COMM_HEARCLAN, TRUE},
  {"notitle", COMM_NOTITLE, TRUE},
  {"nosuperduel", COMM_NOSUPERDUEL, TRUE},
  {"nopk", COMM_NOPK, TRUE},
  {NULL, 0, 0}
};

const struct flag_type comm2_flags[] = {
  {"norant", COMM_NORANT, TRUE},
  {"rantonly", COMM_RANTONLY, TRUE},
  {"nopoll", COMM_NOPOLL,TRUE},
  {"nogemote", COMM_NOGEMOTE,TRUE},
  {"imm_nogemote", COMM_IMM_NOGEMOTE,TRUE},
  {"nodelete", COMM_NODELETE,TRUE},
  {"showdamage", COMM_SHOWDAMAGE,TRUE},
  {"shutup", COMM_SHUTUP, TRUE},
  {NULL, 0, 0}
};

const struct wear_translation_type wear_conversion_table[] = {
  {WEAR_NONE,0,"",""},
  {WEAR_LIGHT,ITEM_WEAR_LIGHT, "as a light","light","used as light"},
  {WEAR_CREST,ITEM_WEAR_CREST,"as a crest","crest","worn as crest"},
  {WEAR_FINGER_L,ITEM_WEAR_FINGER, "on your finger","finger","worn on finger"},
  {WEAR_FINGER_R,ITEM_WEAR_ANOTHER_FINGER, "on your finger","finger","worn on finger"},
  {WEAR_NECK_1,ITEM_WEAR_NECK, "around your neck","neck","worn around neck"},
  {WEAR_NECK_2,ITEM_WEAR_ANOTHER_NECK, "around your neck","neck","worn around neck"},
  {WEAR_BODY,ITEM_WEAR_BODY,"about your torso","torso","worn on torso"},
  {WEAR_HEAD,ITEM_WEAR_HEAD,"on your head","head","worn on head"},
  {WEAR_FACE,ITEM_WEAR_FACE,"on your face","face","worn on face"},
  {WEAR_EARS,ITEM_WEAR_EARS,"in your ears","ears","worn in ears"},
  {WEAR_LEGS,ITEM_WEAR_LEGS,"on your legs","legs","worn on legs"},
  {WEAR_FEET,ITEM_WEAR_FEET,"on your feet","feet","worn on feet"},
  {WEAR_HANDS,ITEM_WEAR_HANDS,"on your hands","hands","worn on hands"},
  {WEAR_ARMS,ITEM_WEAR_ARMS,"on your arms","arms","worn on arms"},
  {WEAR_TATTOO,ITEM_WEAR_TATTOO,"as a tattoo","tattoo","tattoed"},
  {WEAR_SHIELD,ITEM_WEAR_SHIELD,"as a shield","shield","worn as shield"},
  {WEAR_ABOUT,ITEM_WEAR_ABOUT,"about your body","body","worn about body"},
  {WEAR_WAIST,ITEM_WEAR_WAIST,"about your waist","waist","worn about waist"},
  {WEAR_WRIST_L,ITEM_WEAR_WRIST,"around your wrist","wrist","worn around wrist"},
  {WEAR_WRIST_R,ITEM_WEAR_ANOTHER_WRIST,"around your wrist","wrist","worn around wrist"},
  {WEAR_WIELD_R,ITEM_WIELD,"as a weapon","weapon","wielded right"},
  {WEAR_WIELD_L,ITEM_TWO_HANDS,"as a weapon","weapon","wielded left"},
  {WEAR_HOLD,ITEM_HOLD,"in your hands","held","held"},
  {WEAR_FLOAT,ITEM_WEAR_FLOAT,"as a floatie","floatie","floating nearby"},
  {-2,0,"","",""}
};