This commit is contained in:
aozhiwei 2024-01-09 14:52:37 +08:00
parent 17bdb3084b
commit bbbffd3c3b
2 changed files with 6 additions and 6 deletions

View File

@ -172,7 +172,7 @@ AttrHandle Ability::AddAttr(int attr_id, float val)
} }
if (std::fabs(owner_.Get()->GetMaxHP() - old_max_hp) > 0.000001f) { if (std::fabs(owner_.Get()->GetMaxHP() - old_max_hp) > 0.000001f) {
owner_.Get()->SetMaxHP(owner_.Get()->GetMaxHP()); owner_.Get()->SetMaxHP(owner_.Get()->GetMaxHP());
owner_.Get()->SetHP(owner_.Get()->GetHP() * (old_max_hp / owner_.Get()->GetMaxHP())); owner_.Get()->SetHP(owner_.Get()->GetHP() * (owner_.Get()->GetMaxHP() / old_max_hp));
owner_.Get()->room->frame_event.AddHpChg(owner_); owner_.Get()->room->frame_event.AddHpChg(owner_);
} }
return p; return p;
@ -195,7 +195,7 @@ void Ability::RemoveAttr(AttrHandle handle)
p->holder = nullptr; p->holder = nullptr;
if (std::fabs(owner_.Get()->GetMaxHP() - old_max_hp) > 0.000001f) { if (std::fabs(owner_.Get()->GetMaxHP() - old_max_hp) > 0.000001f) {
owner_.Get()->SetMaxHP(owner_.Get()->GetMaxHP()); owner_.Get()->SetMaxHP(owner_.Get()->GetMaxHP());
owner_.Get()->SetHP(owner_.Get()->GetHP() * (old_max_hp / owner_.Get()->GetMaxHP())); owner_.Get()->SetHP(owner_.Get()->GetHP() * (owner_.Get()->GetMaxHP() / old_max_hp));
owner_.Get()->room->frame_event.AddHpChg(owner_); owner_.Get()->room->frame_event.AddHpChg(owner_);
} }
} }
@ -324,7 +324,7 @@ void Ability::GMDelAttr(int attr_id, int idx)
list_for_each_safe(pos, next, head) { list_for_each_safe(pos, next, head) {
AttrAddition* e = list_entry(pos, AttrAddition* e = list_entry(pos,
AttrAddition, AttrAddition,
entry); list_entry);
if (i == idx) { if (i == idx) {
RemoveAttr(e->shared_from_this()); RemoveAttr(e->shared_from_this());
return; return;
@ -363,7 +363,7 @@ std::vector<std::string> Ability::GMShowAttrs()
list_for_each_safe(pos, next, head) { list_for_each_safe(pos, next, head) {
AttrAddition* e = list_entry(pos, AttrAddition* e = list_entry(pos,
AttrAddition, AttrAddition,
entry); list_entry);
data += "" + a8::XValue(e->value).GetString() + ","; data += "" + a8::XValue(e->value).GetString() + ",";
++i; ++i;
} }
@ -394,7 +394,7 @@ std::vector<std::string> Ability::GMShowAttrs()
list_for_each_safe(pos, next, head) { list_for_each_safe(pos, next, head) {
AttrAddition* e = list_entry(pos, AttrAddition* e = list_entry(pos,
AttrAddition, AttrAddition,
entry); list_entry);
data += "" + a8::XValue(e->value).GetString() + ","; data += "" + a8::XValue(e->value).GetString() + ",";
++i; ++i;
} }

View File

@ -1970,7 +1970,7 @@ float Creature::GetHP()
float Creature::GetMaxHP() float Creature::GetMaxHP()
{ {
return ability.max_hp; return GetNetData()->GetMaxHP();
} }
float Creature::GetHPRate() float Creature::GetHPRate()