111 lines
3.2 KiB
C++
111 lines
3.2 KiB
C++
#include "precompile.h"
|
|
|
|
#include "explosion.h"
|
|
|
|
void Explosion::IndifferenceAttack(Room* room,
|
|
const a8::Vec2& center,
|
|
float range,
|
|
int explosion_effect,
|
|
float dmg)
|
|
{
|
|
#if 0
|
|
if (meta->i->explosion_range() <= 0) {
|
|
return;
|
|
}
|
|
std::set<Creature*> objects;
|
|
TraverseProperTargetsNoTeammate
|
|
(
|
|
[this, &objects, team_id] (Creature* c, bool& stop)
|
|
{
|
|
float distance = (c->GetPos() - GetPos()).Norm();
|
|
if (distance < meta->i->explosion_range()) {
|
|
objects.insert(c);
|
|
}
|
|
});
|
|
room->frame_event.AddExplosionEx(GetWeakPtrRef(),
|
|
0,
|
|
GetPos(),
|
|
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->atk();
|
|
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;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void Explosion::EnemyAndObstacleAttack(CreatureWeakPtr& sender,
|
|
const a8::Vec2& center,
|
|
float range,
|
|
int explosion_effect,
|
|
float dmg)
|
|
{
|
|
#if 0
|
|
if (!sender.Get()) {
|
|
return;
|
|
}
|
|
|
|
if (follow_target.Get()) {
|
|
bomb_pos = follow_target.Get()->GetPos();
|
|
}
|
|
room->frame_event.AddExplosionEx(sender,
|
|
meta->i->id(),
|
|
bomb_pos,
|
|
gun_meta->i->explosion_effect());
|
|
std::set<GridCell*> grid_list;
|
|
sender.Get()->room->grid_service->GetAllCellsByXy
|
|
(
|
|
sender.Get()->room,
|
|
bomb_pos.x,
|
|
bomb_pos.y,
|
|
grid_list
|
|
);
|
|
std::set<Creature*> objects;
|
|
sender.Get()->room->grid_service->TraverseCreatures
|
|
(
|
|
sender.Get()->room->GetRoomIdx(),
|
|
grid_list,
|
|
[this, &objects] (Creature* c, bool& stop)
|
|
{
|
|
if (sender.Get()->IsProperTarget(c)) {
|
|
if (bomb_pos.Distance(c->GetPos()) < meta->i->explosion_range()) {
|
|
objects.insert(c);
|
|
}
|
|
}
|
|
}
|
|
);
|
|
std::set<Entity*> entitys;
|
|
sender.Get()->room->grid_service->TraverseAllLayerEntityList
|
|
(
|
|
sender.Get()->room->GetRoomIdx(),
|
|
grid_list,
|
|
[this, &entitys] (Entity* entity, bool& stop)
|
|
{
|
|
}
|
|
);
|
|
|
|
Explosion explosion;
|
|
for (auto& target : objects) {
|
|
target->OnExplosionHit(&explosion);
|
|
}
|
|
|
|
for (auto& target : entitys) {
|
|
target->OnExplosionHit(&explosion);
|
|
}
|
|
#endif
|
|
}
|