Difference for server/alchemy.c from version 1.12 to 1.13


version 1.12 version 1.13
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_alchemy_c =   * static char *rcsid_alchemy_c =
  *   "$Id: alchemy.c,v 1.12 2002/07/15 04:25:40 mwedel Exp $";   *   "$Id: alchemy.c,v 1.13 2002/11/11 08:59:09 garbled Exp $";
  */   */
   
 /*  /*
Line 105
 
Line 105
    
      numb=numb_ob_inside(cauldron);       numb=numb_ob_inside(cauldron);
      if((fl=get_formulalist(numb))) {       if((fl=get_formulalist(numb))) {
   
         /* the caster only gets an increase in ability   
          * if they know alchemy skill */  
         if(find_skill(caster,SK_ALCHEMY)!=NULL) {  
    change_skill(caster,SK_ALCHEMY);  
           ability+=SK_level(caster)*((4.0 + cauldron->magic)/4.0);  
         }  
   
 #ifdef ALCHEMY_DEBUG  
  LOG(llevDebug,"Got alchemy ability lvl = %d\n",ability);  
 #endif  
   
         if(QUERY_FLAG(caster,FLAG_WIZ)) {           if(QUERY_FLAG(caster,FLAG_WIZ)) {
      rp=fl->items;       rp=fl->items;
      while(rp && (formula % rp->index)!=0) {       while(rp && (formula % rp->index)!=0) {
Line 147
 
Line 135
  {   {
    float ave_chance = fl->total_chance/(float)fl->number;     float ave_chance = fl->total_chance/(float)fl->number;
    object *item;     object *item;
      int skillno;
   
      /* the caster gets an increase in ability based on thier skill lvl */
      if (rp->skill != NULL) {
          skillno = lookup_skill_by_name(rp->skill);
          if (skillno < 0) { /* invalid skill */
      LOG(llevDebug, "Recipie %s has invalid skill %s\n",
          rp->title, rp->skill);
      return;
          }
   /*       if(find_skill(caster, skillno) != NULL) {
      change_skill(caster, skillno); */
   
          if (caster->chosen_skill->stats.sp == skillno) {
      ability+=SK_level(caster)*((4.0 + cauldron->magic)/4.0);
   #ifdef ALCHEMY_DEBUG
      LOG(llevDebug, "Got alchemy ability lvl = %d\n", ability);
   #endif
          } else {
      new_draw_info(NDI_UNIQUE, 0, caster, "You did not use the "
          "proper skill for this recipe,");
      /*return;*/
          }
      } else {
          LOG(llevDebug, "Recipie %s has NULL skill!\n", rp->title);
          return;
      }
   
      if (rp->cauldron == NULL) {
          LOG(llevDebug, "Recipie %s has NULL cauldron!\n", rp->title);
          return;
      }
   
    /* 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) {
Line 166
 
Line 186
   
      /* roll the dice */       /* roll the dice */
      if((float)(random_roll(0, 99, caster, PREFER_LOW)) <= 100.0 * success_chance) {       if((float)(random_roll(0, 99, caster, PREFER_LOW)) <= 100.0 * success_chance) {
        /* we learn from our experience IF we know something of the alchemical arts */  
        if(caster->chosen_skill&&caster->chosen_skill->stats.sp==SK_ALCHEMY) {   
  /* more exp is given for higher ingred number recipes */    /* more exp is given for higher ingred number recipes */
  int amount = numb*numb*calc_skill_exp(caster,item);   int amount = numb*numb*calc_skill_exp(caster,item);
  add_exp(caster,amount);   add_exp(caster,amount);
  item->stats.exp=0; /* so when skill id this item, less xp is awarded */   /* so when skill id this item, less xp is awarded */
    item->stats.exp=0;
 #ifdef EXTREME_ALCHEMY_DEBUG   #ifdef EXTREME_ALCHEMY_DEBUG
  LOG(llevDebug,"%s gains %d experience points.\n",caster->name,amount);    LOG(llevDebug,"%s gains %d experience points.\n",caster->name,amount);
 #endif  #endif
        }  
        return;         return;
      }       }
    }     }
Line 239
 
Line 257
  */    */
    
 object * attempt_recipe(object *caster, object *cauldron,int ability, recipe *rp, int nbatches) {   object * attempt_recipe(object *caster, object *cauldron,int ability, recipe *rp, int nbatches) {
   
   object *item=NULL;      object *item=NULL; 
   /* this should be passed to this fctn, not too effiecent cpu use this way */      /* this should be passed to this fctn, not effiecent cpu use this way */
   int batches=abs(nbatches);    int batches=abs(nbatches);
   
   if(rp->keycode)  /* code required for this recipe, search the caster */      /* is the cauldron the right type? */
  { object *tmp;      if (strcmp(rp->cauldron, cauldron->arch->name) != 0) {
    new_draw_info(NDI_UNIQUE, 0, caster, "You are not using the proper"
        " facilities for this formula.");
    return 0;
       }
   
       /* did the caster use the right skill? */
       if (caster->chosen_skill->stats.sp != lookup_skill_by_name(rp->skill))
    return 0;
   
       /* code required for this recipe, search the caster */
       if(rp->keycode) {
    object *tmp;
  for(tmp=caster->inv;tmp!=NULL;tmp=tmp->below) {   for(tmp=caster->inv;tmp!=NULL;tmp=tmp->below) {
  if(tmp->type==FORCE && tmp->slaying && !strcmp(rp->keycode,tmp->slaying))       if(tmp->type==FORCE && tmp->slaying &&
    !strcmp(rp->keycode, tmp->slaying))
    break;     break;
  }   }
  if(tmp==NULL) { /* failure--no code found */   if(tmp==NULL) { /* failure--no code found */
  new_draw_info(NDI_UNIQUE,0,caster,       new_draw_info(NDI_UNIQUE, 0, caster, "You know the ingredients,"
    "You know the ingredients, but not the technique.  Go learn how to do this recipe.");   " but not the technique.  Go learn how to do this recipe.");
  return 0;     return 0; 
  }   }
  }   }
   
 #ifdef EXTREME_ALCHEMY_DEBUG  #ifdef EXTREME_ALCHEMY_DEBUG
   LOG(llevDebug,"attempt_recipe(): got %d nbatches\n",nbatches);    LOG(llevDebug,"attempt_recipe(): got %d nbatches\n",nbatches);
   LOG(llevDebug,"attempt_recipe(): using recipe %s\n", rp->title?rp->title:"unknown");      LOG(llevDebug,"attempt_recipe(): using recipe %s\n",
    rp->title?rp->title:"unknown");
 #endif  #endif
   
   if((item=make_item_from_recipe(cauldron,rp))!=NULL) {    if((item=make_item_from_recipe(cauldron,rp))!=NULL) {
     remove_contents(cauldron->inv,item);      remove_contents(cauldron->inv,item);
     adjust_product(item,ability,rp->yield?(rp->yield*batches):batches); /* adj lvl, nrof on caster level */          /* adj lvl, nrof on caster level */
    adjust_product(item, ability, rp->yield?(rp->yield*batches):batches);
     if(!item->env && (item=insert_ob_in_ob(item,cauldron))==NULL) {       if(!item->env && (item=insert_ob_in_ob(item,cauldron))==NULL) {
       new_draw_info(NDI_UNIQUE, 0,caster,"Nothing happened.");        new_draw_info(NDI_UNIQUE, 0,caster,"Nothing happened.");
       /* new_draw_info_format(NDI_UNIQUE, 0,caster,         /* new_draw_info_format(NDI_UNIQUE, 0,caster,
Line 273
 
Line 308
                "The %s %s.",cauldron->name,cauldron_sound());                 "The %s %s.",cauldron->name,cauldron_sound());
     }         }   
   }        }   
    
   return item;     return item;
 }   }
   
Line 609
 
Line 643
    int danger=0,nrofi=0;      int danger=0,nrofi=0;
    
     /* Knowing alchemy skill reduces yer risk */      /* Knowing alchemy skill reduces yer risk */
    if(caster->chosen_skill&&caster->chosen_skill->stats.sp==SK_ALCHEMY)  /*   if(caster->chosen_skill&&caster->chosen_skill->stats.sp==SK_ALCHEMY) */
      danger -= SK_level(caster);       danger -= SK_level(caster);
   
    /* better cauldrons reduce risk */     /* better cauldrons reduce risk */
Line 634
 
Line 668
    if(QUERY_FLAG(cauldron,FLAG_CURSED)) danger +=80;     if(QUERY_FLAG(cauldron,FLAG_CURSED)) danger +=80;
    if(QUERY_FLAG(cauldron,FLAG_DAMNED)) danger +=200;     if(QUERY_FLAG(cauldron,FLAG_DAMNED)) danger +=200;
    
   #ifdef ALCHEMY_DEBUG
    LOG(llevDebug,"calc_alch_danger() returned danger=%d\n",danger);     LOG(llevDebug,"calc_alch_danger() returned danger=%d\n",danger);
   #endif
   
    return danger;     return danger;
 }  }
   


Legend:
line(s) removed in v.1.12 
line(s) changed
 line(s) added in v.1.13

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