This commit is contained in:
aozhiwei 2021-07-06 17:13:30 +08:00
parent 94f4386b96
commit d0e6c6478d
2 changed files with 17 additions and 1 deletions

View File

@ -380,6 +380,7 @@ void Creature::RecalcBuffAttr()
{ {
CheckAbilityUsed(); CheckAbilityUsed();
ability_->Clear(); ability_->Clear();
bool need_refresh_hp = false;
for (auto& buff : buff_list_) { for (auto& buff : buff_list_) {
if (buff.meta->i->buff_effect() == kBET_ChgAttr || if (buff.meta->i->buff_effect() == kBET_ChgAttr ||
buff.meta->i->buff_effect() == kBET_Car || buff.meta->i->buff_effect() == kBET_Car ||
@ -399,8 +400,16 @@ void Creature::RecalcBuffAttr()
} }
} }
} }
if (buff.add_frameno == room->GetFrameNo() ||
attr_type == kHAT_MaxHp) {
need_refresh_hp = true;
}
} }
} }
if (need_refresh_hp) {
SetHP(GetMaxHP());
GetTrigger()->HpChg();
}
} }
void Creature::OnBuffRemove(Buff& buff) void Creature::OnBuffRemove(Buff& buff)
@ -1920,7 +1929,8 @@ float Creature::GetHP()
float Creature::GetMaxHP() float Creature::GetMaxHP()
{ {
return ability.max_hp; return ability.max_hp * (1 + GetAbility()->GetAttrRate(kHAT_MaxHp)) +
GetAbility()->GetAttrAbs(kHAT_MaxHp);
} }
float Creature::GetDef() float Creature::GetDef()
@ -2191,3 +2201,8 @@ void Creature::CheckAbilityUsed()
*ability_.get() = *(old_val.get()); *ability_.get() = *(old_val.get());
} }
} }
void Creature::RefreshHP()
{
}

View File

@ -203,6 +203,7 @@ class Creature : public MoveableEntity
bool CheckCollision(); bool CheckCollision();
Trigger* GetTrigger() { return trigger_; }; Trigger* GetTrigger() { return trigger_; };
std::shared_ptr<Ability>& GetAbility() { return ability_; }; std::shared_ptr<Ability>& GetAbility() { return ability_; };
void RefreshHP();
protected: protected: