This commit is contained in:
aozhiwei 2022-12-31 09:23:42 +08:00
parent dfd0ac51fa
commit 3f143334f4
3 changed files with 55 additions and 43 deletions

View File

@ -832,50 +832,13 @@ void Bullet::GetHitCreatures(BulletCheckResult& result)
if (c->HasBuffEffect(kBET_BulletThrough)) {
return;
}
{
Buff* hold_shield_buff = c->GetBuffByEffectId(kBET_HoldShield);
if (hold_shield_buff && !IsBomb() && !c->dead && c != sender.Get()) {
// 999
#if 0
//param2是距离 param4是宽度
a8::Vec2 shield_pos = c->GetPos() + c->GetAttackDir() * hold_shield_buff->meta->param2;
bool ret = Check2dRotationRectangle(GetPos().x,
GetPos().y,
//10,
gun_meta->bullet_rad(),
shield_pos.x,
shield_pos.y,
hold_shield_buff->meta->param4,
MetaMgr::Instance()->bullet_planck_step_length,
c->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);
#ifdef DEBUG
a8::XPrintf("命中盾牌 finally_dmg:%f shield_hp:%f\n",
{
finaly_dmg,
c->shield_hp_
});
#endif
room->frame_event.AddPropChg(c->GetWeakPtrRef(),
kPropShieldHp,
c->shield_max_hp_,
c->shield_hp_);
if (c->shield_hp_ <= 0) {
#ifdef DEBUG
a8::XPrintf("shiled destory\n", {});
#endif
c->GetTrigger()->ShieldDestory();
c->RemoveBuffByUniId(hold_shield_buff->buff_uniid);
}
eat = true;
stop = true;
return;
}
#endif
if (c->HasBuffEffect(kBET_HoldShield)) {
c->CheckBulletHitHoldShield(this, result.eat);
if (result.eat) {
stop = true;
return;
}
return;
}
AabbCollider aabb_box;
c->GetHitAabbBox(aabb_box);

View File

@ -3033,3 +3033,51 @@ void Creature::OnLand()
}
}
}
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,
GetPos().y,
//10,
gun_meta->bullet_rad(),
shield_pos.x,
shield_pos.y,
hold_shield_buff->meta->param4,
MetaMgr::Instance()->bullet_planck_step_length,
c->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);
#ifdef DEBUG
a8::XPrintf("命中盾牌 finally_dmg:%f shield_hp:%f\n",
{
finaly_dmg,
c->shield_hp_
});
#endif
room->frame_event.AddPropChg(c->GetWeakPtrRef(),
kPropShieldHp,
c->shield_max_hp_,
c->shield_hp_);
if (c->shield_hp_ <= 0) {
#ifdef DEBUG
a8::XPrintf("shiled destory\n", {});
#endif
c->GetTrigger()->ShieldDestory();
c->RemoveBuffByUniId(hold_shield_buff->buff_uniid);
}
eat = true;
stop = true;
return;
}
#endif
}
}

View File

@ -293,6 +293,7 @@ class Creature : public MoveableEntity
void LockAttackDir(int time);
void PullTarget(const glm::vec3& target_pos);
void MarkSyncActivePlayer(const char* file, int line, const char* func);
void CheckBulletHitHoldShield(IBullet* bullet, bool& eat);
protected:
virtual void OnBuffRemove(Buff& buff);