Beispiel #1
0
        /*
         * Init players with some belongings
         *
         * Having an item identifies it and makes the player "aware" of its purpose.
         */
        static void player_outfit(Player.Player p)
        {
            //Object.Object object_type_body = new Object.Object();

            /* Give the player starting equipment */
            for (Start_Item si = Player.Player.instance.Class.start_items; si != null; si = si.next)
            {
                /* Get local object */
                Object.Object i_ptr = new Object.Object();

                /* Prepare the item */
                i_ptr.prep(si.kind, 0, aspect.MINIMISE);
                i_ptr.number = (byte)Random.rand_range(si.min, si.max);
                i_ptr.origin = Origin.BIRTH;

                i_ptr.flavor_aware();
                i_ptr.notice_everything();

                i_ptr.inven_carry(p);
                si.kind.everseen = true;

                /* Deduct the cost of the item from starting cash */
                p.au -= i_ptr.value(i_ptr.number, false);
            }

            /* Sanity check */
            if (p.au < 0)
            {
                p.au = 0;
            }

            /* Now try wielding everything */
            wield_all(p);
        }
Beispiel #2
0
        /*
         * Init players with some belongings
         *
         * Having an item identifies it and makes the player "aware" of its purpose.
         */
        static void player_outfit(Player.Player p)
        {
            //Object.Object object_type_body = new Object.Object();

            /* Give the player starting equipment */
            for (Start_Item si = Player.Player.instance.Class.start_items; si != null; si = si.next)
            {
                /* Get local object */
                Object.Object i_ptr = new Object.Object();

                /* Prepare the item */
                i_ptr.prep(si.kind, 0, aspect.MINIMISE);
                i_ptr.number = (byte)Random.rand_range(si.min, si.max);
                i_ptr.origin = Origin.BIRTH;

                i_ptr.flavor_aware();
                i_ptr.notice_everything();

                i_ptr.inven_carry(p);
                si.kind.everseen = true;

                /* Deduct the cost of the item from starting cash */
                p.au -= i_ptr.value(i_ptr.number, false);
            }

            /* Sanity check */
            if (p.au < 0)
                p.au = 0;

            /* Now try wielding everything */
            wield_all(p);
        }
Beispiel #3
0
        /*
         * Identify an item.
         *
         * `item` is used to print the slot occupied by an object in equip/inven.
         * Any negative value assigned to "item" can be used for specifying an object
         * on the floor.
         */
        public static void do_ident_item(int item, Object.Object o_ptr)
        {
            string o_name = "";            //80

            Message_Type msg_type = (Message_Type)0;
            int          i;
            bool         bad = true;

            /* Identify it */
            o_ptr.flavor_aware();
            o_ptr.notice_everything();

            /* Apply an autoinscription, if necessary */
            Squelch.apply_autoinscription(o_ptr);

            /* Set squelch flag */
            Misc.p_ptr.notice |= (int)Misc.PN_SQUELCH;

            /* Recalculate bonuses */
            Misc.p_ptr.update |= (Misc.PU_BONUS);

            /* Combine / Reorder the pack (later) */
            Misc.p_ptr.notice |= (int)(Misc.PN_COMBINE | Misc.PN_REORDER | Misc.PN_SORT_QUIVER);

            /* Window stuff */
            Misc.p_ptr.redraw |= (Misc.PR_INVEN | Misc.PR_EQUIP);

            /* Description */
            o_name = o_ptr.object_desc(Object.Object.Detail.PREFIX | Object.Object.Detail.FULL);

            /* Determine the message type. */

            /* CC: we need to think more carefully about how we define "bad" with
             * multiple pvals - currently using "all nonzero pvals < 0" */
            for (i = 0; i < o_ptr.num_pvals; i++)
            {
                if (o_ptr.pval[i] > 0)
                {
                    bad = false;
                }
            }

            if (bad)
            {
                msg_type = Message_Type.MSG_IDENT_BAD;
            }
            else if (o_ptr.artifact != null)
            {
                msg_type = Message_Type.MSG_IDENT_ART;
            }
            else if (o_ptr.ego != null)
            {
                msg_type = Message_Type.MSG_IDENT_EGO;
            }
            else
            {
                msg_type = Message_Type.MSG_GENERIC;
            }

            /* Log artifacts to the history list. */
            if (o_ptr.artifact != null)
            {
                History.add_artifact(o_ptr.artifact, true, true);
            }

            /* Describe */
            if (item >= Misc.INVEN_WIELD)
            {
                Utilities.msgt(msg_type, "{0}: {1} ({2}).", Object.Object.describe_use(item), o_name, Object.Object.index_to_label(item));
                //Utilities.msgt(msg_type, "%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
            }
            else if (item >= 0)
            {
                Utilities.msgt(msg_type, "In your pack: {0} ({1}).", o_name, Object.Object.index_to_label(item));
                //Utilities.msgt(msg_type, "In your pack: %s (%c).", o_name, index_to_label(item));
            }
            else
            {
                Utilities.msgt(msg_type, "On the ground: {0}.", o_name);
            }
        }
