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

CF: bug fix for treasures




	Hi all, 

	Back again after a 2wk vacation.. I see that there are 
	lots of bugs to fix still :<. Other than the two most
	pressing bugs (spell experience problem; multi-square mon
	crash on firewalls) I have discovered that not all of 
	the alchemy code was passed to Mark. The file common/treasure.c
	needs to be patched so that 1) flesh items are properly
	named and inherit donor attributes 2) potions are created 
	properly and 3) copious treasure output is trimmed back (optional).

	The patch file follows this message. Off to check out the 
	SERVER connection to the spell-exp bug. Caio! -b.t.

*** ../../crossfire/common/treasure.c	Wed Jul 24 03:45:38 1996
--- ./treasure.c	Thu May  2 08:51:27 1996
***************
*** 33,43 ****
   * slows the startup some (and not actual game play), it is by default
   * left on
   */
  #define TREASURE_DEBUG
  
! 
  #include <global.h>
  #include <treasure.h>
  #include <spellist.h>
  #include <funcpoint.h>
  
--- 33,45 ----
   * slows the startup some (and not actual game play), it is by default
   * left on
   */
  #define TREASURE_DEBUG
  
! /* TREASURE_VERBOSE enables copious output concerning artifact generation */
! /* #define TREASURE_VERBOSE */
!  
  #include <global.h>
  #include <treasure.h>
  #include <spellist.h>
  #include <funcpoint.h>
  
