Ejemplo n.º 1
0
/*
 * Checks for additional knowledge implied by what the player already knows.
 *
 * \param o_ptr is the object to check
 *
 * returns whether it calls object_notice_everyting
 */
bool object_check_for_ident(object_type *o_ptr)
{
	bitflag flags[OF_SIZE], known_flags[OF_SIZE];
	
	object_flags(o_ptr, flags);
	object_flags_known(o_ptr, known_flags);

	/* Some flags are irrelevant or never learned or too hard to learn */
	flags_clear(flags, OF_SIZE, OF_OBJ_ONLY_MASK, FLAG_END);
	flags_clear(known_flags, OF_SIZE, OF_OBJ_ONLY_MASK, FLAG_END);

	if (!of_is_equal(flags, known_flags)) return FALSE;

	/* If we know attack bonuses, and defence bonuses, and effect, then
	 * we effectively know everything, so mark as such */
	if ((object_attack_plusses_are_visible(o_ptr) || (object_was_sensed(o_ptr) && o_ptr->to_h == 0 && o_ptr->to_d == 0)) &&
	    (object_defence_plusses_are_visible(o_ptr) || (object_was_sensed(o_ptr) && o_ptr->to_a == 0)) &&
	    (object_effect_is_known(o_ptr) || !object_effect(o_ptr)))
	{
		object_notice_everything(o_ptr);
		return TRUE;
	}

	/* We still know all the flags, so we still know if it's an ego */
	else if (ego_item_p(o_ptr))
	{
		/* require worn status so you don't learn launcher of accuracy or gloves of slaying before wield */
		if (object_was_worn(o_ptr))
			object_notice_ego(o_ptr);
	}

	return FALSE;
}
Ejemplo n.º 2
0
/**
 * Tweak the cursed status of an object.
 *
 * \param o_ptr is the object to curse or decurse
 */
