outfitfix.txt
snippets · 3.4 KB · 2010-03-30
Outfit fix for ROM 2.4b6 (novice level, single file).
Download « Back to the snippets list
/*
* Code type: fix
* Code base: Rom 2.4b6
* Multi-file: no
* Level: novice (yet it took me this long to finally just do it, hehe)
* Author: Vorlin
* Date: 11/5/02
*
* Disclaimer: I've just done this now and put a minor amount of claim to
* it although I'm sure it's been done elsewhere. If you see a better way
* to do this, whether it's through a function or something, please let me
* know as I'm trying to better things in stock rom just for practice.
*
* Instructions: replace do_outfit with this version. You'll see the checks
* that prevent a newbie from 'outfit;rem all;outfit;rem all;...'. The obj = NULL
* is me being paranoid although cleanup is done. Please keep credits intact if
* used. Thanks.
*/
/*
equips a character - checks for inventory before equipping but only
after the object is created --Vorlin
*/
void do_outfit ( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *obj;
int i,sn,vnum;
char buf[MAX_STRING_LENGTH];
if (ch->level > 5 || IS_NPC(ch))
{
send_to_char("Find it yourself!\n\r",ch);
return;
}
/* Bug fix for outfit --Vorlin */
if (ch->carry_number + 4 > can_carry_n(ch)) {
send_to_char
("You're carrying too much, try dropping some items.\n\r", ch);
return;
}
if ((obj = get_eq_char(ch, WEAR_LIGHT)) == NULL)
{
obj = create_object( get_obj_index(OBJ_VNUM_SCHOOL_BANNER), 0 );
if (get_obj_carry(ch, obj->name, ch) == NULL) {
obj->cost = 0;
obj_to_char( obj, ch );
equip_char( ch, obj, WEAR_LIGHT );
} else {
obj = NULL;
}
}
if ((obj = get_eq_char(ch, WEAR_BODY)) == NULL)
{
obj = create_object( get_obj_index(OBJ_VNUM_SCHOOL_VEST), 0 );
if (get_obj_carry(ch, obj->name, ch) == NULL) {
obj->cost = 0;
obj_to_char( obj, ch );
equip_char( ch, obj, WEAR_BODY );
} else {
obj = NULL;
}
}
/* do the weapon thing */
if ((obj = get_eq_char(ch,WEAR_WIELD)) == NULL)
{
sn = 0;
vnum = OBJ_VNUM_SCHOOL_SWORD; /* just in case! */
for (i = 0; weapon_table[i].name != NULL; i++)
{
if (ch->pcdata->learned[sn] <
ch->pcdata->learned[*weapon_table[i].gsn])
{
sn = *weapon_table[i].gsn;
vnum = weapon_table[i].vnum;
}
}
obj = create_object(get_obj_index(vnum),0);
if (get_obj_carry(ch, obj->name, ch) == NULL) {
obj_to_char(obj,ch);
equip_char(ch,obj,WEAR_WIELD);
} else {
obj = NULL;
}
}
if (((obj = get_eq_char(ch,WEAR_WIELD)) == NULL
|| !IS_WEAPON_STAT(obj,WEAPON_TWO_HANDS))
&& (obj = get_eq_char( ch, WEAR_SHIELD ) ) == NULL )
{
obj = create_object( get_obj_index(OBJ_VNUM_SCHOOL_SHIELD), 0 );
if (get_obj_carry(ch, obj->name, ch) == NULL) {
obj->cost = 0;
obj_to_char( obj, ch );
equip_char( ch, obj, WEAR_SHIELD );
} else {
obj = NULL;
}
}
sprintf(buf, "The gods of `&%s`` have equipped you.\n\r", MUD_NAME);
send_to_char(buf, ch);
}