diff --git a/server/gameserver/buff/cond_add.cc b/server/gameserver/buff/cond_add.cc index bc7b4500..5313f7ea 100644 --- a/server/gameserver/buff/cond_add.cc +++ b/server/gameserver/buff/cond_add.cc @@ -217,10 +217,12 @@ void CondAddBuff::ProcDisengageBattle() owner->room->xtimer.ResetTimer(timer); }; - owner->GetTrigger()->AddListener - ( - kReceiveDmgEvent, - cb + handlers_.push_back + (owner->GetTrigger()->AddListener + ( + kReceiveDmgEvent, + cb + ) ); } @@ -287,25 +289,80 @@ void CondAddBuff::ProcLimitTimeKillTarget() } } }); + handlers_.push_back(handler); context->watch_targets[target->GetUniId()] = std::make_tuple(timer_wp, handler); } } }; - owner->GetTrigger()->AddListener - ( - kAttackTargetEvent, - cb + handlers_.push_back + (owner->GetTrigger()->AddListener + ( + kAttackTargetEvent, + cb + ) ); - } void CondAddBuff::ProcReload() { + auto context = A8_MAKE_ANON_STRUCT_SHARED + ( + std::vector buffs; + ); + + handlers_.push_back + (owner->GetTrigger()->AddListener + ( + kStartReloadEvent, + [this, context] (const a8::Args& args) mutable + { + if (!owner->dead) { + int buff_uniid = owner->TryAddBuff(GetCaster().Get(), + meta->_int_buff_param4, + skill_meta, + nullptr, + buff_vars); + if (buff_uniid > 0) { + context->buffs.push_back(buff_uniid); + } + } + } + ) + ); + + handlers_.push_back + (owner->GetTrigger()->AddListener + ( + kEndReloadEvent, + [this, context] (const a8::Args& args) mutable + { + for (int buff_uniid : context->buffs) { + owner->RemoveBuffByUniId(buff_uniid); + } + context->buffs.clear(); + } + ) + ); } void CondAddBuff::ProcShot() { - + handlers_.push_back + (owner->GetTrigger()->AddListener + ( + kShotEvent, + [this] (const a8::Args& args) mutable + { + if (!owner->dead) { + owner->TryAddBuff(GetCaster().Get(), + meta->_int_buff_param4, + skill_meta, + nullptr, + buff_vars); + } + } + ) + ); } diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index d88a43f1..724c3356 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -1087,6 +1087,9 @@ void Creature::StartAction(ActionType_e action_type, this->action_target_id == target_id) { return; } + if (action_type == AT_Reload) { + GetTrigger()->StartReload(); + } action_duration = std::max(0, action_duration); this->action_type = action_type; this->action_frameno = room->GetFrameNo(); @@ -1114,6 +1117,9 @@ void Creature::CancelAction() if (action_type == AT_Rescue) { RemoveBuffByEffectId(kBET_InRescue); } + if (action_type == AT_Reload) { + GetTrigger()->EndReload(); + } ResetAction(); } diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index f75aad85..934be339 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1750,6 +1750,7 @@ void Human::ProcReloadAction() } } + GetTrigger()->EndReload(); } void Human::ProcUseItemAction()