Infections Tutorial for Nightmare 3.2.2 written by Descartes of Borg 940906 Last modified: 940906 This document details how to create infectious and non-infectious aflictions for the Nightmare Mudlib. Disease was introduced into the mudlib at version 3.2.2. The inheritable infectious object, germ.c, may be used for three types of afflictions: 1) bacterial (rusty sword cuts, the plague, strep throat) 2) viral (flu, cold, cancer) 3) magical (use your imagination) Infections need not be contagious. You set how contagious and how fast the germs replicate and spread. ******************************************************************** I. A basic germ There is really very little to creating a germ. Like all other inheritables, you do the normal: **** #include <std.h> inherit GERM; **** so that you have the standard germ code inherited into your germ. YOU CANNOT CLONE /std/germ. They have to be in their own little file so that they can reproduce and stay on a player across logins. In the create() function of your germ, you must make the following calls to set up the germ: **** void create() { germ::create(); set_name("cold") set_id( ({ "cold" }) ); set_short("the cold"); set_long( "A viral infection generally harmless, but annoying which " "most people get at one point or another."); set_communicable(10); set_cure_level(10); set_life_span(100); set_type("viral"); } **** Of course, the name of this disease is cold. So the set_name() and set_id() functions set up this fact. Although no one ever sees the disease, the short and long descriptions are used by magic spells to allow certain people to tell something about the disease. The four main calls for infections are: set_communicable() set_cure_level() set_life_span() set_type() The first, set_communicable(), only gets called if the disease can be passed around from player to player. The number you pass determines how communicable it is. The number is chance in 1000 of someone getting it. These numbers should be fairly low. I am sure balance has something to say about the exact nature (and approval/balance documents rule over any numbers which might be presented here), but in general, the more communicable a germ is, the less nasty it is. More on nastiness later. The second, set_cure_level(), is used to set how much of an "antidote" is needed to cure the infection. I use antidote in quotes, because antidote can be anything which is used to cure the germ. The higher the number, the more of an antidote is required (and some antidotes may cause side effects!). Third is the life span of the infection outside of a host. If the germ is sitting in a room, it will only sit there so long before it dies. This number should never be longer than 10 minutes (600 seconds). Fourth, set_type(), is one of "bacterial", "viral", or "magical". Unlike most other inheritables, however, this is not all there is to creating an infection. You also have to write your own functions. The minimum one you *MUST* write is: void suffer(object ob); For example: **** void suffer(object ob) { ob->add_hp(-random(5)); message("my_action", "You cough.", ob); message("other_action", (string)ob->query_cap_name()+" coughs.", environment(ob), ob); } **** This, of course, is really dull. But this is the meat of any disease. This function gets called every 5 seconds the entire time the person suffers from the disease. Ideally, you would write up a bunch of possible symptoms from which a person could suffer in here. IMPORTANT NOTE: The efun this_player() does not work in this function!!! It has no meaning. The variable passed to the function, ob, is the sick person. Since this_player() does not work, write() and say() do not work either. So you need to use the message() efun to send messages. Type "man message" for detailed help, but basically, you have: message(type, msg, who_gets_it, who_does_not); Type is a string, in most cases "my_action" for the sick person (they did something), and "other_action" for everyone else. There is a doc somewhere detailing message types. Do not worry too much about what you put here. msg is what you want people to see. who_gets_it is a list of people who see the message. In this case, it is everyone in the same room as the player. So you just send the room as this argument, and the driver understands you mean everyone in the room since rooms do not get messages! who_does_not is a list of exceptions. After all, the sick person is in the room, and you do not want them to see the messages meant for others. So, if it is one person, just put them there. If it is a list of people, put them in ({ }). This is all you need to write a working disease! Keep in mind that if you make an incurable disease, it should never be deadly, and it should somehow go away on its own. ***************************************************************** II. Advanced Infection Writing There are many functions in the germ object which you can override to modify functionality. This section basically assumes that you understand the concept of overriding functions. If you do not, then you should look into the relevant chapters in the Intermediate LPC. The germ object has the following functions whose behaviour you can override: