1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software; you can redistribute it and/or modify it |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * under the terms of the GNU General Public License as published by the Free |
9 | * it under the terms of the GNU General Public License as published by |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, but |
13 | * This program is distributed in the hope that it will be useful, |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License along |
18 | * You should have received a copy of the GNU General Public License |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | /* March 96 - Laid down original code. -b.t. thomas@astro.psu.edu */ |
24 | /* March 96 - Laid down original code. -b.t. thomas@astro.psu.edu */ |
26 | |
25 | |
27 | #include <global.h> |
26 | #include <global.h> |
… | |
… | |
292 | /* this should be passed to this fctn, not effiecent cpu use this way */ |
291 | /* this should be passed to this fctn, not effiecent cpu use this way */ |
293 | int batches = abs (nbatches); |
292 | int batches = abs (nbatches); |
294 | |
293 | |
295 | |
294 | |
296 | /* is the cauldron the right type? */ |
295 | /* is the cauldron the right type? */ |
297 | if (rp->cauldron != cauldron->arch->name) |
296 | if (rp->cauldron != cauldron->arch->archname) |
298 | { |
297 | { |
299 | new_draw_info (NDI_UNIQUE, 0, caster, "You are not using the proper" " facilities for this formula."); |
298 | new_draw_info (NDI_UNIQUE, 0, caster, "You are not using the proper" " facilities for this formula."); |
300 | return 0; |
299 | return 0; |
301 | } |
300 | } |
302 | |
301 | |
… | |
… | |
316 | break; |
315 | break; |
317 | } |
316 | } |
318 | |
317 | |
319 | if (!tmp) |
318 | if (!tmp) |
320 | { /* failure--no code found */ |
319 | { /* failure--no code found */ |
321 | new_draw_info (NDI_UNIQUE, 0, caster, "You know the ingredients," " but not the technique. Go learn how to do this recipe."); |
320 | new_draw_info (NDI_UNIQUE, 0, caster, "You know the ingredients, but not the technique. Go learn how to do this recipe."); |
322 | return 0; |
321 | return 0; |
323 | } |
322 | } |
324 | } |
323 | } |
325 | |
324 | |
326 | #ifdef EXTREME_ALCHEMY_DEBUG |
325 | #ifdef EXTREME_ALCHEMY_DEBUG |
… | |
… | |
330 | |
329 | |
331 | if ((item = make_item_from_recipe (cauldron, rp)) != NULL) |
330 | if ((item = make_item_from_recipe (cauldron, rp)) != NULL) |
332 | { |
331 | { |
333 | remove_contents (cauldron->inv, item); |
332 | remove_contents (cauldron->inv, item); |
334 | /* Recalc carrying of the cauldron, in case recipe did not conserve mass */ |
333 | /* Recalc carrying of the cauldron, in case recipe did not conserve mass */ |
335 | sum_weight (cauldron); |
334 | cauldron->update_weight (); |
336 | /* adj lvl, nrof on caster level */ |
335 | /* adj lvl, nrof on caster level */ |
337 | adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches); |
336 | adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches); |
338 | if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) |
337 | if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) |
339 | { |
338 | { |
340 | new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); |
339 | new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); |
… | |
… | |
448 | { |
447 | { |
449 | size_t i; |
448 | size_t i; |
450 | |
449 | |
451 | for (i = 0; i < rp->arch_names; i++) |
450 | for (i = 0; i < rp->arch_names; i++) |
452 | { |
451 | { |
453 | if (item->arch->name == rp->arch_name[i]) |
452 | if (item->arch->archname == rp->arch_name[i]) |
454 | { |
453 | { |
455 | *rp_arch_index = i; |
454 | *rp_arch_index = i; |
456 | break; |
455 | break; |
457 | } |
456 | } |
458 | } |
457 | } |
… | |
… | |
559 | } |
558 | } |
560 | while (rndm (0, 2)); |
559 | while (rndm (0, 2)); |
561 | } |
560 | } |
562 | return; |
561 | return; |
563 | } |
562 | } |
|
|
563 | |
564 | if (level == 40) |
564 | if (level == 40) |
565 | { /* MAKE RANDOM RECIPE */ |
565 | { /* MAKE RANDOM RECIPE */ |
566 | recipelist *fl; |
566 | recipelist *fl; |
567 | int numb = numb_ob_inside (cauldron); |
567 | int numb = numb_ob_inside (cauldron); |
568 | |
568 | |
… | |
… | |
570 | if (fl && (rp = get_random_recipe (fl))) |
570 | if (fl && (rp = get_random_recipe (fl))) |
571 | /* even though random, don't grant user any EXP for it */ |
571 | /* even though random, don't grant user any EXP for it */ |
572 | (void) attempt_recipe (op, cauldron, 1, rp, -1); |
572 | (void) attempt_recipe (op, cauldron, 1, rp, -1); |
573 | else |
573 | else |
574 | alchemy_failure_effect (op, cauldron, rp, level - 1); |
574 | alchemy_failure_effect (op, cauldron, rp, level - 1); |
575 | return; |
|
|
576 | |
|
|
577 | } |
575 | } |
578 | else if (level < 45) |
576 | else if (level < 45) |
579 | { /* INFURIATE NPC's */ |
577 | { /* INFURIATE NPC's */ |
580 | /* this is kind of kludgy I know... */ |
578 | /* this is kind of kludgy I know... */ |
581 | cauldron->enemy = op; |
579 | cauldron->enemy = op; |
582 | npc_call_help (cauldron); |
580 | npc_call_help (cauldron); |
583 | cauldron->enemy = NULL; |
581 | cauldron->enemy = NULL; |
584 | |
582 | |
585 | alchemy_failure_effect (op, cauldron, rp, level - 5); |
583 | alchemy_failure_effect (op, cauldron, rp, level - 5); |
586 | return; |
|
|
587 | } |
584 | } |
588 | else if (level < 50) |
585 | else if (level < 50) |
589 | { /* MINOR EXPLOSION/FIREBALL */ |
586 | { /* MINOR EXPLOSION/FIREBALL */ |
590 | object *tmp; |
587 | object *tmp; |
591 | |
588 | |
… | |
… | |
605 | tmp->stats.hp = random_roll (1, level, op, PREFER_LOW) / 10 + 2; |
602 | tmp->stats.hp = random_roll (1, level, op, PREFER_LOW) / 10 + 2; |
606 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
603 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
607 | break; |
604 | break; |
608 | } |
605 | } |
609 | |
606 | |
610 | op->insert_at (cauldron); |
607 | tmp->insert_at (cauldron); |
611 | return; |
|
|
612 | |
|
|
613 | } |
608 | } |
614 | else if (level < 60) |
609 | else if (level < 60) |
615 | { /* CREATE MONSTER */ |
610 | { /* CREATE MONSTER */ |
616 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
611 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
617 | remove_contents (cauldron->inv, NULL); |
612 | remove_contents (cauldron->inv, NULL); |
618 | return; |
|
|
619 | } |
613 | } |
620 | else if (level < 80) |
614 | else if (level < 80) |
621 | { /* MAJOR FIRE */ |
615 | { /* MAJOR FIRE */ |
622 | object *fb = get_archetype (SP_MED_FIREBALL); |
616 | object *fb = get_archetype (SP_MED_FIREBALL); |
623 | |
617 | |
624 | remove_contents (cauldron->inv, NULL); |
618 | remove_contents (cauldron->inv, NULL); |
625 | fire_arch_from_position (cauldron, cauldron, cauldron->x, cauldron->y, 0, fb); |
619 | fire_arch_from_position (cauldron, cauldron, cauldron->x, cauldron->y, 0, fb); |
626 | fb->destroy (); |
620 | fb->destroy (true); |
627 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
621 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s erupts in flame!", &cauldron->name); |
628 | return; |
|
|
629 | |
|
|
630 | } |
622 | } |
631 | else if (level < 100) |
623 | else if (level < 100) |
632 | { /* WHAMMY the CAULDRON */ |
624 | { /* WHAMMY the CAULDRON */ |
633 | if (!QUERY_FLAG (cauldron, FLAG_CURSED)) |
625 | if (!QUERY_FLAG (cauldron, FLAG_CURSED)) |
634 | SET_FLAG (cauldron, FLAG_CURSED); |
626 | SET_FLAG (cauldron, FLAG_CURSED); |
635 | else |
627 | else |
636 | cauldron->magic--; |
628 | cauldron->magic--; |
|
|
629 | |
637 | cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); |
630 | cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); |
|
|
631 | |
638 | if (rndm (0, 1)) |
632 | if (rndm (0, 1)) |
639 | { |
633 | { |
640 | remove_contents (cauldron->inv, NULL); |
634 | remove_contents (cauldron->inv, NULL); |
641 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s turns darker then makes a gulping sound!", &cauldron->name); |
635 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s turns darker then makes a gulping sound!", &cauldron->name); |
642 | } |
636 | } |
643 | else |
637 | else |
644 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s becomes darker.", &cauldron->name); |
638 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s becomes darker.", &cauldron->name); |
645 | return; |
|
|
646 | |
|
|
647 | } |
639 | } |
648 | else if (level < 110) |
640 | else if (level < 110) |
649 | { /* SUMMON EVIL MONSTERS */ |
641 | { /* SUMMON EVIL MONSTERS */ |
650 | object *tmp = get_random_mon (level / 5); |
642 | object *tmp = get_random_mon (level / 5); |
651 | |
643 | |
652 | remove_contents (cauldron->inv, NULL); |
644 | remove_contents (cauldron->inv, NULL); |
|
|
645 | |
653 | if (!tmp) |
646 | if (!tmp) |
654 | alchemy_failure_effect (op, cauldron, rp, level); |
647 | alchemy_failure_effect (op, cauldron, rp, level); |
655 | else if (summon_hostile_monsters (cauldron, random_roll (1, 10, op, PREFER_LOW), tmp->arch->name)) |
648 | else if (summon_hostile_monsters (cauldron, random_roll (1, 10, op, PREFER_LOW), tmp->arch->archname)) |
656 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s and then pours forth monsters!", &cauldron->name, cauldron_sound ()); |
649 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s and then pours forth monsters!", &cauldron->name, cauldron_sound ()); |
657 | return; |
|
|
658 | |
|
|
659 | } |
650 | } |
660 | else if (level < 150) |
651 | else if (level < 150) |
661 | { /* COMBO EFFECT */ |
652 | { /* COMBO EFFECT */ |
662 | int roll = rndm (1, 3); |
653 | int roll = rndm (1, 3); |
663 | |
654 | |
664 | while (roll) |
655 | while (roll) |
665 | { |
656 | { |
666 | alchemy_failure_effect (op, cauldron, rp, level - 39); |
657 | alchemy_failure_effect (op, cauldron, rp, level - 39); |
667 | roll--; |
658 | roll--; |
668 | } |
659 | } |
669 | return; |
|
|
670 | } |
660 | } |
671 | else if (level == 151) |
661 | else if (level == 151) |
672 | { /* CREATE RANDOM ARTIFACT */ |
662 | { /* CREATE RANDOM ARTIFACT */ |
673 | object *tmp; |
663 | object *tmp; |
674 | |
664 | |
… | |
… | |
685 | { |
675 | { |
686 | remove_contents (cauldron->inv, tmp); |
676 | remove_contents (cauldron->inv, tmp); |
687 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
677 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
688 | } |
678 | } |
689 | } |
679 | } |
690 | return; |
|
|
691 | } |
680 | } |
692 | else |
681 | else |
693 | { /* MANA STORM - watch out!! */ |
682 | { /* MANA STORM - watch out!! */ |
694 | object *tmp = get_archetype (LOOSE_MANA); |
683 | object *tmp = get_archetype (LOOSE_MANA); |
695 | |
684 | |
696 | new_draw_info (NDI_UNIQUE, 0, op, "You unwisely release potent forces!"); |
685 | new_draw_info (NDI_UNIQUE, 0, op, "You unwisely release potent forces!"); |
697 | remove_contents (cauldron->inv, NULL); |
686 | remove_contents (cauldron->inv, NULL); |
698 | cast_magic_storm (op, tmp, level); |
687 | cast_magic_storm (op, tmp, level); |
699 | return; |
|
|
700 | } |
688 | } |
701 | } |
689 | } |
702 | |
|
|
703 | |
690 | |
704 | /* |
691 | /* |
705 | * All but object "save_item" are elimentated from |
692 | * All but object "save_item" are elimentated from |
706 | * the container list. Note we have to becareful to remove the inventories |
693 | * the container list. Note we have to becareful to remove the inventories |
707 | * of objects in the cauldron inventory (ex icecube has stuff in it). |
694 | * of objects in the cauldron inventory (ex icecube has stuff in it). |
708 | */ |
695 | */ |
709 | |
|
|
710 | void |
696 | void |
711 | remove_contents (object *first_ob, object *save_item) |
697 | remove_contents (object *first_ob, object *save_item) |
712 | { |
698 | { |
|
|
699 | // this cries for a cleaner rewrite, removing save_item first possibly |
713 | object *next, *tmp = first_ob; |
700 | object *next, *tmp = first_ob; |
714 | |
701 | |
715 | while (tmp) |
702 | while (tmp) |
716 | { |
703 | { |
717 | next = tmp->below; |
704 | next = tmp->below; |
… | |
… | |
725 | } |
712 | } |
726 | |
713 | |
727 | if (tmp->inv) |
714 | if (tmp->inv) |
728 | remove_contents (tmp->inv, NULL); |
715 | remove_contents (tmp->inv, NULL); |
729 | |
716 | |
730 | tmp->destroy (); |
717 | tmp->destroy (true); |
731 | tmp = next; |
718 | tmp = next; |
732 | } |
719 | } |
733 | } |
720 | } |
734 | |
721 | |
735 | /** |
722 | /** |