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,18 +313,16 @@ 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) &&
!a8::HasBitFlag(collider->tag, kHalfWallTag)) {
if (collider->owner->IsEntityType(ET_Obstacle)) { if (collider->owner->IsEntityType(ET_Obstacle)) {
Obstacle* obstacle = (Obstacle*)collider->owner; Obstacle* obstacle = (Obstacle*)collider->owner;
if (obstacle->CanThroughable(this)) { if (!obstacle->CanThroughable(this)) {
continue; if (TestCollision(room, collider)) {
}
}
objects.insert(collider->owner); objects.insert(collider->owner);
} }
} }
} }
}
}
float bullet_range = gun_meta->i->range(); float bullet_range = gun_meta->i->range();
if (gun_upgrade_meta && gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange) > 0) { if (gun_upgrade_meta && gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange) > 0) {
bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange); bullet_range += gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_ShotRange);

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,7 +3969,8 @@ 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);
if (room->grid_service->CanAdd(pos.x, pos.y)) {
RoomObstacle* obstacle = room->CreateObstacle RoomObstacle* obstacle = room->CreateObstacle
( (
raid_meta->i->bomb_id(), raid_meta->i->bomb_id(),
@ -3977,6 +3978,7 @@ void Room::AirRaid(int airraid_id)
pos.y 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,7 +183,9 @@ 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;
if (room->grid_service->CanAdd(bomb_pos.x, bomb_pos.y)) {
Explosion explosion; Explosion explosion;
explosion.exclude_uniid = GetUniId();
explosion.IndifferenceAttack( explosion.IndifferenceAttack(
room, room,
bomb_pos, bomb_pos,
@ -192,6 +194,7 @@ void RoomObstacle::SpecExplosion()
meta->i->damage() 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());
Die(room); Die(room);