diff --git a/server/gameserver/trigger.cc b/server/gameserver/trigger.cc index 9c892ed7..0b3bbec7 100644 --- a/server/gameserver/trigger.cc +++ b/server/gameserver/trigger.cc @@ -259,6 +259,20 @@ void Trigger::Die(int killer_id, int weapon_id) DispatchEvent(kDieEvent, {killer_id, weapon_id}); } +bool Trigger::HasCondBuff(int cond) +{ + if (!IsValidEventBuff(cond)) { + return false; + } + list_head* pos = nullptr; + list_head* next = nullptr; + list_head* head = &owner_->cond_buffs_[cond]; + list_for_each_safe(pos, next, head) { + return true; + } + return false; +} + void Trigger::TraverseCondBuffs(int cond, std::function func) { if (!IsValidEventBuff(cond)) { @@ -367,19 +381,21 @@ void Trigger::DeactiveBuff(const mt::Buff* buff_meta) } } -void Trigger::TryAddBuffs(Buff* buff, int cond, const std::vector& buffids) +void Trigger::TryAddBuffs(Buff* buff, int cond, const std::vector& buffids, + std::shared_ptr> buff_vars) { for (int buffid : buffids) { if (!owner_->GetBuffById(buffid)) { - owner_->TryAddBuff(buff->GetCaster().Get(), buffid, buff->skill_meta); + owner_->TryAddBuff(buff->GetCaster().Get(), buffid, buff->skill_meta, nullptr, buff_vars); } } } -void Trigger::AddBuffs(Buff* buff, int cond, const std::vector& buffids) +void Trigger::AddBuffs(Buff* buff, int cond, const std::vector& buffids, + std::shared_ptr> buff_vars) { for (int buffid : buffids) { - owner_->TryAddBuff(buff->GetCaster().Get(), buffid, buff->skill_meta); + owner_->TryAddBuff(buff->GetCaster().Get(), buffid, buff->skill_meta, nullptr, buff_vars); } } @@ -487,6 +503,12 @@ void Trigger::Attacked(Creature* sender) void Trigger::DmgOut(Creature* target, float dmg) { DispatchEvent(kDmgOutEvent, {target, dmg}); + TraverseCondBuffs + (kEventBuffDmgOut, + [this, dmg] (Buff* buff, bool& stop) + { + AddBuffs(buff, buff->meta->_int_buff_param1, buff->meta->_buff_param4_int_list); + }); } void Trigger::BulletBlock(IBullet* bullet, const glm::vec3& pos) diff --git a/server/gameserver/trigger.h b/server/gameserver/trigger.h index 0503dc3f..f1196977 100644 --- a/server/gameserver/trigger.h +++ b/server/gameserver/trigger.h @@ -90,12 +90,15 @@ public: std::weak_ptr AddListener(int event_id, a8::CommonCbProc cb); void RemoveEventHandler(std::weak_ptr handler_ptr); void DispatchEvent(int event_id, const std::vector& params); + bool HasCondBuff(int cond); private: void TraverseCondBuffs(int cond, std::function func); void TriggeCondBuffAll(int cond); - void TryAddBuffs(Buff* buff, int cond, const std::vector& buffids); - void AddBuffs(Buff* buff, int cond, const std::vector& buffids); + void TryAddBuffs(Buff* buff, int cond, const std::vector& buffids, + std::shared_ptr> buff_vars = nullptr); + void AddBuffs(Buff* buff, int cond, const std::vector& buffids, + std::shared_ptr> buff_vars = nullptr); void RemoveBuffs(int cond, const std::vector& buffids);