summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-04 19:19:53 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-04 19:19:53 +0300
commitdb43ad3b72fe207e6cc03a1fd341ea598d123319 (patch)
tree6d338e9e0bff66e7751d6d0866f32388bdcfe59c /src/being
parent65a88f27b994f7ade178368c569d466f6344ded6 (diff)
downloadplus-db43ad3b72fe207e6cc03a1fd341ea598d123319.tar.gz
plus-db43ad3b72fe207e6cc03a1fd341ea598d123319.tar.bz2
plus-db43ad3b72fe207e6cc03a1fd341ea598d123319.tar.xz
plus-db43ad3b72fe207e6cc03a1fd341ea598d123319.zip
add pickup and drop sound effects.
Works like equip/unequip effects.
Diffstat (limited to 'src/being')
-rw-r--r--src/being/localplayer.cpp2
-rw-r--r--src/being/playerinfo.cpp20
-rw-r--r--src/being/playerinfo.h5
3 files changed, 25 insertions, 2 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 657436f49..787d59038 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -898,7 +898,7 @@ bool LocalPlayer::pickUp(FloorItem *const item)
{
if (actorSpriteManager && actorSpriteManager->checkForPickup(item))
{
- Net::getPlayerHandler()->pickUp(item);
+ PlayerInfo::pickUpItem(item, true);
mPickUpTarget = nullptr;
}
}
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 3d311dd91..169ee5be3 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -24,6 +24,7 @@
#include "client.h"
#include "configuration.h"
#include "depricatedevent.h"
+#include "flooritem.h"
#include "inventory.h"
#include "itemsoundmanager.h"
@@ -321,14 +322,31 @@ void useEquipItem2(const Item *const item, bool sfx)
{
if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
{
- Net::getInventoryHandler()->useItem(item);
if (sfx)
ItemSoundManager::playSfx(item, SOUND_EVENT_USE);
+ Net::getInventoryHandler()->useItem(item);
}
}
}
}
+void dropItem(const Item *const item, const int amount, bool sfx)
+{
+ if (item && mProtectedItems.find(item->getId()) == mProtectedItems.end())
+ {
+ if (sfx)
+ ItemSoundManager::playSfx(item, SOUND_EVENT_DROP);
+ Net::getInventoryHandler()->dropItem(item, amount);
+ }
+}
+
+void pickUpItem(const FloorItem *const item, bool sfx)
+{
+ if (sfx)
+ ItemSoundManager::playSfx(item, SOUND_EVENT_PICKUP);
+ Net::getPlayerHandler()->pickUp(item);
+}
+
// --- Misc -------------------------------------------------------------------
void setBackend(const PlayerInfoBackend &backend)
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index cd454692f..eef07c584 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -61,6 +61,7 @@ struct PlayerInfoBackend final
IntMap mSkills;
};
+class FloorItem;
class Inventory;
class Item;
@@ -267,6 +268,10 @@ namespace PlayerInfo
void useEquipItem2(const Item *const item, bool sfx);
+ void dropItem(const Item *const item, const int amount, bool sfx);
+
+ void pickUpItem(const FloorItem *const item, bool sfx);
+
void protectItem(const int id);
void unprotectItem(const int id);