This commit is contained in:
aozhiwei 2021-06-28 02:35:01 +00:00
commit bebb081ba1
8 changed files with 68 additions and 23 deletions

View File

@ -313,15 +313,13 @@ void Bullet::Check(float distance)
std::set<ColliderComponent*> colliders; std::set<ColliderComponent*> colliders;
room->map_service->GetColliders(room, GetX(), GetY(), colliders); room->map_service->GetColliders(room, GetX(), GetY(), colliders);
for (ColliderComponent* collider : colliders) { for (ColliderComponent* collider : colliders) {
if (TestCollision(room, collider) && if (collider->owner->IsEntityType(ET_Obstacle)) {
!a8::HasBitFlag(collider->tag, kHalfWallTag)) { Obstacle* obstacle = (Obstacle*)collider->owner;
if (collider->owner->IsEntityType(ET_Obstacle)) { if (!obstacle->CanThroughable(this)) {
Obstacle* obstacle = (Obstacle*)collider->owner; if (TestCollision(room, collider)) {
if (obstacle->CanThroughable(this)) { objects.insert(collider->owner);
continue;
} }
} }
objects.insert(collider->owner);
} }
} }
} }

View File

@ -12,6 +12,7 @@
#include "typeconvert.h" #include "typeconvert.h"
#include "bullet.h" #include "bullet.h"
#include "explosion.h" #include "explosion.h"
#include "obstacle.h"
Car::Car():Creature() Car::Car():Creature()
{ {
@ -343,6 +344,7 @@ void Car::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
meta->i->explosion_effect(), meta->i->explosion_effect(),
meta->i->atk() meta->i->atk()
); );
room->NotifyUiUpdate();
} }
void Car::GetAabbBox(AabbCollider& aabb_box) void Car::GetAabbBox(AabbCollider& aabb_box)
@ -392,3 +394,10 @@ float Car::GetMaxOil()
{ {
return meta->i->max_oil(); return meta->i->max_oil();
} }
void Car::DropItems(Obstacle* obstacle)
{
if (obstacle->meta->i->drop() != 0) {
room->ScatterDrop(obstacle->GetPos(), obstacle->meta->i->drop());
}
}

View File

@ -43,6 +43,7 @@ class Car : public Creature
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override; virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;
virtual void SendDebugMsg(const std::string& debug_msg) override; virtual void SendDebugMsg(const std::string& debug_msg) override;
virtual void SetAttackDir(const a8::Vec2& attack_dir) override; virtual void SetAttackDir(const a8::Vec2& attack_dir) override;
virtual void DropItems(Obstacle* obstacle) override;
private: private:
int AllocSeat(); int AllocSeat();

View File

