summaryrefslogtreecommitdiff
path: root/src/being/playerinfo.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-27 00:06:24 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-27 00:06:24 +0300
commit0419f9b7ea98b9de36b6af97fccd964d3cda4750 (patch)
tree254ebf5626fc22f9ef1730b3e4f1a55233d5e076 /src/being/playerinfo.cpp
parentfab734c769e590b086096e29a498a5a4d71d1946 (diff)
downloadplus-0419f9b7ea98b9de36b6af97fccd964d3cda4750.tar.gz
plus-0419f9b7ea98b9de36b6af97fccd964d3cda4750.tar.bz2
plus-0419f9b7ea98b9de36b6af97fccd964d3cda4750.tar.xz
plus-0419f9b7ea98b9de36b6af97fccd964d3cda4750.zip
Calculate damage per second for homunculus and mercenary.
Diffstat (limited to 'src/being/playerinfo.cpp')
-rw-r--r--src/being/playerinfo.cpp46
1 files changed, 29 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()