/* Filename : potion.c
* Description : a potion that increases str and dex
*
* written : 03-10-1996 - Gunner
* last modified : 27-05-1998 - Gunner
* HTML-Version : 04-02-2000 - Ghorwin
*/
#include <mudlib.h>
inherit I_DRINK;
#define FUNC "/doc/crashcourse/course07/potionfuncs"
create()
{
::create();
set_name("magical potion");
add_id(({"potion","magic potion"}));
set_short("A magical potion");
set_long("This is a magical potion. It will attempt to increase your "
"powers for a little while.\n");
set_weight(1);
set_value(2000);
set_heal(0);
set_strength(20+random(10));
set_info("The potion will change your strength and dexterity.\n");
add_property(({"hidden","magic"}));
add_hook("__drink",(:call_other,FUNC,"drink_potion":));
replace_program(I_DRINK);
}
/* Filename : potionfuncs.c
* Description : the functionfile for potion.c
*
* written : 03-10-1996 - Gunner
* last modified : 27-05-1998 - Gunner
* HTML-Version : 04-02-2000 - Ghorwin
*/
#include <mudlib.h>
#include "/doc/crashcourse/defs.h"
inherit I_DAEMON;
#define TIMEOUT 30+random(30)
/*
* drink_potion : called by the __drink hook in potion.c
*/
void
drink_potion()
{
int str, dex;
tell_object(TP,"The potion is invigorating. Ahhhh...\n");
str = 1+random(5);
dex = 1+random(5);
TP->add_tmp_str(str);
TP->add_tmp_prop("str_boost",str);
TP->add_tmp_dex(dex);
TP->add_tmp_prop("dex_boost",dex);
call_out("remove_stats",TIMEOUT,TP);
}
/*
* remove_stats : The effect of the potion is gone. Called by the call_out
*/
void
remove_stats(object player)
{
if (!player) return; // The player's gone.
player->remove_tmp_str(-player->query_tmp_prop("str_boost"));
player->remove_tmp_prop("str_boost");
player->remove_tmp_dex(-player->query_tmp_prop("dex_boost"));
player->remove_tmp_prop("dex_boost");
tell_object(player,"The invigorating feeling is suddenly gone.\n");
}