summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-02 15:45:57 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-02 15:45:57 +0300
commitb17d7d87918b76323e08c0a5c09abd8fa1f3ed71 (patch)
tree03f523babd604b31bff687d50a5caa81723d3455 /src
parentcfcdacfd6ed49916890a93d7565bd2a2d1f1e8f5 (diff)
downloadmanaplus-b17d7d87918b76323e08c0a5c09abd8fa1f3ed71.tar.gz
manaplus-b17d7d87918b76323e08c0a5c09abd8fa1f3ed71.tar.bz2
manaplus-b17d7d87918b76323e08c0a5c09abd8fa1f3ed71.tar.xz
manaplus-b17d7d87918b76323e08c0a5c09abd8fa1f3ed71.zip
Add to status window attribute "damage per second".
Diffstat (limited to 'src')
-rw-r--r--src/net/ea/playerhandler.cpp14
-rw-r--r--src/net/ea/playerhandler.h2
-rw-r--r--src/net/manaserv/playerhandler.cpp5
-rw-r--r--src/net/manaserv/playerhandler.h1
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwa/generalhandler.cpp4
-rw-r--r--src/playerinfo.cpp20
-rw-r--r--src/playerinfo.h7
8 files changed, 50 insertions, 5 deletions
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 4198c14ad..3af237b5b 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -359,9 +359,11 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
case 0x0029:
PlayerInfo::setStatBase(EA_ATK, value);
+ PlayerInfo::updateAttrs();
break;
case 0x002a:
PlayerInfo::setStatMod(EA_ATK, value);
+ PlayerInfo::updateAttrs();
break;
case 0x002b:
@@ -402,8 +404,9 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
case 0x0035:
player_node->setAttackSpeed(value);
- PlayerInfo::setStatBase(ATTACK_SPEED, value);
- PlayerInfo::setStatMod(ATTACK_SPEED, 0);
+ PlayerInfo::setStatBase(ATTACK_DELAY, value);
+ PlayerInfo::setStatMod(ATTACK_DELAY, 0);
+ PlayerInfo::updateAttrs();
break;
case 0x0037:
@@ -484,6 +487,8 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg)
PlayerInfo::setStatBase(type, base, false);
PlayerInfo::setStatMod(type, bonus);
+ if (type == EA_ATK || type == ATTACK_DELAY)
+ PlayerInfo::updateAttrs();
}
void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg)
@@ -552,6 +557,7 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
PlayerInfo::setStatBase(EA_ATK, msg.readInt16(), false);
PlayerInfo::setStatMod(EA_ATK, msg.readInt16());
+ PlayerInfo::updateAttrs();
val = msg.readInt16();
PlayerInfo::setStatBase(EA_MATK, val, false);
@@ -636,4 +642,8 @@ int PlayerHandler::getJobLocation() const
return EA_JOB;
}
+int PlayerHandler::getAttackLocation() const
+{
+ return EA_ATK;
+}
} // namespace Ea
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 8b8751630..57bcbdcd5 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -55,6 +55,8 @@ class PlayerHandler : public Net::PlayerHandler
int getJobLocation() const;
+ int getAttackLocation() const;
+
void processWalkResponse(Net::MessageIn &msg);
void processPlayerWarp(Net::MessageIn &msg);
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 3dfddb436..da8958044 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -432,6 +432,11 @@ int PlayerHandler::getJobLocation() const
return -1;
}
+int PlayerHandler::getAttackLocation() const
+{
+ return -1;
+}
+
Vector PlayerHandler::getDefaultWalkSpeed() const
{
// Return translation in pixels per ticks.
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index dcd05d5fc..f00fea42a 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -74,6 +74,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
bool canCorrectAttributes() const;
int getJobLocation() const;
+ int getAttackLocation() const;
Vector getDefaultWalkSpeed() const;
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 2abd12d57..47d666036 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -68,6 +68,8 @@ class PlayerHandler
virtual int getJobLocation() const = 0;
+ virtual int getAttackLocation() const = 0;
+
virtual Vector getDefaultWalkSpeed() const = 0;
};
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 5ebeb5da9..e1b565399 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -272,12 +272,14 @@ void GeneralHandler::event(Mana::Channels channel,
statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
// xgettext:no-c-format
statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
- statusWindow->addAttribute(ATTACK_SPEED, _("Attack Delay"),
+ statusWindow->addAttribute(ATTACK_DELAY, _("Attack Delay"),
false, "");
statusWindow->addAttribute(WALK_SPEED, _("Walk Delay"),
false, "");
statusWindow->addAttribute(ATTACK_RANGE, _("Attack Range"),
false, "");
+ statusWindow->addAttribute(ATTACK_SPEED, _("Damage per sec."),
+ false, "");
}
else if (event.getName() == Mana::EVENT_GUIWINDOWSUNLOADING)
{
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 3bb196921..769d24a16 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -31,6 +31,9 @@
#include "resources/itemdb.h"
#include "resources/iteminfo.h"
+#include "net/net.h"
+#include "net/playerhandler.h"
+
#include "debug.h"
namespace PlayerInfo
@@ -280,6 +283,23 @@ void setTrading(bool trading)
}
}
+void updateAttrs()
+{
+ int attr = Net::getPlayerHandler()->getAttackLocation();
+ if (attr != -1 && getStatBase(ATTACK_DELAY))
+ {
+ setStatBase(ATTACK_SPEED, getStatBase(attr) * 1000 / getStatBase(
+ ATTACK_DELAY), false);
+ setStatMod(ATTACK_SPEED, getStatMod(attr) * 1000 / getStatBase(
+ ATTACK_DELAY), true);
+ }
+ else
+ {
+ setStatBase(ATTACK_SPEED, 0, false);
+ setStatMod(ATTACK_SPEED, 0, true);
+ }
+}
+
class PlayerInfoListener : Mana::Listener
{
public:
diff --git a/src/playerinfo.h b/src/playerinfo.h
index 401dd26e0..b90e47ce9 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -45,9 +45,10 @@ enum Attribute
SKILL_POINTS,
CHAR_POINTS,
CORR_POINTS,
- ATTACK_SPEED = 100,
+ ATTACK_DELAY = 100,
ATTACK_RANGE = 101,
- WALK_SPEED = 102
+ WALK_SPEED = 102,
+ ATTACK_SPEED = 103
};
/**
@@ -218,6 +219,8 @@ namespace PlayerInfo
*/
void setTrading(bool trading);
+ void updateAttrs();
+
/**
* Initializes some internals.
*/