Mocha Example: troll_leader

The following code is used on the troll leader in the Brown River valley, although it could technically be used (in Mocha form) for any speaker who continues to speak regardless of combat. Speaking begins as soon as a player enters the room (and the troll is awake) and continues until either the troll falls asleep or all players leave. After speaking all of the lines, the troll periodically uses a social on one of the players present.


person {
    public:
        string list lines = {
            "say You not Tymael!",
            "say I crush you.",
            "say You not Isneen.",
            "say No more Isneen.",
            "say All Isneen below silver!",
            "say I smash little skull."
        };
        string list socials = {"growl", "spit", "spit"};
}

special
command_look (person mob, person pc, arguments args)
{
    if (!pc.nohassled && mob.awake)
        add_event (none, mob, none, none, 1, number (5, 10));
    return ignored;
}

special
do_event (room rm, person mob, object obj, entity ent, integer type)
{
    mob.stand;
    if (!mob.awake || mob.in_room.num_players == 0)
        return handled;
    if (type <= lines.length) {
        interpret (mob, lines.member (type));
        add_event (none, mob, none, none, type + 1, number (10, 50));
        return handled;
    }
    interpret_one_entity (mob, mob.pick_other,
                          socials.member (number (1, socials.length)));
    add_event (none, mob, none, none, type, number (50, 150));
    return handled;
}

Return to Mocha's Main Page