1
This commit is contained in:
parent
f255b32153
commit
cdb2bfb5fc
@ -12,6 +12,7 @@
|
||||
#include "obstacle.h"
|
||||
#include "collider.h"
|
||||
#include "bullet.h"
|
||||
#include "explosion.h"
|
||||
|
||||
Hero::Hero():Creature()
|
||||
{
|
||||
@ -75,6 +76,40 @@ void Hero::Update(int delta_time)
|
||||
++updated_times_;
|
||||
}
|
||||
|
||||
void Hero::OnExplosionHit(Explosion* e)
|
||||
{
|
||||
if (IsInvincible()) {
|
||||
return;
|
||||
}
|
||||
if (dead) {
|
||||
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 Hero::OnBulletHit(Bullet* bullet)
|
||||
{
|
||||
if (IsInvincible()) {
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
virtual void Initialize() override;
|
||||
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 OnExplosionHit(Explosion* e) override;
|
||||
virtual void OnBulletHit(Bullet* bullet) override;
|
||||
virtual void Update(int delta_time) override;
|
||||
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user