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.40 by root, Mon Oct 12 14:00:58 2009 UTC vs.
Revision 1.41 by root, Thu Oct 15 23:02:28 2009 UTC

56 "rattles", 56 "rattles",
57 "makes chugging sounds", 57 "makes chugging sounds",
58 "smokes heavily for a while" 58 "smokes heavily for a while"
59}; 59};
60 60
61
62static int is_defined_recipe (const recipe *rp, const object *cauldron, object *caster); 61static int is_defined_recipe (const recipe *rp, const object *cauldron, object *caster);
63static recipe *find_recipe (recipelist * fl, int formula, object *ingredients); 62static recipe *find_recipe (recipelist * fl, int formula, object *ingredients);
64
65 63
66/** Returns a random selection from cauldron_effect[] */ 64/** Returns a random selection from cauldron_effect[] */
67static const char * 65static const char *
68cauldron_sound (void) 66cauldron_sound (void)
69{ 67{
70 int size = sizeof (cauldron_effect) / sizeof (char *); 68 int size = sizeof (cauldron_effect) / sizeof (char *);
71 69
72 return cauldron_effect[rndm (0, size - 1)]; 70 return cauldron_effect[rndm (0, size - 1)];
73} 71}
74 72
75/** 73/**
76 * Main part of the ALCHEMY code. From this we call fctns 74 * Main part of the ALCHEMY code. From this we call fctns
77 * that take a look at the contents of the 'cauldron' and, using these ingredients, 75 * that take a look at the contents of the 'cauldron' and, using these ingredients,
78 * we construct an integer formula value which is referenced (randomly) against a 76 * we construct an integer formula value which is referenced (randomly) against a
79 * formula list (the formula list chosen is based on the # contents of the cauldron). 77 * formula list (the formula list chosen is based on the # contents of the cauldron).
80 * 78 *
201 199
202 /* if we get here, we failed!! */ 200 /* if we get here, we failed!! */
203 alchemy_failure_effect (caster, cauldron, rp, calc_alch_danger (caster, cauldron, rp)); 201 alchemy_failure_effect (caster, cauldron, rp, calc_alch_danger (caster, cauldron, rp));
204} 202}
205 203
206/** 204/**
207 * Recipe value of the entire contents of a container. 205 * Recipe value of the entire contents of a container.
208 * This appears to just generate a hash value, which I guess for now works 206 * This appears to just generate a hash value, which I guess for now works
209 * ok, but the possibility of duplicate hashes is certainly possible - msw 207 * ok, but the possibility of duplicate hashes is certainly possible - msw
210 */ 208 */
211
212int 209int
213content_recipe_value (object *op) 210content_recipe_value (object *op)
214{ 211{
215 char name[MAX_BUF]; 212 char name[MAX_BUF];
216 object *tmp = op->inv; 213 object *tmp = op->inv;
233 LOG (llevDebug, " Formula value=%d\n", formula); 230 LOG (llevDebug, " Formula value=%d\n", formula);
234#endif 231#endif
235 return formula; 232 return formula;
236} 233}
237 234
238/** 235/**
239 * Returns total number of items in op 236 * Returns total number of items in op
240 */ 237 */
241 238
242int 239int
243numb_ob_inside (object *op) 240numb_ob_inside (object *op)
244{ 241{
265 * insert_ob_in_ob. If the caster has some alchemy skill, then they might 262 * insert_ob_in_ob. If the caster has some alchemy skill, then they might
266 * gain some exp from (successfull) fabrication of the product. 263 * gain some exp from (successfull) fabrication of the product.
267 * If nbatches==-1, don't give exp for this creation (random generation/ 264 * If nbatches==-1, don't give exp for this creation (random generation/
268 * failed recipe) 265 * failed recipe)
269 */ 266 */
270
271object * 267object *
272attempt_recipe (object *caster, object *cauldron, int ability, recipe *rp, int nbatches) 268attempt_recipe (object *caster, object *cauldron, int ability, recipe *rp, int nbatches)
273{ 269{
274 270
275 object *item = NULL, *skop; 271 object *item = NULL, *skop;
328 } 324 }
329 325
330 return item; 326 return item;
331} 327}
332 328
333
334
335/** 329/**
336 * We adjust the nrof, exp and level of the final product, based 330 * We adjust the nrof, exp and level of the final product, based
337 * on the item's default parameters, and the relevant caster skill level. 331 * on the item's default parameters, and the relevant caster skill level.
338 */ 332 */
339void 333void
340adjust_product (object *item, int lvl, int yield) 334adjust_product (object *item, int lvl, int yield)
341{ 335{
342 int nrof = 1; 336 int nrof = 1;
355 nrof = yield; 349 nrof = yield;
356 350
357 item->nrof = nrof; 351 item->nrof = nrof;
358 } 352 }
359} 353}
360
361 354
362/** 355/**
363 * Using a list of items and a recipe to make an artifact. 356 * Using a list of items and a recipe to make an artifact.
364 * 357 *
365 * @param cauldron the cauldron (including the ingredients) used to make the item 358 * @param cauldron the cauldron (including the ingredients) used to make the item
366 * 359 *
367 * @param rp the recipe to make the artifact from 360 * @param rp the recipe to make the artifact from
368 * 361 *
369 * @return the newly created object, NULL if something failed 362 * @return the newly created object, NULL if something failed
370 */ 363 */
371
372object * 364object *
373make_item_from_recipe (object *cauldron, recipe *rp) 365make_item_from_recipe (object *cauldron, recipe *rp)
374{ 366{
375 artifact *art = NULL; 367 artifact *art = NULL;
376 object *item = NULL; 368 object *item = NULL;
406 SET_FLAG (item, FLAG_DAMNED); 398 SET_FLAG (item, FLAG_DAMNED);
407 399
408 return item; 400 return item;
409} 401}
410 402
411
412/** 403/**
413 * Looks through the ingredient list. If we find a 404 * Looks through the ingredient list. If we find a
414 * suitable object in it - we will use that to make the requested artifact. 405 * suitable object in it - we will use that to make the requested artifact.
415 * Otherwise the code returns a 'generic' item if create_item is set. -b.t. 406 * Otherwise the code returns a 'generic' item if create_item is set. -b.t.
416 * 407 *
417 * @param rp_arch_index pointer to return value; set to arch index for recipe; 408 * @param rp_arch_index pointer to return value; set to arch index for recipe;
418 * set to zero if not using a transmution formula 409 * set to zero if not using a transmution formula
419 */ 410 */
420
421object * 411object *
422find_transmution_ob (object *first_ingred, recipe *rp, size_t *rp_arch_index, int create_item) 412find_transmution_ob (object *first_ingred, recipe *rp, size_t *rp_arch_index, int create_item)
423{ 413{
424 object *prod_item = 0; 414 object *prod_item = 0;
425 bool found = false; 415 bool found = false;
468#endif 458#endif
469 459
470 return prod_item; 460 return prod_item;
471} 461}
472 462
473
474/** 463/**
475 * Ouch. We didnt get the formula we wanted. 464 * Ouch. We didnt get the formula we wanted.
476 * This fctn simulates the backfire effects--worse effects as the level 465 * This fctn simulates the backfire effects--worse effects as the level
477 * increases. If SPELL_FAILURE_EFFECTS is defined some really evil things 466 * increases. If SPELL_FAILURE_EFFECTS is defined some really evil things
478 * can happen to the would be alchemist. This table probably needs some 467 * can happen to the would be alchemist. This table probably needs some
479 * adjustment for playbalance. -b.t. 468 * adjustment for playbalance. -b.t.
480 */ 469 */
481
482void 470void
483alchemy_failure_effect (object *op, object *cauldron, recipe *rp, int danger) 471alchemy_failure_effect (object *op, object *cauldron, recipe *rp, int danger)
484{ 472{
485 int level = 0; 473 int level = 0;
486 474

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines