1
This commit is contained in:
parent
ecd8bda197
commit
1cc6e36f60
@ -279,6 +279,12 @@ void CallFuncBuff::Activate()
|
||||
AddArmorShield();
|
||||
}
|
||||
break;
|
||||
case BuffCallFunc_e::kBulletDmgCalcProc:
|
||||
{
|
||||
hold_param2_ = meta->GetBuffParam2(this);
|
||||
BulletDmgCalcProc();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
@ -1924,5 +1930,58 @@ void CallFuncBuff::AddArmorShield()
|
||||
|
||||
void CallFuncBuff::BulletDmgCalcProc()
|
||||
{
|
||||
|
||||
int target_type = (int)hold_param2_;
|
||||
if (target_type == 0 || target_type == 1) {
|
||||
if (!owner->dead && !owner->downed) {
|
||||
int attr_id = meta->GetBuffParam3(this);
|
||||
float attr_val = meta->GetBuffParam4(this);
|
||||
float cond = meta->GetBuffParam5(this);
|
||||
AttrHandle attr_handle;
|
||||
auto clear_func =
|
||||
[this, target_type, &attr_handle] (Creature* c)
|
||||
{
|
||||
if (target_type == 0) {
|
||||
owner->GetAbility()->RemoveAttr(attr_handle);
|
||||
} else if (target_type == 1) {
|
||||
c->GetAbility()->RemoveAttr(attr_handle);
|
||||
}
|
||||
};
|
||||
auto start_handle = owner->GetTrigger()->AddListener
|
||||
(
|
||||
kBulletDmgStartEvent,
|
||||
[this, &attr_handle, target_type, attr_id, attr_val, cond, clear_func]
|
||||
(const a8::Args& args) mutable
|
||||
{
|
||||
Creature* target = args.Get<Creature*>(0);
|
||||
clear_func(target);
|
||||
if (IsValidHumanAttr(attr_id) ||
|
||||
IsValidHumanVirtualAttr(attr_id)) {
|
||||
if (target->GetMaxHP() > 0.0f) {
|
||||
bool match = target->GetHP() / target->GetMaxHP() < cond;
|
||||
if (match) {
|
||||
if (target_type == 0) {
|
||||
attr_handle = owner->GetAbility()->AddAttr(attr_id, attr_val);
|
||||
} else if (target_type == 1) {
|
||||
attr_handle = target->GetAbility()->AddAttr(attr_id, attr_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
auto end_handle = owner->GetTrigger()->AddListener
|
||||
(
|
||||
kBulletDmgEndEvent,
|
||||
[this, clear_func] (const a8::Args& args) mutable
|
||||
{
|
||||
Creature* target = args.Get<Creature*>(0);
|
||||
clear_func(target);
|
||||
});
|
||||
deactivate_cb_ =
|
||||
[this, start_handle, end_handle, clear_func] () mutable
|
||||
{
|
||||
owner->GetTrigger()->RemoveEventHandler(start_handle);
|
||||
owner->GetTrigger()->RemoveEventHandler(end_handle);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -726,10 +726,10 @@ void Trigger::BeAttack(int attacker_id)
|
||||
|
||||
void Trigger::BulletDmgStart(Creature* target)
|
||||
{
|
||||
|
||||
DispatchEvent(kBulletDmgStartEvent, {target});
|
||||
}
|
||||
|
||||
void Trigger::BulletDmgEnd(Creature* target)
|
||||
{
|
||||
|
||||
DispatchEvent(kBulletDmgEndEvent, {target});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user