drag.c
snippets · 3.2 KB · 2010-03-30
drag command: drag corpses or players to another room (idea by Artur Biesiadowski), C version.
Download « Back to the snippets list
From: "Artur 'Revinor' Biesiadowski" <abies@pg.gda.pl>
/* You have to put definition of this fun in merc.h
and put its somewhere in interp.h */
/* In act there is some $? - I don't remember what to put there - figure it
by yourself */
void do_drag( CHAR_DATA * ch, char * argument )
{
char buf[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
ROOM_INDEX_DATA *rvnum;
CHAR_DATA *vch;
int door;
argument = one_argument (argument, buf);
obj = get_obj_list( ch, buf, ch->in_room->contents );
if ( !obj )
{
send_to_char ( "I do not see anything like that here.\n\r", ch);
return;
}
/* ITEM_DRAGGABLE is flag which I added for items which I want to be dragged
but not to be taken ( for example wagon in mine ).
If you dislike this idea comment it out */
if ( (!IS_SET( obj->wear_flags, ITEM_TAKE ) &&
(!IS_SET( obj->wear_flags, ITEM_DRAGGABLE ) ) ) )
{
act( "You try to drag $p, but without succes.\n\r", ch,obj, NULL, TO_CHAR);
act( "$n tries to move $p, but it doesn't budge.\n\r",ch,obj, NULL, TO_ROOM);
return;
}
if ( obj->weight > (2 * can_carry_w (ch)) )
{
act( "You try, but $p is too heavy.\n\r", ch, obj, NULL, TO_CHAR);
act( "$n tries to move $p, but $? fail.\n\r", ch, obj, NULL, TO_CHAR);
return;
}
if ( argument[0] == '\0' )
{
send_to_char ( "Where do you want to drag it ?\n\r", ch);
return;
}
rvnum = ch->in_room;
door = find_exit( ch,argument);
if (door == -1)
{
send_to_char("You don't see exit in that direction.\n\r", ch);
return;
}
move_char( ch, door);
if (ch->in_room == rvnum )
return; /* For some reason player didn't move */
obj_from_room (obj);
obj_to_room (obj, ch->in_room);
act ( "You dragged $p with you.\n\r", ch, obj, NULL, TO_CHAR );
act ( "$n dragged $p with $?.\n\r", ch, obj, NULL, TO_ROOM );
if ( !(vch = rvnum->people) )
return;
act ( "$N dragged $p out.\n\r", vch, obj, ch, TO_CHAR );
act ( "$N dragged $p out.\n\r", vch, obj, ch, TO_ROOM );
return;
}
/*
=============================================================================
/ ______ _______ ____ _____ ___ __ _ ______ ____ ____ _____ /
\ | ____|__ __| _ \ / ____\ / _ \| \ / | ____| / __ \| _ \ / ____\ \
/ | |__ | | | |_| | | | |_| | |\/| | |___ | | | | |_| | | /
/ | ___| | | | ___/| | __| _ | | | | ____| | | | | __/| | ___ \
\ | | | | | | | |___| | | | | | | | |____ | |__| | |\ \| |___| | /
/ |_| |_| |_| o \_____/|_| |_|_| |_|______|o \____/|_| \_|\_____/ \
\ /
============================================================================
------------------------------------------------------------------------------
ftp://ftp.game.org/pub/mud FTP.GAME.ORG http://www.game.org/ftpsite/
------------------------------------------------------------------------------
This file came from FTP.GAME.ORG, the ultimate source for MUD resources.
------------------------------------------------------------------------------
*/