1
This commit is contained in:
parent
1dd0b0e25e
commit
68a317c430
@ -684,7 +684,19 @@ int Creature::TryAddBuff(Creature* caster, int buff_id)
|
||||
if (buff_meta) {
|
||||
return AddBuff(caster, buff_meta);
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Creature::TryAddBuffAndSetTime(Creature* caster, int buff_id, int time)
|
||||
{
|
||||
int buff_uniid = TryAddBuff(caster, buff_id);
|
||||
if (buff_uniid) {
|
||||
Buff* buff = GetBuffByUniId(buff_uniid);
|
||||
room->xtimer.ModifyTimer
|
||||
(buff->remover_timer,
|
||||
time / FRAME_RATE_MS);
|
||||
}
|
||||
return buff_uniid;
|
||||
}
|
||||
|
||||
std::weak_ptr<a8::XTimerPtr> Creature::TryDelayAddBuff(Creature* caster, int buff_id, int time)
|
||||
|
@ -138,6 +138,7 @@ class Creature : public MoveableEntity
|
||||
int MustBeAddBuff(Creature* caster, int buff_id);
|
||||
std::weak_ptr<a8::XTimerPtr> TryDelayAddBuff(Creature* caster, int buff_id, int time);
|
||||
int TryAddBuff(Creature* caster, int buff_id);
|
||||
int TryAddBuffAndSetTime(Creature* caster, int buff_id, int time);
|
||||
int TryAddBuffWithTarget(Creature* caster, int buff_id);
|
||||
void RemoveBuffById(int buff_id);
|
||||
void RemoveBuffByUniId(int buff_uniid);
|
||||
|
@ -293,12 +293,35 @@ void Skill::InitPassiveSkill()
|
||||
|
||||
void Skill::ProcSJXY()
|
||||
{
|
||||
int shot_times = 0;
|
||||
std::map<int, long long> hited_objs;
|
||||
owner->GetTrigger()->AddListener
|
||||
(
|
||||
kBulletHitEvent,
|
||||
[this] (const std::vector<std::any>& params)
|
||||
[this, shot_times, hited_objs] (const std::vector<std::any>& params) mutable
|
||||
{
|
||||
|
||||
++shot_times;
|
||||
Bullet* bullet = std::any_cast<Bullet*>(params.at(0));
|
||||
Creature* target = std::any_cast<Creature*>(params.at(1));
|
||||
if (shot_times % meta->number_meta->int_ratio == 0) {
|
||||
if ((rand() % 100) < meta->number_meta->float_probability * 100) {
|
||||
bool is_hit = false;
|
||||
auto itr = hited_objs.find(target->GetUniId());
|
||||
if (itr == hited_objs.end()) {
|
||||
hited_objs[target->GetUniId()] = owner->room->GetFrameNo();
|
||||
is_hit = true;
|
||||
} else {
|
||||
if ((owner->room->GetFrameNo() - itr->second) >=
|
||||
meta->number_meta->float_cd * SERVER_FRAME_RATE) {
|
||||
itr->second = owner->room->GetFrameNo();
|
||||
is_hit = true;
|
||||
}
|
||||
}//endif itr
|
||||
if (is_hit) {
|
||||
target->TryAddBuffAndSetTime(owner, kVertigoBuffId, meta->number_meta->float_cd * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -422,10 +422,10 @@ void Trigger::DispatchEvent(int event_id, const std::vector<std::any>& param)
|
||||
}
|
||||
}
|
||||
|
||||
void Trigger::BulletHit(Bullet* bullet)
|
||||
void Trigger::BulletHit(Bullet* bullet, Creature* target)
|
||||
{
|
||||
if (bullet->sender.Get()) {
|
||||
bullet->sender.Get()->GetTrigger()->DispatchEvent(kBulletHitEvent, {bullet});
|
||||
bullet->sender.Get()->GetTrigger()->DispatchEvent(kBulletHitEvent, {bullet, target});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
void Die();
|
||||
void ActiveBuff(MetaData::Buff* buff_meta);
|
||||
void DeactiveBuff(MetaData::Buff* buff_meta);
|
||||
void BulletHit(Bullet* bullet);
|
||||
void BulletHit(Bullet* bullet, Creature* target);
|
||||
void ShieldDestory();
|
||||
void Rescue(Human* target);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user