diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 1224ddb8..30a2595d 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -2155,6 +2155,7 @@ void Creature::SetCurrWeapon(Weapon* weapon) A8_ABORT(); } #endif + bool need_recalc = curr_weapon_ != weapon; if (auto_switch_weapon_timer_) { room->xtimer.DeleteTimer(auto_switch_weapon_timer_); } @@ -2162,6 +2163,9 @@ void Creature::SetCurrWeapon(Weapon* weapon) GetTrigger()->TakeonWeapon(curr_weapon_, weapon); } curr_weapon_ = weapon; + if (need_recalc) { + RecalcDtoAttr(); + } } void Creature::ResetAllSkillCd() @@ -3049,3 +3053,21 @@ float Creature::GetAttrRate(int attr_id) } return val; } + +void Creature::RecalcDtoAttr() +{ + if (!IsHuman()) { + return; + } + if (GetCurrWeapon()) { + if (GetBattleContext()) { + GetBattleContext()->CalcAttr(AsHuman()->hero_uniid, + GetCurrWeapon()->weapon_uniid); + } + } else { + if (GetBattleContext()) { + GetBattleContext()->CalcAttr(AsHuman()->hero_uniid, + ""); + } + } +} diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index e76b974e..72250a6a 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -255,6 +255,7 @@ class Creature : public MoveableEntity void WinSkillExp(int win_exp); float GetAttrAbs(int attr_id); float GetAttrRate(int attr_id); + void RecalcDtoAttr(); protected: virtual void OnBuffRemove(Buff& buff); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index f25764db..1a664966 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -649,6 +649,7 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google: if (!prepare_items.size() > 0) { SyncAroundPlayers(__FILE__, __LINE__, __func__); } + RecalcDtoAttr(); } void Player::ProcPrepareItems2(const ::google::protobuf::RepeatedPtrField< cs::MFPair >&