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.58 by root, Sun May 1 16:58:17 2011 UTC vs.
Revision 1.63 by root, Sun Jan 29 02:47:05 2017 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 * 12 *
13 * 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,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25/* March 96 - Laid down original code. -b.t. thomas@astro.psu.edu */ 25/* March 96 - Laid down original code. -b.t. thomas@astro.psu.edu */
26 26
133 */ 133 */
134static object * 134static object *
135find_transmution_ob (object *first_ingred, recipe *rp, size_t *rp_arch_index, int create_item) 135find_transmution_ob (object *first_ingred, recipe *rp, size_t *rp_arch_index, int create_item)
136{ 136{
137 object *prod_item = 0; 137 object *prod_item = 0;
138 bool found = false;
139 *rp_arch_index = 0; 138 *rp_arch_index = 0;
140 139
141 if (rp->transmute) /* look for matching ingredient/prod archs */ 140 if (rp->transmute) /* look for matching ingredient/prod archs */
142 for (object *item = first_ingred; item; item = item->below) 141 for (object *item = first_ingred; item; item = item->below)
143 { 142 {
232} 231}
233 232
234/* 233/*
235 * All but object "save_item" are elimentated from 234 * All but object "save_item" are elimentated from
236 * the container list. Note we have to becareful to remove the inventories 235 * the container list. Note we have to becareful to remove the inventories
237 * of objects in the cauldron inventory (ex icecube has stuff in it). 236 * of objects in the cauldron inventory (ex icecube has stuff in it).
238 */ 237 */
239static void 238static void
240remove_contents (object *first_ob, object *save_item) 239remove_contents (object *first_ob, object *save_item)
241{ 240{
242 // this cries for a cleaner rewrite, removing save_item first possibly 241 // this cries for a cleaner rewrite, removing save_item first possibly
287 item->nrof = nrof; 286 item->nrof = nrof;
288 } 287 }
289} 288}
290 289
291/** 290/**
292 * Essentially a wrapper for make_item_from_recipe() and 291 * Essentially a wrapper for make_item_from_recipe() and
293 * insert_ob_in_ob. If the caster has some alchemy skill, then they might 292 * insert_ob_in_ob. If the caster has some alchemy skill, then they might
294 * gain some exp from (successfull) fabrication of the product. 293 * gain some exp from (successfull) fabrication of the product.
295 * If nbatches==-1, don't give exp for this creation (random generation/ 294 * If nbatches==-1, don't give exp for this creation (random generation/
296 * failed recipe) 295 * failed recipe)
297 */ 296 */
298static object * 297static object *
299attempt_recipe (object *caster, object *cauldron, int ability, recipe *rp, int nbatches) 298attempt_recipe (object *caster, object *cauldron, int ability, recipe *rp, int nbatches)
537 } 536 }
538 else if (level == 151) 537 else if (level == 151)
539 { /* CREATE RANDOM ARTIFACT */ 538 { /* CREATE RANDOM ARTIFACT */
540 object *tmp; 539 object *tmp;
541 540
542 /* this is meant to be better than prior possiblity, 541 /* this is meant to be better than prior possiblity,
543 * in this one, we allow *any* valid alchemy artifact 542 * in this one, we allow *any* valid alchemy artifact
544 * to be made (rather than only those on the given 543 * to be made (rather than only those on the given
545 * formulalist) */ 544 * formulalist) */
546 if (!rp) 545 if (!rp)
547 rp = get_random_recipe ((recipelist *) NULL); 546 rp = get_random_recipe ((recipelist *) NULL);
571 * could be if the user fails to concoct a recipe properly. Factors include 570 * could be if the user fails to concoct a recipe properly. Factors include
572 * the number of ingredients, the length of the name of each ingredient, 571 * the number of ingredients, the length of the name of each ingredient,
573 * the user's effective level, the user's Int and the enchantment on the 572 * the user's effective level, the user's Int and the enchantment on the
574 * mixing device (aka "cauldron"). Higher values of 'danger' indicate more 573 * mixing device (aka "cauldron"). Higher values of 'danger' indicate more
575 * danger. Note that we assume that we have had the caster ready the alchemy 574 * danger. Note that we assume that we have had the caster ready the alchemy
576 * skill *before* this routine is called. (no longer auto-readies that skill) 575 * skill *before* this routine is called. (no longer auto-readies that skill)
577 * -b.t. 576 * -b.t.
578 */ 577 */
579static int 578static int
580calc_alch_danger (object *caster, object *cauldron, object *skill, recipe *rp) 579calc_alch_danger (object *caster, object *cauldron, object *skill, recipe *rp)
581{ 580{
582 int danger = 0; 581 int danger = 0;
796 return result; 795 return result;
797} 796}
798 797
799/** 798/**
800 * Main part of the ALCHEMY code. From this we call fctns 799 * Main part of the ALCHEMY code. From this we call fctns
801 * that take a look at the contents of the 'cauldron' and, using these ingredients, 800 * that take a look at the contents of the 'cauldron' and, using these ingredients,
802 * we construct an integer formula value which is referenced (randomly) against a 801 * we construct an integer formula value which is referenced (randomly) against a
803 * formula list (the formula list chosen is based on the # contents of the cauldron). 802 * formula list (the formula list chosen is based on the # contents of the cauldron).
804 * 803 *
805 * If we get a match between the recipe indicated in cauldron contents and a 804 * If we get a match between the recipe indicated in cauldron contents and a
806 * randomly chosen one, an item is created and experience awarded. Otherwise 805 * randomly chosen one, an item is created and experience awarded. Otherwise
807 * various failure effects are possible (getting worse and worse w/ # cauldron 806 * various failure effects are possible (getting worse and worse w/ # cauldron
808 * ingredients). Note that the 'item' to be made can be *anything* listed on 807 * ingredients). Note that the 'item' to be made can be *anything* listed on
809 * the artifacts list in lib/artifacts which has a recipe listed in lib/formulae. 808 * the artifacts list in lib/artifacts which has a recipe listed in lib/formulae.
810 * 809 *
811 * To those wondering why I am using the funky formula index method: 810 * To those wondering why I am using the funky formula index method:
812 * 1) I want to match recipe to ingredients regardless of ordering. 811 * 1) I want to match recipe to ingredients regardless of ordering.
813 * 2) I want a fast search for the 'right' recipe. 812 * 2) I want a fast search for the 'right' recipe.
814 * 813 *
815 * Note: it is just possible that a totally different combination of 814 * Note: it is just possible that a totally different combination of
816 * ingredients will result in a match with a given recipe. This is not a bug! 815 * ingredients will result in a match with a given recipe. This is not a bug!
817 * There is no good reason (in my mind) why alchemical processes have to be 816 * There is no good reason (in my mind) why alchemical processes have to be
818 * unique -- such a 'feature' is one reason why players might want to experiment 817 * unique -- such a 'feature' is one reason why players might want to experiment
819 * around. :) 818 * around. :)
826 recipe *rp = NULL; 825 recipe *rp = NULL;
827 float success_chance; 826 float success_chance;
828 int numb, ability = 1; 827 int numb, ability = 1;
829 int formula = 0; 828 int formula = 0;
830 float ave_chance; 829 float ave_chance;
831 object *item, *skop; 830 object *item;
832 831
833 if (caster->type != PLAYER) 832 if (caster->type != PLAYER)
834 return; /* only players for now */ 833 return; /* only players for now */
835 834
836 if (get_map_flags (caster->map, NULL, caster->x, caster->y, NULL, NULL) & P_SAFE) 835 if (get_map_flags (caster->map, NULL, caster->x, caster->y, NULL, NULL) & P_SAFE)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines