View Single Post
Old 06-11-2002, 10:23 AM   #10
Cougar Khan
New Member
 
Join Date: Apr 2002
Location: Texas
Posts: 19
Cougar Khan is on a distinguished road
Send a message via Yahoo to Cougar Khan
On the MUD - I work on, we've gone to great lengths to try and remove many of the virtual areas in play. One they looked bad and two - they broke and players got stuck.

One of the situations we came up with was the ability to have a ship that moved in "real time" (or something less then instant.)

The ship is 8 rooms large - aft rooms, port rooms, starboard....
plus we have a room for water, where the player could "jump" off.  If the player jumped off, it is possible for the ship to leave them, and the player is stranded in the water until another ship came by. The ship is controled by slaves rowing, if you kill the slaves - the ship stops to row.

Here are my examples of making this work. In this first file - is the ship speed controller.

[code] /* Coded by Zor 05/98 */

#include <shadow.h>

#define SLAVEROOM               SHIP"slaveroom"

int query_speed();
int change_speed();

int howfast;

int change_speed(){
       object *inv;
       int count;
       int slavecount;
   object slave_room;

   slave_room = find_object_or_load(SLAVEROOM);
   if(!objectp(slave_room)) {
       howfast = 13;
       return howfast;
   }

   inv = all_inventory(slave_room);

   slavecount = 0;
   count = 0;
   while(count<sizeof(inv)) {
       if((int)inv[count]->query_is_slave() == 1) slavecount+=1;
   count++;
       }
      howfast=slavecount;
      howfast += 15;
      if(howfast == 0)  howfast = 6;
      if(howfast > 24)  howfast = 40;
       return howfast;
}

int query_speed() { return howfast; }

[/quote]

Here is the actual ship controller:

[code] /* Coded by Zor 12/98 */

#include <shadow.h>
#include "speed_m.h"

#define WATER       SHIP"water"
#define S_AFT        SHIP"star_aft"
#define P_AFT        SHIP"port_aft"
#define S_FORE      SHIP"star_fore"
#define P_FORE      SHIP"port_fore"
#define S_DECK      SHIP"star_deck"
#define P_DECK      SHIP"port_deck"
#define CABIN        SHIP"cabin"
#define SLAVEROOM   SHIP"slaveroom"

#define ATHENS1      SPATH"pier"
#define CRETE1        CRETE"pier"
#define FOOTPAD1    FOOTPAD"pier"
#define DANIEROS1   DANIEROS"Danae_pier1"
#define ATHENSCITY ATHENS"port3"

#define AT_DOCK     30
#define DISTANCE    40

inherit TREASURE;

void arrive();
void tell_ship(string);

string *ports, *port_paths;
int count, num_ports, from, distance_gone,speed;

void create() {
   ports = ({
   "South Port",
   "Crete",
   "Footpad Isle",
   "Danieros",
   "Athens City"
 });
   port_paths = ({
   ATHENS1,
   CRETE1,
   FOOTPAD1,
   DANIEROS1,
   ATHENSCITY,
 });
   ;;create();
   set_id("ship");
   set_alias("galley");
   set_alt_name("slave_galley");
   set_short("Slave Galley");
   set_long(
@DESC
The vessel before you is a large slave galley which has been known to ferry adventurers from island to island. Be warned however, although the captain does not ask for payment, money often goes missing from this ship's passengers.
DESC
   );
   count = 0;
   num_ports = sizeof(ports);
   from = count - 1;
   if(from < 0)
       from = num_ports - 1;
   this_object()->move_me(WATER);
   call_out("water", 20, 0);
}

int get(){
   return 0;
}

void init() {
   ;;init();
   add_action("board", "enter");
   add_action("board", "board");
}

int board(string str) {

   if(str != "ship" && str != "vessel" && str != "slave galley")
       return 0;
   if( random(10) > 3) {
       write("Someone on the boarding plank brushes up against
you\n");
       this_player()->add_money(-(random(70)));
   }
   write("You board the Slave Galley!\n");
   tell_room(environment(TO),sprintf("%s boards the slave galley.\n",
       NAME),this_player());
   tell_room(P_DECK,sprintf("%s boards the slave galley.\n",NAME));
   this_player()->move_me(P_DECK);
   this_player()->command("look brief");
   return 1;
}

void water(int distance_gone) {
   if(distance_gone < DISTANCE){
       speed=change_speed();
       distance_gone+=speed;
       if(speed>12) tell_ship(sprintf("The slaves are whipped and
beaten as they row to %s.\n",ports[count]));
       if(speed<13 && speed>2)tell_ship(sprintf("With effort the
slaves row to %s.\n",ports[count]));
       if(speed==2)tell_ship(sprintf("The currents carry the ship
towards %s.\n",ports[count]));
       remove_call_out("water");
       call_out("water", 20, distance_gone);
   }
   else {
       remove_call_out("water");
       distance_gone=0;
       arrive();
   }
}

void arrive() {
   tell_room(port_paths[count],sprintf(
       "A Slave Galley arrives from %s.\n", ports[from]));
   tell_room(WATER, "The slaves forced efforts carry the galley over
the horizon.\n");
   tell_ship(sprintf("The slave galley arrives at
%s.\n",ports[count]));
   TO->move_me(port_paths[count]);
   count++;
   if(count > num_ports - 1)
       count = 0;
   from = count - 1;
   if(from < 0) from = num_ports - 1;
   call_out("sail", AT_DOCK);
}


void sail() {
   remove_call_out("sail");
   tell_room(environment(TO), sprintf(
       "A whip cracks and the slaves begin rowing for
%s.\n",ports[count]));
   tell_room(WATER,sprintf(
       "A slave galley pulls in from %s.\n",ports[count]));
   tell_ship(sprintf("The slave galley continues on to
%s.\n",ports[count]));
   this_object()->move_me(WATER);
   call_out("water", 20,0);
}

void tell_ship(string mesg) {
   tell_room(S_FORE, mesg);
   tell_room(P_FORE, mesg);
   tell_room(S_DECK, mesg);
   tell_room(P_DECK, mesg);
   tell_room(S_AFT, mesg);
   tell_room(P_AFT, mesg);
   tell_room(CABIN, mesg);
   tell_room(SLAVEROOM, mesg);
}

int clean_up(){
   return 1;
}


string query_location() {
   return ports[count];
[/quote]


Good luck - and this is just one of the examples we have. Many of the other ones have been a bit tweaked. Let me know if we can help out with anything else.

-C...

P.S. I need to thank the Admin and Zor of for letting me show this code.
Cougar Khan is offline   Reply With Quote