/* Mark the item as fully known */
o_ptr->ident |= (IDENT_MENTAL);
+ /* For being treated as random artifact in screen_object() */
+ o_ptr->art_name = quark_add("");
+
(void)screen_object(o_ptr, 0L);
if (!get_string(ask_msg, dummy_name, sizeof dummy_name)
}
-const activation_type* find_activation_info(const object_type *o_ptr)
+int activation_index(object_type *o_ptr)
+{
+ if (object_is_fixed_artifact(o_ptr))
+ {
+ return a_info[o_ptr->name1].act_idx;
+ }
+ if (object_is_ego(o_ptr))
+ {
+ return e_info[o_ptr->name2].act_idx;
+ }
+ if (!object_is_random_artifact(o_ptr))
+ {
+ return k_info[o_ptr->k_idx].act_idx;
+ }
+
+ return o_ptr->xtra2;
+}
+
+const activation_type* find_activation_info(object_type *o_ptr)
{
+ const int index = activation_index(o_ptr);
const activation_type* p;
for (p = activation_info; p->flag != NULL; ++ p) {
- if (p->index == o_ptr->xtra2)
+ if (p->index == index)
{
return p;
}
int plev = p_ptr->lev;
int k, dir, dummy = 0;
cptr name = k_name + k_info[o_ptr->k_idx].name;
- const activation_type* act_ptr;
+ const activation_type* const act_ptr = find_activation_info(o_ptr);
/* Paranoia */
- if (!o_ptr->xtra2) return FALSE;
+ if (!act_ptr) {
+ /* Maybe forgot adding information to activation_info table ? */
+ msg_print("Activation information is not found.");
+ return FALSE;
+ }
/* Activate for attack */
- switch (o_ptr->xtra2)
+ switch (act_ptr->index)
{
case ACT_SUNLIGHT:
{
default:
{
#ifdef JP
- msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
+ msg_format("Unknown activation effect: %d.", act_ptr->index);
#else
- msg_format("Unknown activation effect: %d.", o_ptr->xtra2);
+ msg_format("Unknown activation effect: %d.", act_ptr->index);
#endif
return FALSE;
}
}
/* Set activation timeout */
- act_ptr = find_activation_info(o_ptr);
-
- if (!act_ptr) {
- /* Maybe forgot adding information to activation_info table ? */
- msg_format("Activation information is not found: %d.", o_ptr->xtra2);
- return FALSE;
- }
-
if (act_ptr->timeout.constant >= 0) {
o_ptr->timeout = act_ptr->timeout.constant;
if (act_ptr->timeout.dice > 0) {
}
} else {
/* Activations that have special timeout */
- switch (o_ptr->xtra2) {
+ switch (act_ptr->index) {
case ACT_BR_FIRE:
o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250;
break;
/* Nothing to do */
break;
default:
- msg_format("Special timeout is not implemented: %d.", o_ptr->xtra2);
+ msg_format("Special timeout is not implemented: %d.", act_ptr->index);
return FALSE;
}
}
q_ptr->to_h = a_ptr->to_h;
q_ptr->to_d = a_ptr->to_d;
q_ptr->weight = a_ptr->weight;
- q_ptr->xtra2 = a_ptr->act_idx;
/* Hack -- extract the "cursed" flag */
if (a_ptr->gen_flags & TRG_CURSED) q_ptr->curse_flags |= (TRC_CURSED);
/* Hack -- use artifact level instead */
if (object_is_fixed_artifact(o_ptr)) lev = a_info[o_ptr->name1].level;
- else if (o_ptr->art_name)
+ else if (object_is_random_artifact(o_ptr))
{
- int i;
- for (i = 0; activation_info[i].flag != NULL; i++)
- {
- if (activation_info[i].index == o_ptr->xtra2)
- {
- lev = activation_info[i].level;
- break;
- }
+ const activation_type* const act_ptr = find_activation_info(o_ptr);
+ if (act_ptr) {
+ lev = act_ptr->level;
}
}
else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) && o_ptr->name2) lev = e_info[o_ptr->name2].level;
}
}
- /* Paranoia - Set activation index for older save data */
- if (object_is_fixed_artifact(o_ptr))
- {
- if (!o_ptr->xtra2) o_ptr->xtra2 = a_info[o_ptr->name1].act_idx;
- }
- else if (object_is_ego(o_ptr))
- {
- if (!o_ptr->xtra2) o_ptr->xtra2 = e_info[o_ptr->name2].act_idx;
- }
- else
- {
- if (!o_ptr->xtra2) o_ptr->xtra2 = k_info[o_ptr->k_idx].act_idx;
- }
-
/* Activate object */
- /* if (o_ptr->xtra2 && (object_is_artifact(o_ptr) || object_is_ego(o_ptr))) */
- if (o_ptr->xtra2)
+ if (activation_index(o_ptr))
{
(void)activate_random_artifact(o_ptr);
extern void one_resistance(object_type *o_ptr);
extern void one_ability(object_type *o_ptr);
extern bool create_artifact(object_type *o_ptr, bool a_scroll);
+extern int activation_index(object_type *o_ptr);
extern bool activate_random_artifact(object_type * o_ptr);
-extern const activation_type* find_activation_info(const object_type *o_ptr);
+extern const activation_type* find_activation_info(object_type *o_ptr);
extern void get_bloody_moon_flags(object_type *o_ptr);
extern void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr);
extern bool create_named_art(int a_idx, int y, int x);
cptr desc;
char timeout[32];
int constant, dice;
- const activation_type* act_ptr = find_activation_info(o_ptr);
+ const activation_type* const act_ptr = find_activation_info(o_ptr);
if (!act_ptr) return _("̤ÄêµÁ", "something undefined");
desc = act_ptr->desc;
/* Overwrite description if it is special */
- switch (o_ptr->xtra2) {
+ switch (act_ptr->index) {
case ACT_BR_FIRE:
if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
desc = _("²Ð±ê¤Î¥Ö¥ì¥¹ (200) ¤È²Ð¤Ø¤ÎÂÑÀ", "breath of fire (200) and resist fire");
strcpy(timeout, _("¤¤¤Ä¤Ç¤â", "every turn"));
} else if (constant < 0) {
/* Activations that have special timeout */
- switch (o_ptr->xtra2) {
+ switch (act_ptr->index) {
case ACT_BR_FIRE:
sprintf(timeout, _("%d ¥¿¡¼¥óËè", "every %d turns"),
((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250);
}
}
- /* Paranoia - Set activation index for older save data */
- if (object_is_fixed_artifact(o_ptr))
- {
- if (!o_ptr->xtra2) o_ptr->xtra2 = a_info[o_ptr->name1].act_idx;
- }
- else if (object_is_ego(o_ptr))
- {
- if (!o_ptr->xtra2) o_ptr->xtra2 = e_info[o_ptr->name2].act_idx;
- }
- else
- {
- if (!o_ptr->xtra2) o_ptr->xtra2 = k_info[o_ptr->k_idx].act_idx;
- }
-
/* Get an explain of an activation */
- /* if ((object_is_artifact(o_ptr) || object_is_ego(o_ptr)) && (o_ptr->xtra2)) */
- if (o_ptr->xtra2)
+ if (activation_index(o_ptr))
{
return item_activation_aux(o_ptr);
}
/* Also, give some extra for activatable powers... */
if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
{
- int i;
- for (i = 0; activation_info[i].flag != NULL; i++)
- {
- if (activation_info[i].index == o_ptr->xtra2)
- {
- total += activation_info[i].value;
- break;
- }
+ const activation_type* const act_ptr = find_activation_info(o_ptr);
+ if (act_ptr) {
+ total += act_ptr->value;
}
}
o_ptr->to_h = a_ptr->to_h;
o_ptr->to_d = a_ptr->to_d;
o_ptr->weight = a_ptr->weight;
- o_ptr->xtra2 = a_ptr->act_idx;
/* Success */
return (TRUE);