This commit is contained in:
aozhiwei 2024-03-28 16:38:48 +08:00
parent 095cbdd82b
commit 92c7eb62c0

View File

@ -3728,7 +3728,13 @@ void Room::MobaBatterysUpdate()
( (
[side, &target, &center, &tuple, &last_distance] (Human* hum) -> bool [side, &target, &center, &tuple, &last_distance] (Human* hum) -> bool
{ {
if (hum->side != side) { if (hum->side != side &&
!hum->dead &&
!a8::HasBitFlag(hum->status, CS_Disable) &&
!hum->HasBuffEffect(kBET_Hide) &&
!hum->HasBuffEffect(kBET_Dive) &&
!hum->HasBuffEffect(kBET_Invincible)
) {
float distance = hum->GetPos().Distance2D2(center); float distance = hum->GetPos().Distance2D2(center);
if (distance < std::get<1>(tuple)) { if (distance < std::get<1>(tuple)) {
if (!target.Get() || distance < last_distance) { if (!target.Get() || distance < last_distance) {
@ -3741,7 +3747,7 @@ void Room::MobaBatterysUpdate()
}); });
if (!target.Get() || if (!target.Get() ||
(target.Get() && last_distance <= 0.000001f)) { (target.Get() && last_distance <= 0.000001f)) {
break; continue;
} }
glm::vec3 bullet_dir = target.Get()->GetPos().ToGlmVec3() - center; glm::vec3 bullet_dir = target.Get()->GetPos().ToGlmVec3() - center;
@ -3752,7 +3758,7 @@ void Room::MobaBatterysUpdate()
#ifdef MYDEBUG #ifdef MYDEBUG
abort(); abort();
#endif #endif
return; continue;
} }
glm::vec3 bullet_born_pos = std::get<0>(tuple); glm::vec3 bullet_born_pos = std::get<0>(tuple);
@ -3765,14 +3771,51 @@ void Room::MobaBatterysUpdate()
1, 1,
bullet_born_pos, bullet_born_pos,
bullet_dir, bullet_dir,
0, //last_distance, last_distance,
0, 0,
0, 0,
nullptr, nullptr,
shot_uniid, shot_uniid,
-1); -1);
float fly_time = last_distance / weapon_meta->bullet_speed();
xtimer.SetTimeoutWpEx
(
fly_time * SERVER_FRAME_RATE,
[this, target_pos = target.Get()->GetPos().ToGlmVec3(), side, weapon_meta]
(int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
TraverseHumanList
(
[this, side, target_pos, weapon_meta] (Human* hum) -> bool
{
if (hum->side != side &&
!hum->dead &&
!a8::HasBitFlag(hum->status, CS_Disable) &&
!hum->HasBuffEffect(kBET_Hide) &&
!hum->HasBuffEffect(kBET_Dive) &&
!hum->HasBuffEffect(kBET_Invincible)
) {
if (hum->GetPos().Distance2D2(target_pos) < weapon_meta->bullet_rad()) {
hum->BeKill(
VP_Explosion,
"",
weapon_meta->id(),
VP_Explosion,
""
);
}
}
return true;
});
}
},
&xtimer_attacher_);
#ifdef MYDEBUG #ifdef MYDEBUG
a8::XPrintf("MobaBatterysUpdate fly_distanc:%f\n", {last_distance}); a8::XPrintf("MobaBatterysUpdate fly_distance:%f fly_time:%f speed:%f\n",
{last_distance,
fly_time,
weapon_meta->bullet_speed()});
#endif #endif
} }
} }