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.16 by pippijn, Sat Jan 6 14:42:30 2007 UTC vs.
Revision 1.20 by root, Mon Feb 5 02:07:40 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 7 *
8 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 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
10 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 * (at your 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 GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 *
22 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
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
27#include <global.h> 27#include <global.h>
28#include <object.h> 28#include <object.h>
232 int tval = 0, formula = 0; 232 int tval = 0, formula = 0;
233 233
234 while (tmp) 234 while (tmp)
235 { 235 {
236 tval = 0; 236 tval = 0;
237 strcpy (name, tmp->name); 237 assign (name, tmp->name);
238 if (tmp->title) 238 if (tmp->title)
239 sprintf (name, "%s %s", &tmp->name, &tmp->title); 239 sprintf (name, "%s %s", &tmp->name, &tmp->title);
240 tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1)); 240 tval = (strtoint (name) * (tmp->nrof ? tmp->nrof : 1));
241#ifdef ALCHEMY_DEBUG 241#ifdef ALCHEMY_DEBUG
242 LOG (llevDebug, "Got ingredient %d %s(%d)\n", tmp->nrof ? tmp->nrof : 1, name, tval); 242 LOG (llevDebug, "Got ingredient %d %s(%d)\n", tmp->nrof ? tmp->nrof : 1, name, tval);
291 291
292 /* this should be passed to this fctn, not effiecent cpu use this way */ 292 /* this should be passed to this fctn, not effiecent cpu use this way */
293 int batches = abs (nbatches); 293 int batches = abs (nbatches);
294 294
295 295
296 LOG (llevDebug, "A %s <=> %s\n", &(rp->cauldron), &(cauldron->arch->name));
297 /* is the cauldron the right type? */ 296 /* is the cauldron the right type? */
298 if (strcmp (rp->cauldron, cauldron->arch->name) != 0) 297 if (rp->cauldron != cauldron->arch->name)
299 { 298 {
300 new_draw_info (NDI_UNIQUE, 0, caster, "You are not using the proper" " facilities for this formula."); 299 new_draw_info (NDI_UNIQUE, 0, caster, "You are not using the proper" " facilities for this formula.");
301 return 0; 300 return 0;
302 } 301 }
303 302
309 /* code required for this recipe, search the caster */ 308 /* code required for this recipe, search the caster */
310 if (rp->keycode) 309 if (rp->keycode)
311 { 310 {
312 object *tmp; 311 object *tmp;
313 312
314 for (tmp = caster->inv; tmp != NULL; tmp = tmp->below) 313 for (tmp = caster->inv; tmp; tmp = tmp->below)
315 { 314 {
316 if (tmp->type == FORCE && tmp->slaying && !strcmp (rp->keycode, tmp->slaying)) 315 if (tmp->type == FORCE && tmp->slaying && rp->keycode == tmp->slaying)
317 break; 316 break;
318 } 317 }
318
319 if (tmp == NULL) 319 if (!tmp)
320 { /* failure--no code found */ 320 { /* failure--no code found */
321 new_draw_info (NDI_UNIQUE, 0, caster, "You know the ingredients," " but not the technique. Go learn how to do this recipe."); 321 new_draw_info (NDI_UNIQUE, 0, caster, "You know the ingredients," " but not the technique. Go learn how to do this recipe.");
322 return 0; 322 return 0;
323 } 323 }
324 } 324 }
341 /* new_draw_info_format(NDI_UNIQUE, 0,caster, 341 /* new_draw_info_format(NDI_UNIQUE, 0,caster,
342 "Your spell causes the %s to explode!",&cauldron->name); */ 342 "Your spell causes the %s to explode!",&cauldron->name); */
343 /* kaboom_cauldron(); */ 343 /* kaboom_cauldron(); */
344 } 344 }
345 else 345 else
346 {
347 new_draw_info_format (NDI_UNIQUE, 0, caster, "The %s %s.", &cauldron->name, cauldron_sound ()); 346 new_draw_info_format (NDI_UNIQUE, 0, caster, "The %s %s.", &cauldron->name, cauldron_sound ());
348 }
349 } 347 }
348
350 return item; 349 return item;
351} 350}
352 351
353 352
354 353
355/** 354/**
356 * We adjust the nrof, exp and level of the final product, based 355 * We adjust the nrof, exp and level of the final product, based
357 * on the item's default parameters, and the relevant caster skill level. 356 * on the item's default parameters, and the relevant caster skill level.
358 */ 357 */
359 void 358void
360adjust_product (object *item, int lvl, int yield) 359adjust_product (object *item, int lvl, int yield)
361{ 360{
362 int nrof = 1; 361 int nrof = 1;
363 362
364 if (!yield) 363 if (!yield)
365 yield = 1; 364 yield = 1;
365
366 if (lvl <= 0) 366 if (lvl <= 0)
367 lvl = 1; /* lets avoid div by zero! */ 367 lvl = 1; /* lets avoid div by zero! */
368
368 if (item->nrof) 369 if (item->nrof)
369 { 370 {
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 nrof = (int) ((1.0 - 1.0 / (lvl / 10.0 + 1.0)) * (rndm (0, yield - 1) + rndm (0, yield - 1) + rndm (0, yield - 1)) + 1);
372
371 if (nrof > yield) 373 if (nrof > yield)
372 nrof = yield; 374 nrof = yield;
375
373 item->nrof = nrof; 376 item->nrof = nrof;
374 } 377 }
375} 378}
376 379
377 380
445 { 448 {
446 size_t i; 449 size_t i;
447 450
448 for (i = 0; i < rp->arch_names; i++) 451 for (i = 0; i < rp->arch_names; i++)
449 { 452 {
450 if (strcmp (item->arch->name, rp->arch_name[i]) == 0) 453 if (item->arch->name == rp->arch_name[i])
451 { 454 {
452 *rp_arch_index = i; 455 *rp_arch_index = i;
453 break; 456 break;
454 } 457 }
455 } 458 }
459
456 if (i < rp->arch_names) 460 if (i < rp->arch_names)
457 break; 461 break;
458 } 462 }
459 463
460 /* failed, create a fresh object. Note no nrof>1 because that would 464 /* failed, create a fresh object. Note no nrof>1 because that would
767 * Thus the backfire is worse. Also, more ingredients 771 * Thus the backfire is worse. Also, more ingredients
768 * means we are attempting a more powerfull potion, 772 * means we are attempting a more powerfull potion,
769 * and thus the backfire will be worse. */ 773 * and thus the backfire will be worse. */
770 for (item = cauldron->inv; item; item = item->below) 774 for (item = cauldron->inv; item; item = item->below)
771 { 775 {
772 strcpy (name, item->name); 776 assign (name, item->name);
773 if (item->title) 777 if (item->title)
774 sprintf (name, "%s %s", &item->name, &item->title); 778 sprintf (name, "%s %s", &item->name, &item->title);
775 danger += (strtoint (name) / 1000) + 3; 779 danger += (strtoint (name) / 1000) + 3;
776 nrofi++; 780 nrofi++;
777 } 781 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines