This commit is contained in:
aozhiwei 2021-08-25 05:23:30 +00:00
commit 240cc66a5e
3 changed files with 44 additions and 0 deletions

View File

@ -303,6 +303,48 @@ void Car::OnBulletHit(Bullet* bullet)
}
}
void Car::OnExplosionHit(Explosion* e)
{
if (IsInvincible()) {
return;
}
if (dead) {
return;
}
if (e->IsPreBattleExplosion()) {
return;
}
if (HasBuffEffect(kBET_Jump) ||
HasBuffEffect(kBET_Fly)) {
return;
}
float dmg = e->GetDmg();
float def = GetDef() * (1 + GetAbility()->GetAttrRate(kHAT_Def)) +
GetAbility()->GetAttrAbs(kHAT_Def);
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
finaly_dmg = std::max(finaly_dmg, 0.0f);
#ifdef DEBUG
{
room->BroadcastDebugMsg(a8::Format("explosion dmg:%d def:%d finaly_dmg:%d",
{dmg,
def,
finaly_dmg}));
}
#endif
#if 1
DecHP(finaly_dmg,
1,
"",
1);
#else
DecHP(finaly_dmg,
sender.Get()->GetUniId(),
sender.Get()->GetName(),
gun_meta->i->id());
#endif
}
void Car::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id)
{
if (dec_hp < 0.001f) {

View File

@ -26,6 +26,7 @@ class Car : public Creature
virtual void FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data) override;
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
virtual void OnBulletHit(Bullet* bullet) override;
virtual void OnExplosionHit(Explosion* e) override;
virtual void GetAabbBox(AabbCollider& aabb_box) override;
virtual void GetHitAabbBox(AabbCollider& aabb_box) override;

View File

@ -15,6 +15,7 @@ void FragMiTask::Done()
a8::Vec2 center = bomb_pos;
if (follow_target.Get()) {
bomb_pos = follow_target.Get()->GetPos();
center = bomb_pos;
}
Explosion explosion;