Optional functionality to auto-pickup potions
This commit is contained in:
parent
8d318ae397
commit
f9bc40e8e0
5 changed files with 80 additions and 11 deletions
|
|
@ -301,6 +301,12 @@ void LoadOptions()
|
|||
#endif
|
||||
|
||||
sgOptions.Gameplay.nTickRate = GetIniInt("Game", "Speed", 20);
|
||||
sgOptions.Gameplay.numHealPotionPickup = GetIniInt("Game", "Heal Potion Pickup", 0);
|
||||
sgOptions.Gameplay.numFullHealPotionPickup = GetIniInt("Game", "Full Heal Potion Pickup", 0);
|
||||
sgOptions.Gameplay.numManaPotionPickup = GetIniInt("Game", "Mana Potion Pickup", 0);
|
||||
sgOptions.Gameplay.numFullManaPotionPickup = GetIniInt("Game", "Full Mana Potion Pickup", 0);
|
||||
sgOptions.Gameplay.numRejuPotionPickup = GetIniInt("Game", "Rejuvenation Potion Pickup", 0);
|
||||
sgOptions.Gameplay.numFullRejuPotionPickup = GetIniInt("Game", "Full Rejuvenation Potion Pickup", 0);
|
||||
|
||||
GetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress, sizeof(sgOptions.Network.szBindAddress), "0.0.0.0");
|
||||
sgOptions.Network.nPort = GetIniInt("Network", "Port", 6112);
|
||||
|
|
@ -355,6 +361,13 @@ void SaveOptions()
|
|||
|
||||
SetIniValue("Game", "Speed", sgOptions.Gameplay.nTickRate);
|
||||
|
||||
SetIniValue("Game", "Heal Potion Pickup", sgOptions.Gameplay.numHealPotionPickup);
|
||||
SetIniValue("Game", "Full Heal Potion Pickup", sgOptions.Gameplay.numFullHealPotionPickup);
|
||||
SetIniValue("Game", "Mana Potion Pickup", sgOptions.Gameplay.numManaPotionPickup);
|
||||
SetIniValue("Game", "Full Mana Potion Pickup", sgOptions.Gameplay.numFullManaPotionPickup);
|
||||
SetIniValue("Game", "Rejuvenation Potion Pickup", sgOptions.Gameplay.numRejuPotionPickup);
|
||||
SetIniValue("Game", "Full Rejuvenation Potion Pickup", sgOptions.Gameplay.numFullRejuPotionPickup);
|
||||
|
||||
SetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress);
|
||||
SetIniValue("Network", "Port", sgOptions.Network.nPort);
|
||||
SetIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost);
|
||||
|
|
@ -719,6 +732,8 @@ GameplayOptions::GameplayOptions()
|
|||
, experienceBar("Experience Bar", OptionEntryFlags::None, N_("Experience Bar"), N_("Experience Bar is added to the UI at the bottom of the screen."), false)
|
||||
, enemyHealthBar("Enemy Health Bar", OptionEntryFlags::None, N_("Enemy Health Bar"), N_("Enemy Health Bar is displayed at the top of the screen."), false)
|
||||
, autoGoldPickup("Auto Gold Pickup", OptionEntryFlags::None, N_("Auto Gold Pickup"), N_("Gold is automatically collected when in close proximity to the player."), false)
|
||||
, autoElixirPickup("Auto Elixir Pickup", OptionEntryFlags::None, N_("Auto Elixir Pickup"), N_("Elixirs are automatically collected when in close proximity to the player."), false)
|
||||
, autoPickupInTown("Auto Pickup in Town", OptionEntryFlags::None, N_("Auto Pickup in Town"), N_("Automatically pickup items in town."), false)
|
||||
, adriaRefillsMana("Adria Refills Mana", OptionEntryFlags::None, N_("Adria Refills Mana"), N_("Adria will refill your mana when you visit her shop."), false)
|
||||
, autoEquipWeapons("Auto Equip Weapons", OptionEntryFlags::None, N_("Auto Equip Weapons"), N_("Weapons will be automatically equipped on pickup or purchase if enabled."), true)
|
||||
, autoEquipArmor("Auto Equip Armor", OptionEntryFlags::None, N_("Auto Equip Armor"), N_("Armor will be automatically equipped on pickup or purchase if enabled."), false)
|
||||
|
|
@ -730,6 +745,7 @@ GameplayOptions::GameplayOptions()
|
|||
, autoRefillBelt("Auto Refill Belt", OptionEntryFlags::None, N_("Auto Refill Belt"), N_("Refill belt from inventory when belt item is consumed."), false)
|
||||
, disableCripplingShrines("Disable Crippling Shrines", OptionEntryFlags::None, N_("Disable Crippling Shrines"), N_("When enabled Cauldrons, Fascinating Shrines, Goat Shrines, Ornate Shrines and Sacred Shrines are not able to be clicked on and labeled as disabled."), false)
|
||||
, quickCast("Quick Cast", OptionEntryFlags::None, N_("Quick Cast"), N_("Spell hotkeys instantly cast the spell, rather than switching the readied spell."), false)
|
||||
|
||||
{
|
||||
grabInput.SetValueChangedCallback(OptionGrabInputChanged);
|
||||
experienceBar.SetValueChangedCallback(OptionExperienceBarChanged);
|
||||
|
|
@ -748,6 +764,8 @@ std::vector<OptionEntryBase *> GameplayOptions::GetEntries()
|
|||
&experienceBar,
|
||||
&enemyHealthBar,
|
||||
&autoGoldPickup,
|
||||
&autoElixirPickup,
|
||||
&autoPickupInTown,
|
||||
&adriaRefillsMana,
|
||||
&autoEquipWeapons,
|
||||
&autoEquipArmor,
|
||||
|
|
|
|||
|
|
@ -383,6 +383,10 @@ struct GameplayOptions : OptionCategoryBase {
|
|||
OptionEntryBoolean enemyHealthBar;
|
||||
/** @brief Automatically pick up gold when walking over it. */
|
||||
OptionEntryBoolean autoGoldPickup;
|
||||
/** @brief Auto-pickup elixirs */
|
||||
OptionEntryBoolean autoElixirPickup;
|
||||
/** @brief Enable or Disable auto-pickup in town */
|
||||
OptionEntryBoolean autoPickupInTown;
|
||||
/** @brief Recover mana when talking to Adria. */
|
||||
OptionEntryBoolean adriaRefillsMana;
|
||||
/** @brief Automatically attempt to equip weapon-type items when picking them up. */
|
||||
|
|
@ -405,6 +409,18 @@ struct GameplayOptions : OptionCategoryBase {
|
|||
OptionEntryBoolean disableCripplingShrines;
|
||||
/** @brief Spell hotkeys instantly cast the spell. */
|
||||
OptionEntryBoolean quickCast;
|
||||
/** @brief Number of Healing potions to pick up automatically */
|
||||
int numHealPotionPickup;
|
||||
/** @brief Number of Full Healing potions to pick up automatically */
|
||||
int numFullHealPotionPickup;
|
||||
/** @brief Number of Mana potions to pick up automatically */
|
||||
int numManaPotionPickup;
|
||||
/** @brief Number of Full Mana potions to pick up automatically */
|
||||
int numFullManaPotionPickup;
|
||||
/** @brief Number of Rejuvenating potions to pick up automatically */
|
||||
int numRejuPotionPickup;
|
||||
/** @brief Number of Full Rejuvenating potions to pick up automatically */
|
||||
int numFullRejuPotionPickup;
|
||||
};
|
||||
|
||||
struct ControllerOptions : OptionCategoryBase {
|
||||
|
|
|
|||
|
|
@ -756,7 +756,7 @@ bool DoWalk(int pnum, int variant)
|
|||
ChangeLightOffset(player._plid, { 0, 0 });
|
||||
}
|
||||
|
||||
AutoGoldPickup(pnum);
|
||||
AutoPickup(pnum);
|
||||
return true;
|
||||
} // We didn't reach new tile so update player's "sub-tile" position
|
||||
ChangeOffset(pnum);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@
|
|||
* QoL feature for automatically picking up gold
|
||||
*/
|
||||
|
||||
#include "inv_iterators.hpp"
|
||||
#include "options.h"
|
||||
#include "player.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace devilution {
|
||||
namespace {
|
||||
|
|
@ -30,18 +32,52 @@ bool HasRoomForGold()
|
|||
return false;
|
||||
}
|
||||
|
||||
int NumMiscItemsInInv(int iMiscId)
|
||||
{
|
||||
InventoryAndBeltPlayerItemsRange items { Players[MyPlayerId] };
|
||||
return std::count_if(items.begin(), items.end(), [iMiscId](const Item &item) { return item._iMiscId == iMiscId; });
|
||||
}
|
||||
|
||||
bool DoPickup(Item item)
|
||||
{
|
||||
if (item._itype == ItemType::Gold && *sgOptions.Gameplay.autoGoldPickup && HasRoomForGold())
|
||||
return true;
|
||||
|
||||
if (item._itype == ItemType::Misc
|
||||
&& (AutoPlaceItemInInventory(Players[MyPlayerId], item, false) || AutoPlaceItemInBelt(Players[MyPlayerId], item, false))) {
|
||||
switch (item._iMiscId) {
|
||||
case IMISC_HEAL:
|
||||
return sgOptions.Gameplay.numHealPotionPickup > NumMiscItemsInInv(item._iMiscId);
|
||||
case IMISC_FULLHEAL:
|
||||
return sgOptions.Gameplay.numFullHealPotionPickup > NumMiscItemsInInv(item._iMiscId);
|
||||
case IMISC_MANA:
|
||||
return sgOptions.Gameplay.numManaPotionPickup > NumMiscItemsInInv(item._iMiscId);
|
||||
case IMISC_FULLMANA:
|
||||
return sgOptions.Gameplay.numFullManaPotionPickup > NumMiscItemsInInv(item._iMiscId);
|
||||
case IMISC_REJUV:
|
||||
return sgOptions.Gameplay.numRejuPotionPickup > NumMiscItemsInInv(item._iMiscId);
|
||||
case IMISC_FULLREJUV:
|
||||
return sgOptions.Gameplay.numFullRejuPotionPickup > NumMiscItemsInInv(item._iMiscId);
|
||||
case IMISC_ELIXSTR:
|
||||
case IMISC_ELIXMAG:
|
||||
case IMISC_ELIXDEX:
|
||||
case IMISC_ELIXVIT:
|
||||
return *sgOptions.Gameplay.autoElixirPickup;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void AutoGoldPickup(int pnum)
|
||||
void AutoPickup(int pnum)
|
||||
{
|
||||
if (!*sgOptions.Gameplay.autoGoldPickup)
|
||||
return;
|
||||
|
||||
if (pnum != MyPlayerId)
|
||||
return;
|
||||
if (leveltype == DTYPE_TOWN)
|
||||
return;
|
||||
if (!HasRoomForGold())
|
||||
if (leveltype == DTYPE_TOWN && !*sgOptions.Gameplay.autoPickupInTown)
|
||||
return;
|
||||
|
||||
for (auto pathDir : PathDirs) {
|
||||
|
|
@ -49,12 +85,11 @@ void AutoGoldPickup(int pnum)
|
|||
if (dItem[tile.x][tile.y] != 0) {
|
||||
int itemIndex = dItem[tile.x][tile.y] - 1;
|
||||
auto &item = Items[itemIndex];
|
||||
if (item._itype == ItemType::Gold) {
|
||||
if (DoPickup(item)) {
|
||||
NetSendCmdGItem(true, CMD_REQUESTAGITEM, pnum, pnum, itemIndex);
|
||||
item._iRequest = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@
|
|||
|
||||
namespace devilution {
|
||||
|
||||
void AutoGoldPickup(int pnum);
|
||||
void AutoPickup(int pnum);
|
||||
|
||||
} // namespace devilution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue