1
This commit is contained in:
parent
6ec4ffc438
commit
0e1917a672
@ -122,7 +122,7 @@ void Buff::InternalTimerAddBuff()
|
|||||||
caster.Get()->FillSkillCasterState(&old_caster_state);
|
caster.Get()->FillSkillCasterState(&old_caster_state);
|
||||||
caster.Get()->RecoverSkillCasterState(caster_state.get());
|
caster.Get()->RecoverSkillCasterState(caster_state.get());
|
||||||
//!!!在AddBuff的过程可能删除buff导致caster_state野指针
|
//!!!在AddBuff的过程可能删除buff导致caster_state野指针
|
||||||
receiver->AddBuff(caster.Get(), buff_meta, skill);
|
receiver->AddBuff(caster.Get(), buff_meta, skill, false, nullptr, buff_vars);
|
||||||
#if 0
|
#if 0
|
||||||
caster.Get()->RecoverSkillCasterState(&old_caster_state);
|
caster.Get()->RecoverSkillCasterState(&old_caster_state);
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,6 +36,7 @@ class Buff
|
|||||||
std::shared_ptr<a8::Args> init_args;
|
std::shared_ptr<a8::Args> init_args;
|
||||||
float res_scale = 1;
|
float res_scale = 1;
|
||||||
long long res_scale_frameno = 0;
|
long long res_scale_frameno = 0;
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars;
|
||||||
|
|
||||||
Buff();
|
Buff();
|
||||||
~Buff();
|
~Buff();
|
||||||
|
@ -33,7 +33,7 @@ void BatchAddBuff::Activate()
|
|||||||
buff_meta->name()
|
buff_meta->name()
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
owner->AddBuff(caster_.Get(), buff_meta, skill_meta);
|
owner->AddBuff(caster_.Get(), buff_meta, skill_meta, false, nullptr, buff_vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -43,7 +43,7 @@ void BatchAddBuff::Activate()
|
|||||||
if (rnd <= std::get<1>(item)) {
|
if (rnd <= std::get<1>(item)) {
|
||||||
const mt::Buff* buff_meta = mt::Buff::GetById(std::get<0>(item));
|
const mt::Buff* buff_meta = mt::Buff::GetById(std::get<0>(item));
|
||||||
if (buff_meta) {
|
if (buff_meta) {
|
||||||
owner->AddBuff(caster_.Get(), buff_meta, skill_meta);
|
owner->AddBuff(caster_.Get(), buff_meta, skill_meta, false, nullptr, buff_vars);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,8 @@ int Creature::AddBuff(Creature* caster,
|
|||||||
const mt::Buff* buff_meta,
|
const mt::Buff* buff_meta,
|
||||||
const mt::Skill* buff_skill_meta,
|
const mt::Skill* buff_skill_meta,
|
||||||
bool no_check_immune,
|
bool no_check_immune,
|
||||||
std::shared_ptr<a8::Args> init_args)
|
std::shared_ptr<a8::Args> init_args,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars)
|
||||||
{
|
{
|
||||||
#if 999
|
#if 999
|
||||||
if (buff_meta->buff_id() == 8042) {
|
if (buff_meta->buff_id() == 8042) {
|
||||||
@ -254,6 +255,7 @@ int Creature::AddBuff(Creature* caster,
|
|||||||
buff->add_frameno = room->GetFrameNo();
|
buff->add_frameno = room->GetFrameNo();
|
||||||
buff->xtimer_attacher.SetOwner(&room->xtimer);
|
buff->xtimer_attacher.SetOwner(&room->xtimer);
|
||||||
buff->init_args = init_args;
|
buff->init_args = init_args;
|
||||||
|
buff->buff_vars = buff_vars;
|
||||||
buff->Init();
|
buff->Init();
|
||||||
buff->PreProcess();
|
buff->PreProcess();
|
||||||
if (on_add_buff) {
|
if (on_add_buff) {
|
||||||
@ -361,7 +363,7 @@ int Creature::AddBuff(Creature* caster,
|
|||||||
for (int child_buff_id : buff->meta->_child_buff_list) {
|
for (int child_buff_id : buff->meta->_child_buff_list) {
|
||||||
const mt::Buff* child_buff_meta = mt::Buff::GetById(child_buff_id);
|
const mt::Buff* child_buff_meta = mt::Buff::GetById(child_buff_id);
|
||||||
if (child_buff_meta) {
|
if (child_buff_meta) {
|
||||||
AddBuff(caster, child_buff_meta, buff_skill_meta, true);
|
AddBuff(caster, child_buff_meta, buff_skill_meta, true, init_args, buff_vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,23 +382,25 @@ bool Creature::IsImmuneBuffEffect(int buff_effect)
|
|||||||
|
|
||||||
int Creature::MustBeAddBuff(Creature* caster,
|
int Creature::MustBeAddBuff(Creature* caster,
|
||||||
int buff_id,
|
int buff_id,
|
||||||
std::shared_ptr<a8::Args> init_args)
|
std::shared_ptr<a8::Args> init_args,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars)
|
||||||
{
|
{
|
||||||
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
||||||
if (!buff_meta) {
|
if (!buff_meta) {
|
||||||
A8_ABORT();
|
A8_ABORT();
|
||||||
}
|
}
|
||||||
return AddBuff(caster, buff_meta, nullptr, false, init_args);
|
return AddBuff(caster, buff_meta, nullptr, false, init_args, buff_vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Creature::TryAddBuff(Creature* caster,
|
int Creature::TryAddBuff(Creature* caster,
|
||||||
int buff_id,
|
int buff_id,
|
||||||
const mt::Skill* skill_meta,
|
const mt::Skill* skill_meta,
|
||||||
std::shared_ptr<a8::Args> init_args)
|
std::shared_ptr<a8::Args> init_args,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars)
|
||||||
{
|
{
|
||||||
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
||||||
if (buff_meta) {
|
if (buff_meta) {
|
||||||
return AddBuff(caster, buff_meta, skill_meta, false, init_args);
|
return AddBuff(caster, buff_meta, skill_meta, false, init_args, buff_vars);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -405,9 +409,10 @@ int Creature::TryAddBuffAndSetTime(Creature* caster,
|
|||||||
int buff_id,
|
int buff_id,
|
||||||
int time,
|
int time,
|
||||||
const mt::Skill* skill_meta,
|
const mt::Skill* skill_meta,
|
||||||
std::shared_ptr<a8::Args> init_args)
|
std::shared_ptr<a8::Args> init_args,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars)
|
||||||
{
|
{
|
||||||
int buff_uniid = TryAddBuff(caster, buff_id, skill_meta, init_args);
|
int buff_uniid = TryAddBuff(caster, buff_id, skill_meta, init_args, buff_vars);
|
||||||
if (buff_uniid) {
|
if (buff_uniid) {
|
||||||
Buff* buff = GetBuffByUniId(buff_uniid);
|
Buff* buff = GetBuffByUniId(buff_uniid);
|
||||||
room->xtimer.ModifyTime
|
room->xtimer.ModifyTime
|
||||||
@ -421,13 +426,14 @@ a8::XTimerWp Creature::TryDelayAddBuff(Creature* caster,
|
|||||||
int buff_id,
|
int buff_id,
|
||||||
int time,
|
int time,
|
||||||
DelayAddBuffHandle* handle,
|
DelayAddBuffHandle* handle,
|
||||||
std::shared_ptr<a8::Args> init_args)
|
std::shared_ptr<a8::Args> init_args,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars)
|
||||||
{
|
{
|
||||||
auto caster_wp = caster->GetWeakPtrRef();
|
auto caster_wp = caster->GetWeakPtrRef();
|
||||||
return room->xtimer.SetTimeoutWpEx
|
return room->xtimer.SetTimeoutWpEx
|
||||||
(
|
(
|
||||||
time / FRAME_RATE_MS,
|
time / FRAME_RATE_MS,
|
||||||
[this, caster_wp, buff_id, handle, init_args]
|
[this, caster_wp, buff_id, handle, init_args, buff_vars]
|
||||||
(int event, const a8::Args* args) mutable
|
(int event, const a8::Args* args) mutable
|
||||||
{
|
{
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
@ -435,7 +441,7 @@ a8::XTimerWp Creature::TryDelayAddBuff(Creature* caster,
|
|||||||
if (handle && handle->pre_add_cb) {
|
if (handle && handle->pre_add_cb) {
|
||||||
handle->pre_add_cb(this);
|
handle->pre_add_cb(this);
|
||||||
}
|
}
|
||||||
int buff_uniid = TryAddBuff(caster_wp.Get(), buff_id, nullptr, init_args);
|
int buff_uniid = TryAddBuff(caster_wp.Get(), buff_id, nullptr, init_args, buff_vars);
|
||||||
if (handle && handle->post_add_cb) {
|
if (handle && handle->post_add_cb) {
|
||||||
handle->post_add_cb(this, buff_uniid);
|
handle->post_add_cb(this, buff_uniid);
|
||||||
}
|
}
|
||||||
@ -451,7 +457,8 @@ a8::XTimerWp Creature::TryDelayAddBuff(Creature* caster,
|
|||||||
|
|
||||||
int Creature::TryAddBuffWithTarget(Creature* caster,
|
int Creature::TryAddBuffWithTarget(Creature* caster,
|
||||||
int buff_id,
|
int buff_id,
|
||||||
std::shared_ptr<a8::Args> init_args)
|
std::shared_ptr<a8::Args> init_args,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars)
|
||||||
{
|
{
|
||||||
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
const mt::Buff* buff_meta = mt::Buff::GetById(buff_id);
|
||||||
if (buff_meta) {
|
if (buff_meta) {
|
||||||
@ -477,7 +484,7 @@ int Creature::TryAddBuffWithTarget(Creature* caster,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TryAddBuff(caster, buff_id, nullptr, init_args);
|
return TryAddBuff(caster, buff_id, nullptr, init_args, buff_vars);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -145,31 +145,37 @@ class Creature : public MoveableEntity
|
|||||||
const mt::Buff* buff_meta,
|
const mt::Buff* buff_meta,
|
||||||
const mt::Skill* buff_skill_meta = nullptr,
|
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);
|
std::shared_ptr<a8::Args> init_args = nullptr,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars = nullptr);
|
||||||
bool IsImmuneBuffEffect(int buff_effect);
|
bool IsImmuneBuffEffect(int buff_effect);
|
||||||
int MustBeAddBuff(Creature* caster,
|
int MustBeAddBuff(Creature* caster,
|
||||||
int buff_id,
|
int buff_id,
|
||||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
std::shared_ptr<a8::Args> init_args = nullptr,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars = nullptr);
|
||||||
a8::XTimerWp TryDelayAddBuff
|
a8::XTimerWp TryDelayAddBuff
|
||||||
(
|
(
|
||||||
Creature* caster,
|
Creature* caster,
|
||||||
int buff_id,
|
int buff_id,
|
||||||
int time,
|
int time,
|
||||||
DelayAddBuffHandle* handle = nullptr,
|
DelayAddBuffHandle* handle = nullptr,
|
||||||
std::shared_ptr<a8::Args> init_args = nullptr
|
std::shared_ptr<a8::Args> init_args = nullptr,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars = nullptr
|
||||||
);
|
);
|
||||||
int TryAddBuff(Creature* caster,
|
int TryAddBuff(Creature* caster,
|
||||||
int buff_id,
|
int buff_id,
|
||||||
const mt::Skill* skill_meta = nullptr,
|
const mt::Skill* skill_meta = nullptr,
|
||||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
std::shared_ptr<a8::Args> init_args = nullptr,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars = nullptr);
|
||||||
int TryAddBuffAndSetTime(Creature* caster,
|
int TryAddBuffAndSetTime(Creature* caster,
|
||||||
int buff_id,
|
int buff_id,
|
||||||
int time,
|
int time,
|
||||||
const mt::Skill* skill_meta = nullptr,
|
const mt::Skill* skill_meta = nullptr,
|
||||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
std::shared_ptr<a8::Args> init_args = nullptr,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars = nullptr);
|
||||||
int TryAddBuffWithTarget(Creature* caster,
|
int TryAddBuffWithTarget(Creature* caster,
|
||||||
int buff_id,
|
int buff_id,
|
||||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
std::shared_ptr<a8::Args> init_args = nullptr,
|
||||||
|
std::shared_ptr<std::vector<float>> buff_vars = nullptr);
|
||||||
void RemoveBuffById(int buff_id);
|
void RemoveBuffById(int buff_id);
|
||||||
void RemoveBuffByUniId(int buff_uniid);
|
void RemoveBuffByUniId(int buff_uniid);
|
||||||
void ClearBuffById(int buff_id);
|
void ClearBuffById(int buff_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user