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