This commit is contained in:
aozhiwei 2023-03-30 17:34:26 +08:00
parent d47a9f9f20
commit 6ed7e738b0
3 changed files with 74 additions and 10 deletions

View File

@ -217,10 +217,12 @@ void CondAddBuff::ProcDisengageBattle()
owner->room->xtimer.ResetTimer(timer); owner->room->xtimer.ResetTimer(timer);
}; };
owner->GetTrigger()->AddListener handlers_.push_back
(owner->GetTrigger()->AddListener
( (
kReceiveDmgEvent, kReceiveDmgEvent,
cb cb
)
); );
} }
@ -287,25 +289,80 @@ void CondAddBuff::ProcLimitTimeKillTarget()
} }
} }
}); });
handlers_.push_back(handler);
context->watch_targets[target->GetUniId()] = std::make_tuple(timer_wp, handler); context->watch_targets[target->GetUniId()] = std::make_tuple(timer_wp, handler);
} }
} }
}; };
owner->GetTrigger()->AddListener handlers_.push_back
(owner->GetTrigger()->AddListener
( (
kAttackTargetEvent, kAttackTargetEvent,
cb cb
)
); );
} }
void CondAddBuff::ProcReload() void CondAddBuff::ProcReload()
{ {
auto context = A8_MAKE_ANON_STRUCT_SHARED
(
std::vector<int> 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() 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);
}
}
)
);
} }

View File

@ -1087,6 +1087,9 @@ void Creature::StartAction(ActionType_e action_type,
this->action_target_id == target_id) { this->action_target_id == target_id) {
return; return;
} }
if (action_type == AT_Reload) {
GetTrigger()->StartReload();
}
action_duration = std::max(0, action_duration); action_duration = std::max(0, action_duration);
this->action_type = action_type; this->action_type = action_type;
this->action_frameno = room->GetFrameNo(); this->action_frameno = room->GetFrameNo();
@ -1114,6 +1117,9 @@ void Creature::CancelAction()
if (action_type == AT_Rescue) { if (action_type == AT_Rescue) {
RemoveBuffByEffectId(kBET_InRescue); RemoveBuffByEffectId(kBET_InRescue);
} }
if (action_type == AT_Reload) {
GetTrigger()->EndReload();
}
ResetAction(); ResetAction();
} }

View File

@ -1750,6 +1750,7 @@ void Human::ProcReloadAction()
} }
} }
GetTrigger()->EndReload();
} }
void Human::ProcUseItemAction() void Human::ProcUseItemAction()