static void wiz_tweak_curse(object_type *o_ptr)
{
	if (cursed_p(o_ptr))
	{
		msg_print("Resetting existing curses.");
		flags_clear(o_ptr->flags, OF_SIZE, OF_CURSE_MASK, FLAG_END);
	}

	if (get_check("Set light curse? "))
		flags_set(o_ptr->flags, OF_SIZE, OF_LIGHT_CURSE, FLAG_END);
	else if (get_check("Set heavy curse? "))
		flags_set(o_ptr->flags, OF_SIZE, OF_LIGHT_CURSE, OF_HEAVY_CURSE, FLAG_END);
	else if (get_check("Set permanent curse? "))
		flags_set(o_ptr->flags, OF_SIZE, OF_LIGHT_CURSE, OF_HEAVY_CURSE, OF_PERMA_CURSE, FLAG_END);
}
Ejemplo n.º 3
0
	u32 polflags_from_tileflags( unsigned short tile, u32 uoflags, bool use_no_shoot, bool LOS_through_windows )
	{
	  u32 mapflags = 0;

	  if ( ( uoflags & Core::USTRUCT_TILE::FLAG_LIQUID ) &&
		   ( uoflags & Core::USTRUCT_TILE::FLAG_FLOOR ) )
	  {
		mapflags |= FLAG::MOVESEA;
	  }
	  else if ( ( uoflags & Core::USTRUCT_TILE::FLAG_PLATFORM ) &&
				( ~uoflags & Core::USTRUCT_TILE::FLAG_BLOCKING ) )
	  {
		mapflags |= FLAG::MOVELAND;
	  }

	  // GRADUAL only makes sense if also STANDABLE.
	  if ( ( mapflags & FLAG::MOVELAND ) &&
		   ( uoflags & Core::USTRUCT_TILE::FLAG_HALF_HEIGHT ) )
	  {
		mapflags |= FLAG::GRADUAL;
	  }

	  if ( uoflags & Core::USTRUCT_TILE::FLAG_HOVEROVER )
	  {
		mapflags |= FLAG::OVERFLIGHT;
	  }

	  if ( uoflags & Core::USTRUCT_TILE::FLAG_PLATFORM )
	  {
		mapflags |= FLAG::ALLOWDROPON;
	  }

	  if ( uoflags & Core::USTRUCT_TILE::FLAG_STACKABLE )
	  {
		mapflags |= FLAG::STACKABLE;
	  }

	  if ( uoflags & Core::USTRUCT_TILE::FLAG_EQUIPPABLE )
	  {
		mapflags |= FLAG::EQUIPPABLE;
	  }

	  if ( uoflags & Core::USTRUCT_TILE::FLAG_DESC_NEEDS_A )
	  {
		mapflags |= FLAG::DESC_PREPEND_A;
	  }

	  if ( uoflags & Core::USTRUCT_TILE::FLAG_DESC_NEEDS_AN )
	  {
		mapflags |= FLAG::DESC_PREPEND_AN;
	  }

	  if ( use_no_shoot )

	  {

		if ( ( uoflags & Core::USTRUCT_TILE::FLAG_WALL ) &&

			 ( uoflags & ( Core::USTRUCT_TILE::FLAG_BLOCKING | Core::USTRUCT_TILE::FLAG_DOOR ) )

			 )

			 mapflags |= FLAG::BLOCKSIGHT;



		if ( uoflags & Core::USTRUCT_TILE::FLAG_NO_SHOOT )

		  mapflags |= FLAG::BLOCKSIGHT;



		if ( !LOS_through_windows )

		{

		  if ( ( uoflags & Core::USTRUCT_TILE::FLAG_WINDOW ) &&

			   ( uoflags & Core::USTRUCT_TILE::FLAG_WALL )

			   )

			   mapflags |= FLAG::BLOCKSIGHT;

		}
		else

		{

		  if ( uoflags & Core::USTRUCT_TILE::FLAG_WINDOW )

			mapflags &= ~FLAG::BLOCKSIGHT;

		}

	  }

	  else

	  {

		if ( ( uoflags & Core::USTRUCT_TILE::FLAG_WALL ) &&
			 ( ~uoflags & Core::USTRUCT_TILE::FLAG_BLOCKING ) &&
			 ( uoflags & Core::USTRUCT_TILE::FLAG_DOOR ) )
		{
		  // example: 0xf5 secret door
		  mapflags |= FLAG::BLOCKSIGHT;
		}
		else if ( ( uoflags & Core::USTRUCT_TILE::FLAG_WALL ) &&
				  ( ~uoflags & Core::USTRUCT_TILE::FLAG_BLOCKING ) )
		{
		  // example: 0x245 dungeon arch
		}
		else if ( uoflags & ( Core::USTRUCT_TILE::FLAG_BLOCKING |
		  Core::USTRUCT_TILE::FLAG_PLATFORM |
		  Core::USTRUCT_TILE::FLAG_HALF_HEIGHT ) )
		{
		  mapflags |= FLAG::BLOCKSIGHT;
		}
	  }

	  if ( flags_set( uoflags, Core::USTRUCT_TILE::FLAG_FLOOR | Core::USTRUCT_TILE::FLAG_LIQUID | Core::USTRUCT_TILE::FLAG_BLOCKING ) )
	  {
		// not blocking
	  }
	  else if ( ( uoflags & Core::USTRUCT_TILE::FLAG_BLOCKING ) )
	  {
		mapflags |= FLAG::BLOCKING;
	  }
	  if ( uoflags & Core::USTRUCT_TILE::FLAG_ROOF )
	  {
		mapflags |= FLAG::BLOCKING;
	  }
	  else if ( flags_clear( uoflags, Core::USTRUCT_TILE::FLAG_WALL ) &&
				flags_clear( uoflags, Core::USTRUCT_TILE::FLAG_BLOCKING ) )
	  {
		mapflags |= FLAG::MOVABLE;
	  }

	  // the following flags are probably not useful:

	  // everything allows overflight above it.
	  //mapflags |= FLAG::OVERFLIGHT;

	  if ( Core::cfg_show_roof_and_platform_warning )
      if ( ( mapflags & FLAG::BLOCKING ) && ( mapflags & ( FLAG::MOVELAND | FLAG::MOVESEA ) ) )
        INFO_PRINT << " Warning: Tile 0x" << fmt::hexu( tile ) << " uses Roof- and Platform-Flag at same time.\n";

	  return mapflags;
	}
