Beispiel #1
0
void detachInterrupt(uint8_t interruptNum) {
	uint8_t bit = digitalPinToBitMask(interruptNum);
	uint8_t port = digitalPinToPort(interruptNum);

	if (port == NOT_A_PIN) return;

	switch(port) {
	case P1:
		P1IE &= ~bit;
		intFuncP1[bit_pos(bit)] = 0;
		intChangeVectP1 &= ~(bit);
		break;
    #if defined(PORT2_VECTOR)
	case P2:
		P2IE &= ~bit;
		intFuncP2[bit_pos(bit)] = 0;
		intChangeVectP2 &= ~(bit);
		break;
	#endif
	#if defined(PORT3_VECTOR)
	case P3:
		P3IE &= ~bit;
		intFuncP3[bit_pos(bit)] = 0;
		intChangeVectP3 &= ~(bit);
		break;
	#endif
	#if defined(PORT4_VECTOR)
	case P4:
		P4IE &= ~bit;
		intFuncP4[bit_pos(bit)] = 0;
		intChangeVectP4 &= ~(bit);
		break;
	#endif
	default:
		break;
	}
}
Beispiel #2
0
void blow()
{
  unsigned long   i1;
  integer         i3,chance,i5;
  treas_ptr       i2,item_ptr;
  char            trash_char;
  boolean         redraw,ident;
  obj_set         things_that_blow = {misc_usable,valuable_gems,chime,horn,0};

  reset_flag = true;
  if (inven_ctr > 0) {
    if (find_range(things_that_blow,false,&i2,&i3)) {
      redraw = false;
      if (get_item(&item_ptr,"Use which item?",
		   &redraw,i3,&trash_char,false,false)) {
	//with item_ptr->data. do;
	if (redraw) {
	  draw_cave();
	}
	reset_flag = false;
	//with py.misc do;
	chance = PM.save + PM.lev + bard_adj() - item_ptr->data.level - 5;
	if (((py.flags.confused + py.flags.afraid) > 0) &&
	    ((item_ptr->data.tval == chime) || 
	     (item_ptr->data.tval == horn))) {
	  msg_print("you can not use the instrument...");
	} else if (item_ptr->data.p1 > 0) {
	  if (chance < 0) {
	    chance = 0;
	  }
	  if ((randint(chance) < USE_DEVICE) &&
	      ((item_ptr->data.tval != misc_usable) && 
	       (item_ptr->data.subval != 24))) {
	    msg_print("You failed to use the item properly.");
	  } else {
	    i1 = item_ptr->data.flags;
	    ident = false;
	    item_ptr->data.p1--;
	    for ( ; i1 > 0 ; ) {
	      i5 = bit_pos(&i1) + 1;
	      if ((item_ptr->data.tval == chime) || 
		  (item_ptr->data.tval == horn)) {
		b__chime_and_horn_effects(i5, &ident);
	      } else {
		b__misc_effects(i5, &ident, item_ptr);
	      }
	    }
	    
	    if (ident) {
	      identify(&(inven_temp->data));
	    }
	    if (inven_temp->data.flags != 0) {
	      //with py.misc do;
	      PM.exp += (item_ptr->data.level / (real)PM.lev) + .5;
	      prt_experience();
	    }
	    desc_charges(item_ptr);
	  }
	} /* end if p1 */
      } else {
	if (redraw) {
	  draw_cave();
	}
      }
    } else {
      msg_print("You are not carrying anything to use...");
    }
  } else {
    msg_print("But you are not carrying anything.");
  }
};
Beispiel #3
0
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
	uint8_t bit = digitalPinToBitMask(interruptNum);
	uint8_t port = digitalPinToPort(interruptNum);

	if ((port == NOT_A_PIN) || !((mode == FALLING) || (mode == RISING)
		|| (mode == CHANGE))) return;

	__dint();
	switch(port) {
	case P1:
		if(mode != CHANGE) {
			P1IES = mode ? P1IES | bit : P1IES & ~bit;
		} else {
			intChangeVectP1 |= bit;
			P1IES = (P1IN & bit) ? (P1IES | bit) : (P1IES & ~bit);
		}
		P1IFG &= ~bit;
		intFuncP1[bit_pos(bit)] = userFunc;
		P1IE |= bit;
		break;
	#if defined(PORT2_VECTOR)
	case P2:
		if(mode != CHANGE) {
			P2IES = mode ? P2IES | bit : P2IES & ~bit;
		} else {
			intChangeVectP2 |= bit;
			P2IES = (P2IN & bit) ? (P2IES | bit) : (P2IES & ~bit);
		}
		P2IFG &= ~bit;
		intFuncP2[bit_pos(bit)] = userFunc;
		P2IE |= bit;
		break;
	#endif
    #if defined(PORT3_VECTOR)
case P3:
		if(mode != CHANGE) {
			P3IES = mode ? P3IES | bit : P3IES & ~bit;
		} else {
			intChangeVectP3 |= bit;
			P3IES = (P3IN & bit) ? (P3IES | bit) : (P3IES & ~bit);
		}
		P3IFG &= ~bit;
		intFuncP3[bit_pos(bit)] = userFunc;
		P3IE |= bit;
		break;
    #endif
    #if defined(PORT4_VECTOR)
case P4:
		if(mode != CHANGE) {
			P4IES = mode ? P4IES | bit : P4IES & ~bit;
		} else {
			intChangeVectP4 |= bit;
			P4IES = (P4IN & bit) ? (P4IES | bit) : (P4IES & ~bit);
		}
		P4IFG &= ~bit;
		intFuncP4[bit_pos(bit)] = userFunc;
		P4IE |= bit;
		break;
    #endif
	default:
		break;
	}

	__eint();
}
Beispiel #4
0
/* Potions for the quaffing				-RAK-	*/
void quaff()
{
  int32u i, l;
  int j, k, item_val;
  int ident;
  register inven_type *i_ptr;
  register struct misc *m_ptr;
  register struct flags *f_ptr;
#if 0
  /* used by ifdefed out learn_spell potion */
  register class_type *c_ptr;
#endif

  free_turn_flag = TRUE;
  if (inven_ctr == 0)
    msg_print("But you are not carrying anything.");
  else if (!find_range(TV_POTION1, TV_POTION2, &j, &k))
    msg_print("You are not carrying any potions.");
  else if (get_item(&item_val, "Quaff which potion?", j, k, CNIL, CNIL))
    {
      i_ptr = &inventory[item_val];
      i = i_ptr->flags;
      free_turn_flag = FALSE;
      ident = FALSE;
      if (i == 0)
	{
	  msg_print ("You feel less thirsty.");
	  ident = TRUE;
	}
      else while (i != 0)
	{
	  j = bit_pos(&i) + 1;
	  if (i_ptr->tval == TV_POTION2)
	    j += 32;
	  /* Potions						*/
	  switch(j)
	    {
	    case 1:
	      if (inc_stat (A_STR))
		{
		  msg_print("Wow!  What bulging muscles!");
		  ident = TRUE;
		}
	      break;
	    case 2:
	      ident = TRUE;
	      lose_str();
	      break;
	    case 3:
	      if (res_stat (A_STR))
		{
		  msg_print("You feel warm all over.");
		  ident = TRUE;
		}
	      break;
	    case 4:
	      if (inc_stat (A_INT))
		{
		  msg_print("Aren't you brilliant!");
		  ident = TRUE;
		}
	      break;
	    case 5:
	      ident = TRUE;
	      lose_int();
	      break;
	    case 6:
	      if (res_stat (A_INT))
		{
		  msg_print("You have have a warm feeling.");
		  ident = TRUE;
		}
	      break;
	    case 7:
	      if (inc_stat (A_WIS))
		{
		  msg_print("You suddenly have a profound thought!");
		  ident = TRUE;
		}
	      break;
	    case 8:
	      ident = TRUE;
	      lose_wis();
	      break;
	    case 9:
	      if (res_stat (A_WIS))
		{
		  msg_print("You feel your wisdom returning.");
		  ident = TRUE;
		}
	      break;
	    case 10:
	      if (inc_stat (A_CHR))
		{
		  msg_print("Gee, ain't you cute!");
		  ident = TRUE;
		}
	      break;
	    case 11:
	      ident = TRUE;
	      lose_chr();
	      break;
	    case 12:
	      if (res_stat (A_CHR))
		{
		  msg_print("You feel your looks returning.");
		  ident = TRUE;
		}
	      break;
	    case 13:
	      ident = hp_player(damroll(2, 7));
	      break;
	    case 14:
	      ident = hp_player(damroll(4, 7));
	      break;
	    case 15:
	      ident = hp_player(damroll(6, 7));
	      break;
	    case 16:
	      ident = hp_player(1000);
	      break;
	    case 17:
	      if (inc_stat (A_CON))
		{
		  msg_print("You feel tingly for a moment.");
		  ident = TRUE;
		}
	      break;
	    case 18:
	      m_ptr = &py.misc;
	      if (m_ptr->exp < MAX_EXP)
		{
		  l = (m_ptr->exp / 2) + 10;
		  if (l > 100000L)  l = 100000L;
		  m_ptr->exp += l;
		  msg_print("You feel more experienced.");
		  prt_experience();
		  ident = TRUE;
		}
	      break;
	    case 19:
	      f_ptr = &py.flags;
	      if (!f_ptr->free_act)
		{
		  /* paralysis must == 0, otherwise could not drink potion */
		  msg_print("You fall asleep.");
		  f_ptr->paralysis += randint(4) + 4;
		  ident = TRUE;
		}
	      break;
	    case 20:
	      f_ptr = &py.flags;
	      if (f_ptr->blind == 0)
		{
		  msg_print("You are covered by a veil of darkness.");
		  ident = TRUE;
		}
	      f_ptr->blind += randint(100) + 100;
	      break;
	    case 21:
	      f_ptr = &py.flags;
	      if (f_ptr->confused == 0)
		{
		  msg_print("Hey!  This is good stuff!  * Hick! *");
		  ident = TRUE;
		}
	      f_ptr->confused += randint(20) + 12;
	      break;
	    case 22:
	      f_ptr = &py.flags;
	      if (f_ptr->poisoned == 0)
		{
		  msg_print("You feel very sick.");
		  ident = TRUE;
		}
	      f_ptr->poisoned += randint(15) + 10;
	      break;
	    case 23:
	      if (py.flags.fast == 0)
		ident = TRUE;
	      py.flags.fast += randint(25) + 15;
	      break;
	    case 24:
	      if (py.flags.slow == 0)
		ident = TRUE;
	      py.flags.slow += randint(25) + 15;
	      break;
	    case 26:
	      if (inc_stat (A_DEX))
		{
		  msg_print("You feel more limber!");
		  ident = TRUE;
		}
	      break;
	    case 27:
	      if (res_stat (A_DEX))
		{
		  msg_print("You feel less clumsy.");
		  ident = TRUE;
		}
	      break;
	    case 28:
	      if (res_stat (A_CON))
		{
		  msg_print("You feel your health returning!");
		  ident = TRUE;
		}
	      break;
	    case 29:
	      ident = cure_blindness();
	      break;
	    case 30:
	      ident = cure_confusion();
	      break;
	    case 31:
	      ident = cure_poison();
	      break;
#if 0
	    case 33:
	      /* this is no longer useful, now that there is a 'G'ain magic
		 spells command */
	      m_ptr = &py.misc;
	      c_ptr = &class[m_ptr->pclass];
	      if (c_ptr->spell == MAGE)
		{
		  calc_spells(A_INT);
		  calc_mana(A_INT);
		}
	      else if (c_ptr->spell == PRIEST)
		{
		  calc_spells(A_WIS);
		  calc_mana(A_WIS);
		}
	      else
		{
		  /* A warrior learns something about his equipment. -CJS- */
		  inven_type *w_ptr;
		  vtype tmp_str;
		  extern char *describe_use ();

		  for (k = 22; k < INVEN_ARRAY_SIZE; k++)
		    {
		      w_ptr = &inventory[k];
		      if (w_ptr->tval != TV_NOTHING && enchanted (w_ptr))
			{
			  (void) sprintf (tmp_str,
				  "There's something about what you are %s...",
					  describe_use(k));
			  msg_print (tmp_str);
			  add_inscribe(w_ptr, ID_MAGIK);
			  ident = TRUE;
			}
		    }
		}
	      break;
#endif
	    case 34:
	      if (py.misc.exp > 0)
		{
		  int32 m, scale;
		  msg_print("You feel your memories fade.");
		  /* Lose between 1/5 and 2/5 of your experience */
		  m = py.misc.exp / 5;
		  if (py.misc.exp > MAX_SHORT)
		    {
		      scale = MAX_LONG / py.misc.exp;
		      m += (randint((int)scale) * py.misc.exp) / (scale * 5);
		    }
		  else
		    m += randint((int)py.misc.exp) / 5;
		  lose_exp(m);
		  ident = TRUE;
		}
	      break;
	    case 35:
	      f_ptr = &py.flags;
	      (void) cure_poison();
	      if (f_ptr->food > 150)  f_ptr->food = 150;
	      f_ptr->paralysis = 4;
	      msg_print("The potion makes you vomit!");
	      ident = TRUE;
	      break;
	    case 36:
	      if (py.flags.invuln == 0)
		ident = TRUE;
	      py.flags.invuln += randint(10) + 10;
	      break;
	    case 37:
	      if (py.flags.hero == 0)
		ident = TRUE;
	      py.flags.hero += randint(25) + 25;
	      break;
	    case 38:
	      if (py.flags.shero == 0)
		ident = TRUE;
	      py.flags.shero += randint(25) + 25;
	      break;
	    case 39:
	      ident = remove_fear();
	      break;
	    case 40:
	      ident = restore_level();
	      break;
	    case 41:
	      f_ptr = &py.flags;
	      if (f_ptr->resist_heat == 0)
		ident = TRUE;
	      f_ptr->resist_heat += randint(10) + 10;
	      break;
	    case 42:
	      f_ptr = &py.flags;
	      if (f_ptr->resist_cold == 0)
		ident = TRUE;
	      f_ptr->resist_cold += randint(10) + 10;
	      break;
	    case 43:
	      if (py.flags.detect_inv == 0)
		ident = TRUE;
	      detect_inv2(randint(12)+12);
	      break;
	    case 44:
	      ident = slow_poison();
	      break;
	    case 45:
	      ident = cure_poison();
	      break;
	    case 46:
	      m_ptr = &py.misc;
	      if (m_ptr->cmana < m_ptr->mana)
		{
		  m_ptr->cmana = m_ptr->mana;
		  ident = TRUE;
		  msg_print("Your feel your head clear.");
		  prt_cmana();
		}
	      break;
	    case 47:
	      f_ptr = &py.flags;
	      if (f_ptr->tim_infra == 0)
		{
		  msg_print("Your eyes begin to tingle.");
		  ident = TRUE;
		}
	      f_ptr->tim_infra += 100 + randint(100);
	      break;
	    default:
	      msg_print ("Internal error in potion()");
	      break;
	    }
	  /* End of Potions.					*/
	}
      if (ident)
	{
	  if (!known1_p(i_ptr))
	    {
	      m_ptr = &py.misc;
	      /* round half-way case up */
	      m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) / m_ptr->lev;
	      prt_experience();

	      identify(&item_val);
	      i_ptr = &inventory[item_val];
	    }
	}
Beispiel #5
0
/* Potions for the quaffing				-RAK-	*/
void quaff()
{
  int32u i, l;
  int j, k, item_val;
  int ident;
  register inven_type *i_ptr;
  register struct misc *m_ptr;
  register struct flags *f_ptr;

  free_turn_flag = TRUE;
  if (inven_ctr == 0)
    msg_print("But you are not carrying anything.");
  else if (!find_range(TV_POTION1, TV_POTION2, &j, &k))
    msg_print("You are not carrying any potions.");
  else if (get_item(&item_val, "Quaff which potion?", j, k, 0))
    {
      i_ptr = &inventory[item_val];
      i = i_ptr->flags;
      free_turn_flag = FALSE;
      ident = FALSE;
      if (i == 0)
	{
	  msg_print ("You feel less thirsty.");
	  ident = TRUE;
	}
      else while (i != 0)
	{
	  j = bit_pos(&i) + 1;
	  if (i_ptr->tval == TV_POTION2)
	    j += 32;
	  /* Potions						*/
	  switch(j)
	    {
	    case 1:
	      if (inc_stat (A_STR))
		{
		  msg_print("Wow!  What bulging muscles!");
		  ident = TRUE;
		}
	      break;
	    case 2:
	      ident = TRUE;
	      lose_str();
	      break;
	    case 3:
	      if (res_stat (A_STR))
		{
		  msg_print("You feel warm all over.");
		  ident = TRUE;
		}
	      break;
	    case 4:
	      if (inc_stat (A_INT))
		{
		  msg_print("Aren't you brilliant!");
		  ident = TRUE;
		}
	      break;
	    case 5:
	      ident = TRUE;
	      lose_int();
	      break;
	    case 6:
	      if (res_stat (A_INT))
		{
		  msg_print("You have a warm feeling.");
		  ident = TRUE;
		}
	      break;
	    case 7:
	      if (inc_stat (A_WIS))
		{
		  msg_print("You suddenly have a profound thought!");
		  ident = TRUE;
		}
	      break;
	    case 8:
	      ident = TRUE;
	      lose_wis();
	      break;
	    case 9:
	      if (res_stat (A_WIS))
		{
		  msg_print("You feel your wisdom returning.");
		  ident = TRUE;
		}
	      break;
	    case 10:
	      if (inc_stat (A_CHR))
		{
		  msg_print("Gee, ain't you cute!");
		  ident = TRUE;
		}
	      break;
	    case 11:
	      ident = TRUE;
	      lose_chr();
	      break;
	    case 12:
	      if (res_stat (A_CHR))
		{
		  msg_print("You feel your looks returning.");
		  ident = TRUE;
		}
	      break;
	    case 13:
	      ident = hp_player(damroll(2, 7));
	      if (py.flags.cut>0) {
		py.flags.cut-=10;
		if (py.flags.cut<0) py.flags.cut=0;
		ident = TRUE;
		msg_print("Your wounds heal.");
	      }
	      break;
	    case 14:
	      ident = hp_player(damroll(4, 7));
	      if (py.flags.cut>0) {
		py.flags.cut=(py.flags.cut/2)-50;
		if (py.flags.cut<0) py.flags.cut=0;
		ident = TRUE;
		msg_print("Your wounds heal.");
	      }
	      break;
	    case 15:
	      ident = hp_player(damroll(6, 7));
	      if (py.flags.cut>0) {
		py.flags.cut=0;
		ident = TRUE;
		msg_print("Your wounds heal.");
	      }
 	      if (py.flags.stun>0) {
		if (py.flags.stun>50) {
		  py.misc.ptohit+=20;
		  py.misc.ptodam+=20;
		} else {
		  py.misc.ptohit+=5;
		  py.misc.ptodam+=5;
		}
		py.flags.stun=0;
		ident = TRUE;
		msg_print("Your head stops stinging.");
	      }
	      break;
	    case 16:
	      ident = hp_player(400);
	      if (py.flags.stun>0) {
		if (py.flags.stun>50) {
		  py.misc.ptohit+=20;
		  py.misc.ptodam+=20;
		} else {
		  py.misc.ptohit+=5;
		  py.misc.ptodam+=5;
		}
		py.flags.stun=0;
		ident = TRUE;
		msg_print("Your head stops stinging.");
	      }
	      if (py.flags.cut>0) {
		py.flags.cut=0;
		ident = TRUE;
		msg_print("Your wounds heal.");
	      }
	      break;
	    case 17:
	      if (inc_stat (A_CON))
		{
		  msg_print("You feel tingly for a moment.");
		  ident = TRUE;
		}
	      break;
	    case 18:
	      m_ptr = &py.misc;
	      if (m_ptr->exp < MAX_EXP)
		{
		  l = (m_ptr->exp / 2) + 10;
		  if (l > 100000L)  l = 100000L;
		  m_ptr->exp += l;
		  msg_print("You feel more experienced.");
		  prt_experience();
		  ident = TRUE;
		}
	      break;
	    case 19:
	      f_ptr = &py.flags;
	      if (!f_ptr->free_act)
		{
		  /* paralysis must == 0, otherwise could not drink potion */
		  msg_print("You fall asleep.");
		  f_ptr->paralysis += randint(4) + 4;
		  ident = TRUE;
		}
	      break;
	    case 20:
	      f_ptr = &py.flags;
	      if (!py.flags.blindness_resist) {
	        if (f_ptr->blind == 0)
		  {
		    msg_print("You are covered by a veil of darkness.");
		    ident = TRUE;
		  }
	        f_ptr->blind += randint(100) + 100;
	      }
	      break;
	    case 21:
	      f_ptr = &py.flags;
	      if (!f_ptr->confusion_resist)
		{
	          if (f_ptr->confused == 0)
		    {
		      msg_print("Hey!  This is good stuff!  * Hick! *");
		      ident = TRUE;
		    }
	          f_ptr->confused += randint(20) + 12;
                }
              break;
	    case 22:
	      f_ptr = &py.flags;
	      if (f_ptr->poisoned == 0)
		{
		  msg_print("You feel very sick.");
		  ident = TRUE;
		}
	      if (!f_ptr->poison_resist)
		f_ptr->poisoned += randint(15) + 10;
	      break;
	    case 23:
	      if (py.flags.fast == 0)
		ident = TRUE;
	      if (py.flags.fast <= 0)
		  {
		    py.flags.fast += randint(25) + 15;
		  }
	      else
		py.flags.fast += randint(5);
	      break;
	    case 24:
	      if (py.flags.slow == 0)
		ident = TRUE;
	      py.flags.slow += randint(25) + 15;
	      break;
	    case 26:
	      if (inc_stat (A_DEX))
		{
		  msg_print("You feel more limber!");
		  ident = TRUE;
		}
	      break;
	    case 27:
	      if (res_stat (A_DEX))
		{
		  msg_print("You feel less clumsy.");
		  ident = TRUE;
		}
	      break;
	    case 28:
	      if (res_stat (A_CON))
		{
		  msg_print("You feel your health returning!");
		  ident = TRUE;
		}
	      break;
	    case 29:
	      ident = cure_blindness();
	      break;
	    case 30:
	      ident = cure_confusion();
	      break;
	    case 31:
	      ident = cure_poison();
	      break;
	    case 34:
	      if (!py.flags.hold_life && py.misc.exp>0) {
		  int32 m, scale;
		  msg_print("You feel your memories fade.");
		  m = py.misc.exp / 5;
		  if (py.misc.exp > MAX_SHORT) {
		    scale = MAX_LONG / py.misc.exp;
		    m+=(randint((int)scale)*py.misc.exp)/(scale*5);
		  }
		  else m+=randint((int)py.misc.exp)/5;
		  lose_exp(m);
		  ident=TRUE;
	      }
	      else msg_print
	     ("You feel you memories fade for a moment, but quickly return.");
	      break;
	    case 35:
	      f_ptr = &py.flags;
	      (void) cure_poison();
	      if (f_ptr->food > 150)  f_ptr->food = 150;
	      f_ptr->paralysis = 4;
	      msg_print("The potion makes you vomit!");
	      ident = TRUE;
	      break;
	    case 37:
	      if (py.flags.hero == 0)
		ident = TRUE;
	      py.flags.hero += randint(25) + 25;
	      break;
	    case 38:
	      if (py.flags.shero == 0)
		ident = TRUE;
	      py.flags.shero += randint(25) + 25;
	      break;
	    case 39:
	      ident = remove_fear();
	      break;
	    case 40:
	      ident = restore_level();
	      break;
	    case 41:
	      f_ptr = &py.flags;
	      if (f_ptr->resist_heat == 0)
		ident = TRUE;
	      f_ptr->resist_heat += randint(10) + 10;
	      break;
	    case 42:
	      f_ptr = &py.flags;
	      if (f_ptr->resist_cold == 0)
		ident = TRUE;
	      f_ptr->resist_cold += randint(10) + 10;
	      break;
	    case 43:
	      if (py.flags.detect_inv == 0)
		ident = TRUE;
	      detect_inv2(randint(12)+12);
	      break;
	    case 44:
	      ident = slow_poison();
	      break;
	    case 45:
	      ident = cure_poison();
	      break;
	    case 46:
	      m_ptr = &py.misc;
	      if (m_ptr->cmana < m_ptr->mana)
		{
		  m_ptr->cmana = m_ptr->mana;
		  ident = TRUE;
		  msg_print("Your feel your head clear.");
		  prt_cmana();
		}
	      break;
	    case 47:
	      f_ptr = &py.flags;
	      if (f_ptr->tim_infra == 0)
		{
		  msg_print("Your eyes begin to tingle.");
		  ident = TRUE;
		}
	      f_ptr->tim_infra += 100 + randint(100);
	      break;
	    case 48:
	      wizard_light(TRUE);
	      if (!res_stat(A_WIS)) inc_stat(A_WIS);
	      if (!res_stat(A_INT)) inc_stat(A_INT);
	      msg_print("You feel more enlightened!");
	      identify_pack();
	      ident=TRUE;
	      break;
	    case 49:
	      msg_print("Massive explosions rupture your body!");
	      take_hit(damroll(50,20),"a potion of Detonation");
	      cut_player(5000);
	      stun_player(75);
	      ident=TRUE;
	      break;
	    case 50:
	      msg_print("A feeling of Death flows through your body.");
	      take_hit(5000,"a potion of Death");
	      ident=TRUE;
	      break;
	    case 51:
	      if (restore_level() | res_stat(A_STR) | res_stat(A_CON) |
		  res_stat(A_DEX) | res_stat(A_WIS) | res_stat(A_INT) |
		  res_stat(A_CHR) | hp_player(5000) | cure_poison() |
		  cure_blindness() | cure_confusion() | (py.flags.stun>0) |
		  (py.flags.cut>0) | (py.flags.image>0) | remove_fear()) {
	       ident=TRUE;
	       py.flags.cut=0;
	       py.flags.image=0;
	       if (py.flags.stun>0) {
	         if (py.flags.stun>50) {
		   py.misc.ptohit+=20;
		   py.misc.ptodam+=20;
		 } else {
		   py.misc.ptohit+=5;
		   py.misc.ptodam+=5;
	         }
		 py.flags.stun=0;
               }
  	      }
	      break;
            case 52:
	      if (inc_stat(A_DEX) | inc_stat(A_WIS) | inc_stat(A_INT) |
		  inc_stat(A_STR) | inc_stat(A_CHR) | inc_stat(A_CON)) {
		ident=TRUE;
		msg_print("You feel power flow through your body!");
	      }
	      break;
	    case 53:
	      take_hit(damroll(10,10),"a potion of Ruination");
	      ruin_stat(A_DEX);
	      ruin_stat(A_WIS);
	      ruin_stat(A_CON);
	      ruin_stat(A_STR);
	      ruin_stat(A_CHR);
	      ruin_stat(A_INT);
	      ident=TRUE;
	      msg_print("Your nerves and muscles feel weak and lifeless");
	      break;
	    case 54:
	      wizard_light(TRUE);
	      msg_print("An image of your surroundings forms in your mind");
	      ident = TRUE;
	      break;
	    case 55:
	      msg_print("You feel you know yourself a little better...");
	      self_knowledge();
	      ident = TRUE;
	      break; 
	    case 56: /*  *Healing*  */
              ident = hp_player(1200);
              if (py.flags.stun>0) {
                if (py.flags.stun>50) {
                  py.misc.ptohit+=20;
                  py.misc.ptodam+=20;
	        } else {
                  py.misc.ptohit+=5;
                  py.misc.ptodam+=5;
	        }
                py.flags.stun=0;
                ident = TRUE;
                msg_print("Your head stops stinging.");
	      }
              if (py.flags.cut>0) {
                py.flags.cut=0;
                ident = TRUE;
                msg_print("Your wounds heal.");
	      }
              if (cure_blindness()) ident = TRUE;
              if (cure_confusion()) ident = TRUE;
              if (cure_poison()) ident = TRUE;
              break;
	    default:
	      if (1) {
		char tmp_str[100];
		msg_print ("Internal error in potion()");
		sprintf(tmp_str, "Number %d...", j);
		msg_print (tmp_str);
	      }
	      break;
	    }
	  /* End of Potions.					*/
	}
      if (ident)
	{
	  if (!known1_p(i_ptr))
	    {
	      m_ptr = &py.misc;
	      /* round half-way case up */
	      m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) / m_ptr->lev;
	      prt_experience();

	      identify(&item_val);
	      i_ptr = &inventory[item_val];
	    }
	}
Beispiel #6
0
/* Scrolls for the reading				-RAK-	*/
void read_scroll()
{
  int32u i;
  int j, k, item_val, y, x;
  int tmp[6], flag, used_up;
  bigvtype out_val, tmp_str;
  register int ident, l;
  register inven_type *i_ptr;
  register struct misc *m_ptr;

  free_turn_flag = TRUE;
  if (py.flags.blind > 0)
    msg_print("You can't see to read the scroll.");
  else if (no_light())
    msg_print("You have no light to read by.");
  else if (py.flags.confused > 0)
    msg_print("You are too confused to read a scroll.");
  else if (inven_ctr == 0)
    msg_print("You are not carrying anything!");
  else if (!find_range(TV_SCROLL1, TV_SCROLL2, &j, &k))
    msg_print ("You are not carrying any scrolls!");
  else if (get_item(&item_val, "Read which scroll?", j, k, 0))
    {
      i_ptr = &inventory[item_val];
      free_turn_flag = FALSE;
      used_up = TRUE;
      i = i_ptr->flags;
      ident = FALSE;

      while (i != 0)
	{
	  j = bit_pos(&i) + 1;
	  if (i_ptr->tval == TV_SCROLL2)
	    j += 32;

	  /* Scrolls.			*/
	  switch(j)
	    {
	    case 1:
	      i_ptr = &inventory[INVEN_WIELD];
	      if (i_ptr->tval != TV_NOTHING)
		{
		  objdes(tmp_str, i_ptr, FALSE);
		  (void) sprintf(out_val, "Your %s glows faintly!", tmp_str);
		  msg_print(out_val);
		  if (enchant(&i_ptr->tohit))
		    {
		      i_ptr->flags &= ~TR_CURSED;
		      calc_bonuses();
		    }
		  else
		    msg_print("The enchantment fails.");
		  ident = TRUE;
		}
	      break;
	    case 2:
	      i_ptr = &inventory[INVEN_WIELD];
	      if (i_ptr->tval != TV_NOTHING)
		{
		  objdes(tmp_str, i_ptr, FALSE);
		  (void) sprintf(out_val, "Your %s glows faintly!", tmp_str);
		  msg_print(out_val);
		  if (enchant(&i_ptr->todam))
		    {
		      i_ptr->flags &= ~TR_CURSED;
		      calc_bonuses ();
		    }
		  else
		    msg_print("The enchantment fails.");
		  ident = TRUE;
		}
	      break;
	    case 3:
	      k = 0;
	      l = 0;
	      if (inventory[INVEN_BODY].tval != TV_NOTHING)
		tmp[k++] = INVEN_BODY;
	      if (inventory[INVEN_ARM].tval != TV_NOTHING)
		tmp[k++] = INVEN_ARM;
	      if (inventory[INVEN_OUTER].tval != TV_NOTHING)
		tmp[k++] = INVEN_OUTER;
	      if (inventory[INVEN_HANDS].tval != TV_NOTHING)
		tmp[k++] = INVEN_HANDS;
	      if (inventory[INVEN_HEAD].tval != TV_NOTHING)
		tmp[k++] = INVEN_HEAD;
	      /* also enchant boots */
	      if (inventory[INVEN_FEET].tval != TV_NOTHING)
		tmp[k++] = INVEN_FEET;

	      if (k > 0)  l = tmp[randint(k)-1];
	      if (TR_CURSED & inventory[INVEN_BODY].flags)
		l = INVEN_BODY;
	      else if (TR_CURSED & inventory[INVEN_ARM].flags)
		l = INVEN_ARM;
	      else if (TR_CURSED & inventory[INVEN_OUTER].flags)
		l = INVEN_OUTER;
	      else if (TR_CURSED & inventory[INVEN_HEAD].flags)
		l = INVEN_HEAD;
	      else if (TR_CURSED & inventory[INVEN_HANDS].flags)
		l = INVEN_HANDS;
	      else if (TR_CURSED & inventory[INVEN_FEET].flags)
		l = INVEN_FEET;

	      if (l > 0)
		{
		  i_ptr = &inventory[l];
		  objdes(tmp_str, i_ptr, FALSE);
		  (void) sprintf(out_val, "Your %s glows faintly!", tmp_str);
		  msg_print(out_val);
		  if (enchant(&i_ptr->toac))
		    {
		      i_ptr->flags &= ~TR_CURSED;
		      calc_bonuses ();
		    }
		  else
		    msg_print("The enchantment fails.");
		  ident = TRUE;
		}
	      break;
	    case 4:
	      msg_print("This is an identify scroll.");
	      ident = TRUE;
	      used_up = ident_spell();

	      /* the identify may merge objects, causing the identify scroll
		 to move to a different place.	Check for that here. */
	      if (i_ptr->tval != TV_SCROLL1 || i_ptr->flags != 0x00000008)
		{
		  item_val--;
		  i_ptr = &inventory[item_val];
		  if (i_ptr->tval != TV_SCROLL1 || i_ptr->flags != 0x00000008)
		    {
		      msg_print("internal error with identify spell.");
		      msg_print("Please tell the wizard!");
		      return;
		    }
		}
	      break;
	    case 5:
	      if (remove_curse())
		{
		  msg_print("You feel as if someone is watching over you.");
		  ident = TRUE;
		}
	      break;
	    case 6:
	      ident = light_area(char_row, char_col);
	      break;
	    case 7:
	      for (k = 0; k < randint(3); k++)
		{
		  y = char_row;
		  x = char_col;
		  ident |= summon_monster(&y, &x, FALSE);
		}
	      break;
	    case 8:
	      teleport(10);
	      ident = TRUE;
	      break;
	    case 9:
	      teleport(100);
	      ident = TRUE;
	      break;
	    case 10:
	      (void) tele_level();
	      ident = TRUE;
	      break;
	    case 11:
	      if (py.flags.confuse_monster == 0)
		{
		  msg_print("Your hands begin to glow.");
		  py.flags.confuse_monster = TRUE;
		  ident = TRUE;
		}
	      break;
	    case 12:
	      ident = TRUE;
	      map_area();
	      break;
	    case 13:
	      ident = sleep_monsters1(char_row, char_col);
	      break;
	    case 14:
	      ident = TRUE;
	      warding_glyph();
	      break;
	    case 15:
	      ident = detect_treasure();
	      break;
	    case 16:
	      ident = detect_object();
	      break;
	    case 17:
	      ident = detect_trap();
	      break;
	    case 18:
	      ident = detect_sdoor();
	      break;
	    case 19:
	      msg_print("This is a mass genocide scroll.");
	      ident = mass_genocide(TRUE);
	      break;
	    case 20:
	      ident = detect_invisible();
	      break;
	    case 21:
	      ident = aggravate_monster(20);
	      if (ident)
		msg_print("There is a high pitched humming noise.");
	      break;
	    case 22:
	      ident = trap_creation();
	      break;
	    case 23:
	      ident = td_destroy();
	      break;
	    case 24:  /* Not Used , used to be door creation */
	      break;
	    case 25:
	      msg_print("This is a Recharge-Item scroll.");
	      ident = TRUE;
	      used_up = recharge(60);
	      break;
	    case 26:
	      msg_print("This is a genocide scroll.");
	      ident = genocide(TRUE);
	      break;
	    case 27:
	      ident = unlight_area(char_row, char_col);
	      break;
	    case 28:
	      ident = protect_evil();
	      break;
	    case 29:
	      ident = TRUE;
	      create_food();
	      break;
	    case 30:
	      ident = dispel_creature(UNDEAD, 60);
	      break;
	    case 31:
	      remove_all_curse();
	      ident = TRUE;
	      break;
	    case 33:
	      i_ptr = &inventory[INVEN_WIELD];
	      if (i_ptr->tval != TV_NOTHING)
		{
		  objdes(tmp_str, i_ptr, FALSE);
		  (void) sprintf(out_val, "Your %s glows brightly!", tmp_str);
		  msg_print(out_val);
		  flag = FALSE;
		  for (k = 0; k < randint(2); k++)
		    if (enchant(&i_ptr->tohit))
		      flag = TRUE;
		  for (k = 0; k < randint(2); k++)
		    if (enchant(&i_ptr->todam))
		      flag = TRUE;
		  if (flag)
		    {
		      i_ptr->flags &= ~TR_CURSED;
		      calc_bonuses ();
		    }
		  else
		    msg_print("The enchantment fails.");
		  ident = TRUE;
		}
	      break;
	    case 34:
	      i_ptr = &inventory[INVEN_WIELD];
	      if (i_ptr->tval != TV_NOTHING)
		{
		  objdes(tmp_str, i_ptr, FALSE);
		  (void)sprintf(out_val,"Your %s glows black, fades.",tmp_str);
		  msg_print(out_val);
		  unmagic_name(i_ptr);
		  i_ptr->tohit = -randint(5) - randint(5);
		  i_ptr->todam = -randint(5) - randint(5);
		  i_ptr->flags = TR_CURSED;
		  py_bonuses(i_ptr, -1);
		  calc_bonuses ();
		  ident = TRUE;
		}
	      break;
	    case 35:
	      k = 0;
	      l = 0;
	      if (inventory[INVEN_BODY].tval != TV_NOTHING)
		tmp[k++] = INVEN_BODY;
	      if (inventory[INVEN_ARM].tval != TV_NOTHING)
		tmp[k++] = INVEN_ARM;
	      if (inventory[INVEN_OUTER].tval != TV_NOTHING)
		tmp[k++] = INVEN_OUTER;
	      if (inventory[INVEN_HANDS].tval != TV_NOTHING)
		tmp[k++] = INVEN_HANDS;
	      if (inventory[INVEN_HEAD].tval != TV_NOTHING)
		tmp[k++] = INVEN_HEAD;
	      /* also enchant boots */
	      if (inventory[INVEN_FEET].tval != TV_NOTHING)
		tmp[k++] = INVEN_FEET;

	      if (k > 0)  l = tmp[randint(k)-1];
	      if (TR_CURSED & inventory[INVEN_BODY].flags)
		l = INVEN_BODY;
	      else if (TR_CURSED & inventory[INVEN_ARM].flags)
		l = INVEN_ARM;
	      else if (TR_CURSED & inventory[INVEN_OUTER].flags)
		l = INVEN_OUTER;
	      else if (TR_CURSED & inventory[INVEN_HEAD].flags)
		l = INVEN_HEAD;
	      else if (TR_CURSED & inventory[INVEN_HANDS].flags)
		l = INVEN_HANDS;
	      else if (TR_CURSED & inventory[INVEN_FEET].flags)
		l = INVEN_FEET;

	      if (l > 0)
		{
		  i_ptr = &inventory[l];
		  objdes(tmp_str, i_ptr, FALSE);
		  (void) sprintf(out_val,"Your %s glows brightly!", tmp_str);
		  msg_print(out_val);
		  flag = FALSE;
		  for (k = 0; k < randint(2) + 1; k++)
		    if (enchant(&i_ptr->toac))
		      flag = TRUE;
		  if (flag)
		    {
		      i_ptr->flags &= ~TR_CURSED;
		      calc_bonuses ();
		    }
		  else
		    msg_print("The enchantment fails.");
		  ident = TRUE;
		}
	      break;
	    case 36:
	      if ((inventory[INVEN_BODY].tval != TV_NOTHING)
		  && (randint(4) == 1))
		k = INVEN_BODY;
	      else if ((inventory[INVEN_ARM].tval != TV_NOTHING)
		       && (randint(3) ==1))
		k = INVEN_ARM;
	      else if ((inventory[INVEN_OUTER].tval != TV_NOTHING)
		       && (randint(3) ==1))
		k = INVEN_OUTER;
	      else if ((inventory[INVEN_HEAD].tval != TV_NOTHING)
		       && (randint(3) ==1))
		k = INVEN_HEAD;
	      else if ((inventory[INVEN_HANDS].tval != TV_NOTHING)
		       && (randint(3) ==1))
		k = INVEN_HANDS;
	      else if ((inventory[INVEN_FEET].tval != TV_NOTHING)
		       && (randint(3) ==1))
		k = INVEN_FEET;
	      else if (inventory[INVEN_BODY].tval != TV_NOTHING)
		k = INVEN_BODY;
	      else if (inventory[INVEN_ARM].tval != TV_NOTHING)
		k = INVEN_ARM;
	      else if (inventory[INVEN_OUTER].tval != TV_NOTHING)
		k = INVEN_OUTER;
	      else if (inventory[INVEN_HEAD].tval != TV_NOTHING)
		k = INVEN_HEAD;
	      else if (inventory[INVEN_HANDS].tval != TV_NOTHING)
		k = INVEN_HANDS;
	      else if (inventory[INVEN_FEET].tval != TV_NOTHING)
		k = INVEN_FEET;
	      else
		k = 0;

	      if (k > 0)
		{
		  i_ptr = &inventory[k];
		  objdes(tmp_str, i_ptr, FALSE);
		  (void)sprintf(out_val,"Your %s glows black, fades.",tmp_str);
		  msg_print(out_val);
		  unmagic_name(i_ptr);
		  i_ptr->flags = TR_CURSED;
		  i_ptr->toac = -randint(5) - randint(5);
		  calc_bonuses ();
		  ident = TRUE;
		}
	      break;
	    case 37:
	      ident = FALSE;
	      for (k = 0; k < randint(3); k++)
		{
		  y = char_row;
		  x = char_col;
		  ident |= summon_undead(&y, &x);
		}
	      break;
	    case 38:
	      ident = TRUE;
	      bless(randint(12)+6);
	      break;
	    case 39:
	      ident = TRUE;
	      bless(randint(24)+12);
	      break;
	    case 40:
	      ident = TRUE;
	      bless(randint(48)+24);
	      break;
	    case 41:
	      ident = TRUE;
	      if (py.flags.word_recall == 0)
		py.flags.word_recall = 25 + randint(30);
	      msg_print("The air about you becomes charged.");
	      break;
	    case 42:
	      destroy_area(char_row, char_col);
	      ident = TRUE;
	      break;
	    case 43:
	      place_special(char_row, char_col, SPECIAL);
	      prt_map();
	      break;
	    case 44:
	      special_random_object(char_row, char_col, 1);
	      prt_map();
	      break;
	    default:
	      msg_print("Internal error in scroll()");
	      break;
	    }
	  /* End of Scrolls.			       */
	}
      i_ptr = &inventory[item_val];
      if (ident)
	{
	  if (!known1_p(i_ptr))
	    {
	      m_ptr = &py.misc;
	      /* round half-way case up */
	      m_ptr->exp += (i_ptr->level +(m_ptr->lev >> 1)) / m_ptr->lev;
	      prt_experience();

	      identify(&item_val);
	      i_ptr = &inventory[item_val];
	    }
	}
Beispiel #7
0
/* Use a staff.					-RAK-	*/
void use()
{
  int32u i;
  int j, k, item_val, chance, y, x;
  register int ident;
  register struct misc *m_ptr;
  register inven_type *i_ptr;

  free_turn_flag = TRUE;
  if (inven_ctr == 0)
    msg_print("But you are not carrying anything.");
  else if (!find_range(TV_STAFF, TV_NEVER, &j, &k))
    msg_print("You are not carrying any staffs.");
  else if (get_item(&item_val, "Use which staff?", j, k, CNIL, CNIL))
    {
      i_ptr = &inventory[item_val];
      free_turn_flag = FALSE;
      m_ptr = &py.misc;
      chance = m_ptr->save + stat_adj(A_INT) - (int)i_ptr->level - 5
	+ (class_level_adj[m_ptr->pclass][CLA_DEVICE] * m_ptr->lev / 3);
      if (py.flags.confused > 0)
	chance = chance / 2;
      if ((chance < USE_DEVICE) && (randint(USE_DEVICE - chance + 1) == 1))
	chance = USE_DEVICE; /* Give everyone a slight chance */
      if (chance <= 0)	chance = 1;
      if (randint(chance) < USE_DEVICE)
	msg_print("You failed to use the staff properly.");
      else if (i_ptr->p1 > 0)
	{
	  i = i_ptr->flags;
	  ident = FALSE;
	  (i_ptr->p1)--;
	  while (i != 0)
	    {
	      j = bit_pos(&i) + 1;
	      /* Staffs.				*/
	      switch(j)
		{
		case 1:
		  ident = light_area(char_row, char_col);
		  break;
		case 2:
		  ident = detect_sdoor();
		  break;
		case 3:
		  ident = detect_trap();
		  break;
		case 4:
		  ident = detect_treasure();
		  break;
		case 5:
		  ident = detect_object();
		  break;
		case 6:
		  teleport(100);
		  ident = TRUE;
		  break;
		case 7:
		  ident = TRUE;
		  earthquake();
		  break;
		case 8:
		  ident = FALSE;
		  for (k = 0; k < randint(4); k++)
		    {
		      y = char_row;
		      x = char_col;
		      ident |= summon_monster(&y, &x, FALSE);
		    }
		  break;
		case 10:
		  ident = TRUE;
		  destroy_area(char_row, char_col);
		  break;
		case 11:
		  ident = TRUE;
		  starlite(char_row, char_col);
		  break;
		case 12:
		  ident = speed_monsters(1);
		  break;
		case 13:
		  ident = speed_monsters(-1);
		  break;
		case 14:
		  ident = sleep_monsters2();
		  break;
		case 15:
		  ident = hp_player(randint(8));
		  break;
		case 16:
		  ident = detect_invisible();
		  break;
		case 17:
		  if (py.flags.fast == 0)
		    ident = TRUE;
		  py.flags.fast += randint(30) + 15;
		  break;
		case 18:
		  if (py.flags.slow == 0)
		    ident = TRUE;
		  py.flags.slow += randint(30) + 15;
		  break;
		case 19:
		  ident = mass_poly();
		  break;
		case 20:
		  if (remove_curse())
		    {
		      if (py.flags.blind < 1)
			msg_print("The staff glows blue for a moment..");
		      ident = TRUE;
		    }
		  break;
		case 21:
		  ident = detect_evil();
		  break;
		case 22:
		  if ((cure_blindness()) || (cure_poison()) ||
		      (cure_confusion()))
		    ident = TRUE;
		  break;
		case 23:
		  ident = dispel_creature(CD_EVIL, 60);
		  break;
		case 25:
		  ident = unlight_area(char_row, char_col);
		  break;
		case 32:
		  /* store bought flag */
		  break;
		default:
		  msg_print("Internal error in staffs()");
		  break;
		}
	      /* End of staff actions.		*/
	    }
	  if (ident)
	    {
	      if (!known1_p(i_ptr))
		{
		  m_ptr = &py.misc;
		  /* round half-way case up */
		  m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) /
		    m_ptr->lev;
		  prt_experience();

		  identify(&item_val);
		  i_ptr = &inventory[item_val];
		}
	    }