Mocha Example: venom_sac

The venom_sac function is used for the poison of the grass spider found in the prairie and grasslands south of the Brown River. The poison is particularly potent, and generally lethal if no cleric is available to cure the victim.


object {
    public:
        action[PO] drink_pc =
"   You bite open the @o and slurp down the contents.  The taste reminds "
"you\nof cherries.  At first you feel nothing, but then a growing warmth in "
"your\nlegs bursts into flames all across your body.  You scream in agony!\n",
                   drink_room =
"   @n bites open @a @o and slurps down the contents.  @e stands motionless\n"
"for a second, then begins a long, high-pitched wail.\n";
        action[P] suffer_pc = "Your body burns with pain!\n",
                  suffer_room = "@'n body convulses in pain!\n";
    instance:
        person victim;
 }


// This routine does the work for the do_drink and do_quaff handlers, which
// have the same effect.  The arguments are the venom (obj) and the person
// who drank/quaffed the venom (pc).

special 
drink_venom (object obj, person pc)
{
    // First, show the person drinking the venom.
    show_action (drink_pc, to_player, pc, obj);
    show_action (drink_room, to_room, pc, obj);

    // We can't destroy the object until we move it off of the nohassled
    // person.
    move (obj, find_room_by_vnum (0), inside_of);

    // If a nohassled person drinks the venom, just send the drinking
    // message and quit.  We return handled to ensure that the normal
    // messages are not sent, particularly because we have already
    // destroyed the venom.
    if (pc.nohassled) {
        obj.destroy;
        return handled;
    }

    // Store a pointer to the pc.  We might simply attach the pc to the
    // suffering event (see below), but if the pc died to something besides
    // the venom, the event would be removed and the venom would never be
    // destroyed.
    victim = pc;

    // We now add an event for damaging the pc. */
    add_event (none, none, obj, none, 1, number (15, 25));

    // Add a strength penalty to the pc.  This marker also allows us to
    // detect the use of cure poison on the pc--if the marker is gone,
    // then either 100 ticks have passed (the duration), or someone cast
    // cure poison on the pc.
    add_modifier (pc, spell_poison, 100, modify_strength, -5, false, false);

    // Return handled to avoid normal drink/quaff messages.
    return handled;
}

special
do_drink (object obj, person pc)
{
    return drink_venom (obj, pc);
}

special
do_quaff (object obj, person pc)
{
    return drink_venom (obj, pc);
}

special
do_event (room rm, person mob, object obj, entity ent, integer type)
{
    person pc;
    boolean saved;
    integer damage;

    if (victim == none) {
        obj.destroy;
        return handled;
    }

    pc = victim;
    if (!pc.poisoned ||
        ((saved = save_against (pc, save_poison)) &&
         number (1, 100) < save_chance (pc, save_poison) / 10)) {
        obj.destroy;
        return handled;
    }

    damage = make_dice (type, 8, 5).roll;
    if (saved)
        damage /= 2;
    else
        type++;

    show_action (suffer_pc, to_player, pc);
    show_action (suffer_room, to_room, sight, if_visible, pc);
    do_damage (pc, pc, type_none, damage);
    if (!pc.valid)
        obj.destroy;
    else
        add_event (none, none, obj, none, type, number (25, 75));

    return handled;
}

Return to Mocha's Main Page