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> |
28 | #ifndef __CEXTRACT__ |
|
|
29 | # include <sproto.h> |
28 | #include <sproto.h> |
30 | #endif |
|
|
31 | #include <skills.h> |
29 | #include <skills.h> |
32 | #include <spells.h> |
30 | #include <spells.h> |
33 | |
31 | |
34 | /** define this for some helpful debuging information */ |
32 | /** define this for some helpful debuging information */ |
35 | #if 0 |
33 | #if 0 |
… | |
… | |
233 | int tval = 0, formula = 0; |
231 | int tval = 0, formula = 0; |
234 | |
232 | |
235 | while (tmp) |
233 | while (tmp) |
236 | { |
234 | { |
237 | tval = 0; |
235 | tval = 0; |
238 | strcpy (name, tmp->name); |
236 | assign (name, tmp->name); |
239 | if (tmp->title) |
237 | if (tmp->title) |
240 | sprintf (name, "%s %s", &tmp->name, &tmp->title); |
238 | sprintf (name, "%s %s", &tmp->name, &tmp->title); |
241 | tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1)); |
239 | tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1)); |
242 | #ifdef ALCHEMY_DEBUG |
240 | #ifdef ALCHEMY_DEBUG |
243 | 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); |
… | |
… | |
292 | |
290 | |
293 | /* 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 */ |
294 | int batches = abs (nbatches); |
292 | int batches = abs (nbatches); |
295 | |
293 | |
296 | |
294 | |
297 | LOG (llevDebug, "A %s <=> %s\n", &(rp->cauldron), &(cauldron->arch->name)); |
|
|
298 | /* is the cauldron the right type? */ |
295 | /* is the cauldron the right type? */ |
299 | if (strcmp (rp->cauldron, cauldron->arch->name) != 0) |
296 | if (rp->cauldron != cauldron->arch->archname) |
300 | { |
297 | { |
301 | 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."); |
302 | return 0; |
299 | return 0; |
303 | } |
300 | } |
304 | |
301 | |
… | |
… | |
310 | /* code required for this recipe, search the caster */ |
307 | /* code required for this recipe, search the caster */ |
311 | if (rp->keycode) |
308 | if (rp->keycode) |
312 | { |
309 | { |
313 | object *tmp; |
310 | object *tmp; |
314 | |
311 | |
315 | for (tmp = caster->inv; tmp != NULL; tmp = tmp->below) |
312 | for (tmp = caster->inv; tmp; tmp = tmp->below) |
316 | { |
313 | { |
317 | if (tmp->type == FORCE && tmp->slaying && !strcmp (rp->keycode, tmp->slaying)) |
314 | if (tmp->type == FORCE && tmp->slaying && rp->keycode == tmp->slaying) |
318 | break; |
315 | break; |
319 | } |
316 | } |
|
|
317 | |
320 | if (tmp == NULL) |
318 | if (!tmp) |
321 | { /* failure--no code found */ |
319 | { /* failure--no code found */ |
322 | 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."); |
323 | return 0; |
321 | return 0; |
324 | } |
322 | } |
325 | } |
323 | } |
326 | |
324 | |
327 | #ifdef EXTREME_ALCHEMY_DEBUG |
325 | #ifdef EXTREME_ALCHEMY_DEBUG |
… | |
… | |
331 | |
329 | |
332 | if ((item = make_item_from_recipe (cauldron, rp)) != NULL) |
330 | if ((item = make_item_from_recipe (cauldron, rp)) != NULL) |
333 | { |
331 | { |
334 | remove_contents (cauldron->inv, item); |
332 | remove_contents (cauldron->inv, item); |
335 | /* 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 */ |
336 | sum_weight (cauldron); |
334 | cauldron->update_weight (); |
337 | /* adj lvl, nrof on caster level */ |
335 | /* adj lvl, nrof on caster level */ |
338 | adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches); |
336 | adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches); |
339 | if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) |
337 | if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) |
340 | { |
338 | { |
341 | new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); |
339 | new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); |
342 | /* new_draw_info_format(NDI_UNIQUE, 0,caster, |
340 | /* new_draw_info_format(NDI_UNIQUE, 0,caster, |
343 | "Your spell causes the %s to explode!",&cauldron->name); */ |
341 | "Your spell causes the %s to explode!",&cauldron->name); */ |
344 | /* kaboom_cauldron(); */ |
342 | /* kaboom_cauldron(); */ |
345 | } |
343 | } |
346 | else |
344 | else |
347 | { |
|
|
348 | 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 ()); |
349 | } |
|
|
350 | } |
346 | } |
|
|
347 | |
351 | return item; |
348 | return item; |
352 | } |
349 | } |
353 | |
350 | |
354 | |
351 | |
355 | |
352 | |
356 | /**
|
353 | /** |
357 | * 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 |
358 | * 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.
|
359 | */ |
356 | */ |
360 |
void |
357 | void |
361 | adjust_product (object *item, int lvl, int yield) |
358 | adjust_product (object *item, int lvl, int yield) |
362 | { |
359 | { |
363 | int nrof = 1; |
360 | int nrof = 1; |
364 | |
361 | |
365 | if (!yield) |
362 | if (!yield) |
366 | yield = 1; |
363 | yield = 1; |
|
|
364 | |
367 | if (lvl <= 0) |
365 | if (lvl <= 0) |
368 | lvl = 1; /* lets avoid div by zero! */ |
366 | lvl = 1; /* lets avoid div by zero! */ |
|
|
367 | |
369 | if (item->nrof) |
368 | if (item->nrof) |
370 | { |
369 | { |
371 | 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 | |
372 | if (nrof > yield) |
372 | if (nrof > yield) |
373 | nrof = yield; |
373 | nrof = yield; |
|
|
374 | |
374 | item->nrof = nrof; |
375 | item->nrof = nrof; |
375 | } |
376 | } |
376 | } |
377 | } |
377 | |
378 | |
378 | |
379 | |
… | |
… | |
446 | { |
447 | { |
447 | size_t i; |
448 | size_t i; |
448 | |
449 | |
449 | for (i = 0; i < rp->arch_names; i++) |
450 | for (i = 0; i < rp->arch_names; i++) |
450 | { |
451 | { |
451 | if (strcmp (item->arch->name, rp->arch_name[i]) == 0) |
452 | if (item->arch->archname == rp->arch_name[i]) |
452 | { |
453 | { |
453 | *rp_arch_index = i; |
454 | *rp_arch_index = i; |
454 | break; |
455 | break; |
455 | } |
456 | } |
456 | } |
457 | } |
|
|
458 | |
457 | if (i < rp->arch_names) |
459 | if (i < rp->arch_names) |
458 | break; |
460 | break; |
459 | } |
461 | } |
460 | |
462 | |
461 | /* 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 |
… | |
… | |
508 | |
510 | |
509 | if (rndm (0, 2)) |
511 | if (rndm (0, 2)) |
510 | { /* slag created */ |
512 | { /* slag created */ |
511 | object *tmp = cauldron->inv; |
513 | object *tmp = cauldron->inv; |
512 | int weight = 0; |
514 | int weight = 0; |
513 | uint16 material = M_STONE; |
|
|
514 | |
515 | |
515 | while (tmp) |
|
|
516 | { /* slag has coadded ingredient properties */ |
|
|
517 | weight += tmp->weight; |
|
|
518 | if (!(material & tmp->material)) |
|
|
519 | material |= tmp->material; |
|
|
520 | tmp = tmp->below; |
|
|
521 | } |
|
|
522 | tmp = get_archetype ("rock"); |
516 | tmp = get_archetype ("rock"); |
523 | tmp->weight = weight; |
517 | tmp->weight = weight; |
524 | tmp->value = 0; |
518 | tmp->value = 0; |
525 | tmp->material = material; |
|
|
526 | tmp->materialname = "stone"; |
519 | tmp->materialname = "stone"; |
527 | tmp->name = "slag"; |
520 | tmp->name = "slag"; |
528 | tmp->name_pl = "slags"; |
521 | tmp->name_pl = "slags"; |
529 | item = insert_ob_in_ob (tmp, cauldron); |
522 | item = insert_ob_in_ob (tmp, cauldron); |
530 | CLEAR_FLAG (tmp, FLAG_CAN_ROLL); |
523 | CLEAR_FLAG (tmp, FLAG_CAN_ROLL); |
531 | CLEAR_FLAG (tmp, FLAG_NO_PICK); |
524 | CLEAR_FLAG (tmp, FLAG_NO_PICK); |
532 | tmp->move_block = 0; |
525 | tmp->move_block = 0; |
533 | } |
526 | } |
|
|
527 | |
534 | remove_contents (cauldron->inv, item); |
528 | remove_contents (cauldron->inv, item); |
535 | 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 ()); |
536 | return; |
530 | return; |
537 | } |
531 | } |
538 | else if (level < 40) |
532 | else if (level < 40) |
… | |
… | |
564 | } |
558 | } |
565 | while (rndm (0, 2)); |
559 | while (rndm (0, 2)); |
566 | } |
560 | } |
567 | return; |
561 | return; |
568 | } |
562 | } |
|
|
563 | |
569 | if (level == 40) |
564 | if (level == 40) |
570 | { /* MAKE RANDOM RECIPE */ |
565 | { /* MAKE RANDOM RECIPE */ |
571 | recipelist *fl; |
566 | recipelist *fl; |
572 | int numb = numb_ob_inside (cauldron); |
567 | int numb = numb_ob_inside (cauldron); |
573 | |
568 | |
… | |
… | |
575 | if (fl && (rp = get_random_recipe (fl))) |
570 | if (fl && (rp = get_random_recipe (fl))) |
576 | /* even though random, don't grant user any EXP for it */ |
571 | /* even though random, don't grant user any EXP for it */ |
577 | (void) attempt_recipe (op, cauldron, 1, rp, -1); |
572 | (void) attempt_recipe (op, cauldron, 1, rp, -1); |
578 | else |
573 | else |
579 | alchemy_failure_effect (op, cauldron, rp, level - 1); |
574 | alchemy_failure_effect (op, cauldron, rp, level - 1); |
580 | return; |
|
|
581 | |
|
|
582 | } |
575 | } |
583 | else if (level < 45) |
576 | else if (level < 45) |
584 | { /* INFURIATE NPC's */ |
577 | { /* INFURIATE NPC's */ |
585 | /* this is kind of kludgy I know... */ |
578 | /* this is kind of kludgy I know... */ |
586 | cauldron->enemy = op; |
579 | cauldron->enemy = op; |
587 | npc_call_help (cauldron); |
580 | npc_call_help (cauldron); |
588 | cauldron->enemy = NULL; |
581 | cauldron->enemy = NULL; |
589 | |
582 | |
590 | alchemy_failure_effect (op, cauldron, rp, level - 5); |
583 | alchemy_failure_effect (op, cauldron, rp, level - 5); |
591 | return; |
|
|
592 | } |
584 | } |
593 | else if (level < 50) |
585 | else if (level < 50) |
594 | { /* MINOR EXPLOSION/FIREBALL */ |
586 | { /* MINOR EXPLOSION/FIREBALL */ |
595 | object *tmp; |
587 | object *tmp; |
596 | |
588 | |
597 | remove_contents (cauldron->inv, NULL); |
589 | remove_contents (cauldron->inv, NULL); |
598 | switch (rndm (0, 2)) |
590 | switch (rndm (0, 2)) |
599 | { |
591 | { |
600 | case 0: |
592 | case 0: |
601 | tmp = get_archetype ("bomb"); |
593 | tmp = get_archetype ("bomb"); |
602 | tmp->stats.dam = random_roll (1, level, op, PREFER_LOW); |
594 | tmp->stats.dam = random_roll (1, level, op, PREFER_LOW); |
603 | tmp->stats.hp = random_roll (1, level, op, PREFER_LOW); |
595 | tmp->stats.hp = random_roll (1, level, op, PREFER_LOW); |
604 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s creates a bomb!", &cauldron->name); |
596 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s creates a bomb!", &cauldron->name); |
605 | break; |
597 | break; |
606 | |
598 | |
607 | default: |
599 | default: |
608 | tmp = get_archetype ("fireball"); |
600 | tmp = get_archetype ("fireball"); |
609 | tmp->stats.dam = random_roll (1, level, op, PREFER_LOW) / 5 + 1; |
601 | tmp->stats.dam = random_roll (1, level, op, PREFER_LOW) / 5 + 1; |
610 | 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; |
611 | 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); |
612 | break; |
604 | break; |
613 | } |
605 | } |
614 | tmp->x = cauldron->x, tmp->y = cauldron->y; |
|
|
615 | insert_ob_in_map (tmp, op->map, NULL, 0); |
|
|
616 | return; |
|
|
617 | |
606 | |
|
|
607 | tmp->insert_at (cauldron); |
618 | } |
608 | } |
619 | else if (level < 60) |
609 | else if (level < 60) |
620 | { /* CREATE MONSTER */ |
610 | { /* CREATE MONSTER */ |
621 | 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 ()); |
622 | remove_contents (cauldron->inv, NULL); |
612 | remove_contents (cauldron->inv, NULL); |
623 | return; |
|
|
624 | } |
613 | } |
625 | else if (level < 80) |
614 | else if (level < 80) |
626 | { /* MAJOR FIRE */ |
615 | { /* MAJOR FIRE */ |
627 | object *fb = get_archetype (SP_MED_FIREBALL); |
616 | object *fb = get_archetype (SP_MED_FIREBALL); |
628 | |
617 | |
629 | remove_contents (cauldron->inv, NULL); |
618 | remove_contents (cauldron->inv, NULL); |
630 | 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); |
631 | free_object (fb); |
620 | fb->destroy (true); |
632 | 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); |
633 | return; |
|
|
634 | |
|
|
635 | } |
622 | } |
636 | else if (level < 100) |
623 | else if (level < 100) |
637 | { /* WHAMMY the CAULDRON */ |
624 | { /* WHAMMY the CAULDRON */ |
638 | if (!QUERY_FLAG (cauldron, FLAG_CURSED)) |
625 | if (!QUERY_FLAG (cauldron, FLAG_CURSED)) |
639 | SET_FLAG (cauldron, FLAG_CURSED); |
626 | SET_FLAG (cauldron, FLAG_CURSED); |
640 | else |
627 | else |
641 | cauldron->magic--; |
628 | cauldron->magic--; |
|
|
629 | |
642 | cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); |
630 | cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); |
|
|
631 | |
643 | if (rndm (0, 1)) |
632 | if (rndm (0, 1)) |
644 | { |
633 | { |
645 | remove_contents (cauldron->inv, NULL); |
634 | remove_contents (cauldron->inv, NULL); |
646 | 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); |
647 | } |
636 | } |
648 | else |
637 | else |
649 | 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); |
650 | return; |
|
|
651 | |
|
|
652 | } |
639 | } |
653 | else if (level < 110) |
640 | else if (level < 110) |
654 | { /* SUMMON EVIL MONSTERS */ |
641 | { /* SUMMON EVIL MONSTERS */ |
655 | object *tmp = get_random_mon (level / 5); |
642 | object *tmp = get_random_mon (level / 5); |
656 | |
643 | |
657 | remove_contents (cauldron->inv, NULL); |
644 | remove_contents (cauldron->inv, NULL); |
|
|
645 | |
658 | if (!tmp) |
646 | if (!tmp) |
659 | alchemy_failure_effect (op, cauldron, rp, level); |
647 | alchemy_failure_effect (op, cauldron, rp, level); |
660 | 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)) |
661 | 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 ()); |
662 | return; |
|
|
663 | |
|
|
664 | } |
650 | } |
665 | else if (level < 150) |
651 | else if (level < 150) |
666 | { /* COMBO EFFECT */ |
652 | { /* COMBO EFFECT */ |
667 | int roll = rndm (1, 3); |
653 | int roll = rndm (1, 3); |
668 | |
654 | |
669 | while (roll) |
655 | while (roll) |
670 | { |
656 | { |
671 | alchemy_failure_effect (op, cauldron, rp, level - 39); |
657 | alchemy_failure_effect (op, cauldron, rp, level - 39); |
672 | roll--; |
658 | roll--; |
673 | } |
659 | } |
674 | return; |
|
|
675 | } |
660 | } |
676 | else if (level == 151) |
661 | else if (level == 151) |
677 | { /* CREATE RANDOM ARTIFACT */ |
662 | { /* CREATE RANDOM ARTIFACT */ |
678 | object *tmp; |
663 | object *tmp; |
679 | |
664 | |
… | |
… | |
690 | { |
675 | { |
691 | remove_contents (cauldron->inv, tmp); |
676 | remove_contents (cauldron->inv, tmp); |
692 | 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 ()); |
693 | } |
678 | } |
694 | } |
679 | } |
695 | return; |
|
|
696 | } |
680 | } |
697 | else |
681 | else |
698 | { /* MANA STORM - watch out!! */ |
682 | { /* MANA STORM - watch out!! */ |
699 | object *tmp = get_archetype (LOOSE_MANA); |
683 | object *tmp = get_archetype (LOOSE_MANA); |
700 | |
684 | |
701 | 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!"); |
702 | remove_contents (cauldron->inv, NULL); |
686 | remove_contents (cauldron->inv, NULL); |
703 | cast_magic_storm (op, tmp, level); |
687 | cast_magic_storm (op, tmp, level); |
704 | return; |
|
|
705 | } |
688 | } |
706 | } |
689 | } |
707 | |
690 | |
708 | |
691 | /* |
709 | /**
|
|
|
710 | * All but object "save_item" are elimentated from |
692 | * All but object "save_item" are elimentated from |
711 | * 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 |
712 | * 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). |
713 | */ |
695 | */ |
714 | |
|
|
715 | void |
696 | void |
716 | remove_contents (object *first_ob, object *save_item) |
697 | remove_contents (object *first_ob, object *save_item) |
717 | { |
698 | { |
|
|
699 | // this cries for a cleaner rewrite, removing save_item first possibly |
718 | object *next, *tmp = first_ob; |
700 | object *next, *tmp = first_ob; |
719 | |
701 | |
720 | while (tmp) |
702 | while (tmp) |
721 | { |
703 | { |
722 | next = tmp->below; |
704 | next = tmp->below; |
|
|
705 | |
723 | if (tmp == save_item) |
706 | if (tmp == save_item) |
724 | { |
707 | { |
725 | if (!(tmp = next)) |
708 | if (!(tmp = next)) |
726 | break; |
709 | break; |
727 | else |
710 | else |
728 | next = next->below; |
711 | next = next->below; |
729 | } |
712 | } |
|
|
713 | |
730 | if (tmp->inv) |
714 | if (tmp->inv) |
731 | remove_contents (tmp->inv, NULL); |
715 | remove_contents (tmp->inv, NULL); |
732 | remove_ob (tmp); |
716 | |
733 | free_object (tmp); |
717 | tmp->destroy (true); |
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 |