Difference for server/alchemy.c from version 1.14 to 1.15


version 1.14 version 1.15
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_alchemy_c =   * static char *rcsid_alchemy_c =
  *   "$Id: alchemy.c,v 1.14 2002/11/13 00:26:13 garbled Exp $";   *   "$Id: alchemy.c,v 1.15 2003/01/09 04:20:26 garbled Exp $";
  */   */
   
 /*  /*
Line 97
 
Line 97
   float success_chance;    float success_chance;
   int numb,ability=1;    int numb,ability=1;
   int formula=0;    int formula=0;
       float ave_chance;
       object *item;
       int skillno;
    
      if(caster->type!=PLAYER) return; /* only players for now */       if (caster->type!=PLAYER)
    return; /* only players for now */
   
       /* if no ingredients, no formula! lets forget it */        /* if no ingredients, no formula! lets forget it */
      if(!(formula=content_recipe_value(cauldron))) return;       if(!(formula=content_recipe_value(cauldron))) return;
Line 120
 
Line 124
      LOG(llevDebug,"WIZ got formula: %s of %s\n",       LOG(llevDebug,"WIZ got formula: %s of %s\n",
  rp->arch_name,rp->title);   rp->arch_name,rp->title);
  else    else
      LOG(llevDebug,"WIZ got formula: %s (nbatches:%d)\n",rp->arch_name,       LOG(llevDebug, "WIZ got formula: %s (nbatches:%d)\n",
                       formula/rp->index);   rp->arch_name, formula/rp->index);
 #endif  #endif
  attempt_recipe(caster,cauldron,ability,rp,formula/rp->index);   attempt_recipe(caster,cauldron,ability,rp,formula/rp->index);
      }else LOG(llevDebug,"WIZ couldnt find formula for ingredients.\n");        }else LOG(llevDebug,"WIZ couldnt find formula for ingredients.\n");
Line 129
 
