com/hello.c and help/hello - examples for course 06

[previous example] [course06] [Table of contents] [next example]
/* Filename      : hello.c
 * Description   : command 'hello <player>'
 *
 * written       : 03-10-1996 - Gunner
 * last modified : 27-05-1998 - Gunner
 * HTML-Version  : 02-02-2000 - Ghorwin
 */

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

string
query_action()
{
    return "hello";
}

string
short_help()
{
    return "A friendly greeting command.\n";
}

string
help()
{
    return HELPDIR+"hello";     // HELPDIR is defined in defs.h
}

static int
main(string arg)
{
    object who;

    if (!arg)
        NOT_FAIL("Hello <who>?\n");

    who = present(lower_case(arg),ENV(TP));

    if (!who)
        NOT_FAIL(CAP(arg) + " ain't here!\n");

    if (!living(who))
        NOT_FAIL("Why say hello to an inanimate object??\n");

    tell_object(TP,"You run over to " + Q_NAME(who) + " and greet " +
        Q_OBJ(who) + ".\nYou give " + Q_OBJ(who) + " a nice "
        "warm and friendly hug.\nYou bounce around happily "
        "looking like a complete doofball.\n");
    tell_object(who,Q_NAME(TP) + " comes running over to you and greets "
        "you.\n" + CAP(Q_PRO(TP)) + " then gives you a nice warm "
        "and friendly hug.\n" + CAP(Q_PRO(TP)) + " starts bouncing "
        "around happily looking like a complete doofball.\n");
    tell_room(ENV(TP),Q_NAME(TP) + " runs over to " + Q_NAME(who) + " and "
        "greets " + Q_OBJ(who) + ".\n" + CAP(Q_PRO(TP)) +
        " gives " + Q_NAME(who) + " a nice warm and friendly "
        "hug.\nThen " + Q_PRO(TP) + " starts bouncing around "
        "looking like a complete doofball.\n",({who,TP}));
    return 1;
}

help/hello


NAME
        hello - greet someone in the same room

SYNTAX
        hello <monster/player>

DESCRIPTION
        You will run over to the player or monster and greet him/her/it.
        The monster or player must be in the same room, though.

EXAMPLE
        hello gunner

SEE ALSO