diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-08-23 14:14:51 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-08-23 14:14:51 +0000 |
commit | 5b755a2a6afdba9d07703c3bf5447bf314d842ab (patch) | |
tree | 9c8c1808283d5ecc954668fc53d76d0252eec430 | |
parent | 4b8df221acc3bd3e681357df912bdbc7a1ce6c3f (diff) | |
download | mana-5b755a2a6afdba9d07703c3bf5447bf314d842ab.tar.gz mana-5b755a2a6afdba9d07703c3bf5447bf314d842ab.tar.bz2 mana-5b755a2a6afdba9d07703c3bf5447bf314d842ab.tar.xz mana-5b755a2a6afdba9d07703c3bf5447bf314d842ab.zip |
Changed XP gaining effect to appear on the player instead.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/being.cpp | 10 | ||||
-rw-r--r-- | src/being.h | 12 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 5 | ||||
-rw-r--r-- | src/gui/status.cpp | 15 | ||||
-rw-r--r-- | src/localplayer.cpp | 15 | ||||
-rw-r--r-- | src/localplayer.h | 15 | ||||
-rw-r--r-- | src/net/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/playerhandler.cpp | 2 |
9 files changed, 41 insertions, 39 deletions
@@ -6,6 +6,10 @@ button functionality. * src/particle.h, src/particleemitter.cpp, src/particle.cpp: Renamed Particle::mVector to Particle::mVelocity for clarity. + * src/localplayer.cpp, src/gui/ministatus.cpp, src/gui/status.cpp, + src/being.cpp, src/net/charserverhandler.cpp, + src/net/playerhandler.cpp, src/localplayer.h, src/being.h: Changed XP + gaining effect to appear on the player instead. 2007-08-22 Bjørn Lindeijer <bjorn@lindeijer.nl> diff --git a/src/being.cpp b/src/being.cpp index a1c8faf3..402136c5 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -192,16 +192,6 @@ Being::takeDamage(int amount) } void -Being::showXP(int amount) -{ - const std::string xp = toString(amount) + " xp"; - - // Show XP number - particleEngine->addTextRiseFadeOutEffect(xp, hitYellowFont, - mPx + 16, mPy - 16); -} - -void Being::handleAttack(Being *victim, int damage) { setAction(Being::ATTACK); diff --git a/src/being.h b/src/being.h index 911f8a21..7ba1ec88 100644 --- a/src/being.h +++ b/src/being.h @@ -150,8 +150,7 @@ class Being : public Sprite void setSpeech(const std::string &text, Uint32 time); /** - * Puts a damage bubble above this being for the specified amount of - * time. + * Puts a damage bubble above this being. * * @param amount The amount of damage. */ @@ -159,15 +158,6 @@ class Being : public Sprite takeDamage(int amount); /** - * Puts xp above this being for the specified amount of - * time. - * - * @param amount The amount of experience points. - */ - void - showXP(int amount); - - /** * Handles an attack of another being by this being. * * @param victim The attacked being. diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 932b1f22..694a6f32 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -98,7 +98,8 @@ void MiniStatusWindow::update() mHpBar->setProgress((float) player_node->mHp / player_node->mMaxHp); // mMpBar->setProgress((float) player_node->mMp / player_node->mMaxMp); - mXpBar->setProgress((float) player_node->mXp / player_node->mXpForNextLevel); + mXpBar->setProgress( + (float) player_node->getXp() / player_node->mXpForNextLevel); // Update labels mHpLabel->setCaption(toString(player_node->mHp)); @@ -106,7 +107,7 @@ void MiniStatusWindow::update() std::stringstream updatedText; updatedText << (int) ( - (float) player_node->mXp / + (float) player_node->getXp() / player_node->mXpForNextLevel * 100) << "%"; // Displays the number of monsters to next lvl diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 117e90de..927b3554 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -242,7 +242,7 @@ void StatusWindow::update() "/" + toString(mPlayer->mMaxMp)); mMpValueLabel->adjustSize(); - mXpValueLabel->setCaption(toString(mPlayer->mXp) + + mXpValueLabel->setCaption(toString(mPlayer->getXp()) + "/" + toString(mPlayer->mXpForNextLevel)); mXpValueLabel->adjustSize(); @@ -264,13 +264,13 @@ void StatusWindow::update() mHpBar->setColor(0, 171, 34); // Green } - mHpBar->setProgress((float)mPlayer->mHp / (float)mPlayer->mMaxHp); + mHpBar->setProgress((float) mPlayer->mHp / (float) mPlayer->mMaxHp); // mMpBar->setProgress((float)mPlayer->mp / (float)mPlayer->maxMp); mXpBar->setProgress( - (float)mPlayer->mXp / (float)mPlayer->mXpForNextLevel); + (float) mPlayer->getXp() / (float) mPlayer->mXpForNextLevel); mJobXpBar->setProgress( - (float)mPlayer->mJobXp / (float)mPlayer->mJobXpForNextLevel); + (float) mPlayer->mJobXp / (float) mPlayer->mJobXpForNextLevel); // Stats Part // ---------- @@ -285,10 +285,11 @@ void StatusWindow::update() int statusPoints = mPlayer->mStatsPointsToAttribute; // Update labels - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) + { mStatsLabel[i]->setCaption(attrNames[i]); - mStatsDisplayLabel[i]->setCaption(toString((int)mPlayer->mAttr[i])); - mPointsLabel[i]->setCaption(toString((int)mPlayer->mAttrUp[i])); + mStatsDisplayLabel[i]->setCaption(toString((int) mPlayer->mAttr[i])); + mPointsLabel[i]->setCaption(toString((int) mPlayer->mAttrUp[i])); mStatsLabel[i]->adjustSize(); mStatsDisplayLabel[i]->adjustSize(); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 940934b8..e6a52e10 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -29,13 +29,18 @@ #include "inventory.h" #include "item.h" #include "main.h" +#include "particle.h" #include "sound.h" +#include "gui/gui.h" + #include "net/messageout.h" #include "net/protocol.h" #include "resources/equipmentinfo.h" +#include "utils/tostring.h" + LocalPlayer *player_node = NULL; LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map): @@ -439,11 +444,15 @@ void LocalPlayer::revive() outMsg.writeInt8(0); } -void LocalPlayer::refreshXp(Uint32 xp) +void LocalPlayer::setXp(int xp) { - if (mTarget && xp > mXp) + if (mMap && xp > mXp) { - mTarget->showXP(xp-mXp); + const std::string text = toString(xp - mXp) + " xp"; + + // Show XP number + particleEngine->addTextRiseFadeOutEffect(text, hitYellowFont, + mPx + 16, mPy - 16); } mXp = xp; } diff --git a/src/localplayer.h b/src/localplayer.h index 9be185bf..ab519185 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -173,14 +173,19 @@ class LocalPlayer : public Player void revive(); /** - * Updates the xp value, if a monster was killed then it makes a call - * to show xp. + * Sets the amount of XP. Shows XP gaining effect if the player is on + * a map. */ - void refreshXp(Uint32 xp); + void setXp(int xp); + + /** + * Returns the amount of experience points. + */ + int getXp() const { return mXp; } Uint32 mCharId; - Uint32 mXp, mJobXp; + Uint32 mJobXp; Uint16 mLevel; Uint32 mJobLevel; Uint32 mXpForNextLevel, mJobXpForNextLevel; @@ -207,6 +212,8 @@ class LocalPlayer : public Player protected: void walk(unsigned char dir); + int mXp; /**< Experience points. */ + Network *mNetwork; Being *mTarget; FloorItem *mPickUpTarget; diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index 102bb3e2..9018b0af 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -187,7 +187,7 @@ LocalPlayer* CharServerHandler::readPlayerData(MessageIn &msg, int &slot) tempPlayer->mTotalWeight = 0; tempPlayer->mMaxWeight = 0; tempPlayer->mLastAttackTime = 0; - tempPlayer->refreshXp(msg.readInt32()); + tempPlayer->setXp(msg.readInt32()); tempPlayer->mGp = msg.readInt32(); tempPlayer->mJobXp = msg.readInt32(); tempPlayer->mJobLevel = msg.readInt32(); diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index 07cfaa14..a5a2330b 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -194,7 +194,7 @@ void PlayerHandler::handleMessage(MessageIn *msg) case SMSG_PLAYER_STAT_UPDATE_2: switch (msg->readInt16()) { case 0x0001: - player_node->refreshXp(msg->readInt32()); + player_node->setXp(msg->readInt32()); break; case 0x0002: player_node->mJobXp = msg->readInt32(); |