summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/being/playerinfo.cpp46
-rw-r--r--src/enums/being/attributes.h1
-rw-r--r--src/net/eathena/homunculusrecv.cpp1
-rw-r--r--src/net/eathena/mercenaryrecv.cpp2
4 files changed, 33 insertions, 17 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 6ed4fceba..89fd30245 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -396,25 +396,37 @@ void setTrading(const Trading trading)
mTrading = trading;
}
+#define updateAttackStat(atk, delay, speed) \
+ attackDelay = getStatBase(delay); \
+ if (attackDelay) \
+ { \
+ setStatBase(speed, \
+ getStatBase(atk) * 1000 / attackDelay, \
+ Notify_false); \
+ setStatMod(speed, \
+ getStatMod(atk) * 1000 / attackDelay, \
+ Notify_true); \
+ } \
+ else \
+ { \
+ setStatBase(speed, 0, \
+ Notify_false); \
+ setStatMod(speed, 0, \
+ Notify_true); \
+ }
+
void updateAttrs()
{
- const int attackDelay = getStatBase(Attributes::PLAYER_ATTACK_DELAY);
- if (attackDelay)
- {
- setStatBase(Attributes::PLAYER_ATTACK_SPEED,
- getStatBase(Attributes::PLAYER_ATK) * 1000 / attackDelay,
- Notify_false);
- setStatMod(Attributes::PLAYER_ATTACK_SPEED,
- getStatMod(Attributes::PLAYER_ATK) * 1000 / attackDelay,
- Notify_true);
- }
- else
- {
- setStatBase(Attributes::PLAYER_ATTACK_SPEED, 0,
- Notify_false);
- setStatMod(Attributes::PLAYER_ATTACK_SPEED, 0,
- Notify_true);
- }
+ int attackDelay;
+ updateAttackStat(Attributes::PLAYER_ATK,
+ Attributes::PLAYER_ATTACK_DELAY,
+ Attributes::PLAYER_ATTACK_SPEED)
+ updateAttackStat(Attributes::HOMUN_ATK,
+ Attributes::HOMUN_ATTACK_DELAY,
+ Attributes::HOMUN_ATTACK_SPEED)
+ updateAttackStat(Attributes::MERC_ATK,
+ Attributes::MERC_ATTACK_DELAY,
+ Attributes::MERC_ATTACK_SPEED)
}
void init()
diff --git a/src/enums/being/attributes.h b/src/enums/being/attributes.h
index d5c17b137..398eda1b9 100644
--- a/src/enums/being/attributes.h
+++ b/src/enums/being/attributes.h
@@ -91,6 +91,7 @@ enumStart(Attributes)
MERC_MAX_MP,
MERC_ATTACK_DELAY,
MERC_ATTACK_RANGE,
+ MERC_ATTACK_SPEED,
MERC_CRIT,
MERC_FLEE,
MERC_HIT,
diff --git a/src/net/eathena/homunculusrecv.cpp b/src/net/eathena/homunculusrecv.cpp
index 4f6551488..2366b639b 100644
--- a/src/net/eathena/homunculusrecv.cpp
+++ b/src/net/eathena/homunculusrecv.cpp
@@ -151,6 +151,7 @@ void HomunculusRecv::processHomunculusInfo(Net::MessageIn &msg)
PlayerInfo::setStatBase(Attributes::HOMUN_ATTACK_RANGE,
range);
+ PlayerInfo::updateAttrs();
HomunculusInfo *const info = PlayerInfo::getHomunculus();
if (!info) // we can't find homunculus being because id is missing
return;
diff --git a/src/net/eathena/mercenaryrecv.cpp b/src/net/eathena/mercenaryrecv.cpp
index 350ba5967..3f338e61a 100644
--- a/src/net/eathena/mercenaryrecv.cpp
+++ b/src/net/eathena/mercenaryrecv.cpp
@@ -90,6 +90,8 @@ void MercenaryRecv::processMercenaryInfo(Net::MessageIn &msg)
const int range = msg.readInt16("attack range");
PlayerInfo::setStatBase(Attributes::MERC_ATTACK_RANGE,
range);
+ PlayerInfo::updateAttrs();
+
if (dstBeing && localPlayer)
{
MercenaryInfo *const mercenary = new MercenaryInfo;