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

[previous example] [course06] [Table of contents] [next example]
/* Filename      : icicle.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 50+random(50)

string
query_action()
{
    return "icicle";
}

string
short_help()
{
    return "An attack spell sending a swarm of icicles at a player.\n";
}

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

int
query_cost()
{
    return (DAMAGE / 2);
}

static int
main(string arg)
{
    object who;

    who = Q_ATT(TP);

    if (!who && !arg)
        NOT_FAIL("Icicle <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");

    if (Q_SP(TP) < query_cost())
        NOT_FAIL("You just don't have the power to cast this spell.\n");

    if (Q_BUSY(TP))
        NOT_FAIL("Not while you're busy with other things!\n");

    tell_object(TP,COL_YH(TP,
        "As you chant the ancient words, your breath turns cold "
        "as ice. Suddenly, a swarm of icicles flies out of your "
        "mouth right at " + Q_NAME(who) + "!\n"));
    tell_object(who,COL_HY(who,
        "As " + Q_NAME(TP) + " chants some ancient words, " +
        Q_POSS(TP) + " breath turns to ice, and a swarm of "
        "icicles comes flying out of " + Q_POSS(TP) +
        " mouth right at you!\n"));
    tell_room(ENV(TP),"As " + Q_NAME(TP) + " chants some ancient words, " +
        Q_POSS(TP) + " breath turns to ice, and a swarm of "
        "icicles comes flying out of " + Q_POSS(TP) +
        " mouth right at " + Q_NAME(who) + "!\n", ({TP,who}));

    R_SP(TP,query_cost());
    S_BUSY(TP);

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

help/icicle


NAME
        icicle - sends a swarm of icicles at the attacker

SYNTAX
        icicle [monster/player]

DESCRIPTION
        Your breath turns to ice and a swarm of icicles comes flying
        out of your mouth at your opponent.

EXAMPLE
        icicle gunner

SEE ALSO