wflag.txt
snippets · 2.4 KB · 2010-03-30
wflag: toggle weapon flags on weapons (handy if you don't have OLC).
Download « Back to the snippets list
Here's a quick little function to toggle weapon flags on weapons. It can come in handy if you don't have OLC (like me because I'm lazy :). It seems to work, but hasn't been thoroughly tested as of yet. Here's a helpfile entry for it:
1 WFLAG~
Usage: wflag <object> <flag number>
WFLAG is used to add or remove weapon flags to/from a weapon.
The flag will be toggled when the command is used, ie, if it's on, it'll be turned off, and likewise.
Flag number table:
Flaming: 1
Frost: 2
Vampiric: 3
Sharp : 4
Vorpal: 5
Two Handed: 6
Shocking: 7
Poison: 8
~
put this in act_wiz.c:
void do_wflag(CHAR_DATA *ch, char *argument)
{
OBJ_DATA *obj;
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
int bitvector;
int flag;
argument = one_argument(argument, arg1);
argument = one_argument(argument, arg2);
if (arg1[0] == '\0' || arg2[0] == '\0')
{
send_to_char("Syntax: wflag <object> <flag number>\n",ch);
send_to_char("See the help file for a list of flag numbers.\n\r",ch);
return;
}
if ((obj = get_obj_world(ch, arg1)) == NULL)
{
send_to_char("Nothing like that in Heaven, Hell, or Earth.\n\r",ch);
return;
}
if(obj->item_type != ITEM_WEAPON)
{
send_to_char("That object is not a weapon.\n\r",ch);
return;
}
flag = atoi( arg2 );
switch ( flag )
{
case 1: bitvector = WEAPON_FLAMING; break;
case 2: bitvector = WEAPON_FROST; break;
case 3: bitvector = WEAPON_VAMPIRIC; break;
case 4: bitvector = WEAPON_SHARP; break;
case 5: bitvector = WEAPON_VORPAL; break;
case 6: bitvector = WEAPON_TWO_HANDS; break;
case 7: bitvector = WEAPON_SHOCKING; break;
case 8: bitvector = WEAPON_POISON; break;
default: bitvector = 0;
}
if (bitvector == 0)
{
send_to_char("There are no weapon flags like that.\n\r",ch);
return;
}
if (IS_SET(obj->value[4], bitvector))
REMOVE_BIT(obj->value[4], bitvector);
else
SET_BIT(obj->value[4], bitvector);
send_to_char("Ok.\n\r",ch);
return;
}
Any questions or comments can be sent to kyle@caseynet.com. You're welcome to use this without mentioning me - it's not that complex. :)
Enjoy,
Thori