This commit is contained in:
aozhiwei 2022-05-24 11:06:38 +08:00
parent 4011004f15
commit f2ab697148
3 changed files with 24 additions and 0 deletions

View File

@ -2155,6 +2155,7 @@ void Creature::SetCurrWeapon(Weapon* weapon)
A8_ABORT(); A8_ABORT();
} }
#endif #endif
bool need_recalc = curr_weapon_ != weapon;
if (auto_switch_weapon_timer_) { if (auto_switch_weapon_timer_) {
room->xtimer.DeleteTimer(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); GetTrigger()->TakeonWeapon(curr_weapon_, weapon);
} }
curr_weapon_ = weapon; curr_weapon_ = weapon;
if (need_recalc) {
RecalcDtoAttr();
}
} }
void Creature::ResetAllSkillCd() void Creature::ResetAllSkillCd()
@ -3049,3 +3053,21 @@ float Creature::GetAttrRate(int attr_id)
} }
return val; 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,
"");
}
}
}

View File

@ -255,6 +255,7 @@ class Creature : public MoveableEntity
void WinSkillExp(int win_exp); void WinSkillExp(int win_exp);
float GetAttrAbs(int attr_id); float GetAttrAbs(int attr_id);
float GetAttrRate(int attr_id); float GetAttrRate(int attr_id);
void RecalcDtoAttr();
protected: protected:
virtual void OnBuffRemove(Buff& buff); virtual void OnBuffRemove(Buff& buff);

View File

@ -649,6 +649,7 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
if (!prepare_items.size() > 0) { if (!prepare_items.size() > 0) {
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
RecalcDtoAttr();
} }
void Player::ProcPrepareItems2(const ::google::protobuf::RepeatedPtrField< cs::MFPair >& void Player::ProcPrepareItems2(const ::google::protobuf::RepeatedPtrField< cs::MFPair >&