This commit is contained in:
aozhiwei 2024-05-23 12:23:10 +08:00
parent 15e2e37e5c
commit 871a41749a

View File

@ -27,6 +27,7 @@
#include "virtualbullet.h" #include "virtualbullet.h"
#include "shot.h" #include "shot.h"
#include "entityfactory.h" #include "entityfactory.h"
#include "gridcell.h"
#include "mt/Buff.h" #include "mt/Buff.h"
#include "mt/Equip.h" #include "mt/Equip.h"
@ -35,6 +36,7 @@
void CallFuncBuff::Activate() void CallFuncBuff::Activate()
{ {
int buff_id = meta->buff_id();
hold_weapon_ = owner->GetCurrWeapon(); hold_weapon_ = owner->GetCurrWeapon();
switch ((BuffCallFunc_e)meta->_int_buff_param1) { switch ((BuffCallFunc_e)meta->_int_buff_param1) {
case BuffCallFunc_e::kAddMinorMode: case BuffCallFunc_e::kAddMinorMode:
@ -280,6 +282,7 @@ void CallFuncBuff::Activate()
void CallFuncBuff::Deactivate() void CallFuncBuff::Deactivate()
{ {
int buff_id = meta->buff_id();
if (deactivate_cb_) { if (deactivate_cb_) {
deactivate_cb_(); deactivate_cb_();
} }
@ -562,6 +565,7 @@ void CallFuncBuff::ProcAddEnergyShield()
void CallFuncBuff::ProcAddHp() void CallFuncBuff::ProcAddHp()
{ {
int buff_id = meta->buff_id();
if (!owner->dead && !owner->downed) { if (!owner->dead && !owner->downed) {
if (std::abs(owner->GetMaxHP() - owner->GetHP()) < 0.001f) { if (std::abs(owner->GetMaxHP() - owner->GetHP()) < 0.001f) {
is_valid_ = false; is_valid_ = false;
@ -1266,6 +1270,7 @@ void CallFuncBuff::SpecCenterRangeHoldBuff()
void CallFuncBuff::InternalRangeHoldBuff(std::function<bool(glm::vec3&)> get_center_func) void CallFuncBuff::InternalRangeHoldBuff(std::function<bool(glm::vec3&)> get_center_func)
{ {
int buff_id = meta->buff_id();
if (owner->dead && !meta->dead_valid()) { if (owner->dead && !meta->dead_valid()) {
return; return;
} }
@ -1345,28 +1350,29 @@ void CallFuncBuff::InternalRangeHoldBuff(std::function<bool(glm::vec3&)> get_cen
{ {
float range = meta->GetBuffParam2(this); float range = meta->GetBuffParam2(this);
std::set<Creature*> hit_humans; std::set<Creature*> hit_humans;
owner->room->TraverseAliveHumanList glm::vec3 center;
( if (get_center_func(center)) {
[this, range, &hit_humans, &get_center_func] (Human* hum) mutable std::set<GridCell*> grid_list;
{ owner->room->grid_service->GetAllCellsByXy
if (meta->buff_id() == 203032) { (
int i = 0; owner->room,
} center.x,
glm::vec3 center; center.z,
if (get_center_func(center)) { grid_list);
if (a8::IntersectCylinderCylinder owner->room->grid_service->TraverseCreatures
(owner->room->GetRoomIdx(),
grid_list,
[this, range, &hit_humans, &center] (Creature* c, bool& stop)
{
if (!c->dead && c->IsHuman() && a8::IntersectCylinderCylinder
( (
center, owner->GetRadius(), 10, center, owner->GetRadius(), 10,
hum->GetPos().ToGlmVec3(), range, 10 c->GetPos().ToGlmVec3(), range, 10
)) { )) {
if (meta->buff_id() == 203032) { hit_humans.insert(c);
int i = 0;
}
hit_humans.insert(hum);
} }
} });
return true; }
});
std::vector<Human*> leave_humans; std::vector<Human*> leave_humans;
for (auto& pair : context->in_human_infos) { for (auto& pair : context->in_human_infos) {
if (hit_humans.find(pair.second.c.Get()) == hit_humans.end()) { if (hit_humans.find(pair.second.c.Get()) == hit_humans.end()) {
@ -1394,6 +1400,9 @@ void CallFuncBuff::InternalRangeHoldBuff(std::function<bool(glm::vec3&)> get_cen
(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) {
if (meta->buff_id() == 303013) {
int i = 0;
}
check_cb(); check_cb();
} }
}, },
@ -1414,14 +1423,16 @@ void CallFuncBuff::InternalRangeHoldBuff(std::function<bool(glm::vec3&)> get_cen
context->in_human_infos.clear(); context->in_human_infos.clear();
}; };
{ {
event_handlers_.push_back(owner->GetTrigger()->AddListener if (!meta->dead_valid()) {
( event_handlers_.push_back(owner->GetTrigger()->AddListener
kDieEvent, (
[this, clear_func] (const a8::Args& args) mutable kDieEvent,
{ [this, clear_func] (const a8::Args& args) mutable
clear_func(); {
} clear_func();
)); }
));
}
deactivate_cb_ = deactivate_cb_ =
[this, clear_func] () mutable [this, clear_func] () mutable
{ {