This commit is contained in:
aozhiwei 2023-01-01 16:00:02 +08:00
parent 00affa6a3c
commit f97c4ccc59

View File

@ -19,6 +19,7 @@
#include "battledatacontext.h"
#include "buff.h"
#include "mapinstance.h"
#include "collision.h"
#include "mt/Param.h"
#include "mt/Hero.h"
@ -2923,46 +2924,42 @@ void Creature::CheckBulletHitHoldShield(IBullet* bullet, bool& eat)
{
Buff* hold_shield_buff = GetBuffByEffectId(kBET_HoldShield);
if (hold_shield_buff && !bullet->IsBomb() && !dead && this != bullet->GetSender().Get()) {
// 999
#if 0
//param2是距离 param4是宽度
a8::Vec2 shield_pos = c->GetPos() + c->GetAttackDir() * hold_shield_buff->meta->param2;
bool ret = Check2dRotationRectangle(GetPos().x,
glm::vec3 shield_pos = GetPos().ToGlmVec3() + GetAttackDir() * hold_shield_buff->meta->_param2;
bool ret = Collision::Check2dRotationRectangle
(GetPos().x,
GetPos().y,
//10,
gun_meta->bullet_rad(),
bullet->GetGunMeta()->bullet_rad(),
shield_pos.x,
shield_pos.y,
hold_shield_buff->meta->param4,
MetaMgr::Instance()->bullet_planck_step_length,
c->GetAttackDirRotate() * 180.0f
hold_shield_buff->meta->_param4,
mt::Param::s().bullet_planck_step_length,
GetAttackDirRotate() * 180.0f
);
if (ret) {
float finaly_dmg = c->GetBattleContext()->CalcDmg(c, this);
c->shield_hp_ = std::max(0.0f, c->shield_hp_ - finaly_dmg);
float finaly_dmg = GetBattleContext()->CalcDmg(this, bullet);
shield_hp_ = std::max(0.0f, shield_hp_ - finaly_dmg);
#ifdef DEBUG
a8::XPrintf("命中盾牌 finally_dmg:%f shield_hp:%f\n",
{
finaly_dmg,
c->shield_hp_
shield_hp_
});
#endif
room->frame_event.AddPropChg(c->GetWeakPtrRef(),
room->frame_event.AddPropChg(GetWeakPtrRef(),
kPropShieldHp,
c->shield_max_hp_,
c->shield_hp_);
if (c->shield_hp_ <= 0) {
shield_max_hp_,
shield_hp_);
if (shield_hp_ <= 0) {
#ifdef DEBUG
a8::XPrintf("shiled destory\n", {});
#endif
c->GetTrigger()->ShieldDestory();
c->RemoveBuffByUniId(hold_shield_buff->buff_uniid);
GetTrigger()->ShieldDestory();
RemoveBuffByUniId(hold_shield_buff->buff_uniid);
}
eat = true;
stop = true;
return;
}
#endif
}
}