1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
511 | |
511 | |
512 | if (rndm (0, 2)) |
512 | if (rndm (0, 2)) |
513 | { /* slag created */ |
513 | { /* slag created */ |
514 | object *tmp = cauldron->inv; |
514 | object *tmp = cauldron->inv; |
515 | int weight = 0; |
515 | int weight = 0; |
516 | uint16 material = M_STONE; |
|
|
517 | |
516 | |
518 | while (tmp) |
|
|
519 | { /* slag has coadded ingredient properties */ |
|
|
520 | weight += tmp->weight; |
|
|
521 | if (!(material & tmp->material)) |
|
|
522 | material |= tmp->material; |
|
|
523 | tmp = tmp->below; |
|
|
524 | } |
|
|
525 | tmp = get_archetype ("rock"); |
517 | tmp = get_archetype ("rock"); |
526 | tmp->weight = weight; |
518 | tmp->weight = weight; |
527 | tmp->value = 0; |
519 | tmp->value = 0; |
528 | tmp->material = material; |
|
|
529 | tmp->materialname = "stone"; |
520 | tmp->materialname = "stone"; |
530 | tmp->name = "slag"; |
521 | tmp->name = "slag"; |
531 | tmp->name_pl = "slags"; |
522 | tmp->name_pl = "slags"; |
532 | item = insert_ob_in_ob (tmp, cauldron); |
523 | item = insert_ob_in_ob (tmp, cauldron); |
533 | CLEAR_FLAG (tmp, FLAG_CAN_ROLL); |
524 | CLEAR_FLAG (tmp, FLAG_CAN_ROLL); |
534 | CLEAR_FLAG (tmp, FLAG_NO_PICK); |
525 | CLEAR_FLAG (tmp, FLAG_NO_PICK); |
535 | tmp->move_block = 0; |
526 | tmp->move_block = 0; |
536 | } |
527 | } |
|
|
528 | |
537 | remove_contents (cauldron->inv, item); |
529 | remove_contents (cauldron->inv, item); |
538 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
530 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
539 | return; |
531 | return; |
540 | } |
532 | } |
541 | else if (level < 40) |
533 | else if (level < 40) |
… | |
… | |
738 | tmp->destroy (); |
730 | tmp->destroy (); |
739 | tmp = next; |
731 | tmp = next; |
740 | } |
732 | } |
741 | } |
733 | } |
742 | |
734 | |
743 | /**
|
735 | /** |
744 | *"Danger" level, will determine how bad the backfire |
736 | *"Danger" level, will determine how bad the backfire |
745 | * could be if the user fails to concoct a recipe properly. Factors include |
737 | * could be if the user fails to concoct a recipe properly. Factors include |
746 | * the number of ingredients, the length of the name of each ingredient, |
738 | * the number of ingredients, the length of the name of each ingredient, |
747 | * the user's effective level, the user's Int and the enchantment on the |
739 | * the user's effective level, the user's Int and the enchantment on the |
748 | * mixing device (aka "cauldron"). Higher values of 'danger' indicate more |
740 | * mixing device (aka "cauldron"). Higher values of 'danger' indicate more |
749 | * danger. Note that we assume that we have had the caster ready the alchemy |
741 | * danger. Note that we assume that we have had the caster ready the alchemy |
750 | * skill *before* this routine is called. (no longer auto-readies that skill) |
742 | * skill *before* this routine is called. (no longer auto-readies that skill) |
751 | * -b.t. |
743 | * -b.t. |
752 | */ |
744 | */ |
753 | |
|
|
754 | int |
745 | int |
755 | calc_alch_danger (object *caster, object *cauldron, recipe *rp) |
746 | calc_alch_danger (object *caster, object *cauldron, recipe *rp) |
756 | { |
747 | { |
757 | object *item; |
748 | object *item; |
758 | char name[MAX_BUF]; |
749 | char name[MAX_BUF]; |
759 | int danger = 0, nrofi = 0; |
750 | int danger = 0, nrofi = 0; |
760 | |
751 | |
761 | /* Knowing alchemy skill reduces yer risk */ |
752 | /* Knowing alchemy skill reduces yer risk */ |
762 | danger -= caster->chosen_skill ? caster->chosen_skill->level : caster->level; |
753 | danger -= caster->chosen_skill ? caster->chosen_skill->level : caster->level; |
|
|
754 | |
|
|
755 | if (!caster->chosen_skill) |
|
|
756 | LOG (llevError | logBacktrace, "calc_alch_danger called without a chosen skill, caster %s, cauldron %s\n", |
|
|
757 | caster->debug_desc (), cauldron->debug_desc ()); |
763 | |
758 | |
764 | /* better cauldrons reduce risk */ |
759 | /* better cauldrons reduce risk */ |
765 | danger -= cauldron->magic; |
760 | danger -= cauldron->magic; |
766 | |
761 | |
767 | /* Higher Int, lower the risk */ |
762 | /* Higher Int, lower the risk */ |
… | |
… | |
777 | if (item->title) |
772 | if (item->title) |
778 | sprintf (name, "%s %s", &item->name, &item->title); |
773 | sprintf (name, "%s %s", &item->name, &item->title); |
779 | danger += (strtoint (name) / 1000) + 3; |
774 | danger += (strtoint (name) / 1000) + 3; |
780 | nrofi++; |
775 | nrofi++; |
781 | } |
776 | } |
|
|
777 | |
782 | if (rp == NULL) |
778 | if (rp == NULL) |
783 | danger += 110; |
779 | danger += 110; |
784 | else |
780 | else |
785 | danger += rp->diff * 3; |
781 | danger += rp->diff * 3; |
786 | |
782 | |
… | |
… | |
795 | #endif |
791 | #endif |
796 | |
792 | |
797 | return danger; |
793 | return danger; |
798 | } |
794 | } |
799 | |
795 | |
800 | /**
|
796 | /** |
801 | * Determines if ingredients in a container match the |
797 | * Determines if ingredients in a container match the |
802 | * proper ingredients for a recipe. |
798 | * proper ingredients for a recipe. |
803 | * |
799 | * |
804 | * rp is the recipe to check |
800 | * rp is the recipe to check |
805 | * cauldron is the container that holds the ingredients |
801 | * cauldron is the container that holds the ingredients |
… | |
… | |
909 | LOG (llevDebug, "looking for formula %d:\n", formula); |
905 | LOG (llevDebug, "looking for formula %d:\n", formula); |
910 | #endif |
906 | #endif |
911 | result = NULL; |
907 | result = NULL; |
912 | recipes_matching = 0; |
908 | recipes_matching = 0; |
913 | transmute_found = 0; |
909 | transmute_found = 0; |
|
|
910 | |
914 | for (rp = fl->items; rp != NULL; rp = rp->next) |
911 | for (rp = fl->items; rp; rp = rp->next) |
915 | { |
912 | { |
916 | /* check if recipe matches at all */ |
913 | /* check if recipe matches at all */ |
917 | if (formula % rp->index != 0) |
914 | if (formula % rp->index != 0) |
918 | { |
915 | { |
919 | #ifdef EXTREME_ALCHEMY_DEBUG |
916 | #ifdef EXTREME_ALCHEMY_DEBUG |