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

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

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

#define DAMAGE 30+random(30)

string
query_action()
{
    return "meteor";
}

string
short_help()
{
    return "An attack spell sending a meteor at someone.\n";
}

string
help()
{
    return HELPDIR+"meteor";            // Defined in defs.h
}

static int
main(string arg)
{
    object who;

    who = Q_ATT(TP);

    if (!who && !arg)
        NOT_FAIL("Meteor <who>?\n");    // No attacker and no argument

    if (!who)
    {
        who = present(arg,ENV(TP));
        if (!who)
            NOT_FAIL(CAP(arg) + " ain't here!\n");
    }

    if (!living(who))
        NOT_FAIL("Ehm... Hello? " + CAP(arg) + " is not a living being!\n");

    if (Q_NOFIGHT(who))
        NOT_FAIL("You can't attack " + CAP(arg) + ".\n");

    if (Q_NOFIGHT(who) || Q_NOMATT(ENV(TP)))
        NOT_FAIL("You can't use this spell here.\n");

    tell_object(TP,COL_YH(TP,
        "As you chant the ancient words, a meteor comes falling "
        "down upon " + Q_NAME(who) + "!\n"));
    tell_object(who,COL_HY(who,
        "As " + Q_NAME(TP) + " chants some ancient words, a "
        "meteor comes falling down upon you!\n"));
    tell_room(ENV(TP),"As " + Q_NAME(TP) + " chants some ancient words, a "
        "meteor comes falling down upon " + Q_NAME(who) + "!\n", ({TP,who}));

    who->hit_player(DAMAGE,"impact",TP);
    return 1;
}

help/meteor


NAME
        meteor - sends a meteor at the attacker

SYNTAX
        meteor [monster/player]

DESCRIPTION
        You will call upon the gods to send a meteor in the face of
        the attacker.

EXAMPLE
        meteor gunner

SEE ALSO