diff --git a/server/gameserver/constant_export.h b/server/gameserver/constant_export.h index d1cf70c..f377351 100644 --- a/server/gameserver/constant_export.h +++ b/server/gameserver/constant_export.h @@ -42,7 +42,7 @@ enum BuffEffectType_e kBET_Jump = 25, //跳伞中 kBET_IntervalAddBuff = 26, //持续掉血 //kBET_LastAddHp = 27, //持续加血 - //kBET_OnceAddHp = 28, //加血 + kBET_OnceAddHp = 28, //加血 kBET_SummonHero = 29, //召唤英雄 //kBET_SummonHero = 30, //向前跳跃 kBET_Shield = 31, //护盾 diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 33394d1..fa10eb6 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -868,6 +868,11 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff) buff->ProcIntervalAddBuff(caster); } break; + case kBET_OnceAddHp: + { + AddHp(buff->meta->param1); + } + break; case kBET_SummonHero: { SummonHero(buff, @@ -1766,3 +1771,16 @@ void Creature::GetHitEnemys(std::set& enemys) } }); } + +void Creature::AddHp(float hp) +{ + float old_health = GetHP(); + ability.hp += hp; + ability.hp = std::min(GetHP(), GetMaxHP()); + if (IsHuman()) { + Human* hum = (Human*)this; + hum->stats.heal_amount += GetHP() - old_health; + SyncAroundPlayers(__FILE__, __LINE__, __func__); + } +} + diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 0fc09f7..361b18d 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -119,6 +119,7 @@ class Creature : public MoveableEntity bool IsAndroid() const; bool IsHuman() const; virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) {}; + void AddHp(float hp); RaceType_e GetRace() { return race_; } float GetAttrAbs(int attr_id); diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index a3b6fd3..bf488e8 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -3653,15 +3653,6 @@ void Human::GMAddItem(int item_id, int item_num) SyncAroundPlayers(__FILE__, __LINE__, __func__); } -void Human::AddHp(float hp) -{ - float old_health = GetHP(); - ability.hp += hp; - ability.hp = std::min(GetHP(), GetMaxHP()); - stats.heal_amount += GetHP() - old_health; - SyncAroundPlayers(__FILE__, __LINE__, __func__); -} - void Human::OnBulletHit(Bullet* bullet) { if (IsInvincible()) { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 9a97d37..f5c6b01 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -253,7 +253,6 @@ class Human : public Creature virtual std::string GetName() override { return name;}; void UpdateViewObjects(); void GMAddItem(int item_id, int item_num); - void AddHp(float hp); protected: void _InternalUpdateMove(float speed);