This commit is contained in:
aozhiwei 2022-10-12 19:48:29 +08:00
parent 3b2932797d
commit eec621edc4
4 changed files with 55 additions and 26 deletions

View File

@ -1225,3 +1225,19 @@ void Buff::ClearEventHandlers()
} }
event_handlers_.clear(); event_handlers_.clear();
} }
void Buff::ProcRescuer()
{
Human* target = owner->room->GetHumanByUniId(owner->AsHuman()->GetActionTargetId());
if (target) {
owner->GetTrigger()->StartRescue(target);
}
}
void Buff::ProcRemoveRescuer()
{
Human* target = owner->room->GetHumanByUniId(owner->AsHuman()->GetActionTargetId());
if (target) {
owner->GetTrigger()->EndRescue(target);
}
}

View File

@ -85,6 +85,8 @@ class Buff
void ProcRemoveHoldShield(); void ProcRemoveHoldShield();
void ProcHide(); void ProcHide();
void ProcRemoveHide(); void ProcRemoveHide();
void ProcRescuer();
void ProcRemoveRescuer();
void CalcPassengerShotOffset(); void CalcPassengerShotOffset();

View File

@ -522,6 +522,11 @@ void Creature::OnBuffRemove(Buff& buff)
int i = 0; int i = 0;
} }
break; break;
case kBET_Rescuer:
{
buff.ProcRemoveRescuer();
}
break;
default: default:
{ {
} }
@ -1235,6 +1240,11 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
buff->ProcHide(); buff->ProcHide();
} }
break; break;
case kBET_Rescuer:
{
buff->ProcRescuer();
}
break;
case kBET_SummonObstacle: case kBET_SummonObstacle:
{ {
if (!dead || buff->meta->i->dead_valid() != 0) { if (!dead || buff->meta->i->dead_valid() != 0) {

View File

@ -711,41 +711,42 @@ void Skill::ProcGZJS()
void Skill::ProcJYFH() void Skill::ProcJYFH()
{ {
int buff_id = SkillHelper::GetJyfhBuffId(meta);
float buff_time = SkillHelper::GetJyfhBuffTime(meta);
owner->GetTrigger()->AddListener owner->GetTrigger()->AddListener
( (
kStartRescueEvent, kStartRescueEvent,
[this] (const std::vector<std::any>& params) [this, buff_id, buff_time] (const std::vector<std::any>& params)
{ {
Human* target = std::any_cast<Human*>(params.at(0)); Human* target = std::any_cast<Human*>(params.at(0));
int buff_id = SkillHelper::GetJyfhBuffId(meta);
float buff_time = SkillHelper::GetJyfhBuffTime(meta);
owner->TryAddBuffAndSetTime(owner, buff_id, buff_time, meta); owner->TryAddBuffAndSetTime(owner, buff_id, buff_time, meta);
target->TryAddBuffAndSetTime(owner, buff_id, buff_time, meta); target->TryAddBuffAndSetTime(owner, buff_id, buff_time, meta);
owner->GetTrigger()->AddListener
(
kEndRescueEvent,
[this, buff_id] (const std::vector<std::any>& params)
{
Human* target = std::any_cast<Human*>(params.at(0));
owner->RemoveBuffById(buff_id);
target->RemoveBuffById(buff_id);
}
);
#ifdef DEBUG
{
std::string dbg_msg = a8::Format
(
"skill_id:%d 救援防护 time:%f",
{
meta->i->skill_id(),
buff_time
});
owner->SendDebugMsg(dbg_msg);
a8::XPrintf("%s\n", {dbg_msg});
}
#endif
} }
); );
owner->GetTrigger()->AddListener
(
kEndRescueEvent,
[this, buff_id] (const std::vector<std::any>& params)
{
Human* target = std::any_cast<Human*>(params.at(0));
owner->RemoveBuffById(buff_id);
target->RemoveBuffById(buff_id);
}
);
#ifdef DEBUG
{
std::string dbg_msg = a8::Format
(
"skill_id:%d 救援防护 time:%f",
{
meta->i->skill_id(),
buff_time
});
owner->SendDebugMsg(dbg_msg);
a8::XPrintf("%s\n", {dbg_msg});
}
#endif
} }
void Skill::ProcFH() void Skill::ProcFH()