This commit is contained in:
aozhiwei 2021-04-07 16:00:16 +08:00
parent b4f4b9cdfd
commit 0a4663c9a0

View File

@ -267,6 +267,49 @@ void RoomObstacle::Explosion()
void RoomObstacle::SpecExplosion()
{
++explosion_times_;
if (meta->i->damage_dia() > 0.01f &&
meta->i->damage() > 0.01f) {
if (!grid_list_) {
grid_list_ = new std::set<GridCell*>();
room->grid_service->GetAllCellsByXy(room, GetPos().x, GetPos().y, *grid_list_);
}
std::set<Entity*> objects;
room->grid_service->TouchAllLayerHumanList
(
room->GetRoomIdx(),
*grid_list_,
[this, &objects] (Human* hum, bool& stop)
{
float distance = (hum->GetPos() - GetPos()).Norm();
if (master.Get()->team_id != hum->team_id && distance < meta->i->damage_dia()) {
objects.insert(hum);
}
});
a8::Vec2 bomb_pos = GetPos();
room->frame_event.AddExplosionEx(master,
meta->i->thing_id(),
bomb_pos,
meta->i->explosion_effect());
for (auto& target : objects) {
switch (target->GetEntityType()) {
case ET_Player:
{
Human* hum = (Human*)target;
if (!hum->dead) {
float dmg = meta->i->damage();
float def = hum->ability.def;
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
hum->DecHP(finaly_dmg, VP_Mine, TEXT("battle_server_killer_mine", "地雷"), VW_Mine);
}
}
break;
default:
{
}
break;
}
}
}
if (explosion_times_ >= meta->i->explosion_times()) {
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
}