--- deliantra/server/server/alchemy.C 2007/01/06 14:42:30 1.16 +++ deliantra/server/server/alchemy.C 2007/01/06 21:31:44 1.17 @@ -293,7 +293,6 @@ int batches = abs (nbatches); - LOG (llevDebug, "A %s <=> %s\n", &(rp->cauldron), &(cauldron->arch->name)); /* is the cauldron the right type? */ if (strcmp (rp->cauldron, cauldron->arch->name) != 0) { @@ -311,12 +310,13 @@ { object *tmp; - for (tmp = caster->inv; tmp != NULL; tmp = tmp->below) + for (tmp = caster->inv; tmp; tmp = tmp->below) { if (tmp->type == FORCE && tmp->slaying && !strcmp (rp->keycode, tmp->slaying)) break; } - if (tmp == NULL) + + if (!tmp) { /* failure--no code found */ new_draw_info (NDI_UNIQUE, 0, caster, "You know the ingredients," " but not the technique. Go learn how to do this recipe."); return 0; @@ -343,33 +343,36 @@ /* kaboom_cauldron(); */ } else - { - new_draw_info_format (NDI_UNIQUE, 0, caster, "The %s %s.", &cauldron->name, cauldron_sound ()); - } + new_draw_info_format (NDI_UNIQUE, 0, caster, "The %s %s.", &cauldron->name, cauldron_sound ()); } + return item; } -/** +/** * We adjust the nrof, exp and level of the final product, based * on the item's default parameters, and the relevant caster skill level. */ - void +void adjust_product (object *item, int lvl, int yield) { int nrof = 1; if (!yield) yield = 1; + if (lvl <= 0) lvl = 1; /* lets avoid div by zero! */ + if (item->nrof) { nrof = (int) ((1.0 - 1.0 / (lvl / 10.0 + 1.0)) * (rndm (0, yield - 1) + rndm (0, yield - 1) + rndm (0, yield - 1)) + 1); + if (nrof > yield) nrof = yield; + item->nrof = nrof; } }