Description |
I based the patch on commit e257a1c5c535ba84917669b6846bfce9eb294aea (2014/11/24).
New option "item_slot" is similar to existing "spell_slot" except it affects potions, scrolls and jewelry instead of spells.
Example of init.txt:
item_slot += potion of invisibility:W
item_slot += scroll of fear:a
item_slot += ring of invisibility:I
Example of in-game messages:
Put on which piece of jewellery? (? for menu, Esc to quit)
You become transparent for a moment.
I - a ring of invisibility (left hand)
Read which item? (? for menu, Esc to quit)
As you read the scroll labeled ANLAIMN BUKEXA, it crumbles to dust.
You assume a fearsome visage. Nothing appears to happen.
It was a scroll of fear.
a - a scroll of fear; e - a +0,+0 short sword (weapon)
Drink which item? (? for menu, Esc to quit)
You fade into invisibility!
It was a potion of invisibility.
W - 2 potions of invisibility
Inventory after those actions:
Hand weapons
e - a +0,+0 short sword (weapon)
Scrolls
a - a scroll of fear
Jewellery
I - a ring of invisibility (left hand) {+Inv, !d}
Potions
W - a potion of invisibility
If there is interest, I can try to reassign known items on pickup also (i.e. if there was only potion of invisibility and it was quaff ID-ed but next time a potion of invisibility is picked up, it is automatically assigned to I).
Reasoning for the patch:
I like "c" as ring of protection from cold, "f" as ring of protection from fire, "m" as ring of protectiob from magic etc. but it takes much time and effort in every game. |
Attached Files |
itemslot1.patch [^] (6,405 bytes) 2014-11-29 02:23 [Show Content] [Hide Content]### Eclipse Workspace Patch 1.0
#P Crawl
diff --git source/initfile.cc source/initfile.cc
index 588a71d..511a7fd 100644
--- source/initfile.cc
+++ source/initfile.cc
@@ -1095,6 +1095,7 @@
note_skill_levels.set(15);
note_skill_levels.set(27);
auto_spell_letters.clear();
+ auto_item_letters.clear();
force_more_message.clear();
sound_mappings.clear();
menu_colour_mappings.clear();
@@ -2282,6 +2283,7 @@
&& key != "levels" && key != "level" && key != "entries"
&& key != "include" && key != "bindkey"
&& key != "spell_slot"
+ && key != "item_slot"
&& key.find("font") == string::npos)
{
lowercase(field);
@@ -3076,6 +3078,27 @@
else
auto_spell_letters.push_back(entry);
}
+ else if (key == "item_slot")
+ {
+ if (plain)
+ auto_item_letters.clear();
+
+ vector<string> thesplit = split_string(":", field);
+ if (thesplit.size() != 2)
+ {
+ return report_error("Error parsing item lettering string: %s\n",
+ field.c_str());
+ }
+ pair<text_pattern,string> entry(lowercase_string(thesplit[0]),
+ thesplit[1]);
+
+ if (minus_equal)
+ remove_matching(auto_item_letters, entry);
+ else if (caret_equal)
+ auto_item_letters.insert(auto_item_letters.begin(), entry);
+ else
+ auto_item_letters.push_back(entry);
+ }
else BOOL_OPTION(pickup_thrown);
#ifdef WIZARD
else if (key == "fsim_mode")
diff --git source/item_use.cc source/item_use.cc
index a685558..c640aeb 100644
--- source/item_use.cc
+++ source/item_use.cc
@@ -14,6 +14,7 @@
#include "artefact.h"
#include "cloud.h"
#include "colour.h"
+#include "command.h"
#include "coordit.h"
#include "decks.h"
#include "delay.h"
@@ -2160,7 +2161,7 @@
potion_type pot_type = (potion_type)potion.sub_type;
if (!potion_effect(static_cast<potion_type>(potion.sub_type),
- 40, &potion, alreadyknown))
+ 40, &potion, alreadyknown, false, &slot))
{
return;
}
@@ -3389,6 +3390,8 @@
mprf("It %s a %s.",
you.inv[item_slot].quantity < prev_quantity ? "was" : "is",
scroll_name.c_str());
+ if(you.inv[item_slot].quantity > 0)
+ auto_assign_item_slot(&item_slot, scroll_name.c_str());
}
if (!alreadyknown && dangerous)
@@ -3473,6 +3476,31 @@
return found;
}
+void auto_assign_item_slot(int* slot, string item_name)
+{
+ if(NULL == slot)
+ return;
+ int j = -1;
+ // check to see whether we've chosen an automatic label:
+ for (unsigned k = 0; k < Options.auto_item_letters.size(); ++k)
+ {
+ if (!Options.auto_item_letters[k].first.matches(item_name))
+ continue;
+ for (unsigned l = 0; l < Options.auto_item_letters[k].second.length(); ++l)
+ if (isaalpha(Options.auto_item_letters[k].second[l]))
+ {
+ j = letter_to_index(Options.auto_item_letters[k].second[l]);
+ break;
+ }
+ if (j != -1)
+ break;
+ }
+ if(j != -1 && j != *slot){
+ swap_inv_slots(*slot, j, true);
+ *slot = j;
+ }
+}
+
#ifdef USE_TILE
// Interactive menu for item drop/use.
diff --git source/item_use.h source/item_use.h
index bd8970b..2482458 100644
--- source/item_use.h
+++ source/item_use.h
@@ -57,6 +57,8 @@
const char *silencedmsg = NULL);
item_def* get_only_unided_ring();
+void auto_assign_item_slot(int* slot, string item_name);
+
#ifdef USE_TILE
void tile_item_use_floor(int idx);
void tile_item_pickup(int idx, bool part);
diff --git source/options.h source/options.h
index 40ff709..e7e8765 100644
--- source/options.h
+++ source/options.h
@@ -242,6 +242,7 @@
vector<text_pattern> note_items; // Objects to note
FixedBitVector<27+1> note_skill_levels; // Skill levels to note
vector<pair<text_pattern, string> > auto_spell_letters;
+ vector<pair<text_pattern, string> > auto_item_letters;
bool autoinscribe_cursed; // Auto-inscribe previosly cursed items.
diff --git source/player-equip.cc source/player-equip.cc
index 007de6a..129018f 100644
--- source/player-equip.cc
+++ source/player-equip.cc
@@ -1482,7 +1482,12 @@
// Cursed or not, we know that since we've put the ring on.
set_ident_flags(item, ISFLAG_KNOW_CURSE);
- mprf_nocap("%s", item.name(DESC_INVENTORY_EQUIP).c_str());
+ int slot = item.link;
+ int old_slot = slot;
+ if (ident == ID_KNOWN_TYPE)
+ auto_assign_item_slot(&slot, item.name(DESC_QUALNAME).c_str());
+ if(old_slot == slot)
+ mprf_nocap("%s", item.name(DESC_INVENTORY_EQUIP).c_str());
}
static void _unequip_jewellery_effect(item_def &item, bool mesg, bool meld)
diff --git source/potion.cc source/potion.cc
index 17a7a14..6ab0284 100644
--- source/potion.cc
+++ source/potion.cc
@@ -45,11 +45,12 @@
* @param drank_it Whether the player actually quaffed (potions and fountains).
* @param was_known Whether the potion was already identified.
* @param from_fountain Is this from a fountain?
+ * @param slot inventory slot index
*
* @return If the potion was used.
*/
bool potion_effect(potion_type pot_eff, int pow, item_def *potion, bool was_known,
- bool from_fountain)
+ bool from_fountain, int* slot)
{
pow = min(pow, 150);
@@ -524,6 +525,9 @@
set_ident_flags(*potion, ISFLAG_IDENT_MASK);
set_ident_type(*potion, ID_KNOWN_TYPE);
mprf("It was a %s.", potion->name(DESC_QUALNAME).c_str());
+ // the quaffed potion will be removed later
+ if(you.inv[*slot].quantity > 1)
+ auto_assign_item_slot(slot, potion->name(DESC_QUALNAME).c_str());
}
return true;
diff --git source/potion.h source/potion.h
index 2d5a8b9..43fa266 100644
--- source/potion.h
+++ source/potion.h
@@ -13,6 +13,6 @@
// to abilities which duplicate such effects.)
bool potion_effect(potion_type pot_eff, int pow,
item_def *potion = nullptr, bool was_known = true,
- bool from_fountain = false);
+ bool from_fountain = false, int* slot = NULL);
#endif
|