Only in angband-279v6+/src: #config.h#
diff -c angband-279v6/src/Makefile angband-279v6+/src/Makefile
*** angband-279v6/src/Makefile	Sat Apr 13 12:00:05 1996
--- angband-279v6+/src/Makefile	Tue Jul 23 07:49:22 1996
***************
*** 115,122 ****
  # including "USE_GETCH" and "USE_CURS_SET".  Note that "config.h" will
  # attempt to "guess" at many of these flags based on your system.
  #
! CFLAGS = -Wall -O1 -pipe -g -D"USE_X11" -D"USE_GCU"
! LIBS = -lX11 -lcurses -ltermcap
  
  
  ##
--- 115,122 ----
  # including "USE_GETCH" and "USE_CURS_SET".  Note that "config.h" will
  # attempt to "guess" at many of these flags based on your system.
  #
! #CFLAGS = -Wall -O1 -pipe -g -D"USE_X11" -D"USE_GCU"
! #LIBS = -lX11 -lcurses -ltermcap
  
  
  ##
***************
*** 177,182 ****
--- 177,185 ----
  ##
  #CFLAGS = -Wall -O1 -pipe -g -D"USE_X11" -D"USE_GCU" -D"SOLARIS"
  #LIBS = -lX11 -lsocket -lcurses
+ 
+ CFLAGS = -Wall -O1 -pipe -g -D"USE_X11" -D"SOLARIS" -I/usr/openwin/include
+ LIBS = -lX11 -lsocket
  
  
  ##
Only in angband-279v6+/src: Makefile~
Only in angband-279v6+/src: angband
Only in angband-279v6+/src: birth.o
Only in angband-279v6+/src: cave.o
Only in angband-279v6+/src: cmd1.o
Only in angband-279v6+/src: cmd2.o
Only in angband-279v6+/src: cmd3.o
Only in angband-279v6+/src: cmd4.o
diff -c angband-279v6/src/cmd5.c angband-279v6+/src/cmd5.c
*** angband-279v6/src/cmd5.c	Sun Apr 14 20:09:43 1996
--- angband-279v6+/src/cmd5.c	Thu Jul 25 11:29:26 1996
***************
*** 1371,1381 ****
  
      i_ptr = &inventory[INVEN_WIELD];
  
