1
This commit is contained in:
parent
7b80205461
commit
3a13c07d59
@ -3013,65 +3013,73 @@ void CreatuRemoveSurplusObstacle(int thing_id, int num)
|
||||
}
|
||||
#endif
|
||||
|
||||
std::shared_ptr<std::set<int>> Creature::CalcReporterList(const mt::Equip* weapon_meta,
|
||||
std::shared_ptr<std::set<int>> Creature::CalcReporterList(bool is_trace_bullet,
|
||||
const mt::Equip* weapon_meta,
|
||||
const mt::Equip* bullet_meta)
|
||||
{
|
||||
std::shared_ptr<std::set<int>> p;
|
||||
bool need_gen = false;
|
||||
switch (bullet_meta->_inventory_slot()) {
|
||||
case IS_RPG:
|
||||
{
|
||||
float nearest_distance = FLT_MAX;
|
||||
Creature* nearest_hum = nullptr;
|
||||
TraverseCreatures
|
||||
(
|
||||
[this, &nearest_distance, &nearest_hum] (Creature* c, bool& stop) mutable
|
||||
{
|
||||
if (!c->IsHuman()) {
|
||||
return;
|
||||
}
|
||||
if (a8::HasBitFlag(c->status, CS_Disable)) {
|
||||
return;
|
||||
}
|
||||
if (c->dead) {
|
||||
return;
|
||||
}
|
||||
float distance = std::fabs(c->GetPos().GetX() - GetPos().GetX()) + std::fabs(c->GetPos().GetZ() - GetPos().GetZ());
|
||||
if (c->IsPlayer()) {
|
||||
if (c->AsHuman()->socket_handle) {
|
||||
if (distance < nearest_distance) {
|
||||
nearest_distance = distance;
|
||||
nearest_hum = c;
|
||||
}
|
||||
}
|
||||
} else if (c->AsHuman()->HasObserver()) {
|
||||
c->AsHuman()->TraverseObservers
|
||||
(
|
||||
[this, &nearest_distance, &nearest_hum] (Human* hum, bool& stop) mutable
|
||||
{
|
||||
if (!hum->IsPlayer()) {
|
||||
return;
|
||||
}
|
||||
if (hum->socket_handle) {
|
||||
float distance = std::fabs(hum->GetPos().GetX() - GetPos().GetX()) + std::fabs(hum->GetPos().GetZ() - GetPos().GetZ());
|
||||
if (distance < nearest_distance) {
|
||||
nearest_distance = distance;
|
||||
nearest_hum = hum;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (nearest_hum) {
|
||||
p = std::make_shared<std::set<int>>();
|
||||
p->insert(nearest_hum->GetUniId());
|
||||
}
|
||||
need_gen = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (IsEntityType(ET_Hero) && is_trace_bullet) {
|
||||
need_gen = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (need_gen) {
|
||||
float nearest_distance = FLT_MAX;
|
||||
Creature* nearest_hum = nullptr;
|
||||
TraverseCreatures
|
||||
(
|
||||
[this, &nearest_distance, &nearest_hum] (Creature* c, bool& stop) mutable
|
||||
{
|
||||
if (!c->IsHuman()) {
|
||||
return;
|
||||
}
|
||||
if (a8::HasBitFlag(c->status, CS_Disable)) {
|
||||
return;
|
||||
}
|
||||
if (c->dead) {
|
||||
return;
|
||||
}
|
||||
float distance = std::fabs(c->GetPos().GetX() - GetPos().GetX()) + std::fabs(c->GetPos().GetZ() - GetPos().GetZ());
|
||||
if (c->IsPlayer()) {
|
||||
if (c->AsHuman()->socket_handle) {
|
||||
if (distance < nearest_distance) {
|
||||
nearest_distance = distance;
|
||||
nearest_hum = c;
|
||||
}
|
||||
}
|
||||
} else if (c->AsHuman()->HasObserver()) {
|
||||
c->AsHuman()->TraverseObservers
|
||||
(
|
||||
[this, &nearest_distance, &nearest_hum] (Human* hum, bool& stop) mutable
|
||||
{
|
||||
if (!hum->IsPlayer()) {
|
||||
return;
|
||||
}
|
||||
if (hum->socket_handle) {
|
||||
float distance = std::fabs(hum->GetPos().GetX() - GetPos().GetX()) + std::fabs(hum->GetPos().GetZ() - GetPos().GetZ());
|
||||
if (distance < nearest_distance) {
|
||||
nearest_distance = distance;
|
||||
nearest_hum = hum;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (nearest_hum) {
|
||||
p = std::make_shared<std::set<int>>();
|
||||
p->insert(nearest_hum->GetUniId());
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,8 @@ class Creature : public MoveableEntity
|
||||
float GetSkillRaycastDistance();
|
||||
virtual void NetInitOk();
|
||||
bool IsNearGas();
|
||||
std::shared_ptr<std::set<int>> CalcReporterList(const mt::Equip* weapon_meta,
|
||||
std::shared_ptr<std::set<int>> CalcReporterList(bool is_trace_bullet,
|
||||
const mt::Equip* weapon_meta,
|
||||
const mt::Equip* bullet_meta);
|
||||
|
||||
protected:
|
||||
|
@ -111,9 +111,7 @@ void Hero::Update(int delta_time)
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (!room->stop_world) {
|
||||
agent_->Exec();
|
||||
}
|
||||
agent_->Exec();
|
||||
#else
|
||||
agent_->Exec();
|
||||
#endif
|
||||
|
@ -529,7 +529,6 @@ void InternalShot(Creature* c,
|
||||
bullet_info.bullet_num = bulletNum;
|
||||
bullet_info.weapon_lv = weapon_lv;
|
||||
bullet_info.weapon_buff_id = weapon_buff_id;
|
||||
bullet_info.reporter_list = c->CalcReporterList(weapon_meta, bullet_meta);
|
||||
#if 0
|
||||
if (skill_meta &&
|
||||
(skill_meta->GetMagicId() == MAGIC_20101_HL ||
|
||||
@ -538,6 +537,7 @@ void InternalShot(Creature* c,
|
||||
bullet_info.trace_target_uniid = c->GetSkillTargetId();
|
||||
}
|
||||
#endif
|
||||
bullet_info.reporter_list = c->CalcReporterList(trace_target_uniid, weapon_meta, bullet_meta);
|
||||
if (weapon_meta->double_gun() &&
|
||||
bulletIdx > (int)(bulletNum / 2)) {
|
||||
bullet_info.hand = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user