Ejemplo n.º 4
0
/* XXX Eddie should messages be adhoc all over the place?  perhaps the main
 * loop should check for change in inventory/wieldeds and all messages be
 * printed from one place
 */
void object_notice_on_wield(object_type *o_ptr)
{
	bitflag f[OF_SIZE], obvious_mask[OF_SIZE];
	bool obvious = FALSE;
	const slay_t *s_ptr;

	flags_init(obvious_mask, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END);

	/* Save time of wield for later */
	object_last_wield = turn;

	/* Only deal with un-ID'd items */
	if (object_is_known(o_ptr)) return;

	/* Wear it */
	object_flavor_tried(o_ptr);
	if (object_add_ident_flags(o_ptr, IDENT_WORN))
		object_check_for_ident(o_ptr);

	if (obj_is_light(o_ptr) && ego_item_p(o_ptr))
		object_notice_ego(o_ptr);

	if (object_flavor_is_aware(o_ptr) && easy_know(o_ptr))
	{
		object_notice_everything(o_ptr);
		return;
	}

	/* Automatically sense artifacts upon wield */
	object_sense_artifact(o_ptr);

	/* Note artifacts when found */
	if (artifact_p(o_ptr))
		history_add_artifact(o_ptr->name1, object_is_known(o_ptr), TRUE);

	/* special case FA, needed at least for mages wielding gloves */
	if (object_FA_would_be_obvious(o_ptr))
		of_on(obvious_mask, OF_FREE_ACT);

	/* Learn about obvious flags */
	of_union(o_ptr->known_flags, obvious_mask);

	/* Extract the flags */
	object_flags(o_ptr, f);

	/* Find obvious things (disregarding curses) */
	flags_clear(obvious_mask, OF_SIZE, OF_CURSE_MASK, FLAG_END);
	if (of_is_inter(f, obvious_mask)) obvious = TRUE;
	flags_init(obvious_mask, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END);

	/* XXX Eddie should these next NOT call object_check_for_ident due to worries about repairing? */


	/* XXX Eddie this is a small hack, but jewelry with anything noticeable really is obvious */
	/* XXX Eddie learn =soulkeeping vs =bodykeeping when notice sustain_str */
	if (object_is_jewelry(o_ptr))
	{
		/* Learn the flavor of jewelry with obvious flags */
		if (EASY_LEARN && obvious)
			object_flavor_aware(o_ptr);

		/* Learn all flags on any aware non-artifact jewelry */
		if (object_flavor_is_aware(o_ptr) && !artifact_p(o_ptr))
			object_know_all_flags(o_ptr);
	}

	object_check_for_ident(o_ptr);

	if (!obvious) return;

	/* Messages */
	for (s_ptr = slay_table; s_ptr->slay_flag; s_ptr++)
	{
		if (of_has(f, s_ptr->slay_flag) && s_ptr->brand)
		{
			char o_name[40];
			object_desc(o_name, sizeof(o_name), o_ptr, ODESC_BASE);
			msg_format("Your %s %s!", o_name, s_ptr->active_verb);
		}
	}

	/* XXX Eddie need to add stealth here, also need to assert/double-check everything is covered */
	if (of_has(f, OF_STR))
		msg_format("You feel %s!", o_ptr->pval > 0 ? "stronger" : "weaker");
	if (of_has(f, OF_INT))
		msg_format("You feel %s!", o_ptr->pval > 0 ? "smarter" : "more stupid");
	if (of_has(f, OF_WIS))
		msg_format("You feel %s!", o_ptr->pval > 0 ? "wiser" : "more naive");
	if (of_has(f, OF_DEX))
		msg_format("You feel %s!", o_ptr->pval > 0 ? "more dextrous" : "clumsier");
	if (of_has(f, OF_CON))
		msg_format("You feel %s!", o_ptr->pval > 0 ? "healthier" : "sicklier");
	if (of_has(f, OF_CHR))
		msg_format("You feel %s!", o_ptr->pval > 0 ? "cuter" : "uglier");
	if (of_has(f, OF_SPEED))
		msg_format("You feel strangely %s.", o_ptr->pval > 0 ? "quick" : "sluggish");
	if (flags_test(f, OF_SIZE, OF_BLOWS, OF_SHOTS, FLAG_END))
		msg_format("Your hands %s", o_ptr->pval > 0 ? "tingle!" : "ache.");
	if (of_has(f, OF_INFRA))
		msg_format("Your eyes tingle.");
	if (of_has(f, OF_LIGHT))
		msg_print("It glows!");
	if (of_has(f, OF_TELEPATHY))
		msg_print("Your mind feels strangely sharper!");

	/* WARNING -- masking f by obvious mask -- this should be at the end of this function */
	flags_mask(f, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END);

	/* learn the ego on any obvious brand or slay */
	if (EASY_LEARN && ego_item_p(o_ptr) && obvious &&
	    flags_test(f, OF_SIZE, OF_ALL_SLAY_MASK, FLAG_END))
		object_notice_ego(o_ptr);

	/* Remember the flags */
	object_notice_sensing(o_ptr);

	/* XXX Eddie should we check_for_ident here? */
}
Ejemplo n.º 5
0
/*
 * Given an object, return a short identifier which gives some idea of what
 * the item is.
 */
