添加新手保护buff处理

This commit is contained in:
aozhiwei 2020-05-22 14:59:58 +08:00
parent d92da4f8a4
commit 457c25096d
3 changed files with 15 additions and 2 deletions

View File

@ -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
};

View File

@ -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;
}
}
}

View File

@ -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;