|
Vwear command, cont. [by James A. Young] |
|
|
|
Posted Wednesday, August 12th @ 11:38:44 PM, by George Greer in the Wizard dept.
Updated Jun 26, 1997. Click the link below to read it or download it.
From: James A. Young <ja_young@fang.cs.sunyit.edu>
Subject: VWear. Again
This is a different, but the same approach to the vwear snippet. I made a
few changes so that everything was in one function. I renamed do_vwear
to do_veq to make things simpler and make expansion a lot easier.
Do the following:
In act.wizard.c add the following:
/* where the stuff is declared */
extern struct index_data *obj_index;
extern struct obj_data *obj_proto;
extern int top_of_objt;
/* Anywhere is fine */
ACMD(do_veq)
{
char field[MAX_INPUT_LENGTH], value[MAX_INPUT_LENGTH];
int i, j, l;
void vwear_object(int wearpos, struct char_data * ch) {
int nr, found = 0;
for (nr = 0; nr <= top_of_objt; nr++) {
if (CAN_WEAR(&obj_proto[nr], wearpos)) {
sprintf(buf, "%3d. [%5d] %s\r\n", ++found,
obj_index[nr].virtual, obj_proto[nr].short_description);
send_to_char(buf, ch);
}
}
}
struct listeq_struct {
char *cmd;
int level;
}
/* Change the LVL_GOD1 to your appropriate god levels */
fields[] = {
{ "nothing", LVL_GOD1 },
{ "finger", LVL_GOD1 },
{ "neck", LVL_GOD1 },
{ "body", LVL_GOD1 },
{ "head", LVL_GOD1 },
{ "legs", LVL_GOD1 },
{ "feet", LVL_GOD1 },
{ "hands", LVL_GOD1 },
{ "shield", LVL_GOD1 },
{ "arms", LVL_GOD1 },
{ "about", LVL_GOD1 },
{ "waist", LVL_GOD1 },
{ "wrist", LVL_GOD1 },
{ "wield", LVL_GOD1 },
{ "hold", LVL_GOD1 },
/* Add any extra eq types here */
{ "\n", 0 }
};
skip_spaces(&argument);
if (!*argument) {
strcpy(buf, "List eq options:\r\n");
for (j = 0, i = 1; fields[i].level; i++)
if (fields[i].level <= GET_LEVEL(ch))
sprintf(buf, "%s%-15s%s", buf, fields[i].cmd, (!(++j % 5) ? "\r\n" : ""
));
strcat(buf, "\r\n");
send_to_char(buf, ch);
return;
}
strcpy(arg, two_arguments(argument, field, value));
for (l = 0; *(fields[l].cmd) != '\n'; l++)
if (!strncmp(field, fields[l].cmd, strlen(field)))
break;
if (GET_LEVEL(ch) < fields[l].level) {
send_to_char("You are not godly enough for that!\r\n", ch);
return;
}
buf[0] = '\0';
switch (l) {
/* The order is based on the above list. Try and keep the same order */
/* otherwise you will get what you DON'T want */
case 1: /* Finger eq */
vwear_object(ITEM_WEAR_FINGER, ch);
break;
case 2: /* Neck eq */
vwear_object(ITEM_WEAR_NECK, ch);
break;
case 3: /* Body eq */
vwear_object(ITEM_WEAR_BODY, ch);
break;
case 4: /* Head eq */
vwear_object(ITEM_WEAR_HEAD, ch);
break;
case 5: /* Leg eq */
vwear_object(ITEM_WEAR_LEGS, ch);
break;
case 6: /* Foot eq */
vwear_object(ITEM_WEAR_FEET, ch);
break;
case 7: /* Hand eq */
vwear_object(ITEM_WEAR_HANDS, ch);
break;
case 8: /* Shield eq */
vwear_object(ITEM_WEAR_SHIELD, ch);
break;
case 9: /* Arm eq */
vwear_object(ITEM_WEAR_ARMS, ch);
break;
case 10: /* Worn about body eq */
vwear_object(ITEM_WEAR_ABOUT, ch);
break;
case 11: /* Waist eq */
vwear_object(ITEM_WEAR_WAIST, ch);
break;
case 12: /* Wrist eq */
vwear_object(ITEM_WEAR_WRIST, ch);
break;
case 13: /* Wielded objects */
vwear_object(ITEM_WEAR_WIELD, ch);
break;
case 14: /* Held eq */
vwear_object(ITEM_WEAR_HOLD, ch);
break;
/* You add any other eq types here */
default:
send_to_char("Come again?\r\n", ch);
break;
}
}
In db.h add the following:
void vwear_object(int wearpos, struct char_data * ch);
In interpreter.c add the following
ACMD(do_veq);
- and -
{ "veq" , POS_DEAD , do_veq , LVL_GOD1, 0 },
^^^
again change the LVL_GOD1
Any bugs or questions, feel free to contact me.
James A. Young
<< Vwear command, cont. [by Christian Duvall] | Reply | View as text | Flattened | Water Currents [by Chuck Reed] >> |
|
Related Links |
|
|
|
CircleMUD Snippets |
|
|
Note: Not all of these snippets will work perfectly with
your version of code, so be prepared to fix one
or two bugs that may arise, and please let me know
what you needed to do to fix it. Sending a corrected
version is always welcome.
|
Finally, if you wish to use any of the snippets from this
page, you are more than welcome, just mention the
authors in your credits. If you wish to release any
of these snippets to the public on another site,
contact me FIRST.
|
|
|
|
|
|
|