1
This commit is contained in:
parent
f99aed08bb
commit
46196c85ff
@ -259,6 +259,20 @@ void Trigger::Die(int killer_id, int weapon_id)
|
|||||||
DispatchEvent(kDieEvent, {killer_id, 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<void (Buff*, bool&)> func)
|
void Trigger::TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func)
|
||||||
{
|
{
|
||||||
if (!IsValidEventBuff(cond)) {
|
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<int>& buffids)
|
void Trigger::TryAddBuffs(Buff* buff, int cond, const std::vector<int>& buffids,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars)
|
||||||
{
|
{
|
||||||
for (int buffid : buffids) {
|
for (int buffid : buffids) {
|
||||||
if (!owner_->GetBuffById(buffid)) {
|
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<int>& buffids)
|
void Trigger::AddBuffs(Buff* buff, int cond, const std::vector<int>& buffids,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars)
|
||||||
{
|
{
|
||||||
for (int buffid : buffids) {
|
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)
|
void Trigger::DmgOut(Creature* target, float dmg)
|
||||||
{
|
{
|
||||||
DispatchEvent(kDmgOutEvent, {target, 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)
|
void Trigger::BulletBlock(IBullet* bullet, const glm::vec3& pos)
|
||||||
|
@ -90,12 +90,15 @@ public:
|
|||||||
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, a8::CommonCbProc cb);
|
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, a8::CommonCbProc cb);
|
||||||
void RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler_ptr);
|
void RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler_ptr);
|
||||||
void DispatchEvent(int event_id, const std::vector<std::any>& params);
|
void DispatchEvent(int event_id, const std::vector<std::any>& params);
|
||||||
|
bool HasCondBuff(int cond);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func);
|
void TraverseCondBuffs(int cond, std::function<void (Buff*, bool&)> func);
|
||||||
void TriggeCondBuffAll(int cond);
|
void TriggeCondBuffAll(int cond);
|
||||||
void TryAddBuffs(Buff* buff, int cond, const std::vector<int>& buffids);
|
void TryAddBuffs(Buff* buff, int cond, const std::vector<int>& buffids,
|
||||||
void AddBuffs(Buff* buff, int cond, const std::vector<int>& buffids);
|
std::shared_ptr<std::vector<float>> buff_vars = nullptr);
|
||||||
|
void AddBuffs(Buff* buff, int cond, const std::vector<int>& buffids,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars = nullptr);
|
||||||
void RemoveBuffs(int cond, const std::vector<int>& buffids);
|
void RemoveBuffs(int cond, const std::vector<int>& buffids);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user