summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-24 17:42:28 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-24 17:42:28 +0300
commit466829aef10af6b95d0f443226e8549f4399b567 (patch)
tree2b0e790cad32c16a7b283e82732820032efe9b91
parenta5f9e965323ad4b211405736eda7557cbe6a013a (diff)
downloadmv-466829aef10af6b95d0f443226e8549f4399b567.tar.gz
mv-466829aef10af6b95d0f443226e8549f4399b567.tar.bz2
mv-466829aef10af6b95d0f443226e8549f4399b567.tar.xz
mv-466829aef10af6b95d0f443226e8549f4399b567.zip
Add particle effect support for skill levelup.
New option skillLevelUpEffectId
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/skilldialog.cpp16
-rw-r--r--src/gui/skilldialog.h4
-rw-r--r--src/net/ea/skillhandler.cpp9
-rw-r--r--src/net/tmwa/questhandler.cpp3
5 files changed, 30 insertions, 3 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 30cb22a63..04c2d19cb 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -384,6 +384,7 @@ DefaultsData* getPathsDefaults()
AddDEF("afkEffectId", -1);
AddDEF("newQuestEffectId", -1);
AddDEF("completeQuestEffectId", -1);
+ AddDEF("skillLevelUpEffectId", -1);
AddDEF("minimaps", "graphics/minimaps/");
AddDEF("maps", "maps/");
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 11b11ba8e..b0e3d8e91 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -22,10 +22,11 @@
#include "gui/skilldialog.h"
+#include "configuration.h"
+#include "effectmanager.h"
#include "itemshortcut.h"
#include "localplayer.h"
#include "playerinfo.h"
-#include "configuration.h"
#include "gui/setup.h"
#include "gui/shortcutwindow.h"
@@ -668,6 +669,19 @@ void SkillDialog::updateQuest(const int var, const int val)
}
}
+void SkillDialog::playUpdateEffect(const int id)
+{
+ const int effectId = paths.getIntValue("skillLevelUpEffectId");
+ if (!effectManager || effectId == -1)
+ return;
+ const SkillMap::const_iterator it = mSkills.find(id);
+ if (it != mSkills.end())
+ {
+ if (it->second)
+ effectManager->trigger(effectId, player_node);
+ }
+}
+
SkillInfo::SkillInfo() :
level(0), skillLevelWidth(0), id(0), modifiable(false),
visible(false), model(nullptr), progress(0.0f), range(0)
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index cf2b518e2..968e171d9 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -32,7 +32,7 @@
#include <vector>
const int SKILL_MIN_ID = 200000;
-const int SKILL_VAR_MIN_ID = 1000000;
+const unsigned int SKILL_VAR_MIN_ID = 1000000;
class Button;
class Label;
@@ -148,6 +148,8 @@ class SkillDialog final : public Window, public gcn::ActionListener
void updateQuest(const int var, const int val);
+ void playUpdateEffect(const int id);
+
private:
typedef std::map<int, SkillInfo*> SkillMap;
SkillMap mSkills;
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
index 45177f7e6..5a7268a6e 100644
--- a/src/net/ea/skillhandler.cpp
+++ b/src/net/ea/skillhandler.cpp
@@ -81,6 +81,7 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
{
msg.readInt16(); // length
const int skillCount = (msg.getLength() - 4) / 37;
+ int updateSkill = 0;
for (int k = 0; k < skillCount; k++)
{
@@ -92,7 +93,9 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
const int range = msg.readInt16();
msg.skip(24); // 0 unused
const int up = msg.readInt8();
-
+ const int oldLevel = PlayerInfo::getStatBase(skillId);
+ if (oldLevel && oldLevel != level)
+ updateSkill = skillId;
PlayerInfo::setStatBase(skillId, level);
if (skillDialog)
{
@@ -100,6 +103,8 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg)
skillDialog->addSkill(skillId, level, range, up);
}
}
+ if (updateSkill && skillDialog)
+ skillDialog->playUpdateEffect(updateSkill);
}
void SkillHandler::processPlayerSkillUp(Net::MessageIn &msg)
@@ -110,6 +115,8 @@ void SkillHandler::processPlayerSkillUp(Net::MessageIn &msg)
const int range = msg.readInt16();
const int up = msg.readInt8();
+ if (skillDialog && PlayerInfo::getStatBase(skillId) != level)
+ skillDialog->playUpdateEffect(skillId);
PlayerInfo::setStatBase(skillId, level);
if (skillDialog)
{
diff --git a/src/net/tmwa/questhandler.cpp b/src/net/tmwa/questhandler.cpp
index f819dfc16..1a64e95f7 100644
--- a/src/net/tmwa/questhandler.cpp
+++ b/src/net/tmwa/questhandler.cpp
@@ -80,7 +80,10 @@ void QuestHandler::processSetQuestVar(Net::MessageIn &msg A_UNUSED)
questsWindow->rebuild(true);
}
if (skillDialog)
+ {
skillDialog->updateQuest(var, val);
+ skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
+ }
}
void QuestHandler::processPlayerQuests(Net::MessageIn &msg A_UNUSED)