shorefuncs.c - example for course 11

[previous example] [course 11] [Table of contents] [next example]
/* Filename      : shorefuncs.c
 * Description   : Functionfile for both shore-rooms
 *
 * written       : 23-12-1996 - Gunner
 * last modified : 28-05-1998 - Gunner
 * HTML-Version  : 06-02-2000 - Ghorwin
 */

#include <mudlib.h>
inherit I_DAEMON;
#include "/doc/crashcourse/defs.h"

#define SHORE_W "/doc/crashcourse/course11/shore_w"
#define SHORE_E "/doc/crashcourse/course11/shore_e"


/* 
 * lake_swim : Called whenever someone tries to swim across the lake from 
 *             the west side...
 */
int
lake_swim(object room)
{
    if (room->query_property("icy_lake"))
        NOT_FAIL("What? Swim across what? Better find some way of melting "
            "the ice first.\n");
    tell_object(TP,"You swim across the lake, hoping the best...\n");
    TP->move_player("swims across the lake",load_object(SHORE_E));
    return 1;
}


/* 
 * lake_enter : Called whenever something is dropped on the shore...
 */
void
lake_enter(object room, object ob, object from)
{
    if (!ob->query_property("afire")) return;
    if (!room->query_property("icy_lake")) return;

    tell_room(room,"All of a sudden, the ice on the lake cracks up and "
        "melts away!\n");
    room->remove_item(({"ice","lake","frozen lake"}));
    room->remove_property(({"icy_lake","cold"}));
    room->add_item(({"lake","cool lake","wet lake"}),"The lake is cool and wet.\n");
}

/* 
 * swimback : Called whenever someone tries to swim back from the troll
 */
int
lake_swimback()
{
    tell_object(TP,"You quickly swim back across the lake.\n");
    TP->move_player("swims across the lake",load_object(SHORE_W));
    return 1;
}