This commit is contained in:
aozhiwei 2023-02-16 15:11:22 +08:00
parent 1148c5f79d
commit 057259ce1e
15 changed files with 80 additions and 32 deletions

View File

@ -30,12 +30,14 @@ void DiveBuff::Activate()
true);
return;
}
float dmg_out = 0.0f;
hum->DecHP(mt::Param::s().dive_hp_consume,
VP_Water,
"water",
0,
0,
"water");
"water",
dmg_out);
}
},
&xtimer_attacher

View File

@ -36,13 +36,15 @@ void OnceChgAttrBuff::InternalProcOnceChgAttr()
if (meta->_buff_param3 > 0) {
owner->AddHp(meta->_buff_param3);
} else if (meta->_buff_param3 < 0) {
float dmg_out = 0.0f;
owner->over_delay_time = 100;
owner->DecHP(std::abs(meta->_buff_param3),
VP_Buff,
"",
meta->buff_id(),
real_killer_id,
real_killer_name);
real_killer_name,
dmg_out);
owner->over_delay_time = 0;
}
} else if (meta->_int_buff_param2 == 2) {
@ -51,13 +53,15 @@ void OnceChgAttrBuff::InternalProcOnceChgAttr()
if (chg_hp > 0.0001f) {
owner->AddHp(chg_hp);
} else if (chg_hp < 0.0001f) {
float dmg_out = 0.0f;
owner->over_delay_time = 100;
owner->DecHP(std::abs(chg_hp),
VP_Buff,
"",
meta->buff_id(),
real_killer_id,
real_killer_name);
real_killer_name,
dmg_out);
owner->over_delay_time = 0;
}
}

View File

@ -148,14 +148,15 @@ void SprintBuff::OnEnemyHit(Creature* enemy)
enemy,
skill_meta);
if (dmg > 0.0001f) {
float dmg_out = 0.0f;
enemy->DecHP(
dmg,
owner->GetUniId(),
owner->GetName(),
0,
owner->GetUniId(),
owner->GetName()
);
owner->GetName(),
dmg_out);
}
}
break;

View File

@ -284,13 +284,14 @@ void Car::OnBulletHit(IBullet* bullet)
MustBeAddBuff(bullet->GetSender().Get(), bullet->GetBulletMeta()->buffid());
}
if (!bullet->IsPreBattleBullet()) {
float dmg_out = 0.0f;
DecHP(finaly_dmg,
bullet->GetSender().Get()->GetUniId(),
bullet->GetSender().Get()->GetName(),
bullet->GetGunMeta()->id(),
bullet->GetSender().Get()->GetUniId(),
bullet->GetSender().Get()->GetName()
);
bullet->GetSender().Get()->GetName(),
dmg_out);
}
if (bullet->GetBulletMeta()->_buff_meta) {
MustBeAddBuff(this, bullet->GetBulletMeta()->buffid());
@ -320,18 +321,22 @@ void Car::OnExplosionHit(Explosion* e)
real_killer_name = e->GetSender().Get()->GetName();
}
float dmg_out = 0.0f;
float finaly_dmg = GetBattleContext()->CalcDmg(e);
DecHP(finaly_dmg,
VP_Explosion,
"",
e->GetExplosionEffect(),
real_killer_id,
real_killer_name);
real_killer_name,
dmg_out);
}
void Car::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name)
int real_killer_id, const std::string& real_killer_name,
float& real_dmg_out)
{
real_dmg_out = 0.0f;
if (dec_hp < 0.001f) {
return;
}

View File

@ -35,8 +35,10 @@ class Car : public Creature
bool HasPassenter() { return !passengers_.empty();};
virtual float GetRadius() override;
virtual float GetSpeed() override;
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name) override;
virtual void DecHP(float dec_hp,
int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name,
float& real_dmg_out) override;
virtual void SendDebugMsg(const std::string& debug_msg) override;
virtual void SetAttackDir(const glm::vec3& attack_dir) override;
virtual void DropItems(Obstacle* obstacle) override;

View File

