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,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 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 |
… | |
… | |
166 | &prod_item->arch->archname, prod_item->nrof); |
166 | &prod_item->arch->archname, prod_item->nrof); |
167 | } |
167 | } |
168 | #endif |
168 | #endif |
169 | if (!prod_item) |
169 | if (!prod_item) |
170 | *rp_arch_index = rndm (rp->arch_names); |
170 | *rp_arch_index = rndm (rp->arch_names); |
171 | prod_item = get_archetype (rp->arch_name[*rp_arch_index]); |
171 | prod_item = archetype::get (rp->arch_name[*rp_arch_index]); |
172 | } |
172 | } |
173 | |
173 | |
174 | #ifdef ALCHEMY_DEBUG |
174 | #ifdef ALCHEMY_DEBUG |
175 | LOG (llevDebug, "recipe calls for%stransmution.\n", rp->transmute ? " " : " no "); |
175 | LOG (llevDebug, "recipe calls for%stransmution.\n", rp->transmute ? " " : " no "); |
176 | if (prod_item != NULL) |
176 | if (prod_item != NULL) |
… | |
… | |
340 | { |
340 | { |
341 | remove_contents (cauldron->inv, item); |
341 | remove_contents (cauldron->inv, item); |
342 | /* Recalc carrying of the cauldron, in case recipe did not conserve mass */ |
342 | /* Recalc carrying of the cauldron, in case recipe did not conserve mass */ |
343 | cauldron->update_weight (); |
343 | cauldron->update_weight (); |
344 | /* adj lvl, nrof on caster level */ |
344 | /* adj lvl, nrof on caster level */ |
345 | adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches); |
345 | adjust_product (item, ability, rp->yield ? rp->yield * batches : batches); |
|
|
346 | |
346 | if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) |
347 | if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) |
347 | { |
348 | { |
348 | new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); |
349 | new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); |
349 | /* new_draw_info_format(NDI_UNIQUE, 0,caster, |
350 | /* new_draw_info_format(NDI_UNIQUE, 0,caster, |
350 | "Your spell causes the %s to explode!",&cauldron->name); */ |
351 | "Your spell causes the %s to explode!",&cauldron->name); */ |
… | |
… | |
387 | if (rndm (0, 2)) |
388 | if (rndm (0, 2)) |
388 | { /* slag created */ |
389 | { /* slag created */ |
389 | object *tmp = cauldron->inv; |
390 | object *tmp = cauldron->inv; |
390 | int weight = 0; |
391 | int weight = 0; |
391 | |
392 | |
392 | tmp = get_archetype (shstr_rock); |
393 | tmp = archetype::get (shstr_rock); |
393 | tmp->weight = weight; |
394 | tmp->weight = weight; |
394 | tmp->value = 0; |
395 | tmp->value = 0; |
395 | tmp->material = name_to_material (shstr_stone); |
396 | tmp->material = name_to_material (shstr_stone); |
396 | tmp->name = shstr_slag; |
397 | tmp->name = shstr_slag; |
397 | tmp->name_pl = shstr_slags; |
398 | tmp->name_pl = shstr_slags; |
… | |
… | |
464 | |
465 | |
465 | remove_contents (cauldron->inv, NULL); |
466 | remove_contents (cauldron->inv, NULL); |
466 | switch (rndm (0, 2)) |
467 | switch (rndm (0, 2)) |
467 | { |
468 | { |
468 | case 0: |
469 | case 0: |
469 | tmp = get_archetype (shstr_bomb); |
470 | tmp = archetype::get (shstr_bomb); |
470 | tmp->stats.dam = random_roll (1, level, op, PREFER_LOW); |
471 | tmp->stats.dam = random_roll (1, level, op, PREFER_LOW); |
471 | tmp->stats.hp = random_roll (1, level, op, PREFER_LOW); |
472 | tmp->stats.hp = random_roll (1, level, op, PREFER_LOW); |
472 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s creates a bomb!", &cauldron->name); |
473 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s creates a bomb!", &cauldron->name); |
473 | break; |
474 | break; |
474 | |
475 | |
475 | default: |
476 | default: |
476 | tmp = get_archetype (shstr_fireball); |
477 | tmp = archetype::get (shstr_fireball); |
477 | tmp->stats.dam = random_roll (1, level, op, PREFER_LOW) / 5 + 1; |
478 | tmp->stats.dam = random_roll (1, level, op, PREFER_LOW) / 5 + 1; |
478 | tmp->stats.hp = random_roll (1, level, op, PREFER_LOW) / 10 + 2; |
479 | tmp->stats.hp = random_roll (1, level, op, PREFER_LOW) / 10 + 2; |
479 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
480 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
480 | break; |
481 | break; |
481 | } |
482 | } |
… | |
… | |
487 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
488 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
488 | remove_contents (cauldron->inv, NULL); |
489 | remove_contents (cauldron->inv, NULL); |
489 | } |
490 | } |
490 | else if (level < 80) |
491 | else if (level < 80) |
491 | { /* MAJOR FIRE */ |
492 | { /* MAJOR FIRE */ |
492 | object *fb = get_archetype (SP_MED_FIREBALL); |
493 | object *fb = archetype::get (SP_MED_FIREBALL); |
493 | |
494 | |
494 | remove_contents (cauldron->inv, NULL); |
495 | remove_contents (cauldron->inv, NULL); |
495 | fire_arch_from_position (cauldron, cauldron, cauldron->x, cauldron->y, 0, fb); |
496 | fire_arch_from_position (cauldron, cauldron, cauldron->x, cauldron->y, 0, fb); |
496 | fb->destroy (); |
497 | fb->destroy (); |
497 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
498 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
… | |
… | |
543 | * to be made (rather than only those on the given |
544 | * to be made (rather than only those on the given |
544 | * formulalist) */ |
545 | * formulalist) */ |
545 | if (!rp) |
546 | if (!rp) |
546 | rp = get_random_recipe ((recipelist *) NULL); |
547 | rp = get_random_recipe ((recipelist *) NULL); |
547 | |
548 | |
548 | if (rp && (tmp = get_archetype (rp->arch_name [rndm (rp->arch_names)]))) |
549 | if (rp && (tmp = archetype::get (rp->arch_name [rndm (rp->arch_names)]))) |
549 | { |
550 | { |
550 | generate_artifact (tmp, random_roll (1, op->level / 2 + 1, op, PREFER_HIGH) + 1); |
551 | generate_artifact (tmp, random_roll (1, op->level / 2 + 1, op, PREFER_HIGH) + 1); |
551 | if ((tmp = insert_ob_in_ob (tmp, cauldron))) |
552 | if ((tmp = insert_ob_in_ob (tmp, cauldron))) |
552 | { |
553 | { |
553 | remove_contents (cauldron->inv, tmp); |
554 | remove_contents (cauldron->inv, tmp); |
… | |
… | |
555 | } |
556 | } |
556 | } |
557 | } |
557 | } |
558 | } |
558 | else |
559 | else |
559 | { /* MANA STORM - watch out!! */ |
560 | { /* MANA STORM - watch out!! */ |
560 | object *tmp = get_archetype (LOOSE_MANA); |
561 | object *tmp = archetype::get (LOOSE_MANA); |
561 | |
562 | |
562 | new_draw_info (NDI_UNIQUE, 0, op, "You unwisely release potent forces!"); |
563 | new_draw_info (NDI_UNIQUE, 0, op, "You unwisely release potent forces!"); |
563 | remove_contents (cauldron->inv, NULL); |
564 | remove_contents (cauldron->inv, NULL); |
564 | cast_magic_storm (op, tmp, level); |
565 | cast_magic_storm (op, tmp, level); |
565 | } |
566 | } |
… | |
… | |
888 | |
889 | |
889 | /* create the object **FIRST**, then decide whether to keep it. */ |
890 | /* create the object **FIRST**, then decide whether to keep it. */ |
890 | if ((item = attempt_recipe (caster, cauldron, ability, rp, formula / rp->index)) != NULL) |
891 | if ((item = attempt_recipe (caster, cauldron, ability, rp, formula / rp->index)) != NULL) |
891 | { |
892 | { |
892 | /* compute base chance of recipe success */ |
893 | /* compute base chance of recipe success */ |
893 | success_chance = ((float) ability / (float) (rp->diff * (item->level + 2))); |
894 | success_chance = ((float)ability / (float)(rp->diff * (item->level + 2))); |
894 | if (ave_chance == 0) |
895 | if (ave_chance == 0) |
895 | ave_chance = 1; |
896 | ave_chance = 1; |
896 | |
897 | |
897 | #ifdef ALCHEMY_DEBUG |
898 | #ifdef ALCHEMY_DEBUG |
898 | LOG (llevDebug, "percent success chance = %f ab%d / diff%d*lev%d\n", success_chance, ability, rp->diff, item->level); |
899 | LOG (llevDebug, "percent success chance = %f ab%d / diff%d*lev%d\n", success_chance, ability, rp->diff, item->level); |