Пример #1
0
/**
 * Known is true when the "attributes" of an object are "known".
 * These include tohit, todam, toac, cost, and pval (charges, bonuses, etc.).
 *
 * Note that "knowing" an object gives you everything that an "awareness"
 * gives you, and much more.  In fact, the player is always "aware" of any
 * item of which he has full "knowledge".
 *
 * This routine also removes any inscriptions generated by "feelings".
 */
void object_known(object_type * o_ptr)
{
    artifact_type *a_ptr = artifact_of(o_ptr);

    /* Forget the feeling */
    o_ptr->feel = FEEL_NONE;

    /* Clear the "Felt" info */
    o_ptr->ident &= ~(IDENT_SENSE);

    /* Clear the "Empty" info */
    o_ptr->ident &= ~(IDENT_EMPTY);

    /* Now we know about the item */
    o_ptr->ident |= (IDENT_KNOWN);

    /* ID knowledge is better than wearing knowledge */
    o_ptr->ident |= (IDENT_WORN);

    /* Artifact has now been seen */
    if (a_ptr)
    {
	history_add_artifact(o_ptr->name1, TRUE, TRUE);
    }

    /* Get all the id flags */
    of_copy(o_ptr->id_obj, o_ptr->flags_obj);
    flags_other(o_ptr, o_ptr->id_other);
}
Пример #2
0
/*
 * Mark an object as sensed.
 */
void object_notice_sensing(object_type *o_ptr)
{
	artifact_type *a_ptr = artifact_of(o_ptr);

	if (object_was_sensed(o_ptr))
		return;


	if (a_ptr)
	{
		a_ptr->seen = a_ptr->everseen = TRUE;
		o_ptr->ident |= IDENT_NAME;
	}

	object_notice_curses(o_ptr);
	if (object_add_ident_flags(o_ptr, IDENT_SENSE))
		object_check_for_ident(o_ptr);
}
Пример #3
0
/**
 * Mark as object as fully known, a.k.a identified. 
 * Mark as object as fully known, a.k.a identified.
 *
 * \param o_ptr is the object to mark as identified
 */
void object_notice_everything(object_type *o_ptr)
{
	artifact_type *a_ptr = artifact_of(o_ptr);

	/* The object is "empty" */
	o_ptr->ident &= ~(IDENT_EMPTY);

	/* Mark as known */
	object_flavor_aware(o_ptr);
	object_add_ident_flags(o_ptr, IDENTS_SET_BY_IDENTIFY);

	/* Artifact has now been seen */
	if (a_ptr && !(o_ptr->ident & IDENT_FAKE))
	{
		a_ptr->seen = a_ptr->everseen = TRUE;
		history_add_artifact(o_ptr->name1, TRUE, TRUE);
	}

	/* Know all flags there are to be known */
	object_know_all_flags(o_ptr);
}
Пример #4
0
static int rd_artifacts(void)
{
	int i;
	u16b tmp16u;
	
	/* Load the Artifacts */
	rd_u16b(&tmp16u);
	
	/* Incompatible save files */
	if (tmp16u > z_info->a_max)
	{
		note(format("Too many (%u) artifacts!", tmp16u));
		return (-1);
	}
	
	/* Read the artifact flags */
	for (i = 0; i < tmp16u; i++)
	{
		byte tmp8u;
		
		rd_byte(&tmp8u);
		a_info[i].created = tmp8u;
		rd_byte(&tmp8u);
		rd_byte(&tmp8u);
		rd_byte(&tmp8u);
	}



	/* For old versions, we need to go through objects and update */
	{
		size_t i;
		object_type *o_ptr = NULL;

		bool *anywhere;
		anywhere = C_ZNEW(z_info->a_max, bool);

		/* All inventory/home artifacts need to be marked as seen */
		for (i = 0; i < INVEN_TOTAL; i++)
		{
			o_ptr = &o_list[i];
			if (object_is_known_artifact(o_ptr))
				artifact_of(o_ptr)->seen = TRUE;
			anywhere[o_ptr->name1] = TRUE;
		}

		for (i = 0; i < (size_t)o_max; i++)
		{
			o_ptr = &o_list[i];
			if (object_is_known_artifact(o_ptr))
				artifact_of(o_ptr)->seen = TRUE;
			anywhere[o_ptr->name1] = TRUE;
		}

		for (i = 0; i < MAX_STORES; i++)
		{
			int j = 0;
			for (j = 0; j < store[i].stock_num; j++)
			{
				o_ptr = &store[i].stock[j];
				if (object_is_known_artifact(o_ptr))
					artifact_of(o_ptr)->seen = TRUE;
				anywhere[o_ptr->name1] = TRUE;
			}
		}

		/* Now update the seen flags correctly */
		for (i = 0; i < z_info->a_max; i++)
		{
			artifact_type *a_ptr = &a_info[i];

			/* If it isn't present anywhere, but has been created,
			 * then it has been lost, and thus seen */
			if (a_ptr->created && !anywhere[i])
				a_ptr->seen = TRUE;
		}

		FREE(anywhere);
	}
	

	return 0;
}
Пример #5
0
/*
 * Try to create an item again. Output some statistics.    -Bernd-
 *
 * The statistics are correct now.  We acquire a clean grid, and then
 * repeatedly place an object in this grid, copying it into an item
 * holder, and then deleting the object.  We fiddle with the artifact
 * counter flags to prevent weirdness.  We use the items to collect
 * statistics on item creation relative to the initial item.
 */
