ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/alchemy.C
(Generate patch)

Comparing deliantra/server/server/alchemy.C (file contents):
Revision 1.9 by root, Fri Sep 15 23:11:57 2006 UTC vs.
Revision 1.31 by root, Mon Sep 29 10:20:48 2008 UTC

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
194 192
195 value_item = query_cost (item, NULL, F_TRUE | F_IDENTIFIED | F_NOT_CURSED); 193 value_item = query_cost (item, NULL, F_TRUE | F_IDENTIFIED | F_NOT_CURSED);
196 if (attempt_shadow_alchemy && value_item > value_ingredients) 194 if (attempt_shadow_alchemy && value_item > value_ingredients)
197 { 195 {
198#ifdef ALCHEMY_DEBUG 196#ifdef ALCHEMY_DEBUG
199# ifndef WIN32
200 LOG (llevDebug, 197 LOG (llevDebug,
201 "Forcing failure for shadow alchemy recipe because price of ingredients (%llu) is less than price of result (%llu).\n", 198 "Forcing failure for shadow alchemy recipe because price of ingredients (%llu) is less than price of result (%llu).\n",
202 value_ingredients, value_item); 199 value_ingredients, value_item);
203# else
204 LOG (llevDebug,
205 "Forcing failure for shadow alchemy recipe because price of ingredients (%I64d) is less than price of result (%I64d).\n",
206 value_ingredients, value_item);
207# endif
208#endif 200#endif
209 } 201 }
210 /* roll the dice */ 202 /* roll the dice */
211 else if ((float) (random_roll (0, 101, caster, PREFER_LOW)) <= 100.0 * success_chance) 203 else if ((float) (random_roll (0, 101, caster, PREFER_LOW)) <= 100.0 * success_chance)
212 { 204 {
213 change_exp (caster, rp->exp, rp->skill, SK_EXP_NONE); 205 change_exp (caster, rp->exp, rp->skill, SK_EXP_NONE);
206
207 // let alchemy consume some time, so that exploits are less easy
208 caster->speed_left -= 1.0;
209
214 return; 210 return;
215 } 211 }
216 } 212 }
217 } 213 }
218 } 214 }
215
219 /* if we get here, we failed!! */ 216 /* if we get here, we failed!! */
220 alchemy_failure_effect (caster, cauldron, rp, calc_alch_danger (caster, cauldron, rp)); 217 alchemy_failure_effect (caster, cauldron, rp, calc_alch_danger (caster, cauldron, rp));
221} 218}
222 219
223/** 220/**
234 int tval = 0, formula = 0; 231 int tval = 0, formula = 0;
235 232
236 while (tmp) 233 while (tmp)
237 { 234 {
238 tval = 0; 235 tval = 0;
239 strcpy (name, tmp->name); 236 assign (name, tmp->name);
240 if (tmp->title) 237 if (tmp->title)
241 sprintf (name, "%s %s", &tmp->name, &tmp->title); 238 sprintf (name, "%s %s", &tmp->name, &tmp->title);
242 tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1)); 239 tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1));
243#ifdef ALCHEMY_DEBUG 240#ifdef ALCHEMY_DEBUG
244 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);
293 290
294 /* 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 */
295 int batches = abs (nbatches); 292 int batches = abs (nbatches);
296 293
297 294
298 LOG (llevDebug, "A %s <=> %s\n", &(rp->cauldron), &(cauldron->arch->name));
299 /* is the cauldron the right type? */ 295 /* is the cauldron the right type? */
300 if (strcmp (rp->cauldron, cauldron->arch->name) != 0) 296 if (rp->cauldron != cauldron->arch->archname)
301 { 297 {
302 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.");
303 return 0; 299 return 0;
304 } 300 }
305 301
311 /* code required for this recipe, search the caster */ 307 /* code required for this recipe, search the caster */
312 if (rp->keycode) 308 if (rp->keycode)
313 { 309 {
314 object *tmp; 310 object *tmp;
315 311
316 for (tmp = caster->inv; tmp != NULL; tmp = tmp->below) 312 for (tmp = caster->inv; tmp; tmp = tmp->below)
317 { 313 {
318 if (tmp->type == FORCE && tmp->slaying && !strcmp (rp->keycode, tmp->slaying)) 314 if (tmp->type == FORCE && tmp->slaying && rp->keycode == tmp->slaying)
319 break; 315 break;
320 } 316 }
317
321 if (tmp == NULL) 318 if (!tmp)
322 { /* failure--no code found */ 319 { /* failure--no code found */
323 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.");
324 return 0; 321 return 0;
325 } 322 }
326 } 323 }
327 324
328#ifdef EXTREME_ALCHEMY_DEBUG 325#ifdef EXTREME_ALCHEMY_DEBUG
332 329
333 if ((item = make_item_from_recipe (cauldron, rp)) != NULL) 330 if ((item = make_item_from_recipe (cauldron, rp)) != NULL)
334 { 331 {
335 remove_contents (cauldron->inv, item); 332 remove_contents (cauldron->inv, item);
336 /* 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 */
337 sum_weight (cauldron); 334 cauldron->update_weight ();
338 /* adj lvl, nrof on caster level */ 335 /* adj lvl, nrof on caster level */
339 adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches); 336 adjust_product (item, ability, rp->yield ? (rp->yield * batches) : batches);
340 if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL) 337 if (!item->env && (item = insert_ob_in_ob (item, cauldron)) == NULL)
341 { 338 {
342 new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened."); 339 new_draw_info (NDI_UNIQUE, 0, caster, "Nothing happened.");
343 /* new_draw_info_format(NDI_UNIQUE, 0,caster, 340 /* new_draw_info_format(NDI_UNIQUE, 0,caster,
344 "Your spell causes the %s to explode!",&cauldron->name); */ 341 "Your spell causes the %s to explode!",&cauldron->name); */
345 /* kaboom_cauldron(); */ 342 /* kaboom_cauldron(); */
346 } 343 }
347 else 344 else
348 {
349 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 ());
350 }
351 } 346 }
347
352 return item; 348 return item;
353} 349}
354 350
355 351
356 352
357/** 353/**
358 * 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
359 * 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.
360 */ 356 */
361 void 357void
362adjust_product (object *item, int lvl, int yield) 358adjust_product (object *item, int lvl, int yield)
363{ 359{
364 int nrof = 1; 360 int nrof = 1;
365 361
366 if (!yield) 362 if (!yield)
367 yield = 1; 363 yield = 1;
364
368 if (lvl <= 0) 365 if (lvl <= 0)
369 lvl = 1; /* lets avoid div by zero! */ 366 lvl = 1; /* lets avoid div by zero! */
367
370 if (item->nrof) 368 if (item->nrof)
371 { 369 {
372 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
373 if (nrof > yield) 372 if (nrof > yield)
374 nrof = yield; 373 nrof = yield;
374
375 item->nrof = nrof; 375 item->nrof = nrof;
376 } 376 }
377} 377}
378 378
379 379
447 { 447 {
448 size_t i; 448 size_t i;
449 449
450 for (i = 0; i < rp->arch_names; i++) 450 for (i = 0; i < rp->arch_names; i++)
451 { 451 {
452 if (strcmp (item->arch->name, rp->arch_name[i]) == 0) 452 if (item->arch->archname == rp->arch_name[i])
453 { 453 {
454 *rp_arch_index = i; 454 *rp_arch_index = i;
455 break; 455 break;
456 } 456 }
457 } 457 }
458
458 if (i < rp->arch_names) 459 if (i < rp->arch_names)
459 break; 460 break;
460 } 461 }
461 462
462 /* 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
509 510
510 if (rndm (0, 2)) 511 if (rndm (0, 2))
511 { /* slag created */ 512 { /* slag created */
512 object *tmp = cauldron->inv; 513 object *tmp = cauldron->inv;
513 int weight = 0; 514 int weight = 0;
514 uint16 material = M_STONE;
515 515
516 while (tmp)
517 { /* slag has coadded ingredient properties */
518 weight += tmp->weight;
519 if (!(material & tmp->material))
520 material |= tmp->material;
521 tmp = tmp->below;
522 }
523 tmp = get_archetype ("rock"); 516 tmp = get_archetype ("rock");
524 tmp->weight = weight; 517 tmp->weight = weight;
525 tmp->value = 0; 518 tmp->value = 0;
526 tmp->material = material;
527 tmp->materialname = "stone"; 519 tmp->materialname = "stone";
528 tmp->name = "slag"; 520 tmp->name = "slag";
529 tmp->name_pl = "slags"; 521 tmp->name_pl = "slags";
530 item = insert_ob_in_ob (tmp, cauldron); 522 item = insert_ob_in_ob (tmp, cauldron);
531 CLEAR_FLAG (tmp, FLAG_CAN_ROLL); 523 CLEAR_FLAG (tmp, FLAG_CAN_ROLL);
532 CLEAR_FLAG (tmp, FLAG_NO_PICK); 524 CLEAR_FLAG (tmp, FLAG_NO_PICK);
533 tmp->move_block = 0; 525 tmp->move_block = 0;
534 } 526 }
527
535 remove_contents (cauldron->inv, item); 528 remove_contents (cauldron->inv, item);
536 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 ());
537 return; 530 return;
538 } 531 }
539 else if (level < 40) 532 else if (level < 40)
565 } 558 }
566 while (rndm (0, 2)); 559 while (rndm (0, 2));
567 } 560 }
568 return; 561 return;
569 } 562 }
563
570 if (level == 40) 564 if (level == 40)
571 { /* MAKE RANDOM RECIPE */ 565 { /* MAKE RANDOM RECIPE */
572 recipelist *fl; 566 recipelist *fl;
573 int numb = numb_ob_inside (cauldron); 567 int numb = numb_ob_inside (cauldron);
574 568
576 if (fl && (rp = get_random_recipe (fl))) 570 if (fl && (rp = get_random_recipe (fl)))
577 /* even though random, don't grant user any EXP for it */ 571 /* even though random, don't grant user any EXP for it */
578 (void) attempt_recipe (op, cauldron, 1, rp, -1); 572 (void) attempt_recipe (op, cauldron, 1, rp, -1);
579 else 573 else
580 alchemy_failure_effect (op, cauldron, rp, level - 1); 574 alchemy_failure_effect (op, cauldron, rp, level - 1);
581 return;
582
583 } 575 }
584 else if (level < 45) 576 else if (level < 45)
585 { /* INFURIATE NPC's */ 577 { /* INFURIATE NPC's */
586 /* this is kind of kludgy I know... */ 578 /* this is kind of kludgy I know... */
587 cauldron->enemy = op; 579 cauldron->enemy = op;
588 npc_call_help (cauldron); 580 npc_call_help (cauldron);
589 cauldron->enemy = NULL; 581 cauldron->enemy = NULL;
590 582
591 alchemy_failure_effect (op, cauldron, rp, level - 5); 583 alchemy_failure_effect (op, cauldron, rp, level - 5);
592 return;
593 } 584 }
594 else if (level < 50) 585 else if (level < 50)
595 { /* MINOR EXPLOSION/FIREBALL */ 586 { /* MINOR EXPLOSION/FIREBALL */
596 object *tmp; 587 object *tmp;
597 588
598 remove_contents (cauldron->inv, NULL); 589 remove_contents (cauldron->inv, NULL);
599 switch (rndm (0, 2)) 590 switch (rndm (0, 2))
600 { 591 {
601 case 0: 592 case 0:
602 tmp = get_archetype ("bomb"); 593 tmp = get_archetype ("bomb");
603 tmp->stats.dam = random_roll (1, level, op, PREFER_LOW); 594 tmp->stats.dam = random_roll (1, level, op, PREFER_LOW);
604 tmp->stats.hp = random_roll (1, level, op, PREFER_LOW); 595 tmp->stats.hp = random_roll (1, level, op, PREFER_LOW);
605 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);
606 break; 597 break;
607 598
608 default: 599 default:
609 tmp = get_archetype ("fireball"); 600 tmp = get_archetype ("fireball");
610 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;
611 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;
612 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);
613 break; 604 break;
614 } 605 }
615 tmp->x = cauldron->x, tmp->y = cauldron->y;
616 insert_ob_in_map (tmp, op->map, NULL, 0);
617 return;
618 606
607 tmp->insert_at (cauldron);
619 } 608 }
620 else if (level < 60) 609 else if (level < 60)
621 { /* CREATE MONSTER */ 610 { /* CREATE MONSTER */
622 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 ());
623 remove_contents (cauldron->inv, NULL); 612 remove_contents (cauldron->inv, NULL);
624 return;
625 } 613 }
626 else if (level < 80) 614 else if (level < 80)
627 { /* MAJOR FIRE */ 615 { /* MAJOR FIRE */
628 object *fb = get_archetype (SP_MED_FIREBALL); 616 object *fb = get_archetype (SP_MED_FIREBALL);
629 617
630 remove_contents (cauldron->inv, NULL); 618 remove_contents (cauldron->inv, NULL);
631 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);
632 free_object (fb); 620 fb->destroy (true);
633 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);
634 return;
635
636 } 622 }
637 else if (level < 100) 623 else if (level < 100)
638 { /* WHAMMY the CAULDRON */ 624 { /* WHAMMY the CAULDRON */
639 if (!QUERY_FLAG (cauldron, FLAG_CURSED)) 625 if (!QUERY_FLAG (cauldron, FLAG_CURSED))
640 SET_FLAG (cauldron, FLAG_CURSED); 626 SET_FLAG (cauldron, FLAG_CURSED);
641 else 627 else
642 cauldron->magic--; 628 cauldron->magic--;
629
643 cauldron->magic -= random_roll (0, 4, op, PREFER_LOW); 630 cauldron->magic -= random_roll (0, 4, op, PREFER_LOW);
631
644 if (rndm (0, 1)) 632 if (rndm (0, 1))
645 { 633 {
646 remove_contents (cauldron->inv, NULL); 634 remove_contents (cauldron->inv, NULL);
647 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);
648 } 636 }
649 else 637 else
650 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);
651 return;
652
653 } 639 }
654 else if (level < 110) 640 else if (level < 110)
655 { /* SUMMON EVIL MONSTERS */ 641 { /* SUMMON EVIL MONSTERS */
656 object *tmp = get_random_mon (level / 5); 642 object *tmp = get_random_mon (level / 5);
657 643
658 remove_contents (cauldron->inv, NULL); 644 remove_contents (cauldron->inv, NULL);
645
659 if (!tmp) 646 if (!tmp)
660 alchemy_failure_effect (op, cauldron, rp, level); 647 alchemy_failure_effect (op, cauldron, rp, level);
661 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))
662 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 ());
663 return;
664
665 } 650 }
666 else if (level < 150) 651 else if (level < 150)
667 { /* COMBO EFFECT */ 652 { /* COMBO EFFECT */
668 int roll = rndm (1, 3); 653 int roll = rndm (1, 3);
669 654
670 while (roll) 655 while (roll)
671 { 656 {
672 alchemy_failure_effect (op, cauldron, rp, level - 39); 657 alchemy_failure_effect (op, cauldron, rp, level - 39);
673 roll--; 658 roll--;
674 } 659 }
675 return;
676 } 660 }
677 else if (level == 151) 661 else if (level == 151)
678 { /* CREATE RANDOM ARTIFACT */ 662 { /* CREATE RANDOM ARTIFACT */
679 object *tmp; 663 object *tmp;
680 664
691 { 675 {
692 remove_contents (cauldron->inv, tmp); 676 remove_contents (cauldron->inv, tmp);
693 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 ());
694 } 678 }
695 } 679 }
696 return;
697 } 680 }
698 else 681 else
699 { /* MANA STORM - watch out!! */ 682 { /* MANA STORM - watch out!! */
700 object *tmp = get_archetype (LOOSE_MANA); 683 object *tmp = get_archetype (LOOSE_MANA);
701 684
702 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!");
703 remove_contents (cauldron->inv, NULL); 686 remove_contents (cauldron->inv, NULL);
704 cast_magic_storm (op, tmp, level); 687 cast_magic_storm (op, tmp, level);
705 return;
706 } 688 }
707} 689}
708 690
709 691/*
710/**
711 * All but object "save_item" are elimentated from 692 * All but object "save_item" are elimentated from
712 * 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
713 * 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).
714 */ 695 */
715
716void 696void
717remove_contents (object *first_ob, object *save_item) 697remove_contents (object *first_ob, object *save_item)
718{ 698{
699 // this cries for a cleaner rewrite, removing save_item first possibly
719 object *next, *tmp = first_ob; 700 object *next, *tmp = first_ob;
720 701
721 while (tmp) 702 while (tmp)
722 { 703 {
723 next = tmp->below; 704 next = tmp->below;
705
724 if (tmp == save_item) 706 if (tmp == save_item)
725 { 707 {
726 if (!(tmp = next)) 708 if (!(tmp = next))
727 break; 709 break;
728 else 710 else
729 next = next->below; 711 next = next->below;
730 } 712 }
713
731 if (tmp->inv) 714 if (tmp->inv)
732 remove_contents (tmp->inv, NULL); 715 remove_contents (tmp->inv, NULL);
733 remove_ob (tmp); 716
734 free_object (tmp); 717 tmp->destroy (true);
735 tmp = next; 718 tmp = next;
736 } 719 }
737} 720}
738 721
739/** 722/**
740 *"Danger" level, will determine how bad the backfire 723 *"Danger" level, will determine how bad the backfire
741 * 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
742 * 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,
743 * 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
744 * mixing device (aka "cauldron"). Higher values of 'danger' indicate more 727 * mixing device (aka "cauldron"). Higher values of 'danger' indicate more
745 * 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
746 * 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)
747 * -b.t. 730 * -b.t.
748 */ 731 */
749
750int 732int
751calc_alch_danger (object *caster, object *cauldron, recipe *rp) 733calc_alch_danger (object *caster, object *cauldron, recipe *rp)
752{ 734{
753 object *item; 735 object *item;
754 char name[MAX_BUF]; 736 char name[MAX_BUF];
755 int danger = 0, nrofi = 0; 737 int danger = 0, nrofi = 0;
756 738
757 /* Knowing alchemy skill reduces yer risk */ 739 /* Knowing alchemy skill reduces yer risk */
758 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 ());
759 745
760 /* better cauldrons reduce risk */ 746 /* better cauldrons reduce risk */
761 danger -= cauldron->magic; 747 danger -= cauldron->magic;
762 748
763 /* Higher Int, lower the risk */ 749 /* Higher Int, lower the risk */
767 * Thus the backfire is worse. Also, more ingredients 753 * Thus the backfire is worse. Also, more ingredients
768 * means we are attempting a more powerfull potion, 754 * means we are attempting a more powerfull potion,
769 * and thus the backfire will be worse. */ 755 * and thus the backfire will be worse. */
770 for (item = cauldron->inv; item; item = item->below) 756 for (item = cauldron->inv; item; item = item->below)
771 { 757 {
772 strcpy (name, item->name); 758 assign (name, item->name);
773 if (item->title) 759 if (item->title)
774 sprintf (name, "%s %s", &item->name, &item->title); 760 sprintf (name, "%s %s", &item->name, &item->title);
775 danger += (strtoint (name) / 1000) + 3; 761 danger += (strtoint (name) / 1000) + 3;
776 nrofi++; 762 nrofi++;
777 } 763 }
764
778 if (rp == NULL) 765 if (rp == NULL)
779 danger += 110; 766 danger += 110;
780 else 767 else
781 danger += rp->diff * 3; 768 danger += rp->diff * 3;
782 769
791#endif 778#endif
792 779
793 return danger; 780 return danger;
794} 781}
795 782
796/** 783/**
797 * Determines if ingredients in a container match the 784 * Determines if ingredients in a container match the
798 * proper ingredients for a recipe. 785 * proper ingredients for a recipe.
799 * 786 *
800 * rp is the recipe to check 787 * rp is the recipe to check
801 * cauldron is the container that holds the ingredients 788 * cauldron is the container that holds the ingredients
905 LOG (llevDebug, "looking for formula %d:\n", formula); 892 LOG (llevDebug, "looking for formula %d:\n", formula);
906#endif 893#endif
907 result = NULL; 894 result = NULL;
908 recipes_matching = 0; 895 recipes_matching = 0;
909 transmute_found = 0; 896 transmute_found = 0;
897
910 for (rp = fl->items; rp != NULL; rp = rp->next) 898 for (rp = fl->items; rp; rp = rp->next)
911 { 899 {
912 /* check if recipe matches at all */ 900 /* check if recipe matches at all */
913 if (formula % rp->index != 0) 901 if (formula % rp->index != 0)
914 { 902 {
915#ifdef EXTREME_ALCHEMY_DEBUG 903#ifdef EXTREME_ALCHEMY_DEBUG

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines