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)
{
std::set<Entity*> objects;
TouchAllLayerHumanList
(
[this, &objects] (Human* hum, bool& stop)
room->grid_service->TouchCreatures
(room->GetRoomIdx(),
GetGridList(),
[this, &objects] (Creature* c, bool& stop)
{
if (sender.Get()->IsProperTarget(c)) {
AabbCollider aabb_box;
hum->GetHitAabbBox(aabb_box);
if (hum != sender.Get() && !hum->dead && TestCollision(room, &aabb_box)) {
objects.insert(hum);
c->GetHitAabbBox(aabb_box);
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)
{
#ifdef DEBUG
dec_hp *= 5;
#endif
float old_health = GetHP();
float new_health = std::max(0.0f, GetHP() - dec_hp);
ability.hp = std::max(0.0f, new_health);