static void wiz_statistics(object_type *o_ptr, int level)
{
	long i, matches, better, worse, other;

	char ch;
	cptr quality;

	bool good, great;

	object_type *i_ptr;
	object_type object_type_body;

	cptr q = "Rolls: %ld, Matches: %ld, Better: %ld, Worse: %ld, Other: %ld";


	artifact_type *a_ptr = artifact_of(o_ptr);

	/* Allow multiple artifacts, because breaking the game is fine here */
	if (a_ptr) a_ptr->created = FALSE;


	/* Interact */
	while (TRUE)
	{
		cptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";

		/* Display item */
		wiz_display_item(o_ptr, TRUE);

		/* Get choices */
		if (!get_com(pmt, &ch)) break;

		if (ch == 'n' || ch == 'N')
		{
			good = FALSE;
			great = FALSE;
			quality = "normal";
		}
		else if (ch == 'g' || ch == 'G')
		{
			good = TRUE;
			great = FALSE;
			quality = "good";
		}
		else if (ch == 'e' || ch == 'E')
		{
			good = TRUE;
			great = TRUE;
			quality = "excellent";
		}
		else
		{
#if 0 /* unused */
			good = FALSE;
			great = FALSE;
#endif /* unused */
			break;
		}

		/* Let us know what we are doing */
		msg_format("Creating a lot of %s items. Base level = %d.",
		           quality, p_ptr->depth);
		message_flush();

		/* Set counters to zero */
		matches = better = worse = other = 0;

		/* Let's rock and roll */
		for (i = 0; i <= TEST_ROLL; i++)
		{
			/* Output every few rolls */
			if ((i < 100) || (i % 100 == 0))
			{
				/* Do not wait */
				inkey_scan = SCAN_INSTANT;

				/* Allow interupt */
				if (inkey())
				{
					/* Flush */
					flush();

					/* Stop rolling */
					break;
				}

				/* Dump the stats */
				prt(format(q, i, matches, better, worse, other), 0, 0);
				Term_fresh();
			}


			/* Get local object */
			i_ptr = &object_type_body;

			/* Wipe the object */
			object_wipe(i_ptr);

			/* Create an object */
			make_object(i_ptr, level, good, great);

			/* Allow multiple artifacts, because breaking the game is fine here */
			a_ptr = artifact_of(o_ptr);
			if (a_ptr) a_ptr->created = FALSE;

			/* Test for the same tval and sval. */
			if ((o_ptr->tval) != (i_ptr->tval)) continue;
			if ((o_ptr->sval) != (i_ptr->sval)) continue;

			/* Check for match */
			if ((i_ptr->pval == o_ptr->pval) &&
			    (i_ptr->to_a == o_ptr->to_a) &&
			    (i_ptr->to_h == o_ptr->to_h) &&
			    (i_ptr->to_d == o_ptr->to_d))
			{
				matches++;
			}

			/* Check for better */
			else if ((i_ptr->pval >= o_ptr->pval) &&
			         (i_ptr->to_a >= o_ptr->to_a) &&
			         (i_ptr->to_h >= o_ptr->to_h) &&
			         (i_ptr->to_d >= o_ptr->to_d))
			{
				better++;
			}

			/* Check for worse */
			else if ((i_ptr->pval <= o_ptr->pval) &&
			         (i_ptr->to_a <= o_ptr->to_a) &&
			         (i_ptr->to_h <= o_ptr->to_h) &&
			         (i_ptr->to_d <= o_ptr->to_d))
			{
				worse++;
			}

			/* Assume different */
			else
			{
				other++;
			}
		}

		/* Final dump */
		msg_format(q, i, matches, better, worse, other);
		message_flush();
	}


	/* Hack -- Normally only make a single artifact */
	if (artifact_p(o_ptr)) a_info[o_ptr->name1].created = TRUE;
}