/* * 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); }
/* * 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); }
/* * Take off (some of) a non-cursed equipment item * * Note that only one item at a time can be wielded per slot. * * Note that taking off an item when "full" may cause that item * to fall to the ground. * * Return the inventory slot into which the item is placed. */ public static short inven_takeoff(int item, int amt) { int slot; Object o_ptr; Object i_ptr; //object_type object_type_body; string act; //char o_name[80]; string o_name; bool track_removed_item = false; /* Get the item to take off */ o_ptr = Misc.p_ptr.inventory[item]; /* Paranoia */ if (amt <= 0) return (-1); /* Verify */ if (amt > o_ptr.number) amt = o_ptr.number; /* Get local object */ i_ptr = new Object();//&object_type_body; /* Obtain a local object */ i_ptr = o_ptr.copy(); //object_copy(i_ptr, o_ptr); /* Modify quantity */ i_ptr.number = (byte)amt; /* Describe the object */ o_name = i_ptr.object_desc(Detail.PREFIX | Detail.FULL); /* Took off weapon */ if (item == Misc.INVEN_WIELD) { act = "You were wielding"; } /* Took off bow */ else if (item == Misc.INVEN_BOW) { act = "You were holding"; } /* Took off light */ else if (item == Misc.INVEN_LIGHT) { act = "You were holding"; } /* Took off something */ else { act = "You were wearing"; } /* Update object_idx if necessary, after optimization */ if (Cave.tracked_object_is(item)) { track_removed_item = true; } /* Modify, Optimize */ inven_item_increase(item, -amt); inven_item_optimize(item); /* Carry the object */ slot = i_ptr.inven_carry(Misc.p_ptr); /* Track removed item if necessary */ if (track_removed_item) { Cave.track_object(slot); } /* Message */ Utilities.msgt(Message_Type.MSG_WIELD, "{0} {1} ({2}).", act, o_name, index_to_label(slot)); Misc.p_ptr.notice |= Misc.PN_SQUELCH; /* Return slot */ return (short)(slot); }
/* * 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); }