/* * Return the quantity of a given item in the pack (include quiver). */ static int find_inven(Object.Object o_ptr) { int i, j; int num = 0; /* Similar slot? */ for (j = 0; j < Misc.QUIVER_END; j++) { Object.Object j_ptr = Misc.p_ptr.inventory[j]; /* Check only the inventory and the quiver */ if (j >= Misc.INVEN_WIELD && j < Misc.QUIVER_START) continue; /* Require identical object types */ if (o_ptr.kind != j_ptr.kind) continue; /* Analyze the items */ switch (o_ptr.tval) { /* Chests */ case TVal.TV_CHEST: { /* Never okay */ return 0; } /* Food and Potions and Scrolls */ case TVal.TV_FOOD: case TVal.TV_POTION: case TVal.TV_SCROLL: { /* Assume okay */ break; } /* Staves and Wands */ case TVal.TV_STAFF: case TVal.TV_WAND: { /* Assume okay */ break; } /* Rods */ case TVal.TV_ROD: { /* Assume okay */ break; } /* Weapons and Armor */ 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: /* Fall through */ /* Rings, Amulets, Lights */ case TVal.TV_RING: case TVal.TV_AMULET: case TVal.TV_LIGHT: { /* Require both items to be known */ if (!o_ptr.is_known() || !j_ptr.is_known()) continue; /* Fall through */ goto fucking_fallthroughs; } /* Missiles */ case TVal.TV_BOLT: case TVal.TV_ARROW: case TVal.TV_SHOT: fucking_fallthroughs: { /* Require identical knowledge of both items */ if (o_ptr.is_known() != j_ptr.is_known()) continue; /* Require identical "bonuses" */ if (o_ptr.to_h != j_ptr.to_h) continue; if (o_ptr.to_d != j_ptr.to_d) continue; if (o_ptr.to_a != j_ptr.to_a) continue; /* Require identical "pval" codes */ for (i = 0; i < Misc.MAX_PVALS; i++) if (o_ptr.pval[i] != j_ptr.pval[i]) continue; if (o_ptr.num_pvals != j_ptr.num_pvals) continue; /* Require identical "artifact" names */ if (o_ptr.artifact != j_ptr.artifact) continue; /* Require identical "ego-item" names */ if (o_ptr.ego != j_ptr.ego) continue; /* Lights must have same amount of fuel */ else if (o_ptr.timeout != j_ptr.timeout && o_ptr.tval == TVal.TV_LIGHT) continue; /* Require identical "values" */ if (o_ptr.ac != j_ptr.ac) continue; if (o_ptr.dd != j_ptr.dd) continue; if (o_ptr.ds != j_ptr.ds) continue; /* Probably okay */ break; } /* Various */ default: { /* Require knowledge */ if (!o_ptr.is_known() || !j_ptr.is_known()) continue; /* Probably okay */ break; } } /* Different flags */ if (!o_ptr.flags.is_equal(j_ptr.flags)) continue; /* They match, so add up */ num += j_ptr.number; } return num; }
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; }
/* * Format object o_ptr's name into 'buf'. */ static int obj_desc_name(ref string buf, int max, int end, Object o_ptr, bool prefix, Detail mode, bool spoil) { bool known = o_ptr.is_known() || ((o_ptr.ident & Object.IDENT_STORE) != 0) || spoil; bool aware = o_ptr.flavor_is_aware() || ((o_ptr.ident & Object.IDENT_STORE) != 0) || spoil; string basename = obj_desc_get_basename(o_ptr, aware); string modstr = obj_desc_get_modstr(o_ptr.kind); if (aware && !o_ptr.kind.everseen && !spoil) o_ptr.kind.everseen = true; if (prefix) end = obj_desc_name_prefix(ref buf, max, end, o_ptr, known, basename, modstr); /* Pluralize if (not forced singular) and * (not a known/visible artifact) and * (not one in stack or forced plural) */ obj_desc_name_format(ref buf, basename, modstr, ((mode & Detail.SINGULAR) == 0) && !(o_ptr.artifact == null && (o_ptr.name_is_visible() || known)) && (o_ptr.number != 1 || ((mode & Detail.PLURAL) != 0))); /** Append extra names of various kinds **/ if((o_ptr.name_is_visible() || known) && o_ptr.artifact != null) buf = buf + " " + o_ptr.artifact.Name; else if((spoil && o_ptr.ego != null) || o_ptr.ego_is_visible()) buf = buf + " " + o_ptr.ego.name; else if(aware && o_ptr.artifact == null && (o_ptr.kind.flavor != null || o_ptr.kind.tval == TVal.TV_SCROLL)) buf = buf + " of " + o_ptr.kind.Name; return end; }
/* * 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); } }