@ -1154,9 +1154,11 @@ void Creature::UpdatePoisoning()
} else {
dmg = std::max(1.0f, dmg);
}
float dmg_out = 0.0f;
DecHP(dmg, VP_Gas, TEXT("battle_server_killer_gas", "毒圈"), VW_Gas,
VP_Gas,
TEXT("battle_server_killer_gas", "毒圈"));
TEXT("battle_server_killer_gas", "毒圈"),
dmg_out);
if (dead) {
poisoning_time = 0;
break;

View File

@ -191,8 +191,10 @@ class Creature : public MoveableEntity
Human* AsHuman() { return IsHuman() ? (Human*)this : nullptr; };
Player* AsPlayer() { return IsPlayer() ? (Player*)this : nullptr; };
Car* AsCar() { return IsCar() ? (Car*)this : nullptr; };
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name) {};
virtual void DecHP(float dec_hp, int killer_id,
const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name,
float& real_dmg_out) {};
void AddHp(float hp);
void SetHP(float hp);
void SetMaxHP(float max_hp);

View File

@ -93,13 +93,15 @@ void Hero::OnExplosionHit(Explosion* e)
}
RemoveBuffByEffectId(kBET_PeaceMode);
float dmg_out = 0.0f;
float finaly_dmg = GetBattleContext()->CalcDmg(e);
DecHP(finaly_dmg,
VP_Explosion,
"",
e->GetExplosionEffect(),
real_killer_id,
real_killer_name);
real_killer_name,
dmg_out);
}
void Hero::OnBulletHit(IBullet* bullet)
@ -122,12 +124,14 @@ void Hero::OnBulletHit(IBullet* bullet)
MustBeAddBuff(bullet->GetSender().Get(), bullet->GetBulletMeta()->buffid());
}
if (!bullet->IsPreBattleBullet()) {
float dmg_out = 0.0f;
DecHP(finaly_dmg,
bullet->GetSender().Get()->GetUniId(),
bullet->GetSender().Get()->GetName(),
bullet->GetGunMeta()->id(),
bullet->GetSender().Get()->GetUniId(),
bullet->GetSender().Get()->GetName());
bullet->GetSender().Get()->GetName(),
dmg_out);
}
}
}
@ -164,8 +168,10 @@ void Hero::DetachFromMaster()
}
void Hero::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name)
int real_killer_id, const std::string& real_killer_name,
float& real_dmg_out)
{
real_dmg_out = 0.0f;
if (!room->BattleStarted()) {
return;
}

View File

@ -24,8 +24,10 @@ public:
virtual void OnExplosionHit(Explosion* e) override;
virtual void OnBulletHit(IBullet* 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,
int real_killer_id, const std::string& real_killer_name) override;
virtual void DecHP(float dec_hp,
int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name,
float& real_dmg_out) override;
virtual std::string GetName() override;
virtual void DropItems(Obstacle* obstacle) override;
virtual const mt::Hero* GetHeroMeta() override { return meta; };

View File

@ -652,8 +652,10 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id,
}
void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name)
int real_killer_id, const std::string& real_killer_name,
float& real_dmg_out)
{
real_dmg_out = 0.0f;
if (!room->BattleStarted()) {
return;
}
@ -745,9 +747,11 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i
info->real_killer_id, info->real_killer_name);
return;
}
float dmg_out = 0.0f;
int dec_hp = mt::Param::GetIntParam("downed_dec_hp");
DecHP(dec_hp, info->killer_id, info->killer_name, info->weapon_id,
info->real_killer_id, info->real_killer_name);
info->real_killer_id, info->real_killer_name,
dmg_out);
}
},
&xtimer_attacher);
@ -2457,13 +2461,14 @@ void Human::OnBulletHit(IBullet* bullet)
}
if (bullet->GetSender().Get() && bullet->GetSender().Get()->IsCar() && bullet->GetPassenger().Get()) {
if (!bullet->IsPreBattleBullet()) {
float dmg_out = 0.0f;
DecHP(finaly_dmg,
bullet->GetPassenger().Get()->GetUniId(),
bullet->GetPassenger().Get()->GetName(),
bullet->GetGunMeta()->id(),
bullet->GetPassenger().Get()->GetUniId(),
bullet->GetPassenger().Get()->GetName()
);
bullet->GetPassenger().Get()->GetName(),
dmg_out);
}
} else {
if (!bullet->IsPreBattleBullet()) {
@ -2471,13 +2476,14 @@ void Human::OnBulletHit(IBullet* bullet)
bullet->GetSender().Get()->AsHuman()->stats.IncWeaponDamageOut
(bullet->GetGunMeta()->id(), finaly_dmg);
}
float dmg_out = 0.0f;
DecHP(finaly_dmg,
bullet->GetSender().Get()->GetUniId(),
bullet->GetSender().Get()->GetName(),
bullet->GetGunMeta()->id(),
bullet->GetSender().Get()->GetUniId(),
bullet->GetSender().Get()->GetName()
);
bullet->GetSender().Get()->GetName(),
dmg_out);
}
}
}
@ -2515,12 +2521,14 @@ void Human::OnExplosionHit(Explosion* e)
#else
if (e->GetSender().Get()) {
#endif
float dmg_out = 0.0f;
DecHP(finaly_dmg,
VP_Explosion,
"",
e->GetExplosionEffect(),
real_killer_id,
real_killer_name);
real_killer_name,
dmg_out);
}
}

