diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index af0178c..c2b6050 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -123,7 +123,7 @@ enum BuffEffectType_e kBET_Camouflage = 5, //伪装 kBET_AdPlaying = 6, //看广告中 kBET_LordMode = 7, //上帝模式 - kBET_NewBieMode = 8, //新手模式血量低于50% + kBET_NewProtect = 8, //新手保护血量低于50% kBET_OnceChgAttr = 11, //一次性buff kBET_End }; diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index c777f1b..98e78d7 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -929,7 +929,9 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i SyncAroundPlayers(__FILE__, __LINE__, __func__); } else { float old_health = GetHP(); - ability.hp = std::max(0.0f, GetHP() - dec_hp); + float new_health = std::max(0.0f, GetHP() - dec_hp); + AdjustDecHp(old_health, new_health); + ability.hp = std::max(0.0f, new_health); if (GetHP() - old_health > 0.001f) { stats.damage_amount_in += GetHP() - old_health; } @@ -3202,3 +3204,13 @@ void Human::ClearLordMode() RemoveBuffByEffectId(kBET_LordMode); } } + +void Human::AdjustDecHp(float old_health, float& new_health) +{ + Buff* buff = GetBuffByEffectId(kBET_NewProtect); + if (buff) { + if (GetHP() < GetMaxHP() * buff->meta->param1) { + new_health = GetMaxHP() * buff->meta->param1; + } + } +} diff --git a/server/gameserver/human.h b/server/gameserver/human.h index a9f3af0..0f2e62c 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -271,6 +271,7 @@ private: void FindLocationWithTarget(Entity* target); void Revive(); void ClearLordMode(); + void AdjustDecHp(float old_health, float& new_health); protected: long long last_shot_frameno_ = 0;