@ -73,6 +73,9 @@ void Explosion::InternalAttack()
grid_list, grid_list,
[this, &objects] (Creature* c, bool& stop) [this, &objects] (Creature* c, bool& stop)
{ {
if (c->GetUniId() == exclude_uniid) {
return;
}
if (!c->Attackable(room_)) { if (!c->Attackable(room_)) {
return; return;
} }
@ -98,6 +101,9 @@ void Explosion::InternalAttack()
grid_list, grid_list,
[this, &objects] (Entity* entity, bool& stop) [this, &objects] (Entity* entity, bool& stop)
{ {
if (entity->GetUniId() == exclude_uniid) {
return;
}
if (!entity->Attackable(room_)) { if (!entity->Attackable(room_)) {
return; return;
} }

View File

@ -6,6 +6,7 @@ class Room;
class Explosion class Explosion
{ {
public: public:
int exclude_uniid = 0;
Room* GetRoom() { return room_; }; Room* GetRoom() { return room_; };
CreatureWeakPtr GetSender() { return sender_; }; CreatureWeakPtr GetSender() { return sender_; };

View File

@ -469,6 +469,9 @@ void Obstacle::SetMasterId(Room* room, int master_id)
void Obstacle::OnBulletHit(Bullet* bullet) void Obstacle::OnBulletHit(Bullet* bullet)
{ {
if (meta->i->bullet_hit() == kBulletHitEatDmg) {
return;
}
if (!IsDead(bullet->room) && if (!IsDead(bullet->room) &&
!IsTerminatorAirDropBox(bullet->room)) { !IsTerminatorAirDropBox(bullet->room)) {
if (meta->receive_special_damage_type != 0 && if (meta->receive_special_damage_type != 0 &&
@ -510,6 +513,17 @@ void Obstacle::OnBulletHit(Bullet* bullet)
if (IsDead(bullet->room)) { if (IsDead(bullet->room)) {
ProcDieExplosion(bullet->room); ProcDieExplosion(bullet->room);
bullet->sender.Get()->DropItems(this); bullet->sender.Get()->DropItems(this);
if (meta->i->thing_type() == kObstacleOilBucket) {
MetaData::MapThing* bomb_meta = MetaMgr::Instance()->GetMapThing(meta->int_param1);
if (bomb_meta) {
RoomObstacle* obstacle = bullet->room->CreateObstacle
(
bomb_meta->i->thing_id(),
GetPos().x,
GetPos().y
);
}
}
} }
BroadcastFullState(bullet->room); BroadcastFullState(bullet->room);
#ifdef DEBUG #ifdef DEBUG
@ -553,6 +567,17 @@ void Obstacle::OnExplosionHit(Explosion* e)
if (meta->i->drop() != 0) { if (meta->i->drop() != 0) {
e->GetRoom()->ScatterDrop(GetPos(), meta->i->drop()); e->GetRoom()->ScatterDrop(GetPos(), meta->i->drop());
} }
if (meta->i->thing_type() == kObstacleOilBucket) {
MetaData::MapThing* bomb_meta = MetaMgr::Instance()->GetMapThing(meta->int_param1);
if (bomb_meta) {
RoomObstacle* obstacle = e->GetRoom()->CreateObstacle
(
bomb_meta->i->thing_id(),
GetPos().x,
GetPos().y
);
}
}
} }
BroadcastFullState(e->GetRoom()); BroadcastFullState(e->GetRoom());
} }

View File

@ -3969,14 +3969,16 @@ void Room::AirRaid(int airraid_id)
); );
a8::Vec2 dir = a8::Vec2::UP; a8::Vec2 dir = a8::Vec2::UP;
dir.Rotate(a8::RandAngle()); dir.Rotate(a8::RandAngle());
a8::Vec2 pos = center + dir * (50 + rand() % 100);; a8::Vec2 pos = center + dir * (50 + rand() % 100);
RoomObstacle* obstacle = room->CreateObstacle if (room->grid_service->CanAdd(pos.x, pos.y)) {
( RoomObstacle* obstacle = room->CreateObstacle
raid_meta->i->bomb_id(), (
pos.x, raid_meta->i->bomb_id(),
pos.y pos.x,
); pos.y
obstacle->Active(); );
obstacle->Active();
}
}; };
Room* room = (Room*)param.sender.GetUserData(); Room* room = (Room*)param.sender.GetUserData();
if (room->IsGameOver()) { if (room->IsGameOver()) {

View File

@ -183,14 +183,17 @@ void RoomObstacle::SpecExplosion()
bomb_born_offset.Rotate(a8::RandAngle()); bomb_born_offset.Rotate(a8::RandAngle());
bomb_born_offset = bomb_born_offset * a8::RandEx(1, std::max(2, meta->i->explosion_float())); bomb_born_offset = bomb_born_offset * a8::RandEx(1, std::max(2, meta->i->explosion_float()));
a8::Vec2 bomb_pos = GetPos() + bomb_born_offset; a8::Vec2 bomb_pos = GetPos() + bomb_born_offset;
Explosion explosion; if (room->grid_service->CanAdd(bomb_pos.x, bomb_pos.y)) {
explosion.IndifferenceAttack( Explosion explosion;
room, explosion.exclude_uniid = GetUniId();
bomb_pos, explosion.IndifferenceAttack(
meta->i->damage_dia(), room,
meta->i->explosion_effect(), bomb_pos,
meta->i->damage() meta->i->damage_dia(),
); meta->i->explosion_effect(),
meta->i->damage()
);
}
} }
if (explosion_times_ >= meta->i->explosion_times()) { if (explosion_times_ >= meta->i->explosion_times()) {
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer()); room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());