keep_obj.c
snippets · 2.4 KB · 2010-03-30
keep_obj.c: ITEM_KEEP flag additions to tables.c and merc.h.
Download « Back to the snippets list
/*tables.c: const struct flag_type extra_flags[] =*/
{ "keep", ITEM_KEEP, TRUE },
/*merc.h in the item defines, ie ITEM_BLESS, ITEM_NODROP*/
#define ITEM_KEEP (X)
/*handler.c: char *extra_bit_name( long long vector )*/
if ( vector & ITEM_KEEP ) xcatf( buf, " keep" );
/*act_obj.c: void do_drop( CHAR_DATA *ch, char *argument )*/
/*Right BEFORE the first obj_from_char( obj );*/
if ( IS_SET(obj->extra_flags, ITEM_KEEP) )
REMOVE_BIT( obj->extra_flags, ITEM_KEEP);
/*also, right before the SECOND obj_from_char( obj );*/
&& !IS_SET(obj->extra_flags, ITEM_KEEP)//This line!
&& can_drop_obj( ch, obj ))
{
found = TRUE;
obj_from_char( obj );
/*act_obj.c: void do_steal( CHAR_DATA *ch, char *argument )*/
/*At the end of the steal function, where it says BAM!*/
/*Add this under BOTH check improves*/
if (IS_SET(obj->extra_flags,ITEM_KEEP))
REMOVE_BIT(obj->extra_flags,ITEM_KEEP);
/*interp.h*/
DECLARE_DO_FUN( do_keep );
/*interp.c*/
{ "keep", do_keep, POS_SLEEPING, 0, LOG_NORMAL, 1 },
/*act_obj.c: the keep function*/
/*keep function by Ghreth, 07/15/07*/
void do_keep( CHAR_DATA *ch, char *argument)
{
OBJ_DATA *obj;
OBJ_DATA *obj_next;
char buf[MSL];
bool keep;
keep = FALSE;
for ( obj = ch->carrying; obj != NULL; obj = obj_next )
{
obj_next = obj->next_content;
/*If you have any kept items already*/
if (IS_OBJ_STAT(obj,ITEM_KEEP))
{
keep =TRUE;
}
/*Checking, are you keeping anything? Do you want to?*/
if (argument[0] == '\0' && !keep)
{
send_to_char( "You aren't keeping anything.\n\r",ch);
return;
}
/*List of kept items*/
if(argument[0] == '\0' && keep)
{
send_to_char( "You are keeping:\n\r",ch);
xprintf(buf, "%s\n\r", obj->short_descr);
send_to_char(buf,ch);
return;
}
/*Do you have the item you want to keep?*/
if (obj == NULL)
{
send_to_char("You do not have that?\n\r",ch);
return;
}
/*Sets the flag on the item or removes it*/
if (!IS_SET(obj->extra_flags,ITEM_KEEP))
{
SET_BIT(obj->extra_flags,ITEM_KEEP);
xprintf(buf, "You decide to keep %s during 'drop all'.\n\r", obj->short_descr);
}
else
{
REMOVE_BIT(obj->extra_flags,ITEM_KEEP);
xprintf(buf, "You decide NOT to keep %s during 'drop all'.\n\r", obj->short_descr);
}
}
send_to_char(buf,ch);
return;
}