static int obj_desc_inscrip(Object o_ptr, ref string buf, int max, int end) { string[] u = { "", "", "", "" }; int n = 0; Object.obj_pseudo_t feel = o_ptr.pseudo(); Bitflag flags_known = new Bitflag(Object_Flag.SIZE); Bitflag f2 = new Bitflag(Object_Flag.SIZE); o_ptr.object_flags_known(ref flags_known); /* Get inscription */ if (o_ptr.note != null && o_ptr.note.value != null) { u[n++] = o_ptr.note.ToString(); } /* Use special inscription, if any */ if (!o_ptr.is_known() && feel != 0) { /* cannot tell excellent vs strange vs splendid until wield */ if (!o_ptr.was_worn() && o_ptr.ego != null) { u[n++] = "ego"; } else { u[n++] = Misc.inscrip_text[(int)feel]; //I know that feel bro. } } else if (((o_ptr.ident & Object.IDENT_EMPTY) != 0) && !o_ptr.is_known()) { u[n++] = "empty"; } else if (!o_ptr.is_known() && o_ptr.was_worn()) { if (o_ptr.wield_slot() == Misc.INVEN_WIELD || o_ptr.wield_slot() == Misc.INVEN_BOW) { u[n++] = "wielded"; } else { u[n++] = "worn"; } } else if (!o_ptr.is_known() && o_ptr.was_fired()) { u[n++] = "fired"; } else if (!o_ptr.flavor_is_aware() && o_ptr.flavor_was_tried()) { u[n++] = "tried"; } /* Note curses */ Object_Flag.create_mask(f2, false, Object_Flag.object_flag_type.CURSE); if (flags_known.is_inter(f2)) { u[n++] = "cursed"; } /* Note squelch */ if (Squelch.item_ok(o_ptr)) { u[n++] = "squelch"; } if (n != 0) { int i; for (i = 0; i < n; i++) { if (i == 0) { buf = buf + " {"; } buf = buf + u[i]; if (i < n - 1) { buf += ", "; } } buf += "}"; } return(end); }
/* * Determine the squelch level of an object, which is similar to its pseudo. * * The main point is when the value is undetermined given current info, * return the maximum possible value. */ public static quality_squelch squelch_level_of(Object.Object o_ptr) { quality_squelch value = quality_squelch.SQUELCH_NONE; Bitflag f = new Bitflag(Object_Flag.SIZE); Bitflag f2 = new Bitflag(Object_Flag.SIZE); int i; o_ptr.object_flags_known(ref f); /* Deal with jewelry specially. */ if (o_ptr.is_jewelry()) { /* CC: average jewelry has at least one known positive pval */ for (i = 0; i < o_ptr.num_pvals; i++) { if ((o_ptr.this_pval_is_visible(i)) && (o_ptr.pval[i] > 0)) { return(quality_squelch.SQUELCH_AVERAGE); } } if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0)) { return(quality_squelch.SQUELCH_AVERAGE); } if ((o_ptr.attack_plusses_are_visible() && ((o_ptr.to_h < 0) || (o_ptr.to_d < 0))) || (o_ptr.defence_plusses_are_visible() && o_ptr.to_a < 0)) { return(quality_squelch.SQUELCH_BAD); } return(quality_squelch.SQUELCH_AVERAGE); } /* And lights */ if (o_ptr.tval == TVal.TV_LIGHT) { Object_Flag.create_mask(f2, true, Object_Flag.object_flag_id.WIELD); if (f.is_inter(f2)) { return(quality_squelch.SQUELCH_ALL); } if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0)) { return(quality_squelch.SQUELCH_GOOD); } if ((o_ptr.to_h < 0) || (o_ptr.to_d < 0) || (o_ptr.to_a < 0)) { return(quality_squelch.SQUELCH_BAD); } return(quality_squelch.SQUELCH_AVERAGE); } /* CC: we need to redefine "bad" with multiple pvals * At the moment we use "all pvals known and negative" */ for (i = 0; i < o_ptr.num_pvals; i++) { if (!o_ptr.this_pval_is_visible(i) || (o_ptr.pval[i] > 0)) { break; } if (i == (o_ptr.num_pvals - 1)) { return(quality_squelch.SQUELCH_BAD); } } if (o_ptr.was_sensed()) { Object.Object.obj_pseudo_t pseudo = o_ptr.pseudo(); switch (pseudo) { case Object.Object.obj_pseudo_t.INSCRIP_AVERAGE: { value = quality_squelch.SQUELCH_AVERAGE; break; } case Object.Object.obj_pseudo_t.INSCRIP_EXCELLENT: { /* have to assume splendid until you have tested it */ if (o_ptr.was_worn()) { if (o_ptr.high_resist_is_possible()) { value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL; } else { value = quality_squelch.SQUELCH_EXCELLENT_NO_HI; } } else { value = quality_squelch.SQUELCH_ALL; } break; } case Object.Object.obj_pseudo_t.INSCRIP_SPLENDID: value = quality_squelch.SQUELCH_ALL; break; case Object.Object.obj_pseudo_t.INSCRIP_null: case Object.Object.obj_pseudo_t.INSCRIP_SPECIAL: value = quality_squelch.SQUELCH_MAX; break; /* This is the interesting case */ case Object.Object.obj_pseudo_t.INSCRIP_STRANGE: case Object.Object.obj_pseudo_t.INSCRIP_MAGICAL: { value = quality_squelch.SQUELCH_GOOD; if ((o_ptr.attack_plusses_are_visible() || Random.randcalc_valid(o_ptr.kind.to_h, o_ptr.to_h) || Random.randcalc_valid(o_ptr.kind.to_d, o_ptr.to_d)) && (o_ptr.defence_plusses_are_visible() || Random.randcalc_valid(o_ptr.kind.to_a, o_ptr.to_a))) { int isgood = is_object_good(o_ptr); if (isgood > 0) { value = quality_squelch.SQUELCH_GOOD; } else if (isgood < 0) { value = quality_squelch.SQUELCH_BAD; } else { value = quality_squelch.SQUELCH_AVERAGE; } } break; } default: /* do not handle any other possible pseudo values */ Misc.assert(false); break; } } else { if (o_ptr.was_worn()) { value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL; /* object would be sensed if it were splendid */ } else if (o_ptr.is_known_not_artifact()) { value = quality_squelch.SQUELCH_ALL; } else { value = quality_squelch.SQUELCH_MAX; } } return(value); }
/* * Sense the inventory */ public static void sense_inventory() { int i; //char o_name[80]; string o_name = null; uint rate; /* No ID when confused in a bad state */ if (Misc.p_ptr.timed[(int)Timed_Effect.CONFUSED] != 0) { return; } /* Notice some things after a while */ if (Misc.turn >= (object_last_wield + 3000)) { object_notice_after_time(); object_last_wield = 0; } /* Get improvement rate */ if (Misc.p_ptr.player_has(Misc.PF.PSEUDO_ID_IMPROV.value)) { rate = (uint)(Misc.p_ptr.Class.sense_base / (Misc.p_ptr.lev * Misc.p_ptr.lev + Misc.p_ptr.Class.sense_div)); } else { rate = (uint)(Misc.p_ptr.Class.sense_base / (Misc.p_ptr.lev + Misc.p_ptr.Class.sense_div)); } if (!Random.one_in_((int)rate)) { return; } /* Check everything */ for (i = 0; i < Misc.ALL_INVEN_TOTAL; i++) { string text = null; Object o_ptr = Misc.p_ptr.inventory[i]; obj_pseudo_t feel; bool cursed; bool okay = false; /* Skip empty slots */ if (o_ptr.kind == null) { continue; } /* Valid "tval" codes */ switch (o_ptr.tval) { case TVal.TV_SHOT: case TVal.TV_ARROW: case TVal.TV_BOLT: case TVal.TV_BOW: case TVal.TV_DIGGING: case TVal.TV_HAFTED: case TVal.TV_POLEARM: case TVal.TV_SWORD: case TVal.TV_BOOTS: case TVal.TV_GLOVES: case TVal.TV_HELM: case TVal.TV_CROWN: case TVal.TV_SHIELD: case TVal.TV_CLOAK: case TVal.TV_SOFT_ARMOR: case TVal.TV_HARD_ARMOR: case TVal.TV_DRAG_ARMOR: { okay = true; break; } } /* Skip non-sense machines */ if (!okay) { continue; } /* It is known, no information needed */ if (o_ptr.is_known()) { continue; } /* It has already been sensed, do not sense it again */ if (o_ptr.was_sensed()) { /* Small chance of wielded, sensed items getting complete ID */ if (o_ptr.artifact == null && (i >= Misc.INVEN_WIELD) && Random.one_in_(1000)) { throw new NotImplementedException(); //do_ident_item(i, o_ptr); } continue; } /* Occasional failure on inventory items */ if ((i < Misc.INVEN_WIELD) && Random.one_in_(5)) { continue; } /* Sense the object */ o_ptr.notice_sensing(); cursed = o_ptr.notice_curses(); /* Get the feeling */ feel = o_ptr.pseudo(); /* Stop everything */ Cave.disturb(Misc.p_ptr, 0, 0); if (cursed) { text = "cursed"; } else { text = Misc.inscrip_text[(int)feel]; } o_name = o_ptr.object_desc(Detail.BASE); /* Average pseudo-ID means full ID */ if (feel == obj_pseudo_t.INSCRIP_AVERAGE) { o_ptr.notice_everything(); Utilities.msgt(Message_Type.MSG_PSEUDOID, "You feel the %s (%c) %s %s average...", o_name, index_to_label(i), ((i >= Misc.INVEN_WIELD) ? "you are using" : "in your pack"), ((o_ptr.number == 1) ? "is" : "are")); } else { if (i >= Misc.INVEN_WIELD) { Utilities.msgt(Message_Type.MSG_PSEUDOID, "You feel the %s (%c) you are %s %s %s...", o_name, index_to_label(i), describe_use(i), ((o_ptr.number == 1) ? "is" : "are"), text); } else { Utilities.msgt(Message_Type.MSG_PSEUDOID, "You feel the %s (%c) in your pack %s %s...", o_name, index_to_label(i), ((o_ptr.number == 1) ? "is" : "are"), text); } } /* Set squelch flag as appropriate */ if (i < Misc.INVEN_WIELD) { Misc.p_ptr.notice |= Misc.PN_SQUELCH; } /* Combine / Reorder the pack (later) */ Misc.p_ptr.notice |= (Misc.PN_COMBINE | Misc.PN_REORDER | Misc.PN_SORT_QUIVER); /* Redraw stuff */ Misc.p_ptr.redraw |= (Misc.PR_INVEN | Misc.PR_EQUIP); } }
static int obj_desc_inscrip(Object o_ptr, ref string buf, int max, int end) { string[] u = {"", "", "", ""}; int n = 0; Object.obj_pseudo_t feel = o_ptr.pseudo(); Bitflag flags_known = new Bitflag(Object_Flag.SIZE); Bitflag f2 = new Bitflag(Object_Flag.SIZE); o_ptr.object_flags_known(ref flags_known); /* Get inscription */ if (o_ptr.note != null && o_ptr.note.value != null) u[n++] = o_ptr.note.ToString(); /* Use special inscription, if any */ if (!o_ptr.is_known() && feel != 0) { /* cannot tell excellent vs strange vs splendid until wield */ if (!o_ptr.was_worn() && o_ptr.ego != null) u[n++] = "ego"; else u[n++] = Misc.inscrip_text[(int)feel]; //I know that feel bro. } else if (((o_ptr.ident & Object.IDENT_EMPTY) != 0) && !o_ptr.is_known()) u[n++] = "empty"; else if (!o_ptr.is_known() && o_ptr.was_worn()) { if (o_ptr.wield_slot() == Misc.INVEN_WIELD || o_ptr.wield_slot() == Misc.INVEN_BOW) u[n++] = "wielded"; else u[n++] = "worn"; } else if (!o_ptr.is_known() && o_ptr.was_fired()) u[n++] = "fired"; else if (!o_ptr.flavor_is_aware() && o_ptr.flavor_was_tried()) u[n++] = "tried"; /* Note curses */ Object_Flag.create_mask(f2, false, Object_Flag.object_flag_type.CURSE); if (flags_known.is_inter(f2)) u[n++] = "cursed"; /* Note squelch */ if (Squelch.item_ok(o_ptr)) u[n++] = "squelch"; if (n != 0) { int i; for (i = 0; i < n; i++) { if(i == 0) buf = buf + " {"; buf = buf + u[i]; if (i < n-1) buf += ", "; } buf += "}"; } return end; }
/* * Determine the squelch level of an object, which is similar to its pseudo. * * The main point is when the value is undetermined given current info, * return the maximum possible value. */ public static quality_squelch squelch_level_of(Object.Object o_ptr) { quality_squelch value = quality_squelch.SQUELCH_NONE; Bitflag f = new Bitflag(Object_Flag.SIZE); Bitflag f2 = new Bitflag(Object_Flag.SIZE); int i; o_ptr.object_flags_known(ref f); /* Deal with jewelry specially. */ if (o_ptr.is_jewelry()) { /* CC: average jewelry has at least one known positive pval */ for (i = 0; i < o_ptr.num_pvals; i++) if ((o_ptr.this_pval_is_visible(i)) && (o_ptr.pval[i] > 0)) return quality_squelch.SQUELCH_AVERAGE; if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0)) return quality_squelch.SQUELCH_AVERAGE; if ((o_ptr.attack_plusses_are_visible() && ((o_ptr.to_h < 0) || (o_ptr.to_d < 0))) || (o_ptr.defence_plusses_are_visible() && o_ptr.to_a < 0)) return quality_squelch.SQUELCH_BAD; return quality_squelch.SQUELCH_AVERAGE; } /* And lights */ if (o_ptr.tval == TVal.TV_LIGHT) { Object_Flag.create_mask(f2, true, Object_Flag.object_flag_id.WIELD); if (f.is_inter(f2)) return quality_squelch.SQUELCH_ALL; if ((o_ptr.to_h > 0) || (o_ptr.to_d > 0) || (o_ptr.to_a > 0)) return quality_squelch.SQUELCH_GOOD; if ((o_ptr.to_h < 0) || (o_ptr.to_d < 0) || (o_ptr.to_a < 0)) return quality_squelch.SQUELCH_BAD; return quality_squelch.SQUELCH_AVERAGE; } /* CC: we need to redefine "bad" with multiple pvals * At the moment we use "all pvals known and negative" */ for (i = 0; i < o_ptr.num_pvals; i++) { if (!o_ptr.this_pval_is_visible(i) || (o_ptr.pval[i] > 0)) break; if (i == (o_ptr.num_pvals - 1)) return quality_squelch.SQUELCH_BAD; } if (o_ptr.was_sensed()) { Object.Object.obj_pseudo_t pseudo = o_ptr.pseudo(); switch (pseudo) { case Object.Object.obj_pseudo_t.INSCRIP_AVERAGE: { value = quality_squelch.SQUELCH_AVERAGE; break; } case Object.Object.obj_pseudo_t.INSCRIP_EXCELLENT: { /* have to assume splendid until you have tested it */ if (o_ptr.was_worn()) { if (o_ptr.high_resist_is_possible()) value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL; else value = quality_squelch.SQUELCH_EXCELLENT_NO_HI; } else { value = quality_squelch.SQUELCH_ALL; } break; } case Object.Object.obj_pseudo_t.INSCRIP_SPLENDID: value = quality_squelch.SQUELCH_ALL; break; case Object.Object.obj_pseudo_t.INSCRIP_null: case Object.Object.obj_pseudo_t.INSCRIP_SPECIAL: value = quality_squelch.SQUELCH_MAX; break; /* This is the interesting case */ case Object.Object.obj_pseudo_t.INSCRIP_STRANGE: case Object.Object.obj_pseudo_t.INSCRIP_MAGICAL: { value = quality_squelch.SQUELCH_GOOD; if ((o_ptr.attack_plusses_are_visible() || Random.randcalc_valid(o_ptr.kind.to_h, o_ptr.to_h) || Random.randcalc_valid(o_ptr.kind.to_d, o_ptr.to_d)) && (o_ptr.defence_plusses_are_visible() || Random.randcalc_valid(o_ptr.kind.to_a, o_ptr.to_a))) { int isgood = is_object_good(o_ptr); if (isgood > 0) { value = quality_squelch.SQUELCH_GOOD; } else if (isgood < 0) { value = quality_squelch.SQUELCH_BAD; } else { value = quality_squelch.SQUELCH_AVERAGE; } } break; } default: /* do not handle any other possible pseudo values */ Misc.assert(false); break; } } else { if (o_ptr.was_worn()) value = quality_squelch.SQUELCH_EXCELLENT_NO_SPL; /* object would be sensed if it were splendid */ else if (o_ptr.is_known_not_artifact()) value = quality_squelch.SQUELCH_ALL; else value = quality_squelch.SQUELCH_MAX; } return value; }