51 #define EXTREME_ALCHEMY_DEBUG
57 "produces a cloud of steam",
58 "emits bright flames",
59 "pours forth heavy black smoke",
61 "shoots out small flames",
68 "makes chugging sounds",
69 "smokes heavily for a while"
78 static object *
attempt_recipe(
object *caster,
object *cauldron,
int ability,
recipe *rp,
int nbatches,
int ignore_cauldron);
124 float success_chance;
125 int numb, ability = 1;
148 if (strcmp(rp->
title,
"NONE"))
155 LOG(
llevDebug,
"WIZ couldn't find formula for ingredients.\n");
162 uint64 value_ingredients;
165 int attempt_shadow_alchemy;
169 if (rp->
skill != NULL) {
173 "You do not have the proper skill for this recipe", NULL);
175 ability += skop->
level*((4.0+cauldron->
magic)/4.0);
188 value_ingredients = 0;
189 for (tmp = cauldron->
inv; tmp != NULL; tmp = tmp->
below)
195 if ((item =
attempt_recipe(caster, cauldron, ability, rp, formula/rp->
index, attempt_shadow_alchemy)) != NULL) {
197 success_chance = ((float)ability/(
float)(rp->
diff*(item->
level+2)));
202 LOG(
llevDebug,
"percent success chance = %f ab%d / diff%d*lev%d\n", success_chance, ability, rp->
diff, item->
level);
206 if (attempt_shadow_alchemy && value_item > value_ingredients) {
209 LOG(
llevDebug,
"Forcing failure for shadow alchemy recipe because price of ingredients (%llu) is less than price of result (%llu).\n", value_ingredients, value_item);
211 LOG(
llevDebug,
"Forcing failure for shadow alchemy recipe because price of ingredients (%I64d) is less than price of result (%I64d).\n", value_ingredients, value_item);
238 object *tmp = op->
inv;
239 int tval = 0, formula = 0;
243 strcpy(name, tmp->
name);
267 object *tmp = op->
inv;
275 LOG(
llevDebug,
"numb_ob_inside(%s): found %d ingredients\n", op->
name, o_number);
305 static object *
attempt_recipe(
object *caster,
object *cauldron,
int ability,
recipe *rp,
int nbatches,
int ignore_cauldron) {
306 object *item = NULL, *skop;
308 int batches = abs(nbatches);
311 if (!ignore_cauldron && (strcmp(rp->
cauldron, cauldron->
arch->
name) != 0)) {
313 "You are not using the proper facilities for this formula.", NULL);
326 for (tmp = caster->
inv; tmp != NULL; tmp = tmp->
below) {
334 "You know the ingredients, but not the technique. Go learn how to do this recipe.",
340 #ifdef EXTREME_ALCHEMY_DEBUG
341 LOG(
llevDebug,
"attempt_recipe(): got %d nbatches\n", nbatches);
351 "Nothing happened.", NULL);
381 nrof = (1.0-1.0/(lvl/10.0+1.0))*(
rndm(0, yield-1)+
rndm(0, yield-1)+
rndm(0, yield-1))+1;
401 size_t rp_arch_index;
404 return (
object *)NULL;
408 LOG(
llevDebug,
"make_alchemy_item(): failed to create alchemical object.\n");
409 return (
object *)NULL;
413 if (item->
env != NULL)
417 if (strcmp(rp->
title,
"NONE")) {
419 LOG(
llevError,
"make_alchemy_item(): failed to locate recipe artifact.\n");
421 return (
object *)NULL;
426 if (item->
env != NULL)
456 for (item = first_ingred; item; item = item->
below) {
465 if (i < rp->arch_names)
471 if (create_item && (!item || item->
nrof > 1)) {
505 if (!op || !cauldron)
512 LOG(
llevDebug,
"Alchemy_failure_effect(): using level=%d\n", level);
520 object *tmp = cauldron->
inv;
551 }
else if (level < 40) {
568 if ((tmp = cauldron->
inv)) {
586 }
while (
rndm(0, 2));
614 cauldron->
enemy = op;
616 cauldron->
enemy = NULL;
620 }
else if (level < 50) {
624 switch (
rndm(0, 2)) {
630 "The %s creates a bomb!",
631 "The %s creates a bomb!",
640 "The %s erupts in flame!",
641 "The %s erupts in flame!",
645 tmp->
x = cauldron->
x,
646 tmp->
y = cauldron->
y;
649 }
else if (level < 60) {
654 }
else if (level < 80) {
661 "The %s erupts in flame!",
662 "The %s erupts in flame!",
665 }
else if (level < 100) {
676 "Your %s turns darker then makes a gulping sound!",
677 "Your %s turns darker then makes a gulping sound!",
681 "Your %s becomes darker.",
682 "Your %s becomes darker.",
686 }
else if (level < 110) {
694 "The %s %s and then pours forth monsters!",
695 "The %s %s and then pours forth monsters!",
698 }
else if (level < 150) {
699 int roll =
rndm(1, 3);
705 }
else if (level == 151) {
729 "You unwisely release potent forces!", NULL);
746 object *next, *tmp = first_ob;
750 if (tmp == save_item) {
786 int danger = 0, nrofi = 0;
792 danger -= cauldron->
magic;
801 for (item = cauldron->
inv; item; item = item->
below) {
802 strcpy(name, item->
name);
811 danger += rp->
diff*3;
820 LOG(
llevDebug,
"calc_alch_danger() returned danger=%d\n", danger);
846 uint32 batches_in_cauldron;
853 for (ingredient = rp->
ingred; ingredient != NULL; ingredient = ingredient->
next)
855 for (ob = cauldron->
inv; ob != NULL; ob = ob->
below)
861 batches_in_cauldron = 0;
862 for (ingredient = rp->
ingred; ingredient != NULL; ingredient = ingredient->
next) {
868 name = ingredient->
name;
870 while (isdigit(*name)) {
871 nrof = 10*nrof+(*name-
'0');
881 for (ob = cauldron->
inv; ob != NULL; ob = ob->
below) {
885 if (ob->
title == NULL)
892 if (strcmp(name2, name) == 0) {
893 if (ob->
nrof%nrof == 0) {
896 batches = ob->
nrof/nrof;
897 if (batches_in_cauldron == 0) {
898 batches_in_cauldron = batches;
900 }
else if (batches_in_cauldron == batches)
932 int recipes_matching;
934 size_t rp_arch_index;
936 #ifdef EXTREME_ALCHEMY_DEBUG
940 recipes_matching = 0;
942 for (rp = fl->
items; rp != NULL; rp = rp->
next) {
944 if (formula%rp->
index != 0) {
945 #ifdef EXTREME_ALCHEMY_DEBUG
952 #ifdef EXTREME_ALCHEMY_DEBUG
956 if (!transmute_found) {
958 recipes_matching = 0;
960 }
else if (transmute_found) {
961 #ifdef EXTREME_ALCHEMY_DEBUG
967 #ifdef EXTREME_ALCHEMY_DEBUG
973 if (
rndm(0, recipes_matching) == 0)
979 if (result == NULL) {
981 LOG(
llevDebug,
"couldn't find formula for ingredients.\n");
987 if (strcmp(result->
title,
"NONE") != 0)
1007 object *tmp, *item, *next;
1008 object *unpaid_cauldron = NULL;
1009 object *unpaid_item = NULL;
1010 int did_alchemy = 0;
1013 for (tmp =
GET_MAP_OB(op->
map, op->
x, op->
y); tmp != NULL; tmp = next) {
1017 unpaid_cauldron = tmp;
1021 for (item = tmp->
inv; item; item = item->
below) {
1027 if (unpaid_item != NULL)
1036 if (unpaid_cauldron) {
1039 "You must pay for your %s first!",
1040 "You must pay for your %s first!",
1042 }
else if (unpaid_item) {
1045 "You must pay for your %s first!",
1046 "You must pay for your %s first!",
#define MSG_TYPE_SKILL_MISSING
static void attempt_do_alchemy(object *caster, object *cauldron)
void change_exp(object *op, sint64 exp, const char *skill_name, int flag)
recipe * get_random_recipe(recipelist *rpl)
static void adjust_product(object *item, int lvl, int yield)
object * get_random_mon(int level)
int fire_arch_from_position(object *op, object *caster, sint16 x, sint16 y, int dir, object *spell)
void free_string(sstring str)
#define MSG_TYPE_SKILL_FAILURE
void query_base_name(const object *op, int plural, char *buf, size_t size)
void draw_ext_info(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *message, const char *oldmessage)
void esrv_send_inventory(object *pl, object *op)
void change_attr_value(living *stats, int attr, sint8 value)
static const char *const cauldron_effect[]
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
void transmute_materialname(object *op, const object *change)
#define MSG_TYPE_SKILL_ERROR
static object * find_transmution_ob(object *first_ingred, recipe *rp, size_t *rp_arch_index, int create_item)
int rndm(int min, int max)
struct obj * chosen_skill
void remove_ob(object *op)
#define MSG_TYPE_SKILL_SUCCESS
object * create_archetype(const char *name)
static int content_recipe_value(object *op)
const char * materialname
int summon_hostile_monsters(object *op, int n, const char *monstername)
struct linked_char * next
int strtoint(const char *buf)
static int numb_ob_inside(object *op)
void generate_artifact(object *op, int difficulty)
void cast_magic_storm(object *op, object *tmp, int lvl)
void add_weight(object *op, signed long weight)
#define QUERY_FLAG(xyz, p)
#define CLEAR_FLAG(xyz, p)
object * insert_ob_in_ob(object *op, object *where)
object * insert_ob_in_map(object *op, mapstruct *m, object *originator, int flag)
void npc_call_help(object *op)
static int calc_alch_danger(object *caster, object *cauldron, recipe *rp)
#define FLAG_KNOWN_CURSED
uint64 query_cost(const object *tmp, object *who, int flag)
int snprintf(char *dest, int max, const char *format,...)
static int is_defined_recipe(const recipe *rp, const object *cauldron, object *caster)
struct recipestruct * next
static object * attempt_recipe(object *caster, object *cauldron, int ability, recipe *rp, int nbatches, int ignore_cauldron)
sstring add_string(const char *str)
#define GET_MAP_OB(M, X, Y)
void give_artifact_abilities(object *op, object *artifact)
void LOG(LogLevel logLevel, const char *format,...)
artifact * locate_recipe_artifact(const recipe *rp, size_t idx)
void sub_weight(object *op, signed long weight)
static object * make_item_from_recipe(object *cauldron, recipe *rp)
void free_object(object *ob)
static const char * cauldron_sound(void)
int random_roll(int min, int max, const object *op, int goodbad)
static recipe * find_recipe(recipelist *fl, int formula, object *ingredients)
int use_alchemy(object *op)
object * find_skill_by_name(object *who, const char *name)
static void remove_contents(object *first_ob, object *save_item)
static void alchemy_failure_effect(object *op, object *cauldron, recipe *rp, int danger)
struct recipestruct * items
recipelist * get_formulalist(int i)