This commit is contained in:
aozhiwei 2021-05-14 15:56:24 +08:00
parent e73cc99198
commit ab2f33eafd
2 changed files with 13 additions and 7 deletions

View File

@ -232,14 +232,17 @@ float Bullet::GetAtk()
void Bullet::Check(float distance) void Bullet::Check(float distance)
{ {
std::set<Entity*> objects; std::set<Entity*> objects;
TouchAllLayerHumanList room->grid_service->TouchCreatures
( (room->GetRoomIdx(),
[this, &objects] (Human* hum, bool& stop) GetGridList(),
[this, &objects] (Creature* c, bool& stop)
{ {
AabbCollider aabb_box; if (sender.Get()->IsProperTarget(c)) {
hum->GetHitAabbBox(aabb_box); AabbCollider aabb_box;
if (hum != sender.Get() && !hum->dead && TestCollision(room, &aabb_box)) { c->GetHitAabbBox(aabb_box);
objects.insert(hum); if (c != sender.Get() && !c->dead && TestCollision(room, &aabb_box)) {
objects.insert(c);
}
} }
}); });
{ {

View File

@ -231,6 +231,9 @@ void Car::OnBulletHit(Bullet* bullet)
void Car::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) void Car::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id)
{ {
#ifdef DEBUG
dec_hp *= 5;
#endif
float old_health = GetHP(); float old_health = GetHP();
float new_health = std::max(0.0f, GetHP() - dec_hp); float new_health = std::max(0.0f, GetHP() - dec_hp);
ability.hp = std::max(0.0f, new_health); ability.hp = std::max(0.0f, new_health);