Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CF: Suggested alchemy experience fix (with patch)




    I just did a diff -cr to pull out all the various changes I've been trying
out.  I think some of them are ready to be published here, for further testing
and decisions on whether to include them.  Comments on the changes I've made
are marked with my initials, D.A.M.N.

    This one is a suggested fix for the alchemy bug that grants obscene amounts
of experience for certain formulas.  Those formulas are the ones that create
items with a high fixed level, because those items are pretty worthless
otherwise.  Dust of Repelling Undead, for example, is level 30.
    The fix I implemented here is to base the chance of success largely on the
level of the product, so it's very difficult to produce something like Dust
of Repelling Undead, and therefore worth the extra experience.  The chance of
success is now based on the following factors:
1) level of product
2) number of ingredients in formula
3) rarity of formula as listed in "formulae" data file
4) number of batches being made
5) Alchemy skill (if present)
6) enchantment of cauldron
7) luck

    Possibly a better solution would be to specify a difficulty and experience
reward in the formula definitions.  Factors 1-3 could then be replaced by the 
difficulty and the formula object could be used to calculate the experience 
gain, instead of basing it on the result object.  But that should probably wait
for the object overhaul in 0.96

    The weighting of the various factors may need to be adjusted, or the
overall shape of the function that combines them.  It looks good to me, but
I have only tried a few formulas with only two characters.  That's what Beta
testing is for, right?  If this sounds like a reasonable (temporary?) solution
to you, apply it and try it out.  Let me know what you think.

-- 
            -Dave Noelle,                 dave@Straylight.org
            -the Villa Straylight,  http://www.straylight.org

diff -cr crossfire-0.95.4/server/alchemy.c crossfire-0.95.4-mod/server/alchemy.c
*** crossfire-0.95.4/server/alchemy.c	Tue Jul 13 00:42:14 1999
--- crossfire-0.95.4-mod/server/alchemy.c	Thu Aug  5 23:29:25 1999
***************
*** 85,90 ****
--- 85,94 ----
  	  change_skill(caster,SK_ALCHEMY);
            ability+=SK_level(caster)*((4.0 + cauldron->magic)/4.0);
          }
+ 	/* Add caster's luck to alcheky skill */
+ 	/* cauldron->magic multiplies luck only half as much as	*
+ 	 * it does Alchemy skill.  -- DAMN			*/
+ 	ability += caster->stats.luck*((8.0 + cauldron->magic)/8.0);
  
  #ifdef ALCHEMY_DEBUG
  	LOG(llevDebug,"Got alchemy ability lvl = %d\n",ability);
***************
*** 113,120 ****
  	    return;
  	} /* End of WIZ alchemy */
  
- 	/*  compute base chance of recipe success */
- 	success_chance = 15.0 * ability / ( numb * numb * numb + 30 + 15.0*ability);
  #ifdef ALCHEMY_DEBUG
  	LOG(llevDebug,"base success chance =  %f\n",success_chance);
  #endif
--- 117,122 ----
***************
*** 125,144 ****
  	if(rp)  /* if we found a recipe */
  	{
  	  float ave_chance = fl->total_chance/(float)fl->number;
! 	  if(ave_chance == 0) ave_chance = 1;
! 	  /* adjust the success chance by the chance from the recipe list */
! 	  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
! 	  LOG(llevDebug,"percent success chance =  %f\n",success_chance);
  #endif
! 
! 	  /* roll the dice */
! 	  if(RANDOM()%100 <= 100 * success_chance) {
! 	    if(attempt_recipe(caster,cauldron,ability,rp,formula/rp->index)) return;
  	  }
  	}
       }