View File

@ -299,8 +299,10 @@ class Human : public Creature
void CarShot(const glm::vec3& target_dir);
void BeKill(int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name);
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name) override;
virtual void DecHP(float dec_hp,
int killer_id, const std::string& killer_name, int weapon_id,
int real_killer_id, const std::string& real_killer_name,
float& real_dmg_out) override;
virtual void AddToNewObjects(Entity* entity) override;
virtual void AddToPartObjects(Entity* entity) override;
virtual void AddToImageObjects(Creature* c) override;

View File

@ -859,13 +859,14 @@ void RoomObstacle::ActiveMedicalStation()
float damage = SkillHelper::GetYlzDamage(master.Get(),
c,
skill_meta);
float dmg_out = 0.0f;
c->DecHP(damage,
master.Get()->GetUniId(),
master.Get()->GetName(),
VP_Buff,
master.Get()->GetUniId(),
master.Get()->GetName()
);
master.Get()->GetName(),
dmg_out);
for (int buff_id : meta->_buff_list) {
c->TryAddBuff(master.Get(),

View File

@ -456,12 +456,14 @@ void Skill::Proc30401MAO()
return;
}
float dmg = SkillHelper::GetSwzbDmg(sender.Get(), skill_meta);
float dmg_out = 0.0f;
c->DecHP(dmg,
VP_Explosion,
"",
SkillHelper::GetSwzbEffect(skill_meta),
sender.Get()->GetUniId(),
sender.Get()->GetName());
sender.Get()->GetName(),
dmg_out);
glm::vec3 dir = sender.Get()->GetAttackDir();
if (!GlmHelper::IsZero(dir)) {
// 999
@ -601,12 +603,14 @@ void Skill::Proc30501TZ()
return;
}
float dmg = SkillHelper::GetCmxdDmg(sender.Get(), skill_meta);
float dmg_out = 0.0f;
c->DecHP(dmg,
VP_Explosion,
"",
SkillHelper::GetCmxdExplosion(skill_meta),
sender.Get()->GetUniId(),
sender.Get()->GetName());
sender.Get()->GetName(),
dmg_out);
glm::vec3 dir = sender.Get()->GetAttackDir();
if (!GlmHelper::IsZero(dir)) {
glm::vec3 target_pos = c->GetPos().ToGlmVec3() +

View File

@ -485,3 +485,8 @@ void Trigger::Attacked(Creature* sender)
{
DispatchEvent(kAttacked, {sender});
}
void Trigger::DmgOut(Creature* target, float dmg)
{
DispatchEvent(kDmgOutEvent, {target, dmg});
}

View File

@ -34,6 +34,7 @@ enum EventId_e
kSkillBulletPreCreateEvent,
kUseSkillEvent,
kTriggerBulletHitBuffEvent,
kDmgOutEvent,
kAttacked
};
@ -72,6 +73,7 @@ public:
void FlyHookDestory();
void BulletHitBuff(Bullet* bullet);
void Attacked(Creature* sender);
void DmgOut(Creature* target, float dmg);
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, a8::CommonCbProc cb);
void RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler_ptr);