A blog to follow the development stages of the different programs I am currently in the process of writing.

Sunday, April 15, 2007

Sheathe/Draw SMAUG Snippet

After much frustration and fiddling I finally got my Sheath/Draw code to work for SMAUG. I'll post it here because you need a lot of the hardcoded stuff for it to work.

void do_sheath( CHAR_DATA * ch, char *argument )
{

OBJ_DATA *w_weapon;
OBJ_DATA *w_sheath;
if( ( w_weapon = get_obj_wear( ch, argument ) ) == NULL )

{
send_to_char( "Sheath what?\r\n", ch );
return;
}
if( ( w_sheath = get_eq_char(ch, WEAR_SHEATH ) ) == NULL )

{
send_to_char("\nYou must have something to put the weapon into.\r\n", ch);
return;
}
else
{


separate_obj(w_weapon);
obj_from_char( w_weapon );
w_weapon = obj_to_obj( w_weapon, w_sheath );

ch_printf(ch, "You dextrously slide %s into %s", w_weapon->short_descr,
w_sheath->short_descr);
return;
}
}

void do_draw( CHAR_DATA * ch, char *argument )
{

OBJ_DATA *w_weapon;
OBJ_DATA *w_sheath;

if( argument == '\0' )

{
send_to_char( "Draw what?\r\n", ch );
return;
}
if( ( w_sheath = get_eq_char(ch, WEAR_SHEATH ) ) == NULL )

{
send_to_char("\nYou don't even have a sheath to draw from.\r\n", ch);
return;
}
else
{


w_weapon = get_obj_list( ch, argument, w_sheath->first_content);
if( !w_weapon )

{
act( AT_PLAIN, "There is no $T sheathed.", ch, NULL, argument,
TO_CHAR );

return;
}
// get_obj( ch, w_weapon, w_sheath );
obj_from_obj( w_weapon );
obj_to_char( w_weapon, ch );
equip_char( ch, w_weapon, WEAR_WIELD );

ch_printf(ch, "You quickly draw %s from %s", w_weapon->short_descr,
w_sheath->short_descr);

return;
}
}




Feel free to ask questions or comment here or send me and email.

Labels:

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home