hornofhell.c and hornfuncs.c - examples for course 09

[previous example] [course09] [Table of contents] [next example]
/* Filename      : hornofhell.c
 * Description   : a unique enchanted horn
 *
 * written       : 05-10-1996 - Gunner
 * last modified : 28-05-1998 - Gunner
 * HTML-Version  : 06-02-2000 - Ghorwin
 */

#include <mudlib.h>
inherit I_ITEM;

#define FUNC "/doc/crashcourse/course09/hornfuncs"

create()
{
    ::create();
    set_name("horn of hell");
    add_id(({"horn","dark horn","cold horn","evil horn","hellhorn"}));
    set_short("A dark horn");
    set_long("The horn is dark and cold. You can feel evil lurking "
        "inside it.\n");
    set_weight(3);
    set_value(1000+random(1000));
  
    add_trigger("blow",(:call_other,FUNC,"blow_horn",this_object():));
    add_property(({"hidden","magic","cold","stone"}));
    replace_program(I_ITEM);
}

hornfuncs.c


/* Filename      : hornfuncs.c
 * Description   : the functionfile for hornofhell.c
 *
 * written       : 05-10-1996 - Gunner
 * last modified : 28-05-1998 - Gunner
 * HTML-Version  : 06-02-2000 - Ghorwin
 */

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

#define DEMON "/doc/crashcourse/course09/demon"

/* 
 * blow_horn : Called by the 'blow' trigger in hornofhell.c
 */
int
blow_horn(object horn, string arg)
{
    object demon, 
           room = ENV(TP);

    if (!arg || !horn->query_id(arg))
        NOT_FAIL("Blow what?\n");

    if (!room) return;    // Something is fishy here...

    if (Q_NOTELEIN(room) || Q_NOMAGIC(room))
        NOT_FAIL("Not a sound is heard from the horn...\n");

    tell_object(TP,"As you blow the horn, a terrible scream is heard. "
        "When the scream fades, a ball of flame appears in "
        "front of you. As the fire dies...\n");
    tell_room(room,"As " + Q_NAME(TP) + " blows a horn, a terrible scream "
        "is heard. When the scream fades, a ball of flame appears "
        "in front of " + Q_OBJ(TP) + ". As the fire dies...\n",({TP}));

    demon = clone_object(DEMON);
    demon->add_property("owner_name",Q_RNAME(TP));
    demon->move_player("Z",room);

    horn->destroy();   // The horn vanishes...

    return 1;
}