--- 127,164 ----
  	if(rp)  /* if we found a recipe */
  	{
  	  float ave_chance = fl->total_chance/(float)fl->number;
! 	  object *item;
  
! 	  /* create the object **FIRST**, then decide whether to keep it.	*/
! 	  if((item=attempt_recipe(caster,cauldron,ability,rp,formula/rp->index)) != NULL) {
! 	    /*  compute base chance of recipe success */
! 	    success_chance = ((float)(15*ability) /
! 			      (float)(15*ability + numb*item->level * (numb+item->level+formula/rp->index)));
! 	    if(ave_chance == 0) ave_chance = 1;
! 	    /* adjust the success chance by the chance from the recipe list	*/
! 	    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
! 	    LOG(llevDebug,"percent success chance =  %f\n",success_chance);
! #endif
! 
! 	    /* roll the dice */
! 	    if((float)(RANDOM()%100) <= 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 */ 
! 		int amount = numb*numb*calc_skill_exp(caster,item);
! 		add_exp(caster,amount);
! 		item->stats.exp=0; /* so when skill id this item, less xp is awarded */
! #ifdef EXTREME_ALCHEMY_DEBUG 
! 		LOG(llevDebug,"%s gains %d experience points.\n",caster->name,amount); 
  #endif
! 	      }
! 	      return;
! 	    }
  	  }
  	}
       }
***************
*** 209,233 ****
    LOG(llevDebug,"attempt_recipe(): using recipe %s\n", rp->title?rp->title:"unknown");
  #endif
  
!   if((item=make_item_from_recipe(cauldron,rp))!=NULL) { 
      remove_contents(cauldron->inv,item);
!     adjust_product(item,ability,rp->yield?(rp->yield*batches):batches); /* adj lvl, nrof on caster level */ 
      if(!item->env && (item=insert_ob_in_ob(item,cauldron))==NULL) { 
        new_draw_info(NDI_UNIQUE, 0,caster,"Nothing happened.");
        /* new_draw_info_format(NDI_UNIQUE, 0,caster, 
              "Your spell causes the %s to explode!",cauldron->name); */
        /* kaboom_cauldron(); */ 
      } else {
-       /* we learn from our experience IF we know something of the alchemical arts */
-       if(nbatches>=0 && caster->chosen_skill&&caster->chosen_skill->stats.sp==SK_ALCHEMY) { 
-         /* more exp is given for higher ingred number recipes */ 
-         int amount = numb*numb*calc_skill_exp(caster,item);
-  	add_exp(caster,amount);
- 	item->stats.exp=0; /* so when skill id this item, less xp is awarded */
- #ifdef EXTREME_ALCHEMY_DEBUG 
-         LOG(llevDebug,"%s gains %d experience points.\n",caster->name,amount); 
- #endif
-       }
        new_draw_info_format(NDI_UNIQUE, 0,caster, 
                 "The %s %s.",cauldron->name,cauldron_sound());
      }   
--- 229,243 ----
    LOG(llevDebug,"attempt_recipe(): using recipe %s\n", rp->title?rp->title:"unknown");
  #endif
  
!   if((item=make_item_from_recipe(cauldron,rp))!=NULL) {
      remove_contents(cauldron->inv,item);
!     adjust_product(item,ability,rp->yield?(rp->yield*batches):batches); /* adj lvl, nrof on caster level */
      if(!item->env && (item=insert_ob_in_ob(item,cauldron))==NULL) { 
        new_draw_info(NDI_UNIQUE, 0,caster,"Nothing happened.");
        /* new_draw_info_format(NDI_UNIQUE, 0,caster, 
              "Your spell causes the %s to explode!",cauldron->name); */
        /* kaboom_cauldron(); */ 
      } else {
        new_draw_info_format(NDI_UNIQUE, 0,caster, 
                 "The %s %s.",cauldron->name,cauldron_sound());
      }   
***************
*** 257,263 ****
     item->stats.exp += lvl*lvl*nrof;
  
     /* item->level = (lvl+item->level)/2; avg between default and caster levels */
-    
  }
  
  
--- 267,272 ----
-
[you can put yourself on the announcement list only or unsubscribe altogether
by sending an email stating your wishes to crossfire-request@ifi.uio.no]