1
This commit is contained in:
parent
6e46e42ac3
commit
2ea5d9ae48
@ -32,6 +32,7 @@ class Buff
|
||||
list_head cond_entry;
|
||||
list_head on_remove_contexts;
|
||||
a8::XTimerWp remover_timer;
|
||||
std::shared_ptr<a8::Args> init_args;
|
||||
|
||||
Buff();
|
||||
~Buff();
|
||||
|
@ -8,5 +8,4 @@ class ModifyBuff : public Buff
|
||||
|
||||
virtual void Activate() override;
|
||||
virtual void Deactivate() override;
|
||||
|
||||
};
|
||||
|
@ -127,7 +127,8 @@ int Creature::GetBuffNum(int buff_id)
|
||||
int Creature::AddBuff(Creature* caster,
|
||||
const mt::Buff* buff_meta,
|
||||
const mt::Skill* buff_skill_meta,
|
||||
bool no_check_immune)
|
||||
bool no_check_immune,
|
||||
std::shared_ptr<a8::Args> init_args)
|
||||
{
|
||||
#if 999
|
||||
if (buff_meta->buff_id() == 8042) {
|
||||
@ -196,6 +197,7 @@ int Creature::AddBuff(Creature* caster,
|
||||
buff->skill_meta = buff_skill_meta;
|
||||
buff->add_frameno = room->GetFrameNo();
|
||||
buff->xtimer_attacher.SetOwner(&room->xtimer);
|
||||
buff->init_args = init_args;
|
||||
buff->Init();
|
||||
buff->PreProcess();
|
||||
if (on_add_buff) {
|
||||
@ -301,27 +303,36 @@ bool Creature::IsImmuneBuffEffect(int buff_effect)
|
||||
return false;
|
||||
}
|
||||
|
||||
int Creature::MustBeAddBuff(Creature* caster, int buff_id)
|
||||
int Creature::MustBeAddBuff(Creature* caster,
|
||||
int buff_id,
|
||||
std::shared_ptr<a8::Args> init_args)
|
||||
{
|
||||
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
||||
if (!buff_meta) {
|
||||
A8_ABORT();
|
||||
}
|
||||
return AddBuff(caster, buff_meta);
|
||||
return AddBuff(caster, buff_meta, nullptr, false, init_args);
|
||||
}
|
||||
|
||||
int Creature::TryAddBuff(Creature* caster, int buff_id, const mt::Skill* skill_meta)
|
||||
int Creature::TryAddBuff(Creature* caster,
|
||||
int buff_id,
|
||||
const mt::Skill* skill_meta,
|
||||
std::shared_ptr<a8::Args> init_args)
|
||||
{
|
||||
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
||||
if (buff_meta) {
|
||||
return AddBuff(caster, buff_meta, skill_meta);
|
||||
return AddBuff(caster, buff_meta, skill_meta, false, init_args);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Creature::TryAddBuffAndSetTime(Creature* caster, int buff_id, int time, const mt::Skill* skill_meta)
|
||||
int Creature::TryAddBuffAndSetTime(Creature* caster,
|
||||
int buff_id,
|
||||
int time,
|
||||
const mt::Skill* skill_meta,
|
||||
std::shared_ptr<a8::Args> init_args)
|
||||
{
|
||||
int buff_uniid = TryAddBuff(caster, buff_id, skill_meta);
|
||||
int buff_uniid = TryAddBuff(caster, buff_id, skill_meta, init_args);
|
||||
if (buff_uniid) {
|
||||
Buff* buff = GetBuffByUniId(buff_uniid);
|
||||
room->xtimer.ModifyTime
|
||||
@ -331,14 +342,17 @@ int Creature::TryAddBuffAndSetTime(Creature* caster, int buff_id, int time, cons
|
||||
return buff_uniid;
|
||||
}
|
||||
|
||||
a8::XTimerWp Creature::TryDelayAddBuff(Creature* caster, int buff_id, int time,
|
||||
DelayAddBuffHandle* handle)
|
||||
a8::XTimerWp Creature::TryDelayAddBuff(Creature* caster,
|
||||
int buff_id,
|
||||
int time,
|
||||
DelayAddBuffHandle* handle,
|
||||
std::shared_ptr<a8::Args> init_args)
|
||||
{
|
||||
auto caster_wp = caster->GetWeakPtrRef();
|
||||
return room->xtimer.SetTimeoutWpEx
|
||||
(
|
||||
time / FRAME_RATE_MS,
|
||||
[this, caster_wp, buff_id, handle]
|
||||
[this, caster_wp, buff_id, handle, init_args]
|
||||
(int event, const a8::Args* args) mutable
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
@ -346,7 +360,7 @@ a8::XTimerWp Creature::TryDelayAddBuff(Creature* caster, int buff_id, int time,
|
||||
if (handle && handle->pre_add_cb) {
|
||||
handle->pre_add_cb(this);
|
||||
}
|
||||
int buff_uniid = TryAddBuff(caster_wp.Get(), buff_id);
|
||||
int buff_uniid = TryAddBuff(caster_wp.Get(), buff_id, nullptr, init_args);
|
||||
if (handle && handle->post_add_cb) {
|
||||
handle->post_add_cb(this, buff_uniid);
|
||||
}
|
||||
@ -360,7 +374,9 @@ a8::XTimerWp Creature::TryDelayAddBuff(Creature* caster, int buff_id, int time,
|
||||
&xtimer_attacher);
|
||||
}
|
||||
|
||||
int Creature::TryAddBuffWithTarget(Creature* caster, int buff_id)
|
||||
int Creature::TryAddBuffWithTarget(Creature* caster,
|
||||
int buff_id,
|
||||
std::shared_ptr<a8::Args> init_args)
|
||||
{
|
||||
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
||||
if (buff_meta) {
|
||||
@ -386,7 +402,7 @@ int Creature::TryAddBuffWithTarget(Creature* caster, int buff_id)
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TryAddBuff(caster, buff_id);
|
||||
return TryAddBuff(caster, buff_id, nullptr, init_args);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -139,19 +139,32 @@ class Creature : public MoveableEntity
|
||||
int AddBuff(Creature* caster,
|
||||
const mt::Buff* buff_meta,
|
||||
const mt::Skill* buff_skill_meta = nullptr,
|
||||
bool no_check_immune = false);
|
||||
bool no_check_immune = false,
|
||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
||||
bool IsImmuneBuffEffect(int buff_effect);
|
||||
int MustBeAddBuff(Creature* caster, int buff_id);
|
||||
int MustBeAddBuff(Creature* caster,
|
||||
int buff_id,
|
||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
||||
a8::XTimerWp TryDelayAddBuff
|
||||
(
|
||||
Creature* caster,
|
||||
int buff_id,
|
||||
int time,
|
||||
DelayAddBuffHandle* handle = nullptr
|
||||
DelayAddBuffHandle* handle = nullptr,
|
||||
std::shared_ptr<a8::Args> init_args = nullptr
|
||||
);
|
||||
int TryAddBuff(Creature* caster, int buff_id, const mt::Skill* skill_meta = nullptr);
|
||||
int TryAddBuffAndSetTime(Creature* caster, int buff_id, int time, const mt::Skill* skill_meta = nullptr);
|
||||
int TryAddBuffWithTarget(Creature* caster, int buff_id);
|
||||
int TryAddBuff(Creature* caster,
|
||||
int buff_id,
|
||||
const mt::Skill* skill_meta = nullptr,
|
||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
||||
int TryAddBuffAndSetTime(Creature* caster,
|
||||
int buff_id,
|
||||
int time,
|
||||
const mt::Skill* skill_meta = nullptr,
|
||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
||||
int TryAddBuffWithTarget(Creature* caster,
|
||||
int buff_id,
|
||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
||||
void RemoveBuffById(int buff_id);
|
||||
void RemoveBuffByUniId(int buff_uniid);
|
||||
void ClearBuffById(int buff_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user