Difference for server/spell_effect.c from version 1.163 to 1.164


version 1.163 version 1.164
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_spell_effect_c =   * static char *rcsid_spell_effect_c =
  *   "$Id: spell_effect.c,v 1.163 2006/09/03 14:00:56 ryo_saeba Exp $";   *   "$Id: spell_effect.c,v 1.164 2006/09/16 20:12:40 qal21 Exp $";
  */   */
   
   
Line 1736
 
Line 1736
  *   *
  * This code adds a new spell, called alchemy.  Alchemy will turn   * This code adds a new spell, called alchemy.  Alchemy will turn
  * objects to gold nuggets, the value of the gold nuggets being   * objects to gold nuggets, the value of the gold nuggets being
  * about 90% of that of the item itself.  It uses the value of the   * from 5% to 40% of that of the item itself depending on casting level.
  * object before charisma adjustments, because the nuggets themselves   * It uses the value of the object before charisma adjustments, because
  * will be will be adjusted by charisma when sold.   * the nuggets themselves will be will be adjusted by charisma when sold.
  *   *
  * Large nuggets are worth 25 gp each (base).  You will always get   * Large nuggets are worth 25 gp each (base).  You will always get
  * the maximum number of large nuggets you could get.   * the maximum number of large nuggets you could get.
Line 1761
 
Line 1761
 static object *small, *large;  static object *small, *large;
 static uint64 small_value, large_value;  static uint64 small_value, large_value;
   
 static void alchemy_object(object *obj, int *small_nuggets,  static void alchemy_object(float value_adj, object *obj, int *small_nuggets,
  int *large_nuggets, int *weight)   int *large_nuggets, int *weight)
 {  {
     uint64 value=query_cost(obj, NULL, F_TRUE);      uint64 value=query_cost(obj, NULL, F_TRUE);
   
     /* Give third price when we alchemy money (This should hopefully      /* Multiply the value of the object by value_adj, which should range
      * make it so that it isn't worth it to alchemy money, sell       * from 0.05 to 0.40. Set value to 0 instead if unpaid.
      * the nuggets, alchemy the gold from that, etc.  
      * Otherwise, give 9 silver on the gold for other objects,  
      * so that it would still be more affordable to haul  
      * the stuff back to town.  
      */       */
   
     if (QUERY_FLAG(obj, FLAG_UNPAID))      if (QUERY_FLAG(obj, FLAG_UNPAID))
  value=0;   value=0;
     else if (obj->type==MONEY || obj->type==GEM)  
  value /=3;  
     else      else
  value = (value*9)/10;          value *= value_adj;
   
      
       /* Give half of what value_adj says when we alchemy money (This should
        * hopefully make it so that it isn't worth it to alchemy money, sell
        * the nuggets, alchemy the gold from that, etc.
        */
       if (value && (obj->type==MONEY || obj->type==GEM))
    value /=2;
   
     if ((obj->value>0) && rndm(0, 29)) {      if ((obj->value>0) && rndm(0, 29)) {
  int count;   int count;
Line 1806
 
Line 1807
     free_object(obj);      free_object(obj);
 }  }
   
 static void update_map(object *op, mapstruct *m, int small_nuggets, int large_nuggets,  static void place_alchemy_objects(object *op, mapstruct *m, int small_nuggets, int large_nuggets,
  int x, int y)   int x, int y)
 {  {
     object *tmp;      object *tmp;
Line 1839
 
Line 1840
 {  {
     int x,y,weight=0,weight_max,large_nuggets,small_nuggets, mflags;      int x,y,weight=0,weight_max,large_nuggets,small_nuggets, mflags;
     sint16 nx, ny;      sint16 nx, ny;
       float value_adj;
     object *next,*tmp;      object *next,*tmp;
     mapstruct *mp;      mapstruct *mp;
   
Line 1856
 
Line 1858
     small_value = query_cost(small, NULL, F_TRUE);      small_value = query_cost(small, NULL, F_TRUE);
     large_value = query_cost(large, NULL, F_TRUE);      large_value = query_cost(large, NULL, F_TRUE);
   
       /* Set value_adj to be a multiplier for how much of the original value
        * will be in the nuggets. Starts at 0.05, increasing by 0.01 per casting
        * level, maxing out at 0.40.
        */
       value_adj = (SP_level_dam_adjust(caster, spell_ob) /
           100.00) + 0.05;
          
       if (value_adj > 0.40) value_adj = 0.40;
   
     for(y= op->y-1;y<=op->y+1;y++) {      for(y= op->y-1;y<=op->y+1;y++) {
  for(x= op->x-1;x<=op->x+1;x++) {   for(x= op->x-1;x<=op->x+1;x++) {
      nx = x;       nx = x;
Line 1891
 
Line 1902
      if (tmp1->weight>0 && !QUERY_FLAG(tmp1, FLAG_NO_PICK) &&       if (tmp1->weight>0 && !QUERY_FLAG(tmp1, FLAG_NO_PICK) &&
  !QUERY_FLAG(tmp1, FLAG_ALIVE) &&   !QUERY_FLAG(tmp1, FLAG_ALIVE) &&
  !QUERY_FLAG(tmp1, FLAG_IS_CAULDRON))   !QUERY_FLAG(tmp1, FLAG_IS_CAULDRON))
  alchemy_object(tmp1, &small_nuggets, &large_nuggets,   alchemy_object(value_adj, tmp1, &small_nuggets, &large_nuggets,
     &weight);      &weight);
  }   }
      }       }
      alchemy_object(tmp, &small_nuggets, &large_nuggets, &weight);       alchemy_object(value_adj, tmp, &small_nuggets, &large_nuggets, &weight);
            
      if (weight>weight_max) {       if (weight>weight_max) {
  update_map(op, mp, small_nuggets, large_nuggets, nx, ny);   place_alchemy_objects(op, mp, small_nuggets, large_nuggets, nx, ny);
  free_object(large);   free_object(large);
  free_object(small);   free_object(small);
  return 1;   return 1;
Line 1910
 
Line 1921
       * it also prevents us from alcheming nuggets that were just created        * it also prevents us from alcheming nuggets that were just created
       * with this spell.        * with this spell.
       */        */
      update_map(op, mp, small_nuggets, large_nuggets, nx, ny);       place_alchemy_objects(op, mp, small_nuggets, large_nuggets, nx, ny);
  }   }
     }      }
     free_object(large);      free_object(large);


Legend:
line(s) removed in v.1.163 
line(s) changed
 line(s) added in v.1.164

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