ahhh help with porting snip

Posted by Rob Harper on Sun 29 Jun 2003 05:55 AM — 3 posts, 14,620 views.

#0
..hey guys well I'm getting pretty ok at coding..but I'm clueless on porting other code to smaug.

I found a useful snip, would anyone know how to port this over to smaug 1.4a?




* To install, simply add a ROOM_VEHICLE room flag, a field to room_index *
* data called "in_room", and the interpreter declarations for do_drive. *
* Then, for maximum effect, add the following lines of code into the *
* do_look command after showing the rooms description: *
* *
* if ( ch->in_room->in_room != NULL ) *
* { *
* send_to_char("{WThrough the windows, you see:{x\n\r",ch); *
* *
* sprintf( buf, "{y%s{x\n\r{w%s{x", *
* ch->in_room->in_room->name, *
* ch->in_room->in_room->description ); *
* send_to_char( buf, ch ); *
* } *
* *
* Place this file in your /src directory as vehicle.c and add the proper *
* lines to your Makefile to compile this with the other source files. *
* *
***************************************************************************/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "merc.h"

void do_drive( CHAR_DATA *ch, char *argument )
{
EXIT_DATA *pexit;
ROOM_INDEX_DATA *orig;
ROOM_INDEX_DATA *vroom;
char buf[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
int door = 0;

argument = one_argument( argument, arg );

if ( !IS_SET( ch->in_room->room_flags, ROOM_VEHICLE ) )
{
send_to_char("You are not in a vehicle!\n\r",ch);
return;
}

if ( ch->in_room->in_room == NULL )
{
send_to_char("You are not in the controlling area!\n\r",ch);
return;
}
if ( !str_cmp( arg, "n" ) || !str_cmp( arg, "north" ) ) door = 0;
else if ( !str_cmp( arg, "e" ) || !str_cmp( arg, "east" ) ) door = 1;
else if ( !str_cmp( arg, "s" ) || !str_cmp( arg, "south" ) ) door = 2;
else if ( !str_cmp( arg, "w" ) || !str_cmp( arg, "west" ) ) door = 3;
else if ( !str_cmp( arg, "u" ) || !str_cmp( arg, "up" ) ) door = 4;
else if ( !str_cmp( arg, "d" ) || !str_cmp( arg, "down" ) ) door = 5;

if ( arg[0] == '\0' )
{
send_to_char("Usage: drive <direction>\n\r",ch);
return;
}

vroom = ch->in_room->in_room;

if ( ( pexit = vroom->exit[door] ) == NULL )
{
send_to_char("You can't drive THAT way!\n\r",ch);
return;
}

sprintf( buf, "#WYou drive %s %s.#x\n\r",
ch->in_room->name,
dir_name[door]);
send_to_char(buf,ch);
ch->in_room->in_room = pexit->to_room;
orig = ch->in_room;
char_from_room(ch);
char_to_room(ch, vroom);
do_function(ch, &do_look, "");
char_from_room(ch);
char_to_room(ch, orig);
return;
}
#1
Argh...I'll type the rest later.

(1)Go to mud.h, go to line 1880ish or wherever your room flag declarations are.

the surrounding code should look like
#define ROOM_TUNNEL BV08
#define ROOM_PRIVATE BV09

or something like that. Go to the end, and type in
#define ROOM_VEHICLE BV32
(replace 32 with the last one's number + 1)

(2)Go to struct room_index_data and add
ROOM_INDEX_DATA * in_room;

(3)go to act_info.c and paste in that code it said to paste after the room desc after the lines

send_to_char( ch->in_room->, ch);
send_to_char( "\n\r", ch);
set_char_color( AT_RMDESC, ch );

if ( ch->in_room->in_room != NULL )
{
send_to_char("{WThrough the windows, you see:{x\n\r",ch);

//you can set your own colors here
sprintf( buf, "%s\n\r%s",
ch->in_room->in_room->name,
ch->in_room->in_room->description );
send_to_char( buf, ch );
}
#2
Thanks celestine, dont think I would have ever figured this one out, Is there much more to it?