summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-09-19 17:28:33 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-09-19 17:28:33 +0000
commit1a9320fafb23940d0463e6f384713d0f99fc0c61 (patch)
treed152680dbdc8febf0b5a445ba760255068d72f04 /src/localplayer.cpp
parent2f027ebcf8f0ad78f7edf58af7dda94d89034c85 (diff)
downloadmana-1a9320fafb23940d0463e6f384713d0f99fc0c61.tar.gz
mana-1a9320fafb23940d0463e6f384713d0f99fc0c61.tar.bz2
mana-1a9320fafb23940d0463e6f384713d0f99fc0c61.tar.xz
mana-1a9320fafb23940d0463e6f384713d0f99fc0c61.zip
Merged 0.0 changes from revision 3362 to 3580 to trunk.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 95e7a478..f4ad7587 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -29,11 +29,19 @@
#include "inventory.h"
#include "item.h"
#include "main.h"
+#include "particle.h"
#include "sound.h"
#include "log.h"
#include "net/gameserver/player.h"
+#include "gui/gui.h"
+
+#include "net/messageout.h"
+#include "net/protocol.h"
+
+#include "utils/tostring.h"
+
LocalPlayer *player_node = NULL;
LocalPlayer::LocalPlayer():
@@ -46,6 +54,7 @@ LocalPlayer::LocalPlayer():
mLevel(1), mMoney(0),
mTotalWeight(1), mMaxWeight(1),
mHP(1), mMaxHP(1),
+ mXp(0),
mTarget(NULL), mPickUpTarget(NULL),
mTrading(false),
mLastAction(-1), mWalkingDir(0),
@@ -112,6 +121,17 @@ LocalPlayer::moveInvItem(Item *item, int newIndex)
item->getInvIndex(), newIndex, item->getQuantity());
}
+Item* LocalPlayer::searchForItem(int itemId)
+{
+ for (int i = 0; i < INVENTORY_SIZE; i++)
+ {
+ if (itemId == mInventory->getItem(i)->getId()) {
+ return mInventory->getItem(i);
+ }
+ }
+ return NULL;
+}
+
void LocalPlayer::equipItem(Item *item)
{
Net::GameServer::Player::equip(item->getInvIndex());
@@ -302,10 +322,14 @@ void LocalPlayer::attack()
setAction(ATTACK);
- if (getWeapon() == 2)
- sound.playSfx("sfx/bow_shoot_1.ogg");
- else
+ if (mEquippedWeapon)
+ {
+ std::string soundFile = mEquippedWeapon->getSound(EQUIP_EVENT_STRIKE);
+ if (soundFile != "") sound.playSfx(soundFile);
+ }
+ else {
sound.playSfx("sfx/fist-swish.ogg");
+ }
Net::GameServer::Player::attack(getSpriteDirection());
}
@@ -329,3 +353,16 @@ void LocalPlayer::raiseAttribute(size_t attr)
mAttributeBase.at(attr)++;
// TODO: Inform the server about our desire to raise the attribute
}
+
+void LocalPlayer::setXp(int xp)
+{
+ if (mMap && xp > mXp)
+ {
+ const std::string text = toString(xp - mXp) + " xp";
+
+ // Show XP number
+ particleEngine->addTextRiseFadeOutEffect(text, hitYellowFont,
+ mPx + 16, mPy - 16);
+ }
+ mXp = xp;
+}