!     /* you can never modify artifacts / ego-items */
      /* you can never modify broken / cursed items */
      if ((i_ptr->k_idx) &&
!         (!artifact_p(i_ptr)) && (!ego_item_p(i_ptr)) &&
!         (!broken_p(i_ptr)) && (!cursed_p(i_ptr)))
      {
          cptr act = NULL;
  
--- 1371,1391 ----
  
      i_ptr = &inventory[INVEN_WIELD];
  
!     /* you can never modify artifacts / (double) ego-items */
      /* you can never modify broken / cursed items */
+     /* you cannot add a second brand to any weapon */
      if ((i_ptr->k_idx) &&
!         (!artifact_p(i_ptr)) && 
! #ifdef ALLOW_DOUBLE_EGO
! 	(!double_ego_item_p(i_ptr)) &&
! #else
! 	(!ego_item_p(i_ptr)) &&
! #endif
!         (!broken_p(i_ptr)) && (!cursed_p(i_ptr)) &&
! 	(i_ptr->name2 != EGO_BRAND_ACID) && 
! 	(i_ptr->name2 != EGO_BRAND_ELEC) && 
! 	(i_ptr->name2 != EGO_BRAND_FIRE) && 
! 	(i_ptr->name2 != EGO_BRAND_COLD))
      {
          cptr act = NULL;
  
***************
*** 1384,1396 ****
          if (rand_int(100) < 25)
          {
              act = "is covered in a fiery shield!";
!             i_ptr->name2 = EGO_BRAND_FIRE;
          }
  
          else
          {
              act = "glows deep, icy blue!";
!             i_ptr->name2 = EGO_BRAND_COLD;
          }
  
          object_desc(i_name, i_ptr, FALSE, 0);
--- 1394,1412 ----
          if (rand_int(100) < 25)
          {
              act = "is covered in a fiery shield!";
! 	    if (i_ptr->name2)
! 	      i_ptr->name1 = EGO_BRAND_FIRE;
! 	    else
! 	      i_ptr->name2 = EGO_BRAND_FIRE;
          }
  
          else
          {
              act = "glows deep, icy blue!";
! 	    if (i_ptr->name2)
! 	      i_ptr->name1 = EGO_BRAND_COLD;
! 	    else
! 	      i_ptr->name2 = EGO_BRAND_COLD;
          }
  
          object_desc(i_name, i_ptr, FALSE, 0);
Only in angband-279v6+/src: cmd5.c~
Only in angband-279v6+/src: cmd5.o
diff -c angband-279v6/src/cmd6.c angband-279v6+/src/cmd6.c
*** angband-279v6/src/cmd6.c	Sun Apr 14 20:10:07 1996
--- angband-279v6+/src/cmd6.c	Thu Jul 25 11:27:40 1996
***************
*** 2415,2421 ****
  
  
      /* Artifacts activate by name */
!     if (i_ptr->name1)
      {
          /* This needs to be changed */
          switch (i_ptr->name1)
--- 2415,2421 ----
  
  
      /* Artifacts activate by name */
!     if (artifact_p(i_ptr))
      {
          /* This needs to be changed */
          switch (i_ptr->name1)
***************
*** 2573,2580 ****
                  {
                      object_type *j_ptr = &inventory[a];
                      if ((j_ptr->tval == TV_BOLT) &&
!                         (!artifact_p(j_ptr)) && (!ego_item_p(j_ptr)) &&
!                         (!cursed_p(j_ptr) && !broken_p(j_ptr))) break;
                  }
  
                  /* Enchant the bolts (or fail) */
--- 2573,2587 ----
                  {
                      object_type *j_ptr = &inventory[a];
                      if ((j_ptr->tval == TV_BOLT) &&
!                         (!artifact_p(j_ptr)) && 
! #ifdef ALLOW_DOUBLE_EGO
! 			(!double_ego_item_p(j_ptr)) &&
! #else
! 			(!ego_item_p(j_ptr)) &&
! #endif
!                         (!cursed_p(j_ptr) && !broken_p(j_ptr)) &&
! 			(j_ptr->name2 != EGO_FLAME) && 
! 			(j_ptr->name2 != EGO_FROST)) break;
                  }
  
                  /* Enchant the bolts (or fail) */
***************
*** 2582,2588 ****
                  {
                      object_type *j_ptr = &inventory[a];
                      msg_print("Your bolts are covered in a fiery aura!");
!                     j_ptr->name2 = EGO_FLAME;
                      enchant(j_ptr, rand_int(3) + 4, ENCH_TOHIT | ENCH_TODAM);
                  }
                  else
--- 2589,2598 ----
                  {
                      object_type *j_ptr = &inventory[a];
                      msg_print("Your bolts are covered in a fiery aura!");
! 		    if (j_ptr->name2)
! 		      j_ptr->name1 = EGO_FLAME;
! 		    else
! 		      j_ptr->name2 = EGO_FLAME;
                      enchant(j_ptr, rand_int(3) + 4, ENCH_TOHIT | ENCH_TODAM);
                  }
                  else
Only in angband-279v6+/src: cmd6.c~
Only in angband-279v6+/src: cmd6.o
diff -c angband-279v6/src/config.h angband-279v6+/src/config.h
*** angband-279v6/src/config.h	Sat Apr 13 11:24:29 1996
--- angband-279v6+/src/config.h	Thu Jul 25 11:32:02 1996
***************
*** 90,96 ****
  /*
   * OPTION: Include "ncurses.h" instead of "curses.h" in "main-gcu.c"
   */
! /* #define USE_NCURSES */
  
  
  /*
--- 90,96 ----
  /*
   * OPTION: Include "ncurses.h" instead of "curses.h" in "main-gcu.c"
   */
! #define USE_NCURSES
  
  
  /*
***************
*** 169,174 ****
--- 169,178 ----
  /* #define VERIFY_SAVEFILE */
  
  
+ /*
+  * OPTION: Allow generation of double ego items
+  */
+ #define ALLOW_DOUBLE_EGO
  
  /*
   * OPTION: Hack -- Compile in support for "Cyborg" mode
***************
*** 178,189 ****
  /*
   * OPTION: Hack -- Compile in support for "Wizard Commands"
   */
! /* #define ALLOW_WIZARD */
  
  /*
   * OPTION: Hack -- Compile in support for "Spoiler Generation"
   */
! /* #define ALLOW_SPOILERS */
  
  
  /*
--- 182,193 ----
  /*
   * OPTION: Hack -- Compile in support for "Wizard Commands"
   */
! #define ALLOW_WIZARD
  
  /*
   * OPTION: Hack -- Compile in support for "Spoiler Generation"
   */
! #define ALLOW_SPOILERS
  
  
  /*
Only in angband-279v6+/src: config.h~
diff -c angband-279v6/src/defines.h angband-279v6+/src/defines.h
*** angband-279v6/src/defines.h	Sun Apr 14 20:10:27 1996
--- angband-279v6+/src/defines.h	Thu Jul 25 08:43:15 1996
***************
*** 2199,2214 ****
  
  
  /*
!  * Artifacts use the "name1" field
   */
  #define artifact_p(T) \
!         ((T)->name1 ? TRUE : FALSE)
  
  /*
!  * Ego-Items use the "name2" field
   */
  #define ego_item_p(T) \
          ((T)->name2 ? TRUE : FALSE)
  
  
  /*
--- 2199,2220 ----
  
  
  /*
!  * Artifacts use the "name1" field, and their "name2" is zero.
   */
  #define artifact_p(T) \
!         (((T)->name1 && !(T)->name2) ? TRUE : FALSE)
  
  /*
!  * Ego-items use the "name2" field; double ego items may also use "name1".
   */
  #define ego_item_p(T) \
          ((T)->name2 ? TRUE : FALSE)
+ 
+ /*
+  * Double ego-items use both the name1 and name2 fields.
+  */
+ #define double_ego_item_p(T) \
+         (((T)->name1 && (T)->name2) ? TRUE : FALSE)
  
  
  /*
Only in angband-279v6+/src: defines.h~
Only in angband-279v6+/src: dungeon.o
Only in angband-279v6+/src: files.o
Only in angband-279v6+/src: generate.o
Only in angband-279v6+/src: h-config.h~
Only in angband-279v6+/src: init1.o
Only in angband-279v6+/src: init2.o
Only in angband-279v6+/src: load1.o
Only in angband-279v6+/src: load2.o
Only in angband-279v6+/src: main-cap.o
Only in angband-279v6+/src: main-gcu.o
Only in angband-279v6+/src: main-x11.o
Only in angband-279v6+/src: main-xaw.o
Only in angband-279v6+/src: main.o
Only in angband-279v6+/src: melee1.o
Only in angband-279v6+/src: melee2.o
Only in angband-279v6+/src: monster1.o
Only in angband-279v6+/src: monster2.o
diff -c angband-279v6/src/object1.c angband-279v6+/src/object1.c
*** angband-279v6/src/object1.c	Sat Apr 13 11:32:07 1996
--- angband-279v6+/src/object1.c	Thu Jul 25 09:05:23 1996
***************
*** 803,809 ****
      (*f3) = k_ptr->flags3;
  
      /* Artifact */
!     if (i_ptr->name1)
      {
          artifact_type *a_ptr = &a_info[i_ptr->name1];
  
--- 803,809 ----
      (*f3) = k_ptr->flags3;
  
      /* Artifact */
!     if (artifact_p(i_ptr))
      {
          artifact_type *a_ptr = &a_info[i_ptr->name1];
  
***************
*** 813,819 ****
      }
  
      /* Ego-item */
!     if (i_ptr->name2)
      {
          ego_item_type *e_ptr = &e_info[i_ptr->name2];
  
--- 813,819 ----
      }
  
      /* Ego-item */
!     if (ego_item_p(i_ptr))
      {
          ego_item_type *e_ptr = &e_info[i_ptr->name2];
  
***************
*** 820,827 ****
--- 820,839 ----
          (*f1) |= e_ptr->flags1;
          (*f2) |= e_ptr->flags2;
          (*f3) |= e_ptr->flags3;
+ 	
+ 	/* Double ego-item */
+ 	if (double_ego_item_p(i_ptr))
+ 	{
+ 	    e_ptr = &e_info[i_ptr->name1];
+ 	    
+ 	    (*f1) |= e_ptr->flags1;
+ 	    (*f2) |= e_ptr->flags2;
+ 	    (*f3) |= e_ptr->flags3;
+ 	    
+ 	}
      }
  
+ 
      /* Extra powers */
      switch (i_ptr->xtra1)
      {
***************
*** 1397,1403 ****
      if (known)
      {
          /* Grab any artifact name */
!         if (i_ptr->name1)
          {
              artifact_type *a_ptr = &a_info[i_ptr->name1];
  
--- 1409,1415 ----
      if (known)
      {
          /* Grab any artifact name */
!         if (artifact_p(i_ptr))
          {
              artifact_type *a_ptr = &a_info[i_ptr->name1];
  
***************
*** 1406,1417 ****
          }
  
          /* Grab any ego-item name */
!         else if (i_ptr->name2)
          {
              ego_item_type *e_ptr = &e_info[i_ptr->name2];
  
              t = object_desc_chr(t, ' ');
              t = object_desc_str(t, (e_name + e_ptr->name));
          }
      }
  
--- 1418,1437 ----
          }
  
          /* Grab any ego-item name */
!         else if (ego_item_p(i_ptr))
          {
              ego_item_type *e_ptr = &e_info[i_ptr->name2];
  
              t = object_desc_chr(t, ' ');
              t = object_desc_str(t, (e_name + e_ptr->name));
+ 
+ 	    if (double_ego_item_p(i_ptr))
+ 	    {
+ 		e_ptr = &e_info[i_ptr->name1];
+ 
+ 		t = object_desc_chr(t, ' ');
+ 		t = object_desc_str(t, (e_name + e_ptr->name));
+ 	    }
          }
      }
  
Only in angband-279v6+/src: object1.c~
Only in angband-279v6+/src: object1.o
diff -c angband-279v6/src/object2.c angband-279v6+/src/object2.c
*** angband-279v6/src/object2.c	Sat Apr 13 11:32:37 1996
--- angband-279v6+/src/object2.c	Thu Jul 25 15:05:31 1996
***************
*** 569,575 ****
  
  
      /* Artifact */
!     if (i_ptr->name1)
      {
          artifact_type *a_ptr = &a_info[i_ptr->name1];
  
--- 569,575 ----
  
  
      /* Artifact */
!     if (artifact_p(i_ptr))
      {
          artifact_type *a_ptr = &a_info[i_ptr->name1];
  
***************
*** 581,587 ****
      }
  
      /* Ego-Item */
!     else if (i_ptr->name2)
      {
          ego_item_type *e_ptr = &e_info[i_ptr->name2];
  
--- 581,587 ----
      }
  
      /* Ego-Item */
!     else if (ego_item_p(i_ptr))
      {
          ego_item_type *e_ptr = &e_info[i_ptr->name2];
  
***************
*** 590,595 ****
--- 590,606 ----
  
          /* Hack -- Reward the ego-item with a bonus */
          value += e_ptr->cost;
+ 
+ 	if (double_ego_item_p(i_ptr))
+ 	{
+ 	    e_ptr = &e_info[i_ptr->name1];
+ 
+ 	    /* Hack -- "worthless" ego-items */
+ 	    if (!e_ptr->cost) return (0L);
+ 	    
+ 	    /* Hack -- Reward the ego-item with a bonus */
+ 	    value += e_ptr->cost;
+ 	}
      }
  
  
***************
*** 921,932 ****
              /* Require identical "pval" code */
              if (i_ptr->pval != j_ptr->pval) return (FALSE);
  
!             /* Require identical "artifact" names */
!             if (i_ptr->name1 != j_ptr->name1) return (FALSE);
  
-             /* Require identical "ego-item" names */
-             if (i_ptr->name2 != j_ptr->name2) return (FALSE);
- 
              /* Hack -- Never stack "powerful" items */
              if (i_ptr->xtra1 || j_ptr->xtra1) return (FALSE);
  
--- 932,941 ----
              /* Require identical "pval" code */
              if (i_ptr->pval != j_ptr->pval) return (FALSE);
  
!             /* Require identical artifact and ego-item names */
!             if ((i_ptr->name1 != j_ptr->name1) ||
! 		(i_ptr->name2 != j_ptr->name2)) return (FALSE);
  
              /* Hack -- Never stack "powerful" items */
              if (i_ptr->xtra1 || j_ptr->xtra1) return (FALSE);
  
***************
*** 1278,1284 ****
  
  
  /*
!  * Attempt to change an object into an artifact
   *
   * This routine should only be called by "apply_magic()"
   *
--- 1287,1294 ----
  
  
  /*
!  * Attempt to change an object into an artifact.  If successful, initialize
!  * the object and return TRUE.  Otherwise no changes made and FALSE return.
   *
   * This routine should only be called by "apply_magic()"
   *
***************
*** 1288,1294 ****
  {
      int i;
  
- 
      /* No artifacts in the town */
      if (!dun_level) return (FALSE);
  
--- 1298,1303 ----
***************
*** 1323,1332 ****
          /* We must make the "rarity roll" */
          if (rand_int(a_ptr->rarity) != 0) continue;
  
          /* Hack -- mark the item as an artifact */
          i_ptr->name1 = i;
  
!         /* Success */
          return (TRUE);
      }
  
--- 1332,1373 ----
          /* We must make the "rarity roll" */
          if (rand_int(a_ptr->rarity) != 0) continue;
  
+         /* Success! */
+ 
          /* Hack -- mark the item as an artifact */
          i_ptr->name1 = i;
  
!         /* Hack -- Mark the artifact as "created" */
!         a_ptr->cur_num = 1;
! 
!         /* Extract the other fields */
!         i_ptr->pval = a_ptr->pval;
!         i_ptr->ac = a_ptr->ac;
!         i_ptr->dd = a_ptr->dd;
!         i_ptr->ds = a_ptr->ds;
!         i_ptr->to_a = a_ptr->to_a;
!         i_ptr->to_h = a_ptr->to_h;
!         i_ptr->to_d = a_ptr->to_d;
!         i_ptr->weight = a_ptr->weight;
! 
!         /* Hack -- extract the "broken" flag */
!         if (!a_ptr->cost) i_ptr->ident |= ID_BROKEN;
! 
!         /* Hack -- extract the "cursed" flag */
!         if (a_ptr->flags3 & TR3_CURSED) i_ptr->ident |= ID_CURSED;
! 
!         /* Mega-Hack -- increase the level rating */
!         rating += 10;
! 
!         /* Mega-Hack -- increase the rating again */
!         if (a_ptr->cost > 50000L) rating += 10;
! 
!         /* Set the good item flag */
!         good_item_flag = TRUE;
! 
!         /* Cheat -- peek at the item */
!         if (cheat_peek) object_mention(i_ptr);
! 
          return (TRUE);
      }
  
***************
*** 1417,1439 ****
  }
  
  
  
  /*
   * Apply magic to an item known to be a "weapon"
   *
-  * Hack -- note special base damage dice boosting
   * Hack -- note special processing for weapon/digger
-  * Hack -- note special rating boost for dragon scale mail
   */
! static void a_m_aux_1(object_type *i_ptr, int level, int power)
  {
!     int tohit1 = randint(5) + m_bonus(5, level);
!     int todam1 = randint(5) + m_bonus(5, level);
  
!     int tohit2 = m_bonus(10, level);
!     int todam2 = m_bonus(10, level);
  
  
      /* Good */
      if (power > 0)
      {
--- 1458,1753 ----
  }
  
  
+ static void a_m_get_ego_weapon_type(object_type *i_ptr, int power)
+ {
+   /* */
+   if (power > 1) {
+     /* Analyze type */
+     switch (i_ptr->tval)
+       {
+       case TV_DIGGING:
+ 	/* Special Ego-weapon */
+ 	i_ptr->name2 = EGO_DIGGING;
+ 	break;
  
+       case TV_HAFTED:
+       case TV_POLEARM:
+       case TV_SWORD:
+ 	/* Roll for an ego-weapon */
+ 	switch (randint(29))
+ 	  {
+ 	  case 1:
+ 	    i_ptr->name2 = EGO_HA;
+ 	    break;
+ 	  case 2:
+ 	    i_ptr->name2 = EGO_DF;
+ 	    break;
+ 	  case 3:
+ 	    i_ptr->name2 = EGO_BRAND_ACID;
+ 	    break;
+ 	  case 4:
+ 	    i_ptr->name2 = EGO_BRAND_ELEC;
+ 	    break;
+ 	  case 5:
+ 	    i_ptr->name2 = EGO_BRAND_FIRE;
+ 	    break;
+ 	  case 6:
+ 	    i_ptr->name2 = EGO_BRAND_COLD;
+ 	    break;
+ 	  case 7: case 8:
+ 	    i_ptr->name2 = EGO_SLAY_ANIMAL;
+ 	    if (rand_int(100) < 20)
+ 	      {
+ 		i_ptr->name2 = EGO_KILL_ANIMAL;
+ 	      }
+ 	    break;
+ 	  case 9: case 10:
+ 	    i_ptr->name2 = EGO_SLAY_DRAGON;
+ 	    if (rand_int(100) < 20)
+ 	      {
+ 		i_ptr->name2 = EGO_KILL_DRAGON;
+ 	      }
+ 	    break;
+ 	  case 11: case 12:
+ 	    i_ptr->name2 = EGO_SLAY_EVIL;
+ 	    if (rand_int(100) < 20)
+ 	      {
+ 		i_ptr->name2 = EGO_KILL_EVIL;
+ 	      }
+ 	    break;
+ 	  case 13: case 14:
+ 	    i_ptr->name2 = EGO_SLAY_UNDEAD;
+ 	    if (rand_int(100) < 20)
+ 	      {
+ 		i_ptr->name2 = EGO_KILL_UNDEAD;
+ 	      }
+ 	    break;
+ 	  case 15: case 16: case 17:
+ 	    i_ptr->name2 = EGO_SLAY_ORC;
+ 	    if (rand_int(100) < 20)
+ 	      {
+ 		i_ptr->name2 = EGO_KILL_ORC;
+ 	      }
+ 	    break;
+ 	  case 18: case 19: case 20:
+ 	    i_ptr->name2 = EGO_SLAY_TROLL;
+ 	    if (rand_int(100) < 20)
+ 	      {
+ 		i_ptr->name2 = EGO_KILL_TROLL;
+ 	      }
+ 	    break;
+ 	  case 21: case 22: case 23:
+ 	    i_ptr->name2 = EGO_SLAY_GIANT;
+ 	    if (rand_int(100) < 20)
+ 	      {
+ 		i_ptr->name2 = EGO_KILL_GIANT;
+ 	      }
+ 	    break;
+ 	  case 24: case 25: case 26:
+ 	    i_ptr->name2 = EGO_SLAY_DEMON;
+ 	    if (rand_int(100) < 20)
+ 	      {
+ 		i_ptr->name2 = EGO_KILL_DEMON;
+ 	      }
+ 	    break;
+ 	  case 27:
+ 	    i_ptr->name2 = EGO_WEST;
+ 	    break;
+ 	  case 28:
+ 	    i_ptr->name2 = EGO_BLESS_BLADE;
+ 	    break;
+ 	  case 29:
+ 	    i_ptr->name2 = EGO_ATTACKS;
+ 	    break;
+ 	  }
+ 	break;
+ 
+         case TV_BOW:
+ 	switch (randint(10))
+ 	  {
+ 	  case 1:
+ 	    i_ptr->name2 = EGO_EXTRA_MIGHT;
+ 	    break;
+ 	  case 2:
+ 	    i_ptr->name2 = EGO_EXTRA_SHOTS;
+ 	    break;
+ 	  case 3: case 4: case 5: case 6:
+ 	    i_ptr->name2 = EGO_VELOCITY;
+ 	    break;
+ 	  case 7: case 8: case 9: case 10:
+ 	    i_ptr->name2 = EGO_ACCURACY;
+ 	    break;
+ 	  }
+ 	break;
+ 
+         case TV_BOLT:
+         case TV_ARROW:
+         case TV_SHOT:
+ 	switch (randint(10))
+ 	  {
+ 	  case 1: case 2: case 3:
+ 	    i_ptr->name2 = EGO_WOUNDING;
+ 	    break;
+ 	  case 4:
+ 	    i_ptr->name2 = EGO_FLAME;
+ 	    break;
+ 	  case 5:
+ 	    i_ptr->name2 = EGO_FROST;
+ 	    break;
+ 	  case 6: case 7:
+ 	    i_ptr->name2 = EGO_HURT_ANIMAL;
+ 	    break;
+ 	  case 8: case 9:
+ 	    i_ptr->name2 = EGO_HURT_EVIL;
+ 	    break;
+ 	  case 10:
+ 	    i_ptr->name2 = EGO_HURT_DRAGON;
+ 	    break;
+ 	  }
+ 	break;
+       }
+     return;
+   } /* if (power > 1) */
+ 
+   /*
+    * Assignment of cursed ego weapons.
+    */
+   if (power < -1) {
+     switch (i_ptr->tval)
+     {
+     case TV_DIGGING:
+       /* Hack -- Horrible digging bonus */
+       i_ptr->pval = 0 - (5 + randint(5));
+       /* Fall through -- digger of Morgul!  */
+ 
+     case TV_HAFTED:
+     case TV_POLEARM:
+     case TV_SWORD:
+       if (rand_int(MAX_DEPTH) < object_level)
+ 	{
+ 	  i_ptr->name2 = EGO_MORGUL;
+ 	}
+       break;
+ 
+     case TV_BOW:
+       break;
+ 
+     case TV_BOLT:
+     case TV_ARROW:
+     case TV_SHOT:
+       if (rand_int(MAX_DEPTH) < object_level)
+ 	{
+ 	  i_ptr->name2 = EGO_BACKBITING;
+ 	}
+       break;
+     }
+     return;
+   }  /* if (power < -1) */
+ }
+ 
+ 
+ static void a_m_ego(object_type *i_ptr)
+ {
+     /*
+      * Get pointer to template for this kind of ego item.
+      */
+     ego_item_type *e_ptr = &e_info[i_ptr->name2];
+ 
+     /* Hack -- Apply extra powers. */
+     switch (i_ptr->name2) {
+     case EGO_BLESS_BLADE:	/* Weapon (Blessed) */
+     case EGO_MAGI:		/* Crown of the Magi */
+       i_ptr->xtra1 |= EGO_XTRA_ABILITY;
+       break;
+ 
+     case EGO_AMAN:		/* Cloak of Aman */
+     case EGO_ELVENKIND:		/* Armor of Elvenkind */
+     case EGO_PERMANENCE:	/* Robe of Permanance */
+       i_ptr->xtra1 |= EGO_XTRA_POWER;
+       break;
+ 
+     case EGO_DF:		/* Weapon (Defender) */
+     case EGO_HA:		/* Weapon (Holy Avenger) */
+       i_ptr->xtra1 |= EGO_XTRA_SUSTAIN;
+       break;
+     }
+ 
+     /* Randomize the "xtra" power */
+     if (i_ptr->xtra1) i_ptr->xtra2 = randint(256);
+     
+     /* Hack -- acquire "broken" flag */
+     if (!e_ptr->cost) i_ptr->ident |= ID_BROKEN;
+     
+     /* Hack -- acquire "cursed" flag */
+     if (e_ptr->flags3 & TR3_CURSED) i_ptr->ident |= ID_CURSED;
+     
+     /* Hack -- apply extra penalties if needed */
+     if (cursed_p(i_ptr) || broken_p(i_ptr))
+       {
+ 	/* Hack -- obtain bonuses */
+ 	if (e_ptr->max_to_h) i_ptr->to_h -= randint(e_ptr->max_to_h);
+ 	if (e_ptr->max_to_d) i_ptr->to_d -= randint(e_ptr->max_to_d);
+ 	if (e_ptr->max_to_a) i_ptr->to_a -= randint(e_ptr->max_to_a);
+ 
+ 	/* Hack -- obtain pval */
+ 	if (e_ptr->max_pval) i_ptr->pval -= randint(e_ptr->max_pval);
+       }
+     /* Hack -- apply extra bonuses if needed */
+     else
+       {
+ 	/* Hack -- obtain bonuses */
+ 	if (e_ptr->max_to_h) i_ptr->to_h += randint(e_ptr->max_to_h);
+ 	if (e_ptr->max_to_d) i_ptr->to_d += randint(e_ptr->max_to_d);
+ 	if (e_ptr->max_to_a) i_ptr->to_a += randint(e_ptr->max_to_a);
+ 
+ 	/* Hack -- obtain pval */
+ 	if (e_ptr->max_pval) i_ptr->pval += randint(e_ptr->max_pval);
+       }
+     
+ }
+ 
+ 
  /*
   * Apply magic to an item known to be a "weapon"
   *
   * Hack -- note special processing for weapon/digger
   */
! static void a_m_weapon(object_type *i_ptr, int level, int power)
  {
!     int tohit1, todam1, tohit2, todam2;
  
!     /*
!      * Get the ego weapon type: 
!      */
!     a_m_get_ego_weapon_type(i_ptr, power);
  
+     /* 
+      * Supercharge damage dice for all weapons except bows.
+      * Note that this will supercharge any weapon, not just ego ones.
+      * In particular, it allows both {good} weapons AND weapons of morgul
+      * to supercharge, thereby making it impossible to know _a_priori_
+      * whether a supercharged item is a good ego item, a bad one, or a normal
+      * one.  Supercharged normal items may be slightly useful even to 
+      * high level characters.
+      */
+     if (i_ptr->tval != TV_BOW)
+       {
+ 	/* Super-charge the damage dice */
+ 	while (rand_int(10L + (1 + i_ptr->dd) * i_ptr->ds) == 0) 
+ 	  i_ptr->dd++;
+ 	/* Hack -- Cap damage dice at 9. */
+ 	if (i_ptr->dd > 9) 
+ 	  i_ptr->dd = 9;
+       }
  
+     /*
+      * Add extra plusses to hit and damage 
+      */
+     tohit1 = randint(5) + m_bonus(5, level);
+     todam1 = randint(5) + m_bonus(5, level);
+     tohit2 = m_bonus(10, level);
+     todam2 = m_bonus(10, level);
+     
      /* Good */
      if (power > 0)
      {
***************
*** 1449,1455 ****
              i_ptr->to_d += todam2;
          }
      }
- 
      /* Cursed */
      else if (power < 0)
      {
--- 1763,1768 ----
***************
*** 1469,1721 ****
          if (i_ptr->to_h + i_ptr->to_d < 0) i_ptr->ident |= ID_CURSED;
      }
  
  
-     /* Analyze type */
-     switch (i_ptr->tval)
-     {
-         case TV_DIGGING:
  
-             /* Very good */
-             if (power > 1)
-             {
-                 /* Special Ego-item */
-                 i_ptr->name2 = EGO_DIGGING;
-             }
  
!             /* Bad */
!             else if (power < 0)
!             {
!                 /* Hack -- Reverse digging bonus */
!                 i_ptr->pval = 0 - (i_ptr->pval);
!             }
  
!             /* Very bad */
!             else if (power < -1)
!             {
!                 /* Hack -- Horrible digging bonus */
!                 i_ptr->pval = 0 - (5 + randint(5));
!             }
  
!             break;
  
  
!         case TV_HAFTED:
!         case TV_POLEARM:
!         case TV_SWORD:
  
!             /* Very Good */
!             if (power > 1)
!             {
!                 /* Roll for an ego-item */
!                 switch (randint(29))
!                 {
!                     case 1:
!                         i_ptr->name2 = EGO_HA;
!                         break;
  
!                     case 2:
!                         i_ptr->name2 = EGO_DF;
!                         break;
  
!                     case 3:
!                         i_ptr->name2 = EGO_BRAND_ACID;
!                         break;
  
!                     case 4:
!                         i_ptr->name2 = EGO_BRAND_ELEC;
!                         break;
  
!                     case 5:
!                         i_ptr->name2 = EGO_BRAND_FIRE;
!                         break;
  
!                     case 6:
!                         i_ptr->name2 = EGO_BRAND_COLD;
!                         break;
  
!                     case 7: case 8:
!                         i_ptr->name2 = EGO_SLAY_ANIMAL;
!                         if (rand_int(100) < 20)
!                         {
!                             i_ptr->name2 = EGO_KILL_ANIMAL;
!                         }
!                         break;
  
!                     case 9: case 10:
!                         i_ptr->name2 = EGO_SLAY_DRAGON;
!                         if (rand_int(100) < 20)
!                         {
!                             i_ptr->name2 = EGO_KILL_DRAGON;
!                         }
!                         break;
  
-                     case 11: case 12:
-                         i_ptr->name2 = EGO_SLAY_EVIL;
-                         if (rand_int(100) < 20)
-                         {
-                             i_ptr->name2 = EGO_KILL_EVIL;
-                         }
-                         break;
  
-                     case 13: case 14:
-                         i_ptr->name2 = EGO_SLAY_UNDEAD;
-                         if (rand_int(100) < 20)
-                         {
-                             i_ptr->name2 = EGO_KILL_UNDEAD;
-                         }
-                         break;
- 
-                     case 15: case 16: case 17:
-                         i_ptr->name2 = EGO_SLAY_ORC;
-                         if (rand_int(100) < 20)
-                         {
-                             i_ptr->name2 = EGO_KILL_ORC;
-                         }
-                         break;
- 
-                     case 18: case 19: case 20:
-                         i_ptr->name2 = EGO_SLAY_TROLL;
-                         if (rand_int(100) < 20)
-                         {
-                             i_ptr->name2 = EGO_KILL_TROLL;
-                         }
-                         break;
- 
-                     case 21: case 22: case 23:
-                         i_ptr->name2 = EGO_SLAY_GIANT;
-                         if (rand_int(100) < 20)
-                         {
-                             i_ptr->name2 = EGO_KILL_GIANT;
-                         }
-                         break;
- 
-                     case 24: case 25: case 26:
-                         i_ptr->name2 = EGO_SLAY_DEMON;
-                         if (rand_int(100) < 20)
-                         {
-                             i_ptr->name2 = EGO_KILL_DEMON;
-                         }
-                         break;
- 
-                     case 27:
-                         i_ptr->name2 = EGO_WEST;
-                         break;
- 
-                     case 28:
-                         i_ptr->name2 = EGO_BLESS_BLADE;
-                         break;
- 
-                     case 29:
-                         i_ptr->name2 = EGO_ATTACKS;
-                         break;
-                 }
- 
-                 /* Hack -- Super-charge the damage dice */
-                 while (rand_int(10L * i_ptr->dd * i_ptr->ds) == 0) i_ptr->dd++;
- 
-                 /* Hack -- Lower the damage dice */
-                 if (i_ptr->dd > 9) i_ptr->dd = 9;
-             }
- 
-             /* Very cursed */
-             else if (power < -1)
-             {
-                 /* Roll for ego-item */
-                 if (rand_int(MAX_DEPTH) < level)
-                 {
-                     i_ptr->name2 = EGO_MORGUL;
-                 }
-             }
- 
-             break;
- 
- 
-         case TV_BOW:
- 
-             /* Very good */
-             if (power > 1)
-             {
-                 /* Roll for ego-item */
-                 switch (randint(10))
-                 {
-                     case 1:
-                         i_ptr->name2 = EGO_EXTRA_MIGHT;
-                         break;
- 
-                     case 2:
-                         i_ptr->name2 = EGO_EXTRA_SHOTS;
-                         break;
- 
-                     case 3: case 4: case 5: case 6:
-                         i_ptr->name2 = EGO_VELOCITY;
-                         break;
- 
-                     case 7: case 8: case 9: case 10:
-                         i_ptr->name2 = EGO_ACCURACY;
-                         break;
-                 }
-             }
- 
-             break;
- 
- 
-         case TV_BOLT:
-         case TV_ARROW:
-         case TV_SHOT:
- 
-             /* Very good */
-             if (power > 1)
-             {
-                 /* Roll for ego-item */
-                 switch (randint(10))
-                 {
-                     case 1: case 2: case 3:
-                         i_ptr->name2 = EGO_WOUNDING;
-                         break;
- 
-                     case 4:
-                         i_ptr->name2 = EGO_FLAME;
-                         break;
- 
-                     case 5:
-                         i_ptr->name2 = EGO_FROST;
-                         break;
- 
-                     case 6: case 7:
-                         i_ptr->name2 = EGO_HURT_ANIMAL;
-                         break;
- 
-                     case 8: case 9:
-                         i_ptr->name2 = EGO_HURT_EVIL;
-                         break;
- 
-                     case 10:
-                         i_ptr->name2 = EGO_HURT_DRAGON;
-                         break;
-                 }
- 
-                 /* Hack -- super-charge the damage dice */
-                 while (rand_int(10L * i_ptr->dd * i_ptr->ds) == 0) i_ptr->dd++;
- 
-                 /* Hack -- restrict the damage dice */
-                 if (i_ptr->dd > 9) i_ptr->dd = 9;
-             }
- 
-             /* Very cursed */
-             else if (power < -1)
-             {
-                 /* Roll for ego-item */
-                 if (rand_int(MAX_DEPTH) < level)
-                 {
-                     i_ptr->name2 = EGO_BACKBITING;
-                 }
-             }
- 
-             break;
-     }
- }
- 
- 
  /*
   * Apply magic to an item known to be "armor"
   *
--- 1782,2056 ----
          if (i_ptr->to_h + i_ptr->to_d < 0) i_ptr->ident |= ID_CURSED;
      }
  
+     /*
+      * Further processing only for ego-items. */
+     if (ego_item_p(i_ptr))
+       a_m_ego(i_ptr);
+ }
  
  
  
! static void a_m_get_ego_armor_type(object_type *i_ptr, int power)
! {
!   /* */
!   if (power > 1) {
!     /* 
!      * Good stuff
!      */
!     switch (i_ptr->tval)
!       {
!       case TV_DRAG_ARMOR:
! 	/* Rating boost */
! 	rating += 30;
! 	break;
  
!       case TV_HARD_ARMOR:
!       case TV_SOFT_ARMOR:
! 	/* Hack -- Try for "Robes of the Magi" */
! 	if ((i_ptr->tval == TV_SOFT_ARMOR) &&
! 	    (i_ptr->sval == SV_ROBE) &&
! 	    (rand_int(100) < 10))
! 	  {
! 	    i_ptr->name2 = EGO_PERMANENCE;
! 	    break;
! 	  }
  
! 	/* Roll for ego-item */
! 	switch (randint(19))
! 	  {
! 	  case 1: case 2: case 3: case 4:
! 	    i_ptr->name2 = EGO_RESIST_ACID;
! 	    break;
! 	  case 5: case 6: case 7: case 8:
! 	    i_ptr->name2 = EGO_RESIST_ELEC;
! 	    break;
! 	  case 9: case 10: case 11: case 12:
! 	    i_ptr->name2 = EGO_RESIST_FIRE;
! 	    break;
! 	  case 13: case 14: case 15: case 16:
! 	    i_ptr->name2 = EGO_RESIST_COLD;
! 	    break;
! 	  case 17: case 18:
! 	    i_ptr->name2 = EGO_RESISTANCE;
! 	    break;
! 	  default:
! 	    i_ptr->name2 = EGO_ELVENKIND;
! 	    break;
! 	  }
! 	break;
  
+         case TV_SHIELD:
+ 	/* Roll for ego-item */
+ 	switch (randint(10))
+ 	  {
+ 	  case 1:
+ 	    i_ptr->name2 = EGO_ENDURE_ACID;
+ 	    break;
+ 	  case 2: case 3: case 4:
+ 	    i_ptr->name2 = EGO_ENDURE_ELEC;
+ 	    break;
+ 	  case 5: case 6:
+ 	    i_ptr->name2 = EGO_ENDURE_FIRE;
+ 	    break;
+ 	  case 7: case 8: case 9:
+ 	    i_ptr->name2 = EGO_ENDURE_COLD;
+ 	    break;
+ 	  default:
+ 	    i_ptr->name2 = EGO_ENDURANCE;
+ 	    break;
+ 	  }
+ 	break;
  
!         case TV_GLOVES:
! 	switch (randint(10))
! 	  {
! 	  case 1: case 2: case 3: case 4:
! 	    i_ptr->name2 = EGO_FREE_ACTION;
! 	    break;
! 	  case 5: case 6: case 7:
! 	    i_ptr->name2 = EGO_SLAYING;
! 	    break;
! 	  case 8: case 9:
! 	    i_ptr->name2 = EGO_AGILITY;
! 	    break;
! 	  case 10:
! 	    i_ptr->name2 = EGO_POWER;
! 	    break;
! 	  }
! 	break;
  
!         case TV_BOOTS:
! 	switch (randint(24))
! 	  {
! 	  case 1:
! 	    i_ptr->name2 = EGO_SPEED;
! 	    break;
! 	  case 2: case 3: case 4: case 5:
! 	    i_ptr->name2 = EGO_MOTION;
! 	    break;
! 	  case 6: case 7: case 8: case 9:
! 	  case 10: case 11: case 12: case 13:
! 	    i_ptr->name2 = EGO_QUIET;
! 	    break;
! 	  default:
! 	    i_ptr->name2 = EGO_SLOW_DESCENT;
! 	    break;
! 	  }
! 	break;
  
!         case TV_CROWN:
! 	switch (randint(8))
! 	  {
! 	  case 1:
! 	    i_ptr->name2 = EGO_MAGI;
! 	    break;
! 	  case 2:
! 	    i_ptr->name2 = EGO_MIGHT;
! 	    break;
! 	  case 3:
! 	    i_ptr->name2 = EGO_TELEPATHY;
! 	    break;
! 	  case 4:
! 	    i_ptr->name2 = EGO_REGENERATION;
! 	    break;
! 	  case 5: case 6:
! 	    i_ptr->name2 = EGO_LORDLINESS;
! 	    break;
! 	  default:
! 	    i_ptr->name2 = EGO_SEEING;
! 	    break;
! 	  }
! 	break;
  
!         case TV_HELM:
! 	switch (randint(14))
! 	  {
! 	  case 1: case 2:
! 	    i_ptr->name2 = EGO_INTELLIGENCE;
! 	    break;
! 	  case 3: case 4:
! 	    i_ptr->name2 = EGO_WISDOM;
! 	    break;
! 	  case 5: case 6:
! 	    i_ptr->name2 = EGO_BEAUTY;
! 	    break;
! 	  case 7: case 8:
! 	    i_ptr->name2 = EGO_SEEING;
! 	    break;
! 	  case 9: case 10:
! 	    i_ptr->name2 = EGO_LITE;
! 	    break;
! 	  default:
! 	    i_ptr->name2 = EGO_INFRAVISION;
! 	    break;
! 	  }
! 	break;
  
!         case TV_CLOAK:
! 	switch (randint(17))
! 	  {
! 	  case 1: case 2: case 3: case 4:
! 	  case 5: case 6: case 7: case 8:
! 	    i_ptr->name2 = EGO_PROTECTION;
! 	    break;
  
! 	  case 9: case 10: case 11: case 12:
! 	  case 13: case 14: case 15: case 16:
! 	    i_ptr->name2 = EGO_STEALTH;
! 	    break;
  
! 	  case 17:
! 	    i_ptr->name2 = EGO_AMAN;
! 	    break;
! 	  }
! 	break;
!       } /* switch */
!     return;
!   } /* if */
  
!   if (power < -1) {
!     /*
!      * Curses!
!      */
!     switch (i_ptr->tval)
!       {
!       case TV_DRAG_ARMOR:
! 	/* Hack.  Rating boost */
! 	rating += 30;
!       case TV_HARD_ARMOR:
!       case TV_SOFT_ARMOR:
! 	/* (There are currently no cursed ego items of these types) */
! 	break;
  
!       case TV_GLOVES:
! 	switch (randint(2))
! 	  {
! 	  case 1:
! 	    i_ptr->name2 = EGO_CLUMSINESS;
! 	    break;
! 	  default:
! 	    i_ptr->name2 = EGO_WEAKNESS;
! 	    break;
! 	  }
! 	break;
! 	
!       case TV_BOOTS:
! 	switch (randint(3))
! 	  {
! 	  case 1:
! 	    i_ptr->name2 = EGO_NOISE;
! 	    break;
! 	  case 2:
! 	    i_ptr->name2 = EGO_SLOWNESS;
! 	    break;
! 	  case 3:
! 	    i_ptr->name2 = EGO_ANNOYANCE;
! 	    break;
! 	  }
! 	break;
! 	
!       case TV_CROWN:
!       case TV_HELM:
! 	switch (randint(7))
! 	  {
! 	  case 1: case 2:
! 	    i_ptr->name2 = EGO_STUPIDITY;
! 	    break;
! 	  case 3: case 4:
! 	    i_ptr->name2 = EGO_NAIVETY;
! 	    break;
! 	  case 5:
! 	    i_ptr->name2 = EGO_UGLINESS;
! 	    break;
! 	  case 6:
! 	    i_ptr->name2 = EGO_SICKLINESS;
! 	    break;
! 	  case 7:
! 	    i_ptr->name2 = EGO_TELEPORTATION;
! 	    break;
! 	  }
! 	break;
! 	
!       case TV_CLOAK:
! 	/* Choose some damage */
! 	switch (randint(3))
! 	  {
! 	  case 1:
! 	    i_ptr->name2 = EGO_IRRITATION;
! 	    break;
! 	  case 2:
! 	    i_ptr->name2 = EGO_VULNERABILITY;
! 	    break;
! 	  case 3:
! 	    i_ptr->name2 = EGO_ENVELOPING;
! 	    break;
! 	  }
! 	break;
!       } /* switch */
!   } /* if */
! } /* function */
  
  
  /*
   * Apply magic to an item known to be "armor"
   *
***************
*** 1722,1736 ****
   * Hack -- note special processing for crown/helm
   * Hack -- note special processing for robe of permanence
   */
! static void a_m_aux_2(object_type *i_ptr, int level, int power)
  {
!     int toac1 = randint(5) + m_bonus(5, level);
  
!     int toac2 = m_bonus(10, level);
  
  
!     /* Good */
!     if (power > 0)
      {
          /* Enchant */
          i_ptr->to_a += toac1;
--- 2057,2079 ----
   * Hack -- note special processing for crown/helm
   * Hack -- note special processing for robe of permanence
   */
! static void a_m_armor(object_type *i_ptr, int level, int power)
  {
!     int toac1, toac2;
  
!     /*
!      * Determine type of ego armor, if it is an ego-item.
!      */
!     a_m_get_ego_armor_type(i_ptr, power);
  
+     
+     /*
+      * Get extra armor bonuses
+      */
+     toac1 = randint(5) + m_bonus(5, level);
+     toac2 = m_bonus(10, level);
  
!     if (power > 0)    /* Good */
      {
          /* Enchant */
          i_ptr->to_a += toac1;
***************
*** 1742,1750 ****
              i_ptr->to_a += toac2;
          }
      }
! 
!     /* Cursed */
!     else if (power < 0)
      {
          /* Penalize */
          i_ptr->to_a -= toac1;
--- 2085,2091 ----
              i_ptr->to_a += toac2;
          }
      }
!     else if (power < 0)    /* Cursed */
      {
          /* Penalize */
          i_ptr->to_a -= toac1;
***************
*** 1760,2118 ****
          if (i_ptr->to_a < 0) i_ptr->ident |= ID_CURSED;
      }
  
! 
!     /* Analyze type */
!     switch (i_ptr->tval)
!     {
!         case TV_DRAG_ARMOR:
! 
!             /* Rating boost */
!             rating += 30;
! 
!             /* Mention the item */
!             if (cheat_peek) object_mention(i_ptr);
! 
!             break;
! 
! 
!         case TV_HARD_ARMOR:
!         case TV_SOFT_ARMOR:
! 
!             /* Very good */
!             if (power > 1)
!             {
!                 /* Hack -- Try for "Robes of the Magi" */
!                 if ((i_ptr->tval == TV_SOFT_ARMOR) &&
!                     (i_ptr->sval == SV_ROBE) &&
!                     (rand_int(100) < 10))
!                 {
!                     i_ptr->name2 = EGO_PERMANENCE;
!                     break;
!                 }
! 
!                 /* Roll for ego-item */
!                 switch (randint(19))
!                 {
!                     case 1: case 2: case 3: case 4:
!                         i_ptr->name2 = EGO_RESIST_ACID;
!                         break;
! 
!                     case 5: case 6: case 7: case 8:
!                         i_ptr->name2 = EGO_RESIST_ELEC;
!                         break;
! 
!                     case 9: case 10: case 11: case 12:
!                         i_ptr->name2 = EGO_RESIST_FIRE;
!                         break;
! 
!                     case 13: case 14: case 15: case 16:
!                         i_ptr->name2 = EGO_RESIST_COLD;
!                         break;
! 
!                     case 17: case 18:
!                         i_ptr->name2 = EGO_RESISTANCE;
!                         break;
! 
!                     default:
!                         i_ptr->name2 = EGO_ELVENKIND;
!                         break;
!                 }
!             }
! 
!             break;
! 
! 
!         case TV_SHIELD:
! 
!             /* Very good */
!             if (power > 1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(10))
!                 {
!                     case 1:
!                         i_ptr->name2 = EGO_ENDURE_ACID;
!                         break;
! 
!                     case 2: case 3: case 4:
!                         i_ptr->name2 = EGO_ENDURE_ELEC;
!                         break;
! 
!                     case 5: case 6:
!                         i_ptr->name2 = EGO_ENDURE_FIRE;
!                         break;
! 
!                     case 7: case 8: case 9:
!                         i_ptr->name2 = EGO_ENDURE_COLD;
!                         break;
! 
!                     default:
!                         i_ptr->name2 = EGO_ENDURANCE;
!                         break;
!                 }
!             }
! 
!             break;
! 
! 
!         case TV_GLOVES:
! 
!             /* Very good */
!             if (power > 1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(10))
!                 {
!                     case 1: case 2: case 3: case 4:
!                         i_ptr->name2 = EGO_FREE_ACTION;
!                         break;
! 
!                     case 5: case 6: case 7:
!                         i_ptr->name2 = EGO_SLAYING;
!                         break;
! 
!                     case 8: case 9:
!                         i_ptr->name2 = EGO_AGILITY;
!                         break;
! 
!                     case 10:
!                         i_ptr->name2 = EGO_POWER;
!                         break;
!                 }
!             }
! 
!             /* Very cursed */
!             else if (power < -1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(2))
!                 {
!                     case 1:
!                         i_ptr->name2 = EGO_CLUMSINESS;
!                         break;
!                     default:
!                         i_ptr->name2 = EGO_WEAKNESS;
!                         break;
!                 }
!             }
! 
!             break;
! 
! 
!         case TV_BOOTS:
! 
!             /* Very good */
!             if (power > 1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(24))
!                 {
!                     case 1:
!                         i_ptr->name2 = EGO_SPEED;
!                         break;
! 
!                     case 2: case 3: case 4: case 5:
!                         i_ptr->name2 = EGO_MOTION;
!                         break;
! 
!                     case 6: case 7: case 8: case 9:
!                     case 10: case 11: case 12: case 13:
!                         i_ptr->name2 = EGO_QUIET;
!                         break;
! 
!                     default:
!                         i_ptr->name2 = EGO_SLOW_DESCENT;
!                         break;
!                 }
!             }
! 
!             /* Very cursed */
!             else if (power < -1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(3))
!                 {
!                     case 1:
!                         i_ptr->name2 = EGO_NOISE;
!                         break;
!                     case 2:
!                         i_ptr->name2 = EGO_SLOWNESS;
!                         break;
!                     case 3:
!                         i_ptr->name2 = EGO_ANNOYANCE;
!                         break;
!                 }
!             }
! 
!             break;
! 
! 
!         case TV_CROWN:
! 
!             /* Very good */
!             if (power > 1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(8))
!                 {
!                     case 1:
!                         i_ptr->name2 = EGO_MAGI;
!                         break;
! 
!                     case 2:
!                         i_ptr->name2 = EGO_MIGHT;
!                         break;
! 
!                     case 3:
!                         i_ptr->name2 = EGO_TELEPATHY;
!                         break;
! 
!                     case 4:
!                         i_ptr->name2 = EGO_REGENERATION;
!                         break;
! 
!                     case 5: case 6:
!                         i_ptr->name2 = EGO_LORDLINESS;
!                         break;
! 
!                     default:
!                         i_ptr->name2 = EGO_SEEING;
!                         break;
!                 }
!             }
! 
!             /* Very cursed */
!             else if (power < -1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(7))
!                 {
!                     case 1: case 2:
!                         i_ptr->name2 = EGO_STUPIDITY;
!                         break;
!                     case 3: case 4:
!                         i_ptr->name2 = EGO_NAIVETY;
!                         break;
!                     case 5:
!                         i_ptr->name2 = EGO_UGLINESS;
!                         break;
!                     case 6:
!                         i_ptr->name2 = EGO_SICKLINESS;
!                         break;
!                     case 7:
!                         i_ptr->name2 = EGO_TELEPORTATION;
!                         break;
!                 }
!             }
! 
!             break;
! 
! 
!         case TV_HELM:
! 
!             /* Very good */
!             if (power > 1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(14))
!                 {
!                     case 1: case 2:
!                         i_ptr->name2 = EGO_INTELLIGENCE;
!                         break;
! 
!                     case 3: case 4:
!                         i_ptr->name2 = EGO_WISDOM;
!                         break;
! 
!                     case 5: case 6:
!                         i_ptr->name2 = EGO_BEAUTY;
!                         break;
! 
!                     case 7: case 8:
!                         i_ptr->name2 = EGO_SEEING;
!                         break;
! 
!                     case 9: case 10:
!                         i_ptr->name2 = EGO_LITE;
!                         break;
! 
!                     default:
!                         i_ptr->name2 = EGO_INFRAVISION;
!                         break;
!                 }
!             }
! 
!             /* Very cursed */
!             else if (power < -1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(7))
!                 {
!                     case 1: case 2:
!                         i_ptr->name2 = EGO_STUPIDITY;
!                         break;
!                     case 3: case 4:
!                         i_ptr->name2 = EGO_NAIVETY;
!                         break;
!                     case 5:
!                         i_ptr->name2 = EGO_UGLINESS;
!                         break;
!                     case 6:
!                         i_ptr->name2 = EGO_SICKLINESS;
!                         break;
!                     case 7:
!                         i_ptr->name2 = EGO_TELEPORTATION;
!                         break;
!                 }
!             }
! 
!             break;
! 
! 
!         case TV_CLOAK:
! 
!             /* Very good */
!             if (power > 1)
!             {
!                 /* Roll for ego-item */
!                 switch (randint(17))
!                 {
!                     case 1: case 2: case 3: case 4:
!                     case 5: case 6: case 7: case 8:
!                         i_ptr->name2 = EGO_PROTECTION;
!                         break;
! 
!                     case 9: case 10: case 11: case 12:
!                     case 13: case 14: case 15: case 16:
!                         i_ptr->name2 = EGO_STEALTH;
!                         break;
! 
!                     case 17:
!                         i_ptr->name2 = EGO_AMAN;
!                         break;
!                 }
!             }
! 
!             /* Very cursed */
!             else if (power < -1)
!             {
!                 /* Choose some damage */
!                 switch (randint(3))
!                 {
!                     case 1:
!                         i_ptr->name2 = EGO_IRRITATION;
!                         break;
!                     case 2:
!                         i_ptr->name2 = EGO_VULNERABILITY;
!                         break;
!                     case 3:
!                         i_ptr->name2 = EGO_ENVELOPING;
!                         break;
!                 }
!             }
! 
!             break;
!     }
  }
  
  
