From c3f7f72f37adad5103587069ff549798fc9d652d Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Wed, 18 Feb 2009 20:14:23 +0100 Subject: Introduced a toLower method and grouped string utils The string utility methods are now grouped together in the stringutils.h header. Also, a toLower method was added for convenience. --- src/resources/itemdb.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/resources/itemdb.cpp') diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index ceaf0395..0031bbd0 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -30,7 +30,7 @@ #include "../utils/dtor.h" #include "../utils/gettext.h" -#include "../utils/trim.h" +#include "../utils/stringutils.h" #include "../utils/xml.h" namespace @@ -125,12 +125,7 @@ void ItemDB::load() if (itr == mNamedItemInfos.end()) { std::string temp = name; - trim(temp); - - for (unsigned int i = 0; i < temp.size(); i++) - { - temp[i] = (char) tolower(temp[i]); - } + toLower(trim(temp)); mNamedItemInfos[temp] = itemInfo; } -- cgit v1.2.3-70-g09d2 From 1d7b4c4640635c809feca83e76b1aa62109c0707 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Mon, 2 Mar 2009 19:10:40 -0700 Subject: Added particle attacks back on to the players. However, instead of being constant, particle attacks are now weapon specific, so that different weapons can have different attacks. Signed-off-by: Ira Rice --- src/localplayer.cpp | 26 +++++++++++++++++++++++++- src/player.cpp | 24 ++++++++++++++++++++++++ src/resources/itemdb.cpp | 4 ++++ src/resources/iteminfo.h | 22 ++++++++++++++-------- src/resources/monsterinfo.cpp | 1 - 5 files changed, 67 insertions(+), 10 deletions(-) (limited to 'src/resources/itemdb.cpp') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 9bf5d990..bcf3fb15 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -103,7 +103,8 @@ LocalPlayer::~LocalPlayer() void LocalPlayer::logic() { - switch (mAction) { + switch (mAction) + { case STAND: break; @@ -123,13 +124,36 @@ void LocalPlayer::logic() break; case ATTACK: + int rotation = 0; + std::string particleEffect = ""; int frames = 4; + if (mEquippedWeapon && mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW) frames = 5; mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed; + //attack particle effect + if (mEquippedWeapon) + particleEffect = mEquippedWeapon->getParticleEffect(); + + if (!particleEffect.empty() && mParticleEffects) + { + switch (mDirection) + { + case DOWN: rotation = 0; break; + case LEFT: rotation = 90; break; + case UP: rotation = 180; break; + case RIGHT: rotation = 270; break; + default: break; + } + Particle *p; + p = particleEngine->addEffect("graphics/particles/" + + particleEffect, 0, 0, rotation); + controlParticle(p); + } + if (mFrame >= frames) nextStep(); diff --git a/src/player.cpp b/src/player.cpp index 4d5ef171..16f810ad 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -22,6 +22,7 @@ #include "animatedsprite.h" #include "game.h" +#include "particle.h" #include "player.h" #include "text.h" @@ -91,7 +92,10 @@ void Player::logic() break; case ATTACK: + int rotation = 0; + std::string particleEffect = ""; int frames = 4; + if (mEquippedWeapon && mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW) { @@ -100,6 +104,26 @@ void Player::logic() mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed; + //attack particle effect + if (mEquippedWeapon) + particleEffect = mEquippedWeapon->getParticleEffect(); + + if (!particleEffect.empty() && mParticleEffects) + { + switch (mDirection) + { + case DOWN: rotation = 0; break; + case LEFT: rotation = 90; break; + case UP: rotation = 180; break; + case RIGHT: rotation = 270; break; + default: break; + } + Particle *p; + p = particleEngine->addEffect("graphics/particles/" + + particleEffect, 0, 0, rotation); + controlParticle(p); + } + if (mFrame >= frames) nextStep(); diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 0031bbd0..2eff514c 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -110,6 +110,10 @@ void ItemDB::load() { if (xmlStrEqual(itemChild->name, BAD_CAST "sprite")) { + std::string attackParticle = XML::getProperty( + itemChild, "particle-effect", ""); + itemInfo->setParticleEffect(attackParticle); + loadSpriteRef(itemInfo, itemChild); } else if (xmlStrEqual(itemChild->name, BAD_CAST "sound")) diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index d3dd4908..0ea59050 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -67,6 +67,11 @@ class ItemInfo const std::string& getName() const { return mName; } + void setParticleEffect(const std::string &particleEffect) + { mParticle = particleEffect; } + + std::string getParticleEffect() const { return mParticle; } + void setImageName(const std::string &imageName) { mImageName = imageName; } @@ -113,17 +118,18 @@ class ItemInfo const std::string& getSound(EquipmentSoundEvent event) const; protected: - std::string mImageName; /**< The filename of the icon image. */ + std::string mImageName; /**< The filename of the icon image. */ std::string mName; - std::string mDescription; /**< Short description. */ - std::string mEffect; /**< Description of effects. */ - std::string mType; /**< Item type. */ - short mWeight; /**< Weight in grams. */ - int mView; /**< Item ID of how this item looks. */ - int mId; /**< Item ID */ + std::string mDescription; /**< Short description. */ + std::string mEffect; /**< Description of effects. */ + std::string mType; /**< Item type. */ + std::string mParticle; /**< Particle effect used with this item */ + short mWeight; /**< Weight in grams. */ + int mView; /**< Item ID of how this item looks. */ + int mId; /**< Item ID */ // Equipment related members - SpriteAction mAttackType; /**< Attack type, in case of weapon. */ + SpriteAction mAttackType; /**< Attack type, in case of weapon. */ /** Maps gender to sprite filenames. */ std::map mAnimationFiles; diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 5491a0bd..725e9cf5 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -36,7 +36,6 @@ MonsterInfo::~MonsterInfo() mSounds.clear(); } - void MonsterInfo::addSound(MonsterSoundEvent event, std::string filename) { if (mSounds.find(event) == mSounds.end()) -- cgit v1.2.3-70-g09d2 From 0d50333f996a4d5c4bb28032e52a3c57f31805b6 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 11 Mar 2009 18:20:54 -0600 Subject: Only check for name and descriptions in items with positive ID's in the ItemDB. This helps reduce the junk logging for the player and hair sprites. Signed-off-by: Ira Rice --- src/resources/itemdb.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/resources/itemdb.cpp') diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 2eff514c..2b94bd61 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -145,9 +145,12 @@ void ItemDB::load() if (param == error_value) \ logger->log("ItemDB: Missing " #param " attribute for item %i!",id) - CHECK_PARAM(name, ""); + if (id >= 0) + { + CHECK_PARAM(name, ""); + CHECK_PARAM(description, ""); + } CHECK_PARAM(image, ""); - CHECK_PARAM(description, ""); // CHECK_PARAM(effect, ""); // CHECK_PARAM(type, 0); // CHECK_PARAM(weight, 0); -- cgit v1.2.3-70-g09d2