diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 12 | ||||
-rw-r--r-- | src/being.h | 9 | ||||
-rw-r--r-- | src/gui/gui.cpp | 2 | ||||
-rw-r--r-- | src/localplayer.cpp | 10 | ||||
-rw-r--r-- | src/localplayer.h | 12 | ||||
-rw-r--r-- | src/net/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/playerhandler.cpp | 2 | ||||
-rw-r--r-- | src/particle.cpp | 19 | ||||
-rw-r--r-- | src/particle.h | 7 |
9 files changed, 69 insertions, 6 deletions
diff --git a/src/being.cpp b/src/being.cpp index 5d30614c..4c3c03f6 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -191,6 +191,18 @@ Being::takeDamage(int amount) } void +Being::showXP(int amount) +{ + gcn::Font* font; + std::string xp = (amount ? toString(amount) : "") + " xp"; + + font = hitYellowFont; + + // show xp number + particleEngine->addTextRiseFadeOutEffect(xp, font, 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 f0c263b0..911f8a21 100644 --- a/src/being.h +++ b/src/being.h @@ -159,6 +159,15 @@ 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/gui.cpp b/src/gui/gui.cpp index ba9aa930..3f9dfd73 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -149,7 +149,7 @@ Gui::Gui(Graphics *graphics): hitBlueFont = new gcn::ImageFont("graphics/gui/hits_blue.png", "0123456789"); hitYellowFont = new gcn::ImageFont("graphics/gui/hits_yellow.png", - "mis"); + "0123456789misxp "); } catch (gcn::Exception e) { diff --git a/src/localplayer.cpp b/src/localplayer.cpp index cc270296..fa8db881 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -40,6 +40,7 @@ LocalPlayer *player_node = NULL; LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map): Player(id, job, map), + mXp(0), mAttackRange(0), mInventory(new Inventory()), mTarget(NULL), mPickUpTarget(NULL), @@ -426,3 +427,12 @@ void LocalPlayer::revive() outMsg.writeInt16(0x00b2); outMsg.writeInt8(0); } + +void LocalPlayer::refreshXp(Uint32 xp) +{ + if (mTarget && xp > mXp) + { + mTarget->showXP(xp-mXp); + } + mXp = xp; +} diff --git a/src/localplayer.h b/src/localplayer.h index 55e63d40..b721e276 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -92,12 +92,12 @@ class LocalPlayer : public Player void useItem(Item *item); void dropItem(Item *item, int quantity); void pickUp(FloorItem *item); - + /** * Sets the attack range. */ void setAttackRange(int range) { mAttackRange = range; } - + /** * Gets the attack range. */ @@ -164,6 +164,12 @@ class LocalPlayer : public Player void revive(); + /** + * Updates the xp value, if a monster was killed then it makes a call + * to show xp. + */ + void refreshXp(Uint32 xp); + Uint32 mCharId; Uint32 mXp, mJobXp; @@ -172,7 +178,7 @@ class LocalPlayer : public Player Uint32 mXpForNextLevel, mJobXpForNextLevel; Uint16 mHp, mMaxHp, mMp, mMaxMp; Uint32 mGp; - + Uint16 mAttackRange; Uint32 mTotalWeight, mMaxWeight; diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index 6d4149ec..102bb3e2 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->mXp = msg.readInt32(); + tempPlayer->refreshXp(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 514e7538..07cfaa14 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->mXp = msg->readInt32(); + player_node->refreshXp(msg->readInt32()); break; case 0x0002: player_node->mJobXp = msg->readInt32(); diff --git a/src/particle.cpp b/src/particle.cpp index 805da102..8e47fb06 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -338,6 +338,25 @@ Particle::addTextSplashEffect(std::string text, return newParticle; } +Particle* +Particle::addTextRiseFadeOutEffect(std::string text, gcn::Font *font, + int x, int y) +{ + Particle *newParticle = new TextParticle(mMap, text, 255, 255, 255, font); + newParticle->setPosition(x, y, 0); + newParticle->setVector ( 0.0f, // X vector + 0.0f, // Y vector + 0.5f // Z vector + ); + newParticle->setGravity(0.0015f); + newParticle->setLifetime(300); + newParticle->setFadeOut(50); + newParticle->setFadeIn(200); + + mChildParticles.push_back(newParticle); + + return newParticle; +} void Particle::setMap(Map *map) diff --git a/src/particle.h b/src/particle.h index 9e9223c7..6d180ecc 100644 --- a/src/particle.h +++ b/src/particle.h @@ -125,6 +125,13 @@ class Particle : public Sprite gcn::Font *font, int x, int y); /** + * Creates a standalone text particle. + */ + Particle* + addTextRiseFadeOutEffect(std::string text, gcn::Font *font, + int x, int y); + + /** * Adds an emitter to the particle. */ void |