--- 2101,2110 ----
          if (i_ptr->to_a < 0) i_ptr->ident |= ID_CURSED;
      }
  
!     /*
!      * Further processing only for ego-items. */
!     if (ego_item_p(i_ptr))
!       a_m_ego(i_ptr);
  }
  
  
***************
*** 2530,2542 ****
   */
  void apply_magic(object_type *i_ptr, int lev, bool okay, bool good, bool great)
  {
!     int i, rolls, f1, f2, power;
  
  
      /* Maximum "level" for various things */
!     if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
  
- 
      /* Base chance of being "good" */
      f1 = lev + 10;
  
--- 2522,2535 ----
   */
  void apply_magic(object_type *i_ptr, int lev, bool okay, bool good, bool great)
  {
!     int i, rolls, f1, f2, f3, power, power2;
!     object_type	forge, *i_ptr2 = &forge;
  
  
      /* Maximum "level" for various things */
!     if (lev > MAX_DEPTH - 1) 
!       lev = MAX_DEPTH - 1;
  
      /* Base chance of being "good" */
      f1 = lev + 10;
  
***************
*** 2549,2554 ****
--- 2542,2549 ----
      /* Maximal chance of being "great" */
      if (f2 > 20) f2 = 20;
  
+     /* Chance of being doubly great */
+     f3 = (lev + 10) / 3;
  
      /* Assume normal */
      power = 0;
***************
*** 2584,2640 ****
      if (great) rolls = 4;
  
      /* Hack -- Get no rolls if not allowed */
!     if (!okay || i_ptr->name1) rolls = 0;
  
      /* Roll for artifacts if allowed */
      for (i = 0; i < rolls; i++)
      {
!         /* Roll for an artifact */
!         if (make_artifact(i_ptr)) break;
      }
  
  
!     /* Hack -- analyze artifacts */
!     if (i_ptr->name1)
!     {
!         artifact_type *a_ptr = &a_info[i_ptr->name1];
! 
!         /* Hack -- Mark the artifact as "created" */
!         a_ptr->cur_num = 1;
! 
!         /* Extract the other fields */
!         i_ptr->pval = a_ptr->pval;
!         i_ptr->ac = a_ptr->ac;
!         i_ptr->dd = a_ptr->dd;
!         i_ptr->ds = a_ptr->ds;
!         i_ptr->to_a = a_ptr->to_a;
!         i_ptr->to_h = a_ptr->to_h;
!         i_ptr->to_d = a_ptr->to_d;
!         i_ptr->weight = a_ptr->weight;
! 
!         /* Hack -- extract the "broken" flag */
!         if (!a_ptr->cost) i_ptr->ident |= ID_BROKEN;
! 
!         /* Hack -- extract the "cursed" flag */
!         if (a_ptr->flags3 & TR3_CURSED) i_ptr->ident |= ID_CURSED;
! 
!         /* Mega-Hack -- increase the rating */
!         rating += 10;
! 
!         /* Mega-Hack -- increase the rating again */
!         if (a_ptr->cost > 50000L) rating += 10;
! 
!         /* Set the good item flag */
!         good_item_flag = TRUE;
! 
!         /* Cheat -- peek at the item */
!         if (cheat_peek) object_mention(i_ptr);
! 
!         /* Done */
!         return;
      }
  
- 
      /* Apply magic */
      switch (i_ptr->tval)
      {
--- 2579,2616 ----
      if (great) rolls = 4;
  
      /* Hack -- Get no rolls if not allowed */
!     if (!okay || artifact_p(i_ptr)) rolls = 0;
  
      /* Roll for artifacts if allowed */
      for (i = 0; i < rolls; i++)
      {
!         /* Roll for an artifact; return if success. */
!         if (make_artifact(i_ptr)) return;
      }
  
+     /* It's not an artifact if we get this far. */
  
!     /* Roll up a second power level for possible double ego item */
!     power2 = 0;
! #ifdef ALLOW_DOUBLE_EGO
!     if ((power >= 2) || (power <= -2)) {
!       if (good || magik(f1))
! 	{
! 	  /* Roll for second greatness */
! 	  if (magik(f3)) 
! 	    power2 = 2;
! 	}
!       
!       /* Roll for "cursed" */
!       else if (magik(f1))
! 	{
! 	  /* Roll for "broken" */
! 	  if (magik(f3)) 
! 	    power2 = -2;
! 	}
      }
+ #endif
  
      /* Apply magic */
      switch (i_ptr->tval)
      {
***************
*** 2646,2652 ****
          case TV_SHOT:
          case TV_ARROW:
          case TV_BOLT:
!             if (power) a_m_aux_1(i_ptr, lev, power);
              break;
  
          case TV_DRAG_ARMOR:
--- 2622,2633 ----
          case TV_SHOT:
          case TV_ARROW:
          case TV_BOLT:
!             if (power) a_m_weapon(i_ptr, lev, power);
! 	    if (power2) {
! 	      invwipe(i_ptr2);
! 	      invcopy(i_ptr2, i_ptr->k_idx);
! 	      a_m_weapon(i_ptr2, lev, power2);
! 	    }
              break;
  
          case TV_DRAG_ARMOR:
***************
*** 2658,2664 ****
          case TV_CLOAK:
          case TV_GLOVES:
          case TV_BOOTS:
!             if (power) a_m_aux_2(i_ptr, lev, power);
              break;
  
          case TV_RING:
--- 2639,2650 ----
          case TV_CLOAK:
          case TV_GLOVES:
          case TV_BOOTS:
!             if (power) a_m_armor(i_ptr, lev, power);
! 	    if (power2) {
! 	      invwipe(i_ptr2);
! 	      invcopy(i_ptr2, i_ptr->k_idx);
! 	      a_m_armor(i_ptr2, lev, power2);
! 	    }
              break;
  
          case TV_RING:
***************
*** 2673,2758 ****
      }
  
  
!     /* Hack -- analyze ego-items */
!     if (i_ptr->name2)
!     {
!         ego_item_type *e_ptr = &e_info[i_ptr->name2];
  
!         /* Hack -- extra powers */
!         switch (i_ptr->name2)
!         {
!             /* Weapon (Holy Avenger) */
!             case EGO_HA:
!                 i_ptr->xtra1 = EGO_XTRA_SUSTAIN;
!                 break;
  
!             /* Weapon (Defender) */
!             case EGO_DF:
!                 i_ptr->xtra1 = EGO_XTRA_SUSTAIN;
!                 break;
! 
!             /* Weapon (Blessed) */
!             case EGO_BLESS_BLADE:
!                 i_ptr->xtra1 = EGO_XTRA_ABILITY;
!                 break;
! 
!             /* Robe of Permanance */
!             case EGO_PERMANENCE:
!                 i_ptr->xtra1 = EGO_XTRA_POWER;
!                 break;
! 
!             /* Armor of Elvenkind */
!             case EGO_ELVENKIND:
!                 i_ptr->xtra1 = EGO_XTRA_POWER;
!                 break;
! 
!             /* Crown of the Magi */
!             case EGO_MAGI:
!                 i_ptr->xtra1 = EGO_XTRA_ABILITY;
!                 break;
! 
!             /* Cloak of Aman */
!             case EGO_AMAN:
!                 i_ptr->xtra1 = EGO_XTRA_POWER;
!                 break;
!         }
! 
!         /* Randomize the "xtra" power */
!         if (i_ptr->xtra1) i_ptr->xtra2 = randint(256);
! 
!         /* Hack -- acquire "broken" flag */
!         if (!e_ptr->cost) i_ptr->ident |= ID_BROKEN;
! 
!         /* Hack -- acquire "cursed" flag */
!         if (e_ptr->flags3 & TR3_CURSED) i_ptr->ident |= ID_CURSED;
! 
!         /* Hack -- apply extra penalties if needed */
!         if (cursed_p(i_ptr) || broken_p(i_ptr))
!         {
!             /* Hack -- obtain bonuses */
!             if (e_ptr->max_to_h) i_ptr->to_h -= randint(e_ptr->max_to_h);
!             if (e_ptr->max_to_d) i_ptr->to_d -= randint(e_ptr->max_to_d);
!             if (e_ptr->max_to_a) i_ptr->to_a -= randint(e_ptr->max_to_a);
! 
!             /* Hack -- obtain pval */
!             if (e_ptr->max_pval) i_ptr->pval -= randint(e_ptr->max_pval);
!         }
! 
!         /* Hack -- apply extra bonuses if needed */
!         else
!         {
!             /* Hack -- obtain bonuses */
!             if (e_ptr->max_to_h) i_ptr->to_h += randint(e_ptr->max_to_h);
!             if (e_ptr->max_to_d) i_ptr->to_d += randint(e_ptr->max_to_d);
!             if (e_ptr->max_to_a) i_ptr->to_a += randint(e_ptr->max_to_a);
! 
!             /* Hack -- obtain pval */
!             if (e_ptr->max_pval) i_ptr->pval += randint(e_ptr->max_pval);
!         }
! 
!         /* Hack -- apply rating bonus */
!         rating += e_ptr->rating;
! 
          /* Cheat -- describe the item */
          if (cheat_peek) object_mention(i_ptr);
  
--- 2659,2736 ----
      }
  
  
!     /* Analyze single ego items */
!     if (ego_item_p(i_ptr) && (power2 == 0))
!       {
!         /* Cheat -- describe the item */
!         if (cheat_peek) object_mention(i_ptr);
  
! 	return;
!       }
!     /* Analyze double ego items */
!     if (power2)
!       {
!         /* 
! 	 * i_ptr and i_ptr2 are both fully filled in single ego items.
! 	 * (Actually, not quite always true since DSMs have no ego.)
! 	 * They need to be "reconciled" into a single item with double
! 	 * ego powers.
! 	 */
! 	/*
! 	 * Hack -- Make sure they are not "conflicting" ego items, i.e.
! 	 * they have opposite valued pvals.
! 	 */
! 	if (i_ptr->pval * i_ptr2->pval < 0)
! 	  return;
!         /*
! 	 * If egotisms are distinct, assign second ego-power to first item.
! 	 */
! 	if (i_ptr->name2 != i_ptr2->name2)
! 	  i_ptr->name1 = i_ptr2->name2;
! 	/* 
! 	 * Assign "broken"/cursed if either ego object is.
! 	 */
! 	if (i_ptr2->ident & ID_BROKEN)
! 	  i_ptr->ident |= ID_BROKEN;
! 	if (i_ptr2->ident & ID_CURSED)
! 	  i_ptr->ident |= ID_CURSED;
! 	/*
! 	 * Assign random powers/sustains/abilities from both items.
! 	 */
! 	i_ptr->xtra1 |= i_ptr2->xtra1;
! 	/*
! 	 * If an item has zero +to hit, +to damage, or +AC, use the other
! 	 * item's value for this position.  If both items provide a value, 
! 	 * randomly take the value from one item or the other.
! 	 */
! 	if ((i_ptr->to_h == 0) || (rand_int(100) < 50))
! 	  i_ptr->to_h = i_ptr2->to_h;
!         if ((i_ptr->to_d == 0) || (rand_int(100) < 50))
! 	  i_ptr->to_d = i_ptr2->to_d;
!         if ((i_ptr->to_a == 0) || (rand_int(100) < 50))
! 	  i_ptr->to_a = i_ptr2->to_a;
! 	/*
! 	 * Take minimum pval from either item, if either is nonzero.
! 	 * This is needed to prevent disparate pval ranges from combining
! 	 * to create a god-item, like a 
! 	 *   weapon of extra attacks (Holy Avenger) (+4 attacks).
! 	 * Exception: take maximum pval if double ego of same type.
! 	 */
! 	if (i_ptr->name2 == i_ptr2->name2) {
! 	  if (i_ptr->pval < 0) {
! 	    if (i_ptr2->pval < i_ptr->pval)
! 	      i_ptr->pval = i_ptr2->pval;
! 	    }
! 	  else 
! 	    if (i_ptr2->pval > i_ptr->pval)
! 	      i_ptr->pval = i_ptr2->pval;
! 	}
! 	else 
! 	  if ((i_ptr->pval == 0) || 
! 	      ((i_ptr2->pval != 0) && (i_ptr2->pval < i_ptr->pval)))
! 	    i_ptr->pval = i_ptr2->pval;
  
! 	   
          /* Cheat -- describe the item */
          if (cheat_peek) object_mention(i_ptr);
  
Only in angband-279v6+/src: object2.c~
Only in angband-279v6+/src: object2.o
Only in angband-279v6+/src: save.o
Only in angband-279v6+/src: spells1.o
Only in angband-279v6+/src: spells2.o
diff -c angband-279v6/src/store.c angband-279v6+/src/store.c
*** angband-279v6/src/store.c	Sat Apr 13 11:34:08 1996
--- angband-279v6+/src/store.c	Thu Jul 25 08:39:53 1996
***************
*** 480,486 ****
          case TV_HAFTED:
          case TV_DIGGING:
          case TV_BOW:
!             if (i_ptr->name2) break;
              if (cost <= 10L) size += mass_roll(3,5);
              if (cost <= 100L) size += mass_roll(3,5);
              break;
--- 480,486 ----
          case TV_HAFTED:
          case TV_DIGGING:
          case TV_BOW:
!             if (ego_item_p(i_ptr)) break;
              if (cost <= 10L) size += mass_roll(3,5);
              if (cost <= 100L) size += mass_roll(3,5);
              break;
***************
*** 554,565 ****
      if (i_ptr->to_d  !=  j_ptr->to_d) return (0);
      if (i_ptr->to_a  !=  j_ptr->to_a) return (0);
  
!     /* Require identical "artifact" names */
!     if (i_ptr->name1 != j_ptr->name1) return (0);
  
-     /* Require identical "ego-item" names */
-     if (i_ptr->name2 != j_ptr->name2) return (0);
- 
      /* Hack -- Never stack "powerful" items */
      if (i_ptr->xtra1 || j_ptr->xtra1) return (0);
  
--- 554,563 ----
      if (i_ptr->to_d  !=  j_ptr->to_d) return (0);
      if (i_ptr->to_a  !=  j_ptr->to_a) return (0);
  
!     /* Require identical artifact and ego-item names */
!     if ((i_ptr->name1 != j_ptr->name1) ||
! 	(i_ptr->name2 != j_ptr->name2)) return (0);
  
      /* Hack -- Never stack "powerful" items */
      if (i_ptr->xtra1 || j_ptr->xtra1) return (0);
  
***************
*** 1020,1026 ****
      int		i, j;
  
      /* Ego items are never crap */
!     if (i_ptr->name2) return (FALSE);
  
      /* Good items are never crap */
      if (i_ptr->to_a > 0) return (FALSE);
--- 1018,1024 ----
      int		i, j;
  
      /* Ego items are never crap */
!     if (ego_item_p(i_ptr)) return (FALSE);
  
      /* Good items are never crap */
      if (i_ptr->to_a > 0) return (FALSE);
Only in angband-279v6+/src: store.c~
Only in angband-279v6+/src: store.o
Only in angband-279v6+/src: tables.o
Only in angband-279v6+/src: util.o
Only in angband-279v6+/src: variable.o
Only in angband-279v6+/src: wizard1.o
Only in angband-279v6+/src: wizard2.o
Only in angband-279v6+/src: xtra1.o
Only in angband-279v6+/src: xtra2.o
Only in angband-279v6+/src: xxx.c~
Only in angband-279v6+/src: z-form.o
Only in angband-279v6+/src: z-rand.o
Only in angband-279v6+/src: z-term.o
Only in angband-279v6+/src: z-util.o
Only in angband-279v6+/src: z-virt.o