obj_pseudo_t object_pseudo(const object_type *o_ptr)
{
	object_kind *k_ptr = &k_info[o_ptr->k_idx];
	bitflag flags[OF_SIZE];

	/* Get the known and obvious flags on the object,
	 * not including curses or properties of the kind
	 */
	object_flags_known(o_ptr, flags);

	/* MEGA-hack : there needs to be a table of what is obvious in each slot perhaps for each class */
	/* FA on gloves is obvious to mage casters */
	if (object_FA_would_be_obvious(o_ptr))
		flags_mask(flags, OF_SIZE, OF_OBVIOUS_MASK, OF_FREE_ACT, FLAG_END);
	else
		flags_mask(flags, OF_SIZE, OF_OBVIOUS_MASK, FLAG_END);

	flags_clear(flags, OF_SIZE, OF_CURSE_MASK, FLAG_END);
	of_diff(flags, k_ptr->flags);

	if (o_ptr->ident & IDENT_INDESTRUCT)
		return INSCRIP_SPECIAL;
	if ((object_was_sensed(o_ptr) || object_was_worn(o_ptr)) && artifact_p(o_ptr))
		return INSCRIP_SPECIAL;

	/* jewelry does not pseudo */
	if (object_is_jewelry(o_ptr))
		return INSCRIP_NULL;

	/* XXX Eddie should also check for flags with pvals where the pval exceeds
	 * the base pval for things like picks of digging, though for now acid brand gets those
	 */
	if (!of_is_empty(flags))
		return INSCRIP_SPLENDID;

	if (!object_is_known(o_ptr) && !object_was_sensed(o_ptr))
		return INSCRIP_NULL;

	if (ego_item_p(o_ptr))
	{
		/* uncursed bad egos are not excellent */
		if (flags_test(e_info[o_ptr->name2].flags, OF_SIZE, OF_CURSE_MASK, FLAG_END))
			return INSCRIP_STRANGE; /* XXX Eddie need something worse */
		else
			return INSCRIP_EXCELLENT;
	}

	if (o_ptr->to_a == randcalc(k_ptr->to_a, 0, MINIMISE) &&
	    o_ptr->to_h == randcalc(k_ptr->to_h, 0, MINIMISE) &&
		 o_ptr->to_d == randcalc(k_ptr->to_d, 0, MINIMISE))
		return INSCRIP_AVERAGE;

	if (o_ptr->to_a >= randcalc(k_ptr->to_a, 0, MINIMISE) &&
	    o_ptr->to_h >= randcalc(k_ptr->to_h, 0, MINIMISE) &&
	    o_ptr->to_d >= randcalc(k_ptr->to_d, 0, MINIMISE))
		return INSCRIP_MAGICAL;

	if (o_ptr->to_a <= randcalc(k_ptr->to_a, 0, MINIMISE) &&
	    o_ptr->to_h <= randcalc(k_ptr->to_h, 0, MINIMISE) &&
	    o_ptr->to_d <= randcalc(k_ptr->to_d, 0, MINIMISE))
		return INSCRIP_MAGICAL;

	return INSCRIP_STRANGE;
}