#include <sys/types.h> #include <stdio.h> #include <time.h> #include "merc.h" #include "interp.h" #include "act_pully.h" const struct pullyaction_type pullyaction_table[] = { {"no action"}, {"open door"}, {"close door"}, {"create item"}, {"create mobile"}, {NULL}, }; const struct pully_stat_type pully_stat_table[] = { {"no requirement", -1}, {"Strength", STAT_STR}, {"Wisdom", STAT_WIS}, {"Intelligence", STAT_INT}, {"Constitution", STAT_CON}, {"Dexterity", STAT_DEX}, {"Level", -1}, {"Class", -1}, {NULL, -2}, }; /* * pully_lookup() * * Takes the name, and returns table value of pully */ int pully_lookup(const char *name) { int i; for (i = 0; i < MAX_PULLY; i++) { if (pullyaction_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (pullyaction_table[i].name[0]) && !str_prefix (name, pullyaction_table[i].name)) return i; } return -1; } /* * pully_stat_lookup() * * Takes name, returns table value of the action */ int pully_stat_lookup(const char *name) { int i; for (i = 0; i < MAX_PULLY; i++) { if (pully_stat_table[i].name == NULL) break; if (LOWER (name[0]) == LOWER (pully_stat_table[i].name[0]) && !str_prefix (name, pully_stat_table[i].name)) return i; } return -1; } /* * pully_name_lookup() * * Wrapper, i had some cool stuff in here, removed it ;( */ char * pully_name_lookup(int value) { return pullyaction_table[value].name; } /* * cmd_pull() * * Ye pull command. Phrases the object's values and produces the * results. */ void cmd_pull(CHAR_DATA * ch, char *argument) { char buf[MSL]; char arg[MSL]; OBJ_DATA * obj; OBJ_INDEX_DATA *pObjIndex; OBJ_DATA *create; argument = one_argument (argument, arg); if (arg[0] == '\0') { stc("Pull on what item?\n", ch); return; } /* Boredom command ;) */ if (!str_prefix (arg, "self")) { stc("You pull on yourself for a little while. You fail to reach enlightment.\n", ch); return; } obj = get_obj_here (ch, arg); if (obj == NULL) { sprintf(buf, "You do not see any '%s' here to pull!\n", arg); stc(buf, ch); return; } if (obj->item_type != ITEM_PULLY) { sprintf(buf, "You search around %s looking for something to pull, but cannot find anything.\n", obj->short_descr); stc(buf, ch); return; } /* Ok its a pully, lets pull the thing! */ sprintf(buf, "You pull on %s.\n", obj->short_descr); stc(buf, ch); switch(obj->value[2]) { default: case 0: /* No action */ break; case 1: /* Ok we open a door, requires a room, and a direction if ((location = find_location (ch, obj->value[3])) == NULL) { log_string("cmd_pull: obj: (): Invalid room!\n"); return; } */ break; case 3: /* Create an item. Wheeww. Not too hard really. Creates it at location */ if ((pObjIndex = get_obj_index (obj->value[4])) == NULL) { log_string("cmd_pull: obj: (): Invalid obj vnum!\n"); return; } create = create_object (pObjIndex, pObjIndex->level); obj_to_room (create, ch->in_room); act ("$p drops to the floor!", NULL, create, NULL, TO_ROOM); sprintf(buf, "%s drops to the floor!\n", create->short_descr); stc(buf, ch); break; } } /* {"no action"}, {"open door"}, {"close door"}, {"create item"}, {"create mobile"}, V0 = Statistic to use V1 = Minimum requirement V2 = Action (open, close, create) V3 = Vnum of room to do this in V4 = Direction/Item vnum/Mob vnum */