Beispiel #4
0
        /*
         * 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);
            }
        }
Beispiel #5
0
        /*
         * Buy the item with the given index from the current store's inventory.
         */
        public static void buy(Command_Code code, cmd_arg[] args)
        {
            int item = args[0].value;
            int amt = args[1].value;

            Object.Object o_ptr;
            //object_type object_type_body;
            Object.Object i_ptr = new Object.Object();//&object_type_body;

            //char o_name[80];
            string o_name;
            int price, item_new;

            Store store = Store.current_store();

            if (store == null) {
                Utilities.msg("You cannot purchase items when not in a store.");
                return;
            }

            /* Get the actual object */
            o_ptr = store.stock[item];

            /* Get desired object */
            Object.Object.copy_amt(ref i_ptr, o_ptr, amt);

            /* Ensure we have room */
            if (!i_ptr.inven_carry_okay())
            {
                Utilities.msg("You cannot carry that many items.");
                return;
            }

            /* Describe the object (fully) */
            o_name = i_ptr.object_desc(Object.Object.Detail.PREFIX | Object.Object.Detail.FULL);

            /* Extract the price for the entire stack */
            price = Store.price_item(i_ptr, false, i_ptr.number);

            if (price > Misc.p_ptr.au)
            {
                Utilities.msg("You cannot afford that purchase.");
                return;
            }

            /* Spend the money */
            Misc.p_ptr.au -= price;

            /* Update the display */
            Store.store_flags |= Store.STORE_GOLD_CHANGE;

            /* ID objects on buy */
            i_ptr.notice_everything();

            /* Combine / Reorder the pack (later) */
            Misc.p_ptr.notice |= (Misc.PN_COMBINE | Misc.PN_REORDER | Misc.PN_SORT_QUIVER | Misc.PN_SQUELCH);

            /* The object no longer belongs to the store */
            i_ptr.ident &= ~(Object.Object.IDENT_STORE);

            /* Message */
            if (Random.one_in_(3)) Utilities.msgt(Message_Type.MSG_STORE5, "{0}", Store.comment_accept[Random.randint0(Store.comment_accept.Length)]);
            Utilities.msg("You bought {0} for {1} gold.", o_name, (long)price);

            /* Erase the inscription */
            i_ptr.note = null;

            /* Give it to the player */
            item_new = i_ptr.inven_carry(Misc.p_ptr);

            /* Message */
            o_name = Misc.p_ptr.inventory[item_new].object_desc(Object.Object.Detail.PREFIX | Object.Object.Detail.FULL);
            Utilities.msg("You have {0} ({1}).", o_name, Object.Object.index_to_label(item_new));

            /* Hack - Reduce the number of charges in the original stack */
            if (o_ptr.tval == TVal.TV_WAND || o_ptr.tval == TVal.TV_STAFF)
            {
                o_ptr.pval[Misc.DEFAULT_PVAL] -= i_ptr.pval[Misc.DEFAULT_PVAL];
            }

            /* Handle stuff */
            Misc.p_ptr.handle_stuff();

            /* Remove the bought objects from the store */

            store.item_increase(item, -amt);
            store.item_optimize(item);

            /* Store is empty */
            if (store.stock_num == 0)
            {
                int i;

                /* Shuffle */
                if (Random.one_in_(Store.SHUFFLE))
                {
                    /* Message */
                    Utilities.msg("The shopkeeper retires.");

                    /* Shuffle the store */
                    store.store_shuffle();
                    Store.store_flags |= Store.STORE_FRAME_CHANGE;
                }

                /* Maintain */
                else
                {
                    /* Message */
                    Utilities.msg("The shopkeeper brings out some new stock.");
                }

                /* New inventory */
                for (i = 0; i < 10; ++i)
                    store.store_maint();
            }

            Game_Event.signal(Game_Event.Event_Type.INVENTORY);
            Game_Event.signal(Game_Event.Event_Type.EQUIPMENT);
        }