rat.c, ratfuncs.c and ratdisease.c - examples for course 14

[previous example] [course14] [Table of contents] [next example]
/* Filename      : rat.c
 * Description   : An infective rat
 *
 * written       : 06-01-1998 - Gunner
 * last modified : 02-06-1998 - Gunner
 * HTML-Version  : 13-02-2000 - Ghorwin
 */

#include <mudlib.h>
inherit I_MONSTER;

#define FUNC "/doc/crashcourse/course14/ratfuncs"

create()
{
    ::create();
    set_name("dirty rat");
    add_id("rat");
    set_short("A dirty rat");
    set_long("This is a carrier of diseases.\n");
    set_level(10);
    load_a_chat(20,({(:call_other,FUNC,"infect",this_object():)}));
    replace_program(I_MONSTER);
}

ratfuncs.c


/* Filename      : ratfuncs.c
 * Description   : the functionfile for rat.c
 *
 * written       : 06-01-1998 - Gunner
 * last modified : 02-06-1998 - Gunner
 * HTML-Version  : 13-02-2000 - Ghorwin
 */

#include <mudlib.h>
inherit I_DAEMON;

#define RAT_DISEASE "/doc/crashcourse/course14/ratdisease"

int
infect(object rat)
{
    tell_object(rat->query_attack(),"The rat bites your hand.\n");

    // If the disease fails, the object is destroyed automagically, so
    // there's no need for us to do it.
    new(RAT_DISEASE)->disease_victim(rat->query_attack(),rat);

    return 1;
}

string
hurt(object victim, string diseasename)
{
    return "You feel rather uncomfortable. *puke*\n";
}

ratdisease.c


/* Filename      : ratdisease.c
 * Description   : the disease for rat.c
 *
 * written       : 06-01-1998 - Gunner
 * last modified : 02-06-1998 - Gunner
 * HTML-Version  : 13-02-2000 - Ghorwin
 */

#include <mudlib.h>
inherit I_DISEASE;

#define FUNC    "/doc/crashcourse/course14/ratfuncs"

create()
{
    ::create();
    set_disease_name("rat plague");
    set_end_time(180); // 3 minutes runtime
    set_base_damage(20);
    set_random_damage(10);
    set_interval_time(20);
    set_interval_random_time(10);
    set_victim_start_msg("You feel a bit sick.\n");
    set_other_start_msg("$N appears to be feeling unwell.\n");
    set_victim_hurt_msg((:call_other,FUNC,"hurt":));
    set_other_hurt_msg("$N appears to be sick.\n");
    set_victim_stop_msg("Ahhhh... You feel a whole lot better.\n");
    set_other_stop_msg("$N seems to be feeling better.\n");
    set_disease_look("$O seems to be awfully sick.\n");
    set_str_reduce(2);
    set_dex_reduce(2);
    replace_program(I_DISEASE);
}