Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ ahhh help with porting snip

ahhh help with porting snip

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Rob Harper   (108 posts)  Bio
Date Sun 29 Jun 2003 05:55 AM (UTC)
Message
..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;
}
Top

Posted by Celestine   (29 posts)  Bio
Date Reply #1 on Mon 30 Jun 2003 05:19 AM (UTC)
Message
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 );
}
Top

Posted by Rob Harper   (108 posts)  Bio
Date Reply #2 on Mon 30 Jun 2003 06:30 AM (UTC)
Message
Thanks celestine, dont think I would have ever figured this one out, Is there much more to it?
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,931 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.