This commit is contained in:
azw 2023-11-07 02:51:16 +00:00
commit e68ec41ac8
3 changed files with 140 additions and 1 deletions

View File

@ -172,6 +172,12 @@ void CallFuncBuff::Activate()
{
SummonCarSpecPoint();
}
break;
case BuffCallFunc_e::kRangeHoldBuff:
{
RangeHoldBuff();
}
break;
default:
{
}
@ -273,6 +279,7 @@ void CallFuncBuff::ProcAddMinorMode()
if (owner_ptr.Get()) {
if (action == 1) {
owner_ptr.Get()->TryAddBuff(owner_ptr.Get(), meta_ptr->_int_buff_param4, skill_meta_ptr);
owner_ptr.Get()->RemoveBuffById(meta_ptr->_int_buff_param6);
} else if (action == 0) {
owner_ptr.Get()->TryAddBuff(owner_ptr.Get(), meta_ptr->_int_buff_param5, skill_meta_ptr);
}
@ -964,3 +971,131 @@ void CallFuncBuff::SummonCarSpecPoint()
},
&owner->room->xtimer_attacher_);
}
void CallFuncBuff::RangeHoldBuff()
{
if (owner->dead) {
return;
}
struct InnerObject
{
CreatureWeakPtr c;
std::vector<int> buff_uniids;
void OnEnter()
{
}
void OnLeave()
{
}
};
auto context = A8_MAKE_ANON_STRUCT_SHARED
(
std::map<int, InnerObject> in_human_infos;
);
auto on_enter =
[this, context] (Creature* hum)
{
if (context->in_human_infos.find(hum->GetUniId()) != context->in_human_infos.end()) {
abort();
}
InnerObject o;
o.c = hum->GetWeakPtrRef();
if (owner->team_id == hum->team_id) {
for (int buff_id : meta->_buff_param3_int_list) {
o.buff_uniids.push_back(hum->TryAddBuff(GetCaster().Get(), buff_id, skill_meta));
}
} else {
for (int buff_id : meta->_buff_param4_int_list) {
o.buff_uniids.push_back(hum->TryAddBuff(GetCaster().Get(), buff_id, skill_meta));
}
}
context->in_human_infos[hum->GetUniId()] = o;
context->in_human_infos[hum->GetUniId()].OnEnter();
};
auto on_stay =
[this, context] (Creature* hum)
{
};
auto on_leave =
[this, context] (Creature* hum)
{
auto itr = context->in_human_infos.find(hum->GetUniId());
if (itr == context->in_human_infos.end()) {
abort();
}
for (int buff_uniid : itr->second.buff_uniids) {
hum->RemoveBuffByUniId(buff_uniid);
}
itr->second.OnLeave();
};
auto check_cb =
[this, context, on_enter, on_stay, on_leave]
()
{
float range = meta->GetBuffParam2(this);
std::set<Creature*> hit_humans;
owner->room->TraverseAliveHumanList
(
[this, range] (Human* hum)
{
if (Collision::CheckCC(owner, owner->GetRadius(),
hum, range)) {
}
return true;
});
std::vector<Human*> leave_humans;
for (auto& pair : context->in_human_infos) {
if (hit_humans.find(pair.second.c.Get()) == hit_humans.end()) {
on_leave(pair.second.c.Get()->AsHuman());
leave_humans.push_back(pair.second.c.Get()->AsHuman());
}
}
for (Human* hum : leave_humans) {
context->in_human_infos.erase(hum->GetUniId());
}
for (Creature* hum : hit_humans) {
if (context->in_human_infos.find(hum->GetUniId()) ==
context->in_human_infos.end()) {
on_enter(hum);
on_stay(hum);
} else {
on_stay(hum);
}
}
};
owner->room->xtimer.SetIntervalWpEx
(
SERVER_FRAME_RATE,
[this, context, on_enter, on_stay, on_leave, check_cb]
(int event, const a8::Args* args) mutable
{
if (a8::TIMER_EXEC_EVENT == event) {
check_cb();
}
},
&owner->xtimer_attacher);
{
event_handlers_.push_back(owner->GetTrigger()->AddListener
(
kDieEvent,
[this, context] (const a8::Args& args) mutable
{
for (auto& pair : context->in_human_infos) {
for (int buff_uniid : pair.second.buff_uniids) {
if (pair.second.c.Get()) {
pair.second.c.Get()->RemoveBuffByUniId(buff_uniid);
}
}
}
}
));
}
}

View File

@ -29,6 +29,9 @@ A8_DECLARE_CLASS_ENUM(BuffCallFunc_e, int,
kAddMaxHp = 29,
kSummonCarSpecPoint = 30,
kBossAnimi = 31,
kAntiHide = 32,
kDisableClientSkill = 33,
kRangeHoldBuff = 34,
);
@ -59,6 +62,7 @@ class CallFuncBuff : public Buff
void ClearSummonObstacle();
void DecSkillCd();
void SummonCarSpecPoint();
void RangeHoldBuff();
float hold_param2_ = 0.0;
Weapon* hold_weapon_ = nullptr;

View File

@ -48,7 +48,7 @@ A8_DECLARE_ENUM(BuffEffectType_e,
kBET_ModifyAttr = 13,
kBET_PlayShotAni = 14, //播放射击动画
kBET_Vertigo = 15, //眩晕
kBET_UnUse16 = 16,
kBET_Floating = 16, //浮空
kBET_PullDone = 17, //拖拽到目的地
kBET_DelayAddBuff = 18, //延迟加buff
kBET_ModifyBaseAttr = 19,