girl.c and girlfuncs.c - examples for course 11

[previous example] [course 11] [Table of contents] [next example]
/* Filename      : girl.c
 * Description   : the sobbing girl
 *
 * written       : 23-12-1996 - Gunner
 * last modified : 28-05-1998 - Gunner
 * HTML-Version  : 06-02-2000 - Ghorwin
 */

#include <mudlib.h>
inherit I_MONSTER;

#define FUNC "/doc/crashcourse/course11/girlfuncs"

create()
{
    ::create();
    set_name("sad girl");
    add_id(({"girl","woman","sad woman"}));
    set_short("A sad girl");
    set_long("This girl sure looks sad. Wonder what's wrong...\n");
    set_gender(1);
    set_level(5);
    set_random_pick(30);
    load_chat(10,({
        "The girl sobs: ''That terrible troll ran off with my "
        "beautiful necklace!''\n",
        "The girl sobs: ''Can't you help me get it back, please?''\n",
        "The girl sobs: ''The troll ran off with my necklace and "
        "hid himself way across the lake and I can't get there!''\n"}));

    add_property("no_fight");
    add_hook("__reset",(:call_other,FUNC,"reset_girl",this_object():));
    add_hook("__enter_inv",({FUNC,"enter_girl"}),this_object());

    replace_program(I_MONSTER);
}

girlfuncs.c


/* Filename      : girlfuncs.c
 * Description   : the functionfile for girl.c
 *
 * written       : 23-12-1996 - Gunner
 * last modified : 28-05-1998 - Gunner
 * HTML-Version  : 04-02-2000 - Ghorwin
 */

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

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

/* 
 * reset_girl : Called every time the girl resets (once an hour), and cleans up
 *              the quest for the next attempt...
 */
void
reset_girl(object girl)
{
    object shore, room = ENV(girl);

    if (!room) return;  // Just to be sure

    if (room->query_property("icy_lake"))
        return;         // Nothing needs to be done.

    room->add_item(({"lake","frozen lake"}),
        "The lake is frozen solid. If you want to cross it, you'd "
        "better wait for the spring to defrost it, because there's "
        "no way you would survive a walk across it, without falling "
        "through and drowning.\n");
    room->add_item("ice","There sure is a lot of it.\n");
    room->add_property(({"cold","icy_lake"}));
    shore = load_object(SHORE_E);
    if (!shore) return;
    shore->reset(1); // Force the room(and the troll) to reset...
}


/* 
 * enter_girl : Called whenever the girl receives anything and we use it to check
 *              for her necklace...
 */
void
enter_girl(object girl, object ob, object from)
{
    object room = ENV(girl);

    if (!room || !from) return;

    if (!ob->query_property("girly_necklace"))
        return;

    if (interactive(from))
    {
        tell_room(room,"The girl starts running around smiling happily.\n");
        tell_object(from,"The girl thanks you dearly for returning her necklace.\n");
        if (!from->query_quests("return_necklace"))
        {
            from->set_quest("return_necklace");
            from->add_exp(1000);   // A small bonus... ;-)
        }
    }
    girl->move_player("runs off into the distance",load_object(R_VOID));
}