EFFECTS MAJIK MUDLIB DOCUMENTATION Effects are things that happen to player and last a specific time, or until specific action that cancels the effect. Good example might be player drinking a potion which boosts his strength for ten minutes. We will use a strength potion as an example. The code for the potion in compilable form can be found from /doc/example/example_effect.c. Note that you shouldn't create potions this way; there will be a separate potion inheritable for that :). It is assumed that you have some basic knowledge about how add_action() works. The following is a couple of snippets from the example: ============ inherit ITEM; #define EFFECT "dazzt_str_potion" (1) ... init() { add_action("do_drink", "drink"); (2) } do_drink() { THIS->add_hb_effect(EFFECT, 5 * 60, "potion_on", "potion_off"); (3) } potion_on() { THIS->set_str(THIS->query_str() + 3) (4) } potion_off() { THIS->set_str(THIS->query_str() - 3) (5) } ============== The effect needs to have a name that separates it from the other effects. The name _must_ be unique or the effect might not work properly if the same name is used by another effect. I used #define to set the effect's name (1) in a single place to avoid typing errors in the names. For the naming convention I suggest that you use the form "__" unless you really have better (and unique!) name. Using this convention, my potion's effect will be named "dazzt_str_potion". Then we need something to trigger the effect, the drinking. I made an add_action() to perform this task (2). When player drinks this potion, do_drink() function will be called. In the do_drink() we will now start the effect. The syntax for starting an effect with specific duration is: THIS->add_hb_effect("dazzt_str_potion", 600, "potion_on", "potion_off"); We already have the effect name and now decide that the potion's effect should last ten minutes (10 * 60 = 600 seconds). +) Dazzt MAJIK MUDLIB DOCUMENTATION 29.12.1997 MAJIK