summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-09 21:31:02 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-09 21:31:02 +0300
commit90705929b29445a4569ff5c9ad13b7efcb304e0a (patch)
tree0dae1643b0fb33131fb918fe3a1729e879379e26 /src/being
parentb3fa7a53a29a1001935514a38f140af2b816771a (diff)
downloadmanaverse-90705929b29445a4569ff5c9ad13b7efcb304e0a.tar.gz
manaverse-90705929b29445a4569ff5c9ad13b7efcb304e0a.tar.bz2
manaverse-90705929b29445a4569ff5c9ad13b7efcb304e0a.tar.xz
manaverse-90705929b29445a4569ff5c9ad13b7efcb304e0a.zip
Add different use actions for items.
Can be used from chat or from custom item menu from items.xml
Diffstat (limited to 'src/being')
-rw-r--r--src/being/playerinfo.cpp22
-rw-r--r--src/being/playerinfo.h8
2 files changed, 24 insertions, 6 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 4429ba5f7..9f1514243 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -267,7 +267,9 @@ void useItem(const Item *const item, const Sfx sfx)
inventoryHandler->useItem(item);
}
-void useEquipItem(const Item *const item, const Sfx sfx)
+void useEquipItem(const Item *const item,
+ const int16_t useType,
+ const Sfx sfx)
{
if (item != nullptr)
{
@@ -303,7 +305,12 @@ void useEquipItem(const Item *const item, const Sfx sfx)
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
if (inventoryHandler != nullptr)
- inventoryHandler->useItem(item);
+ {
+ if (useType == 0)
+ inventoryHandler->useItem(item);
+ else
+ inventoryHandler->useItem(item, useType);
+ }
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
}
@@ -311,7 +318,9 @@ void useEquipItem(const Item *const item, const Sfx sfx)
}
}
-void useEquipItem2(const Item *const item, const Sfx sfx)
+void useEquipItem2(const Item *const item,
+ const int16_t useType,
+ const Sfx sfx)
{
if (item != nullptr)
{
@@ -339,7 +348,12 @@ void useEquipItem2(const Item *const item, const Sfx sfx)
if (sfx == Sfx_true)
ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
if (inventoryHandler != nullptr)
- inventoryHandler->useItem(item);
+ {
+ if (useType == 0)
+ inventoryHandler->useItem(item);
+ else
+ inventoryHandler->useItem(item, useType);
+ }
}
}
}
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index 1c81d7761..004691e86 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -239,9 +239,13 @@ namespace PlayerInfo
void useItem(const Item *const item, const Sfx sfx);
- void useEquipItem(const Item *const item, const Sfx sfx);
+ void useEquipItem(const Item *const item,
+ const int16_t useType,
+ const Sfx sfx);
- void useEquipItem2(const Item *const item, const Sfx sfx);
+ void useEquipItem2(const Item *const item,
+ const int16_t useType,
+ const Sfx sfx);
void dropItem(const Item *const item, const int amount, const Sfx sfx);