***************
*** 271,280 ****
--- 273,283 ----
          tmp=arch_to_object(t->item);
          if(t->nrof&&tmp->nrof<=1)
            tmp->nrof = RANDOM()%((int) t->nrof) + 1;
          fix_generated_item(tmp,op,difficulty,t->magic);
          if(flag != GT_ENVIRONMENT) {
+ 	  fix_flesh_item(tmp, op);
            tmp = insert_ob_in_ob(tmp,op);
            (void) (*monster_check_apply_func)(op,tmp);
          } else {
            tmp->x=op->x,tmp->y=op->y;
            insert_ob_in_map(tmp,op->map);
***************
*** 319,328 ****
--- 322,332 ----
  	object *tmp=arch_to_object(t->item);
          if(t->nrof&&tmp->nrof<=1)
            tmp->nrof = RANDOM()%((int) t->nrof) + 1;
          fix_generated_item(tmp,op,difficulty,t->magic);
          if(flag != GT_ENVIRONMENT) {
+ 	  fix_flesh_item(tmp, op);
            tmp = insert_ob_in_ob(tmp,op);
            (void) (*monster_check_apply_func)(op,tmp);
          } else {
            tmp->x=op->x,tmp->y=op->y;
            insert_ob_in_map(tmp,op->map);
***************
*** 685,694 ****
--- 689,717 ----
          set_ring_bonus(op,QUERY_FLAG(op, FLAG_CURSED)?-DICE2:DICE2);
          if (!QUERY_FLAG(op, FLAG_CURSED))
            op->value*=3;
        }
        break;
+     case POTION: {
+ 	int too_many_tries=0,is_special=0; 
+ 	while(!(is_special=special_potion(op))) {
+ 	   generate_artifact(op,difficulty);
+ 	   if(too_many_tries++ > 10) break;
+ 	}
+ 	if(is_special) { 
+ 	   int nrof_potion=spells[op->stats.sp].scrolls-RANDOM()%3;
+            /* these 'potions' have been generated as artifacts 
+ 	    * and therefore need a few adjustments 
+             */ 
+            /* give fewer potions than scrolls */
+            if(nrof_potion>0)
+               op->nrof=RANDOM()%(nrof_potion)+1;
+            /* value multiplier is same as for scrolls */
+            op->value=(op->value*spells[op->stats.sp].level)/
+                  (spells[op->stats.sp].level+4);
+ 	}
+ 	break; } 
      case AMULET:
        if(op->arch==amulet_arch)
          op->value*=5; /* Since it's not just decoration */
      case RING:
        if(op->arch==NULL) {
***************
*** 819,829 ****
        break;
      case RUNE:
        (*trap_adjust_func)(op,difficulty);
        break;
      }
!   if (op->type == POTION) {
      op->face = potion_face;
      free_string(op->name);
      op->name = add_string("potion");
      op->level = spells[op->stats.sp].level/2+ RANDOM()%difficulty + RANDOM()%difficulty;
      if (RANDOM()%2)
--- 842,852 ----
        break;
      case RUNE:
        (*trap_adjust_func)(op,difficulty);
        break;
      }
!   if (op->type == POTION && special_potion(op)) {
      op->face = potion_face;
      free_string(op->name);
      op->name = add_string("potion");
      op->level = spells[op->stats.sp].level/2+ RANDOM()%difficulty + RANDOM()%difficulty;
      if (RANDOM()%2)
***************
*** 1016,1026 ****
--- 1039,1051 ----
   */
  
  void add_abilities(object *op, object *change) {
    int i, tmp;
    if (change->face != blank_face) {
+ #ifdef TREASURE_VERBOSE
      LOG(llevDebug, "FACE: %d\n", change->face->number);
+ #endif
      op->face = change->face;
    }
    for (i = 0; i < 7; i++)
      change_attr_value(&(op->stats), i, get_attr_value(&(change->stats), i));
    if (QUERY_FLAG(change,FLAG_CURSED))
***************
*** 1152,1162 ****
--- 1177,1189 ----
    char *name;
  
    if (art->allowed == (linked_char *) NULL)
      return 1; /* Ie, "all" */
    for (tmp = art->allowed; tmp; tmp = tmp->next) {
+ #ifdef TREASURE_VERBOSE
      LOG(llevDebug, "legal_art: %s\n", tmp->name);
+ #endif
      if (*tmp->name == '!')
        name = tmp->name + 1, neg = 1;
      else
        name = tmp->name, neg = 0;
  
***************
*** 1246,1260 ****
--- 1273,1328 ----
      /* Map difficulty not high enough */
      if (difficulty<art->difficulty)
  	continue;
  
      if (!legal_artifact_combination(op, art)) {
+ #ifdef TREASURE_VERBOSE
        LOG(llevDebug, "%s of %s was not a legal combination.\n",
            op->name, art->item->name);
+ #endif
        continue;
      }
      give_artifact_abilities(op, art->item);
      return;
    }
  }
  
+ /* fix_flesh_item() - objects of type FLESH are similar to type
+  * FOOD, except they inherit properties (name, food value, etc).
+  * based on the original owner (or 'donor' if you like). -b.t.
+  */
+ 
+ void fix_flesh_item(object *item, object *donor) {
+   char tmpbuf[MAX_BUF];
+ 
+   if(item->type==FLESH && donor) {
+       /* change the name */
+       sprintf(tmpbuf,"%s's %s",donor->name,item->name);
+       free_string(item->name);
+       item->name=add_string(tmpbuf);
+      /* weight is FLESH weight/100 * donor */
+       if((item->weight = (float) (item->weight/100.0) * donor->weight)==0)
+ 		item->weight=1;
+      /* value is multiplied by level of donor */
+       item->value *= donor->level;
+      /* food value */
+       item->stats.food += (donor->stats.hp/100) + donor->stats.Con;
+      /* flesh items inherit vuln, prot of donor */
+       item->vulnerable = donor->vulnerable;
+       item->protected = donor->protected;
+      /* if donor has some attacktypes, the flesh is poisonous */
+       if(donor->attacktype&AT_POISON)
+ 	item->type=POISON;
+       if(donor->attacktype&AT_ACID) item->stats.hp = -1*item->stats.food; }
+ }
+ 
+ /* special_potion() - so that old potion code is still done right. */
+ 
+ int special_potion (object *op) {
+ 
+   if(op->attacktype) return 1;
+   if(op->immune || op->vulnerable || op->protected || op->stats.sp) return 1;
+   if(op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow
+  	|| op->stats.Wis || op->stats.Int || op->stats.Cha ) return 1;
  
+   return 0;
+ }