Line 133
  } /* End of WIZ alchemy */   } /* End of WIZ alchemy */
   
  /* find the recipe */   /* find the recipe */
  for(rp = fl->items;rp!=NULL && (formula % rp->index)!=0;rp=rp->next);   for (rp = fl->items;rp!=NULL && (formula % rp->index)!=0;rp=rp->next)
        ;
  if(rp)  /* if we found a recipe */  
  {  
    float ave_chance = fl->total_chance/(float)fl->number;  
    object *item;  
    int skillno;  
   
    if (rp) { /* if we found a recipe */
        ave_chance = fl->total_chance/(float)fl->number;
    /* the caster gets an increase in ability based on thier skill lvl */     /* the caster gets an increase in ability based on thier skill lvl */
    if (rp->skill != NULL) {     if (rp->skill != NULL) {
        skillno = lookup_skill_by_name(rp->skill);         skillno = lookup_skill_by_name(rp->skill);
Line 145
 
Line 146
        rp->title, rp->skill);         rp->title, rp->skill);
    return;     return;
        }         }
 /*       if(find_skill(caster, skillno) != NULL) {  
    change_skill(caster, skillno); */  
   
        if (caster->chosen_skill->stats.sp == skillno) {         if (caster->chosen_skill->stats.sp == skillno) {
    ability+=SK_level(caster)*((4.0 + cauldron->magic)/4.0);     ability+=SK_level(caster)*((4.0 + cauldron->magic)/4.0);
 #ifdef ALCHEMY_DEBUG  #ifdef ALCHEMY_DEBUG
Line 155
 
Line 153
 #endif  #endif
        } else {         } else {
    new_draw_info(NDI_UNIQUE, 0, caster, "You did not use the "     new_draw_info(NDI_UNIQUE, 0, caster, "You did not use the "
        "proper skill for this recipe,");     "proper skill for this recipe.");
    /*return;*/     /*return;*/
        }         }
    } else {     } else {
Line 171
 
Line 169
    /* create the object **FIRST**, then decide whether to keep it. */     /* create the object **FIRST**, then decide whether to keep it. */
    if((item=attempt_recipe(caster,cauldron,ability,rp,formula/rp->index)) != NULL) {     if((item=attempt_recipe(caster,cauldron,ability,rp,formula/rp->index)) != NULL) {
      /*  compute base chance of recipe success */       /*  compute base chance of recipe success */
      success_chance = ((float)(15*ability) /   success_chance = ((float)ability /
        (float)(15*ability + numb*item->level * (numb+item->level+formula/rp->index)));     (float)(rp->diff * (item->level+2)));
      if(ave_chance == 0) ave_chance = 1;   if (ave_chance == 0)
      /* adjust the success chance by the chance from the recipe list */       ave_chance = 1;
      if(ave_chance > rp->chance)  
        success_chance *= (rp->chance + ave_chance)/ (2.0*ave_chance);  
      else  
        success_chance = 1.0- ( (1.0-success_chance)*(rp->chance +ave_chance)/(2.0*rp->chance));  
   
 #ifdef ALCHEMY_DEBUG  #ifdef ALCHEMY_DEBUG
      LOG(llevDebug,"percent success chance =  %f\n",success_chance);   LOG(llevDebug, "percent success chance =  %f ab%d / diff%d*lev%d\n",
        success_chance, ability, rp->diff, item->level);
 #endif  #endif
   
      /* roll the dice */       /* roll the dice */
      if ((float)(random_roll(0, 99, caster, PREFER_LOW)) <= 100.0 * success_chance) {   if ((float)(random_roll(0, 101, caster, PREFER_LOW)) <= 100.0 * success_chance) {
  /* more exp is given for higher ingred number recipes */        add_exp(caster, rp->exp);
  int amount = numb*numb*calc_skill_exp(caster, item);  
  add_exp(caster, amount);  
  /* so when skill id this item, less xp is awarded */  
  item->stats.exp=0;  
 #ifdef EXTREME_ALCHEMY_DEBUG   
  LOG(llevDebug,"%s gains %d experience points.\n",caster->name,amount);   
 #endif  
          return;           return;
      }       }
    }     }
  }   }
      }       }
      /* if we get here, we failed!! */       /* if we get here, we failed!! */
      alchemy_failure_effect(caster,cauldron,rp,calc_alch_danger(caster,cauldron));      alchemy_failure_effect(caster, cauldron, rp,
    calc_alch_danger(caster, cauldron, rp));
 }  }
   
 /* content_recipe_value()- recipe value of the entire contents of a container.  /* content_recipe_value()- recipe value of the entire contents of a container.
Line 319
 
Line 308
 void adjust_product(object *item,int lvl ,int yield) {  void adjust_product(object *item,int lvl ,int yield) {
    int nrof=1;     int nrof=1;
   
    if(!yield) yield = 1;      if (!yield)
    if(lvl<=0) lvl = 1; /* lets avoid div by zero! */    yield = 1;
       if (lvl<=0)
    lvl = 1; /* lets avoid div by zero! */
    if(item->nrof) {     if(item->nrof) {
 /*     nrof = (RANDOM() % yield + RANDOM() % yield + RANDOM() % yield)/ 3 + 1;*/   nrof = (1.0 - 1.0/(lvl/10.0 + 1.0)) *
      nrof = ( 1.0 - 1.0/(lvl/10.0 + 1.0)) * (rndm(0, yield-1) + rndm(0, yield-1) + rndm(0, yield-1)) + 1;       (rndm(0, yield-1) + rndm(0, yield-1) + rndm(0, yield-1)) + 1;
      if(nrof > yield) nrof = yield;   if (nrof > yield)
        nrof = yield;
      item->nrof=nrof;       item->nrof=nrof;
    }     }
   
    /* item exp. This will be used later for experience calculation */  
    item->stats.exp += lvl*lvl*nrof;  
   
    /* item->level = (lvl+item->level)/2; avg between default and caster levels */  
 }  }
   
   
Line 585
 
Line 572
  }   }
       }        }
       return;        return;
   } else if (level<200) {               /* MANA STORM - watch out!! */    } else {               /* MANA STORM - watch out!! */
       new_draw_info(NDI_UNIQUE,0,op,"You unwisely release potent forces!");        new_draw_info(NDI_UNIQUE,0,op,"You unwisely release potent forces!");
       remove_contents (cauldron->inv,NULL);        remove_contents (cauldron->inv,NULL);
       cast_mana_storm(op,level);        cast_mana_storm(op,level);
Line 625
 
Line 612
  * -b.t.    * -b.t.
  */   */
    
 int calc_alch_danger(object *caster,object *cauldron) {  int calc_alch_danger(object *caster,object *cauldron, recipe *rp) {
    object *item;      object *item;
    char name[MAX_BUF];     char name[MAX_BUF];
    int danger=0,nrofi=0;      int danger=0,nrofi=0;
Line 650
 
Line 637
         danger += (strtoint(name)/1000) + 3;          danger += (strtoint(name)/1000) + 3;
  nrofi++;   nrofi++;
    }     }
    if(nrofi>1) danger *= nrofi;     danger += rp->diff*3;
    
     /* Using a bad device is *majorly* stupid */      /* Using a bad device is *majorly* stupid */
    if(QUERY_FLAG(cauldron,FLAG_CURSED)) danger +=80;     if(QUERY_FLAG(cauldron,FLAG_CURSED)) danger +=80;


Legend:
line(s) removed in v.1.14 
line(s) changed
 line(s) added in v.1.15

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:21