1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
76 | * ok, but the possibility of duplicate hashes is certainly possible - msw |
76 | * ok, but the possibility of duplicate hashes is certainly possible - msw |
77 | */ |
77 | */ |
78 | static int |
78 | static int |
79 | content_recipe_value (object *op) |
79 | content_recipe_value (object *op) |
80 | { |
80 | { |
81 | char name[MAX_BUF]; |
|
|
82 | object *tmp = op->inv; |
81 | object *tmp = op->inv; |
83 | int tval = 0, formula = 0; |
82 | int formula = 0; |
84 | |
83 | |
85 | while (tmp) |
84 | while (tmp) |
86 | { |
85 | { |
87 | tval = 0; |
86 | const char *name = tmp->title |
88 | assign (name, tmp->name); |
|
|
89 | if (tmp->title) |
|
|
90 | sprintf (name, "%s %s", &tmp->name, &tmp->title); |
87 | ? (const char *)format ("%s %s", &tmp->name, &tmp->title) |
|
|
88 | : tmp->name; |
|
|
89 | |
91 | tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1)); |
90 | int tval = strtoint (name) * tmp->number_of (); |
92 | #ifdef ALCHEMY_DEBUG |
91 | #ifdef ALCHEMY_DEBUG |
93 | LOG (llevDebug, "Got ingredient %d %s(%d)\n", tmp->nrof ? tmp->nrof : 1, name, tval); |
92 | LOG (llevDebug, "Got ingredient %d %s(%d)\n", tmp->nrof ? tmp->nrof : 1, name, tval); |
94 | #endif |
93 | #endif |
95 | formula += tval; |
94 | formula += tval; |
96 | tmp = tmp->below; |
95 | tmp = tmp->below; |
97 | } |
96 | } |
98 | #ifdef ALCHEMY_DEBUG |
97 | #ifdef ALCHEMY_DEBUG |
99 | LOG (llevDebug, " Formula value=%d\n", formula); |
98 | LOG (llevDebug, " Formula value=%d\n", formula); |
100 | #endif |
99 | #endif |
|
|
100 | |
101 | return formula; |
101 | return formula; |
102 | } |
102 | } |
103 | |
103 | |
104 | /** |
104 | /** |
105 | * Returns total number of items in op |
105 | * Returns total number of items in op |
… | |
… | |
223 | |
223 | |
224 | transmute_materialname (item, art->item); |
224 | transmute_materialname (item, art->item); |
225 | give_artifact_abilities (item, art->item); |
225 | give_artifact_abilities (item, art->item); |
226 | } |
226 | } |
227 | |
227 | |
228 | if (QUERY_FLAG (cauldron, FLAG_CURSED)) |
228 | if (cauldron->flag [FLAG_CURSED]) |
229 | SET_FLAG (item, FLAG_CURSED); |
229 | item->set_flag (FLAG_CURSED); |
230 | if (QUERY_FLAG (cauldron, FLAG_DAMNED)) |
230 | if (cauldron->flag [FLAG_DAMNED]) |
231 | SET_FLAG (item, FLAG_DAMNED); |
231 | item->set_flag (FLAG_DAMNED); |
232 | |
232 | |
233 | return item; |
233 | return item; |
234 | } |
234 | } |
235 | |
235 | |
236 | /* |
236 | /* |
… | |
… | |
396 | tmp->value = 0; |
396 | tmp->value = 0; |
397 | tmp->material = name_to_material (shstr_stone); |
397 | tmp->material = name_to_material (shstr_stone); |
398 | tmp->name = shstr_slag; |
398 | tmp->name = shstr_slag; |
399 | tmp->name_pl = shstr_slags; |
399 | tmp->name_pl = shstr_slags; |
400 | item = insert_ob_in_ob (tmp, cauldron); |
400 | item = insert_ob_in_ob (tmp, cauldron); |
401 | CLEAR_FLAG (tmp, FLAG_CAN_ROLL); |
401 | tmp->clr_flag (FLAG_CAN_ROLL); |
402 | SET_FLAG (tmp, FLAG_NO_DROP); |
402 | tmp->set_flag (FLAG_NO_DROP); |
403 | tmp->move_block = 0; |
403 | tmp->move_block = 0; |
404 | } |
404 | } |
405 | |
405 | |
406 | remove_contents (cauldron->inv, item); |
406 | remove_contents (cauldron->inv, item); |
407 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
407 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
… | |
… | |
415 | if ((rp = get_random_recipe ((recipelist *) NULL)) == NULL) |
415 | if ((rp = get_random_recipe ((recipelist *) NULL)) == NULL) |
416 | return; |
416 | return; |
417 | |
417 | |
418 | if ((tmp = attempt_recipe (op, cauldron, 1, rp, -1))) |
418 | if ((tmp = attempt_recipe (op, cauldron, 1, rp, -1))) |
419 | { |
419 | { |
420 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) /* curse it */ |
420 | if (!tmp->flag [FLAG_CURSED]) /* curse it */ |
421 | SET_FLAG (tmp, FLAG_CURSED); |
421 | tmp->set_flag (FLAG_CURSED); |
422 | |
422 | |
423 | /* the apply code for potions already deals with cursed |
423 | /* the apply code for potions already deals with cursed |
424 | * potions, so any code here is basically ignored. |
424 | * potions, so any code here is basically ignored. |
425 | */ |
425 | */ |
426 | if (tmp->type == FOOD) |
426 | if (tmp->type == FOOD) |
… | |
… | |
498 | fb->destroy (); |
498 | fb->destroy (); |
499 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
499 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
500 | } |
500 | } |
501 | else if (level < 100) |
501 | else if (level < 100) |
502 | { /* WHAMMY the CAULDRON */ |
502 | { /* WHAMMY the CAULDRON */ |
503 | if (!QUERY_FLAG (cauldron, FLAG_CURSED)) |
503 | if (!cauldron->flag [FLAG_CURSED]) |
504 | SET_FLAG (cauldron, FLAG_CURSED); |
504 | cauldron->set_flag (FLAG_CURSED); |
505 | else |
505 | else |
506 | cauldron->magic--; |
506 | cauldron->magic--; |
507 | |
507 | |
508 | cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); |
508 | cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); |
509 | |
509 | |
… | |
… | |
614 | danger += 110; |
614 | danger += 110; |
615 | else |
615 | else |
616 | danger += rp->diff * 3; |
616 | danger += rp->diff * 3; |
617 | |
617 | |
618 | /* Using a bad device is *majorly* stupid */ |
618 | /* Using a bad device is *majorly* stupid */ |
619 | if (QUERY_FLAG (cauldron, FLAG_CURSED)) |
619 | if (cauldron->flag [FLAG_CURSED]) |
620 | danger += 80; |
620 | danger += 80; |
621 | if (QUERY_FLAG (cauldron, FLAG_DAMNED)) |
621 | if (cauldron->flag [FLAG_DAMNED]) |
622 | danger += 200; |
622 | danger += 200; |
623 | |
623 | |
624 | #ifdef ALCHEMY_DEBUG |
624 | #ifdef ALCHEMY_DEBUG |
625 | LOG (llevDebug, "calc_alch_danger() returned danger=%d\n", danger); |
625 | LOG (llevDebug, "calc_alch_danger() returned danger=%d\n", danger); |
626 | #endif |
626 | #endif |
… | |
… | |
853 | return; |
853 | return; |
854 | |
854 | |
855 | numb = numb_ob_inside (cauldron); |
855 | numb = numb_ob_inside (cauldron); |
856 | if ((fl = get_formulalist (numb))) |
856 | if ((fl = get_formulalist (numb))) |
857 | { |
857 | { |
858 | if (QUERY_FLAG (caster, FLAG_WIZ)) |
858 | if (caster->flag [FLAG_WIZ]) |
859 | { |
859 | { |
860 | rp = find_recipe (fl, formula, cauldron->inv); |
860 | rp = find_recipe (fl, formula, cauldron->inv); |
861 | if (rp != NULL) |
861 | if (rp != NULL) |
862 | { |
862 | { |
863 | #ifdef ALCHEMY_DEBUG |
863 | #ifdef ALCHEMY_DEBUG |
… | |
… | |
885 | object *tmp; |
885 | object *tmp; |
886 | int attempt_shadow_alchemy; |
886 | int attempt_shadow_alchemy; |
887 | |
887 | |
888 | ave_chance = fl->total_chance / (float)fl->number; |
888 | ave_chance = fl->total_chance / (float)fl->number; |
889 | |
889 | |
890 | ability += (int) (skill->level * ((4.0 + cauldron->magic) / 4.0)); |
890 | ability += skill->level * ((4.0 + cauldron->magic) / 4.0); |
891 | |
891 | |
892 | /* determine value of ingredients */ |
892 | /* determine value of ingredients */ |
893 | value_ingredients = 0; |
893 | value_ingredients = 0; |
894 | for (tmp = cauldron->inv; tmp; tmp = tmp->below) |
894 | for (tmp = cauldron->inv; tmp; tmp = tmp->below) |
895 | value_ingredients += query_cost (tmp, NULL, F_TRUE); |
895 | value_ingredients += query_cost (tmp, NULL, F_TRUE); |
… | |
… | |
916 | "Forcing failure for shadow alchemy recipe because price of ingredients (%llu) is less than price of result (%llu).\n", |
916 | "Forcing failure for shadow alchemy recipe because price of ingredients (%llu) is less than price of result (%llu).\n", |
917 | value_ingredients, value_item); |
917 | value_ingredients, value_item); |
918 | #endif |
918 | #endif |
919 | } |
919 | } |
920 | /* roll the dice */ |
920 | /* roll the dice */ |
921 | else if ((float) (random_roll (0, 101, caster, PREFER_LOW)) <= 100.0 * success_chance) |
921 | else if (random_roll (0, 101, caster, PREFER_LOW) <= 100.0 * success_chance) |
922 | { |
922 | { |
923 | change_exp (caster, rp->exp, rp->skill, SK_EXP_NONE); |
923 | change_exp (caster, rp->exp, rp->skill, SK_EXP_NONE); |
924 | |
924 | |
925 | // let alchemy consume some time, so that exploits are less easy |
925 | // let alchemy consume some time, so that exploits are less easy |
926 | caster->speed_left -= 1.0; |
926 | caster->speed_left -= 1.0; |