divine_cloak.c

skylib_mudos_v1/mudlib/std/shadows/rituals/divine_cloak.c · 2.1 KB

From the archive skylib_mudos_v1.tar.gz

Download the archive   « Back to the archive contents

/**
 * This is the effect shadow for shielding rituals.
 * Sandoz 2001.
 */

inherit "/std/effect_shadow";

private int ac;
private string cloak;

/**
 * This method sets the armour class and a description of the cloak for
 * the shield shadow, so that query_ac() wouldn't have to call arg()
 * every time we are hit.
 * @param i the armour class to set
 * @param str the description of the cloak
 */
void setup_faith_shield( int i, string str ) {
    ac = i;
    cloak = str;
} /* setup_faith_shield() */

/**
 * This method returns the armour class of the faith shield.
 * @return the armour class of the faith shield
 */
int query_faith_shield_ac() { return ac; }

/** @ignore yes */
varargs int query_ac( string type, int amount, string zone ) {
    int player_ac;

    amount -= ac;

    if( amount < 1 ) {
        player->set_stopped( cloak );
        return ac;
    }

    player_ac = (int)player->query_ac( type, amount, zone );
    player->set_stopped( cloak );

    return ac + player_ac;

} /* query_ac() */

/** @ignore yes */
varargs int adjust_hp( int num, object attacker, object wep, string attack ) {
    // Make sure we don't backlash on ourselves etc.
    if( !random( 4 ) && num < -ac && objectp(attacker) &&
        attacker != player && objectp(wep) &&
        ( !attack || attack != "disarm") && ENV(attacker) == ENV(player) ) {
        int back = num * ac / 160;

        if( back < num / 2 )
            back = num / 2;

        tell_room( ENV(attacker), "With a crackle, "+
            (string)player->poss_short()+" "+cloak+" lashes back at "+
            (string)attacker->one_short()+".\n", player );
        tell_object( player, "Your "+cloak+" lashes back at "+
            (string)attacker->the_short()+" with a crackle.\n" );

        attacker->adjust_hp( back, player );

    }

    return player->adjust_hp( num, attacker, wep, attack );

} /* adjust_hp() */

/** @ignore yes */
string *query_arcane_shields() {
    string deity = arg()[ 2 ];

    return player->query_arcane_shields() + ({
           "You are protected by the power of "+deity+".",
           CAP(player->HE)+" is protected by the power of "+deity+"."});

} /* query_arcane_shields() */

Site Stats

Snippets: 1791
Codebases: 571