1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | |
3 | * |
|
|
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * |
20 | |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
|
|
22 | */ |
22 | */ |
23 | |
23 | |
24 | /* 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 */ |
25 | |
25 | |
26 | #include <global.h> |
26 | #include <global.h> |
27 | #include <object.h> |
27 | #include <object.h> |
… | |
… | |
231 | int tval = 0, formula = 0; |
231 | int tval = 0, formula = 0; |
232 | |
232 | |
233 | while (tmp) |
233 | while (tmp) |
234 | { |
234 | { |
235 | tval = 0; |
235 | tval = 0; |
236 | strcpy (name, tmp->name); |
236 | assign (name, tmp->name); |
237 | if (tmp->title) |
237 | if (tmp->title) |
238 | sprintf (name, "%s %s", &tmp->name, &tmp->title); |
238 | sprintf (name, "%s %s", &tmp->name, &tmp->title); |
239 | tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1)); |
239 | tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1)); |
240 | #ifdef ALCHEMY_DEBUG |
240 | #ifdef ALCHEMY_DEBUG |
241 | LOG (llevDebug, "Got ingredient %d %s(%d)\n", tmp->nrof ? tmp->nrof : 1, name, tval); |
241 | LOG (llevDebug, "Got ingredient %d %s(%d)\n", tmp->nrof ? tmp->nrof : 1, name, tval); |
… | |
… | |
290 | |
290 | |
291 | /* 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 */ |
292 | int batches = abs (nbatches); |
292 | int batches = abs (nbatches); |
293 | |
293 | |
294 | |
294 | |
295 | LOG (llevDebug, "A %s <=> %s\n", &(rp->cauldron), &(cauldron->arch->name)); |
|
|
296 | /* is the cauldron the right type? */ |
295 | /* is the cauldron the right type? */ |
297 | if (strcmp (rp->cauldron, cauldron->arch->name) != 0) |
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 | |
… | |
… | |
308 | /* code required for this recipe, search the caster */ |
307 | /* code required for this recipe, search the caster */ |
309 | if (rp->keycode) |
308 | if (rp->keycode) |
310 | { |
309 | { |
311 | object *tmp; |
310 | object *tmp; |
312 | |
311 | |
313 | for (tmp = caster->inv; tmp != NULL; tmp = tmp->below) |
312 | for (tmp = caster->inv; tmp; tmp = tmp->below) |
314 | { |
313 | { |
315 | if (tmp->type == FORCE && tmp->slaying && !strcmp (rp->keycode, tmp->slaying)) |
314 | if (tmp->type == FORCE && tmp->slaying && rp->keycode == tmp->slaying) |
316 | break; |
315 | break; |
317 | } |
316 | } |
|
|
317 | |
318 | if (tmp == NULL) |
318 | if (!tmp) |
319 | { /* failure--no code found */ |
319 | { /* failure--no code found */ |
320 | 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."); |
321 | return 0; |
321 | return 0; |
322 | } |
322 | } |
323 | } |
323 | } |
324 | |
324 | |
325 | #ifdef EXTREME_ALCHEMY_DEBUG |
325 | #ifdef EXTREME_ALCHEMY_DEBUG |
… | |
… | |
329 | |
329 | |
330 | if ((item = make_item_from_recipe (cauldron, rp)) != NULL) |
330 | if ((item = make_item_from_recipe (cauldron, rp)) != NULL) |
331 | { |
331 | { |
332 | remove_contents (cauldron->inv, item); |
332 | remove_contents (cauldron->inv, item); |
333 | /* 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 */ |
334 | sum_weight (cauldron); |
334 | cauldron->update_weight (); |
335 | /* adj lvl, nrof on caster level */ |
335 | /* adj lvl, nrof on caster level */ |
336 | adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches); |
336 | adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches); |
337 | if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) |
337 | if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) |
338 | { |
338 | { |
339 | new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); |
339 | new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); |
340 | /* new_draw_info_format(NDI_UNIQUE, 0,caster, |
340 | /* new_draw_info_format(NDI_UNIQUE, 0,caster, |
341 | "Your spell causes the %s to explode!",&cauldron->name); */ |
341 | "Your spell causes the %s to explode!",&cauldron->name); */ |
342 | /* kaboom_cauldron(); */ |
342 | /* kaboom_cauldron(); */ |
343 | } |
343 | } |
344 | else |
344 | else |
345 | { |
|
|
346 | new_draw_info_format (NDI_UNIQUE, 0, caster, "The %s %s.", &cauldron->name, cauldron_sound ()); |
345 | new_draw_info_format (NDI_UNIQUE, 0, caster, "The %s %s.", &cauldron->name, cauldron_sound ()); |
347 | } |
|
|
348 | } |
346 | } |
|
|
347 | |
349 | return item; |
348 | return item; |
350 | } |
349 | } |
351 | |
350 | |
352 | |
351 | |
353 | |
352 | |
354 | /**
|
353 | /** |
355 | * We adjust the nrof, exp and level of the final product, based |
354 | * We adjust the nrof, exp and level of the final product, based |
356 | * on the item's default parameters, and the relevant caster skill level.
|
355 | * on the item's default parameters, and the relevant caster skill level.
|
357 | */ |
356 | */ |
358 |
void |
357 | void |
359 | adjust_product (object *item, int lvl, int yield) |
358 | adjust_product (object *item, int lvl, int yield) |
360 | { |
359 | { |
361 | int nrof = 1; |
360 | int nrof = 1; |
362 | |
361 | |
363 | if (!yield) |
362 | if (!yield) |
364 | yield = 1; |
363 | yield = 1; |
|
|
364 | |
365 | if (lvl <= 0) |
365 | if (lvl <= 0) |
366 | lvl = 1; /* lets avoid div by zero! */ |
366 | lvl = 1; /* lets avoid div by zero! */ |
|
|
367 | |
367 | if (item->nrof) |
368 | if (item->nrof) |
368 | { |
369 | { |
369 | nrof = (int) ((1.0 - 1.0 / (lvl / 10.0 + 1.0)) * (rndm (0, yield - 1) + rndm (0, yield - 1) + rndm (0, yield - 1)) + 1); |
370 | nrof = (int) ((1.0 - 1.0 / (lvl / 10.0 + 1.0)) * (rndm (0, yield - 1) + rndm (0, yield - 1) + rndm (0, yield - 1)) + 1); |
|
|
371 | |
370 | if (nrof > yield) |
372 | if (nrof > yield) |
371 | nrof = yield; |
373 | nrof = yield; |
|
|
374 | |
372 | item->nrof = nrof; |
375 | item->nrof = nrof; |
373 | } |
376 | } |
374 | } |
377 | } |
375 | |
378 | |
376 | |
379 | |
… | |
… | |
444 | { |
447 | { |
445 | size_t i; |
448 | size_t i; |
446 | |
449 | |
447 | for (i = 0; i < rp->arch_names; i++) |
450 | for (i = 0; i < rp->arch_names; i++) |
448 | { |
451 | { |
449 | if (strcmp (item->arch->name, rp->arch_name[i]) == 0) |
452 | if (item->arch->archname == rp->arch_name[i]) |
450 | { |
453 | { |
451 | *rp_arch_index = i; |
454 | *rp_arch_index = i; |
452 | break; |
455 | break; |
453 | } |
456 | } |
454 | } |
457 | } |
|
|
458 | |
455 | if (i < rp->arch_names) |
459 | if (i < rp->arch_names) |
456 | break; |
460 | break; |
457 | } |
461 | } |
458 | |
462 | |
459 | /* failed, create a fresh object. Note no nrof>1 because that would |
463 | /* failed, create a fresh object. Note no nrof>1 because that would |
… | |
… | |
506 | |
510 | |
507 | if (rndm (0, 2)) |
511 | if (rndm (0, 2)) |
508 | { /* slag created */ |
512 | { /* slag created */ |
509 | object *tmp = cauldron->inv; |
513 | object *tmp = cauldron->inv; |
510 | int weight = 0; |
514 | int weight = 0; |
511 | uint16 material = M_STONE; |
|
|
512 | |
515 | |
513 | while (tmp) |
|
|
514 | { /* slag has coadded ingredient properties */ |
|
|
515 | weight += tmp->weight; |
|
|
516 | if (!(material & tmp->material)) |
|
|
517 | material |= tmp->material; |
|
|
518 | tmp = tmp->below; |
|
|
519 | } |
|
|
520 | tmp = get_archetype ("rock"); |
516 | tmp = get_archetype ("rock"); |
521 | tmp->weight = weight; |
517 | tmp->weight = weight; |
522 | tmp->value = 0; |
518 | tmp->value = 0; |
523 | tmp->material = material; |
|
|
524 | tmp->materialname = "stone"; |
519 | tmp->materialname = "stone"; |
525 | tmp->name = "slag"; |
520 | tmp->name = "slag"; |
526 | tmp->name_pl = "slags"; |
521 | tmp->name_pl = "slags"; |
527 | item = insert_ob_in_ob (tmp, cauldron); |
522 | item = insert_ob_in_ob (tmp, cauldron); |
528 | CLEAR_FLAG (tmp, FLAG_CAN_ROLL); |
523 | CLEAR_FLAG (tmp, FLAG_CAN_ROLL); |
529 | CLEAR_FLAG (tmp, FLAG_NO_PICK); |
524 | CLEAR_FLAG (tmp, FLAG_NO_PICK); |
530 | tmp->move_block = 0; |
525 | tmp->move_block = 0; |
531 | } |
526 | } |
|
|
527 | |
532 | remove_contents (cauldron->inv, item); |
528 | remove_contents (cauldron->inv, item); |
533 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
529 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s %s.", &cauldron->name, cauldron_sound ()); |
534 | return; |
530 | return; |
535 | } |
531 | } |
536 | else if (level < 40) |
532 | else if (level < 40) |
… | |
… | |
562 | } |
558 | } |
563 | while (rndm (0, 2)); |
559 | while (rndm (0, 2)); |
564 | } |
560 | } |
565 | return; |
561 | return; |
566 | } |
562 | } |
|
|
563 | |
567 | if (level == 40) |
564 | if (level == 40) |
568 | { /* MAKE RANDOM RECIPE */ |
565 | { /* MAKE RANDOM RECIPE */ |
569 | recipelist *fl; |
566 | recipelist *fl; |
570 | int numb = numb_ob_inside (cauldron); |
567 | int numb = numb_ob_inside (cauldron); |
571 | |
568 | |
… | |
… | |
573 | if (fl && (rp = get_random_recipe (fl))) |
570 | if (fl && (rp = get_random_recipe (fl))) |
574 | /* even though random, don't grant user any EXP for it */ |
571 | /* even though random, don't grant user any EXP for it */ |
575 | (void) attempt_recipe (op, cauldron, 1, rp, -1); |
572 | (void) attempt_recipe (op, cauldron, 1, rp, -1); |
576 | else |
573 | else |
577 | alchemy_failure_effect (op, cauldron, rp, level - 1); |
574 | alchemy_failure_effect (op, cauldron, rp, level - 1); |
578 | return; |
|
|
579 | |
|
|
580 | } |
575 | } |
581 | else if (level < 45) |
576 | else if (level < 45) |
582 | { /* INFURIATE NPC's */ |
577 | { /* INFURIATE NPC's */ |
583 | /* this is kind of kludgy I know... */ |
578 | /* this is kind of kludgy I know... */ |
584 | cauldron->enemy = op; |
579 | cauldron->enemy = op; |
585 | npc_call_help (cauldron); |
580 | npc_call_help (cauldron); |
586 | cauldron->enemy = NULL; |
581 | cauldron->enemy = NULL; |
587 | |
582 | |
588 | alchemy_failure_effect (op, cauldron, rp, level - 5); |
583 | alchemy_failure_effect (op, cauldron, rp, level - 5); |
589 | return; |
|
|
590 | } |
584 | } |
591 | else if (level < 50) |
585 | else if (level < 50) |
592 | { /* MINOR EXPLOSION/FIREBALL */ |
586 | { /* MINOR EXPLOSION/FIREBALL */ |
593 | object *tmp; |
587 | object *tmp; |
594 | |
588 | |
… | |
… | |
608 | 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; |
609 | 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); |
610 | break; |
604 | break; |
611 | } |
605 | } |
612 | |
606 | |
613 | op->insert_at (cauldron); |
607 | tmp->insert_at (cauldron); |
614 | return; |
|
|
615 | |
|
|
616 | } |
608 | } |
617 | else if (level < 60) |
609 | else if (level < 60) |
618 | { /* CREATE MONSTER */ |
610 | { /* CREATE MONSTER */ |
619 | 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 ()); |
620 | remove_contents (cauldron->inv, NULL); |
612 | remove_contents (cauldron->inv, NULL); |
621 | return; |
|
|
622 | } |
613 | } |
623 | else if (level < 80) |
614 | else if (level < 80) |
624 | { /* MAJOR FIRE */ |
615 | { /* MAJOR FIRE */ |
625 | object *fb = get_archetype (SP_MED_FIREBALL); |
616 | object *fb = get_archetype (SP_MED_FIREBALL); |
626 | |
617 | |
627 | remove_contents (cauldron->inv, NULL); |
618 | remove_contents (cauldron->inv, NULL); |
628 | 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); |
629 | fb->destroy (); |
620 | fb->destroy (); |
630 | 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); |
631 | return; |
|
|
632 | |
|
|
633 | } |
622 | } |
634 | else if (level < 100) |
623 | else if (level < 100) |
635 | { /* WHAMMY the CAULDRON */ |
624 | { /* WHAMMY the CAULDRON */ |
636 | if (!QUERY_FLAG (cauldron, FLAG_CURSED)) |
625 | if (!QUERY_FLAG (cauldron, FLAG_CURSED)) |
637 | SET_FLAG (cauldron, FLAG_CURSED); |
626 | SET_FLAG (cauldron, FLAG_CURSED); |
638 | else |
627 | else |
639 | cauldron->magic--; |
628 | cauldron->magic--; |
|
|
629 | |
640 | cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); |
630 | cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); |
|
|
631 | |
641 | if (rndm (0, 1)) |
632 | if (rndm (0, 1)) |
642 | { |
633 | { |
643 | remove_contents (cauldron->inv, NULL); |
634 | remove_contents (cauldron->inv, NULL); |
644 | 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); |
645 | } |
636 | } |
646 | else |
637 | else |
647 | 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); |
648 | return; |
|
|
649 | |
|
|
650 | } |
639 | } |
651 | else if (level < 110) |
640 | else if (level < 110) |
652 | { /* SUMMON EVIL MONSTERS */ |
641 | { /* SUMMON EVIL MONSTERS */ |
653 | object *tmp = get_random_mon (level / 5); |
642 | object *tmp = get_random_mon (level / 5); |
654 | |
643 | |
655 | remove_contents (cauldron->inv, NULL); |
644 | remove_contents (cauldron->inv, NULL); |
|
|
645 | |
656 | if (!tmp) |
646 | if (!tmp) |
657 | alchemy_failure_effect (op, cauldron, rp, level); |
647 | alchemy_failure_effect (op, cauldron, rp, level); |
658 | 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)) |
659 | 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 ()); |
660 | return; |
|
|
661 | |
|
|
662 | } |
650 | } |
663 | else if (level < 150) |
651 | else if (level < 150) |
664 | { /* COMBO EFFECT */ |
652 | { /* COMBO EFFECT */ |
665 | int roll = rndm (1, 3); |
653 | int roll = rndm (1, 3); |
666 | |
654 | |
667 | while (roll) |
655 | while (roll) |
668 | { |
656 | { |
669 | alchemy_failure_effect (op, cauldron, rp, level - 39); |
657 | alchemy_failure_effect (op, cauldron, rp, level - 39); |
670 | roll--; |
658 | roll--; |
671 | } |
659 | } |
672 | return; |
|
|
673 | } |
660 | } |
674 | else if (level == 151) |
661 | else if (level == 151) |
675 | { /* CREATE RANDOM ARTIFACT */ |
662 | { /* CREATE RANDOM ARTIFACT */ |
676 | object *tmp; |
663 | object *tmp; |
677 | |
664 | |
… | |
… | |
688 | { |
675 | { |
689 | remove_contents (cauldron->inv, tmp); |
676 | remove_contents (cauldron->inv, tmp); |
690 | 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 ()); |
691 | } |
678 | } |
692 | } |
679 | } |
693 | return; |
|
|
694 | } |
680 | } |
695 | else |
681 | else |
696 | { /* MANA STORM - watch out!! */ |
682 | { /* MANA STORM - watch out!! */ |
697 | object *tmp = get_archetype (LOOSE_MANA); |
683 | object *tmp = get_archetype (LOOSE_MANA); |
698 | |
684 | |
699 | 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!"); |
700 | remove_contents (cauldron->inv, NULL); |
686 | remove_contents (cauldron->inv, NULL); |
701 | cast_magic_storm (op, tmp, level); |
687 | cast_magic_storm (op, tmp, level); |
702 | return; |
|
|
703 | } |
688 | } |
704 | } |
689 | } |
705 | |
|
|
706 | |
690 | |
707 | /* |
691 | /* |
708 | * All but object "save_item" are elimentated from |
692 | * All but object "save_item" are elimentated from |
709 | * 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 |
710 | * 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). |
711 | */ |
695 | */ |
712 | |
|
|
713 | void |
696 | void |
714 | remove_contents (object *first_ob, object *save_item) |
697 | remove_contents (object *first_ob, object *save_item) |
715 | { |
698 | { |
|
|
699 | // this cries for a cleaner rewrite, removing save_item first possibly |
716 | object *next, *tmp = first_ob; |
700 | object *next, *tmp = first_ob; |
717 | |
701 | |
718 | while (tmp) |
702 | while (tmp) |
719 | { |
703 | { |
720 | next = tmp->below; |
704 | next = tmp->below; |
… | |
… | |
733 | tmp->destroy (); |
717 | tmp->destroy (); |
734 | tmp = next; |
718 | tmp = next; |
735 | } |
719 | } |
736 | } |
720 | } |
737 | |
721 | |
738 | /**
|
722 | /** |
739 | *"Danger" level, will determine how bad the backfire |
723 | *"Danger" level, will determine how bad the backfire |
740 | * could be if the user fails to concoct a recipe properly. Factors include |
724 | * could be if the user fails to concoct a recipe properly. Factors include |
741 | * the number of ingredients, the length of the name of each ingredient, |
725 | * the number of ingredients, the length of the name of each ingredient, |
742 | * the user's effective level, the user's Int and the enchantment on the |
726 | * the user's effective level, the user's Int and the enchantment on the |
743 | * mixing device (aka "cauldron"). Higher values of 'danger' indicate more |
727 | * mixing device (aka "cauldron"). Higher values of 'danger' indicate more |
744 | * danger. Note that we assume that we have had the caster ready the alchemy |
728 | * danger. Note that we assume that we have had the caster ready the alchemy |
745 | * skill *before* this routine is called. (no longer auto-readies that skill) |
729 | * skill *before* this routine is called. (no longer auto-readies that skill) |
746 | * -b.t. |
730 | * -b.t. |
747 | */ |
731 | */ |
748 | |
|
|
749 | int |
732 | int |
750 | calc_alch_danger (object *caster, object *cauldron, recipe *rp) |
733 | calc_alch_danger (object *caster, object *cauldron, recipe *rp) |
751 | { |
734 | { |
752 | object *item; |
735 | object *item; |
753 | char name[MAX_BUF]; |
736 | char name[MAX_BUF]; |
754 | int danger = 0, nrofi = 0; |
737 | int danger = 0, nrofi = 0; |
755 | |
738 | |
756 | /* Knowing alchemy skill reduces yer risk */ |
739 | /* Knowing alchemy skill reduces yer risk */ |
757 | danger -= caster->chosen_skill ? caster->chosen_skill->level : caster->level; |
740 | danger -= caster->chosen_skill ? caster->chosen_skill->level : caster->level; |
|
|
741 | |
|
|
742 | if (!caster->chosen_skill) |
|
|
743 | LOG (llevError | logBacktrace, "calc_alch_danger called without a chosen skill, caster %s, cauldron %s\n", |
|
|
744 | caster->debug_desc (), cauldron->debug_desc ()); |
758 | |
745 | |
759 | /* better cauldrons reduce risk */ |
746 | /* better cauldrons reduce risk */ |
760 | danger -= cauldron->magic; |
747 | danger -= cauldron->magic; |
761 | |
748 | |
762 | /* Higher Int, lower the risk */ |
749 | /* Higher Int, lower the risk */ |
… | |
… | |
766 | * Thus the backfire is worse. Also, more ingredients |
753 | * Thus the backfire is worse. Also, more ingredients |
767 | * means we are attempting a more powerfull potion, |
754 | * means we are attempting a more powerfull potion, |
768 | * and thus the backfire will be worse. */ |
755 | * and thus the backfire will be worse. */ |
769 | for (item = cauldron->inv; item; item = item->below) |
756 | for (item = cauldron->inv; item; item = item->below) |
770 | { |
757 | { |
771 | strcpy (name, item->name); |
758 | assign (name, item->name); |
772 | if (item->title) |
759 | if (item->title) |
773 | sprintf (name, "%s %s", &item->name, &item->title); |
760 | sprintf (name, "%s %s", &item->name, &item->title); |
774 | danger += (strtoint (name) / 1000) + 3; |
761 | danger += (strtoint (name) / 1000) + 3; |
775 | nrofi++; |
762 | nrofi++; |
776 | } |
763 | } |
|
|
764 | |
777 | if (rp == NULL) |
765 | if (rp == NULL) |
778 | danger += 110; |
766 | danger += 110; |
779 | else |
767 | else |
780 | danger += rp->diff * 3; |
768 | danger += rp->diff * 3; |
781 | |
769 | |
… | |
… | |
790 | #endif |
778 | #endif |
791 | |
779 | |
792 | return danger; |
780 | return danger; |
793 | } |
781 | } |
794 | |
782 | |
795 | /**
|
783 | /** |
796 | * Determines if ingredients in a container match the |
784 | * Determines if ingredients in a container match the |
797 | * proper ingredients for a recipe. |
785 | * proper ingredients for a recipe. |
798 | * |
786 | * |
799 | * rp is the recipe to check |
787 | * rp is the recipe to check |
800 | * cauldron is the container that holds the ingredients |
788 | * cauldron is the container that holds the ingredients |
… | |
… | |
904 | LOG (llevDebug, "looking for formula %d:\n", formula); |
892 | LOG (llevDebug, "looking for formula %d:\n", formula); |
905 | #endif |
893 | #endif |
906 | result = NULL; |
894 | result = NULL; |
907 | recipes_matching = 0; |
895 | recipes_matching = 0; |
908 | transmute_found = 0; |
896 | transmute_found = 0; |
|
|
897 | |
909 | for (rp = fl->items; rp != NULL; rp = rp->next) |
898 | for (rp = fl->items; rp; rp = rp->next) |
910 | { |
899 | { |
911 | /* check if recipe matches at all */ |
900 | /* check if recipe matches at all */ |
912 | if (formula % rp->index != 0) |
901 | if (formula % rp->index != 0) |
913 | { |
902 | { |
914 | #ifdef EXTREME_ALCHEMY_DEBUG |
903 | #ifdef EXTREME_ALCHEMY_DEBUG |