子弹战前无伤害

This commit is contained in:
aozhiwei 2021-08-19 04:53:23 +00:00
parent 9759132ed6
commit 0c51f6badb
10 changed files with 78 additions and 24 deletions

View File

@ -33,6 +33,7 @@ void Bullet::Initialize()
RecalcSelfCollider();
ability_ = sender.Get()->GetAbility();
is_curr_weapon = sender.Get()->GetCurrWeapon()->meta == gun_meta;
create_frameno_ = room->GetFrameNo();
}
void Bullet::Update(int delta_time)
@ -588,3 +589,8 @@ void Bullet::AddGunBuff()
sender.Get()->context_ability = old_context_ability;
}
}
bool Bullet::IsPreBattleBullet()
{
return create_frameno_ <= room->GetBattleStartFrameNo();
}

View File

@ -41,6 +41,7 @@ class Bullet : public MoveableEntity
float GetAtk();
float GetExplosionRange();
bool IsCurrWeapon();
bool IsPreBattleBullet();
protected:
Bullet();
@ -67,6 +68,7 @@ private:
std::shared_ptr<Ability> ability_;
bool is_curr_weapon = false;
std::set<int> hit_objects_;
long long create_frameno_ = 0;
friend class EntityFactory;
};

View File

@ -291,10 +291,12 @@ void Car::OnBulletHit(Bullet* bullet)
if (bullet->meta->buff_meta) {
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
}
DecHP(finaly_dmg,
bullet->sender.Get()->GetUniId(),
bullet->sender.Get()->GetName(),
bullet->gun_meta->i->id());
if (!bullet->IsPreBattleBullet()) {
DecHP(finaly_dmg,
bullet->sender.Get()->GetUniId(),
bullet->sender.Get()->GetName(),
bullet->gun_meta->i->id());
}
if (bullet->meta->buff_meta) {
MustBeAddBuff(this, bullet->meta->i->buffid());
}

View File

@ -42,9 +42,8 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
}
if (bullet_info.delay_time <= 0) {
int bullet_uniid = 0;
if (c->room->BattleStarted() ||
(c->room->GetGasData().gas_mode == GasJump &&
!c->HasBuffEffect(kBET_Jump))) {
if (MetaMgr::Instance()->prebattle_can_use_skill ||
!(c->HasBuffEffect(kBET_Jump) || c->HasBuffEffect(kBET_Fly))) {
bullet_uniid = c->room->CreateBullet
(c,
c->shot_passenger,
@ -56,9 +55,7 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
bullet_info.fly_distance,
bullet_info.is_tank_skin);
}
if (bullet_uniid == 0) {
bullet_uniid = c->room->AllocUniid();
}
bullet_uniid = bullet_uniid ? bullet_uniid : c->room->AllocUniid();
c->room->frame_event.AddBullet
(bullet_uniid,
c->GetWeakPtrRef(),
@ -70,7 +67,7 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
} else {
BulletInfo* info_copy = new BulletInfo();
*info_copy = bullet_info;
bullet_info.c.Get()->room->xtimer.AddDeadLineTimerAndAttach
xtimer_list* timer = bullet_info.c.Get()->room->xtimer.AddDeadLineTimerAndAttach
(
bullet_info.delay_time / FRAME_RATE_MS,
a8::XParams()
@ -88,6 +85,9 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
delete info_copy;
}
);
if (!c->room->BattleStarted()) {
c->room->AddToPostBattleAutoFreeList(timer);
}
}
}

View File

@ -131,10 +131,12 @@ void Hero::OnBulletHit(Bullet* bullet)
if (bullet->meta->buff_meta) {
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
}
DecHP(finaly_dmg,
bullet->sender.Get()->GetUniId(),
bullet->sender.Get()->GetName(),
bullet->gun_meta->i->id());
if (!bullet->IsPreBattleBullet()) {
DecHP(finaly_dmg,
bullet->sender.Get()->GetUniId(),
bullet->sender.Get()->GetName(),
bullet->gun_meta->i->id());
}
}
}

View File

@ -3618,15 +3618,19 @@ void Human::OnBulletHit(Bullet* bullet)
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
}
if (bullet->sender.Get() && bullet->sender.Get()->IsCar() && bullet->passenger.Get()) {
DecHP(finaly_dmg,
bullet->passenger.Get()->GetUniId(),
bullet->passenger.Get()->GetName(),
bullet->gun_meta->i->id());
if (!bullet->IsPreBattleBullet()) {
DecHP(finaly_dmg,
bullet->passenger.Get()->GetUniId(),
bullet->passenger.Get()->GetName(),
bullet->gun_meta->i->id());
}
} else {
DecHP(finaly_dmg,
bullet->sender.Get()->GetUniId(),
bullet->sender.Get()->GetName(),
bullet->gun_meta->i->id());
if (!bullet->IsPreBattleBullet()) {
DecHP(finaly_dmg,
bullet->sender.Get()->GetUniId(),
bullet->sender.Get()->GetName(),
bullet->gun_meta->i->id());
}
}
#ifdef DEBUG
bullet->sender.Get()->SendDebugMsg

View File

@ -472,6 +472,9 @@ void Obstacle::OnBulletHit(Bullet* bullet)
if (meta->i->bullet_hit() == kBulletHitEatDmg) {
return;
}
if (bullet->IsPreBattleBullet()) {
return;
}
if (!IsDead(bullet->room) &&
!IsTerminatorAirDropBox(bullet->room)) {
if (meta->receive_special_damage_type != 0 &&

View File

@ -1399,6 +1399,7 @@ void Room::UpdateGasJump()
InitAirDrop();
InitAirRaid();
}
ClearPostBattleAutoFreeList();
}
}
@ -4000,3 +4001,33 @@ void Room::AirRaid(int airraid_id)
raid_cb,
&xtimer_attacher_.timer_list_);
}
void Room::AddToPostBattleAutoFreeList(xtimer_list* timer)
{
if (BattleStarted()) {
abort();
}
if (!timer) {
abort();
}
if (post_battle_auto_free_list_.find(timer) != post_battle_auto_free_list_.end()) {
abort();
}
auto cb =
[this] (xtimer_list* timer)
{
post_battle_auto_free_list_.erase(timer);
};
xtimer.AddTimerDestoryHandle(timer, cb);
post_battle_auto_free_list_.insert(timer);
}
void Room::ClearPostBattleAutoFreeList()
{
while (!post_battle_auto_free_list_.empty()) {
for (xtimer_list* timer : post_battle_auto_free_list_) {
xtimer.DeleteTimer(timer);
break;
}
}
}

View File

@ -188,6 +188,7 @@ public:
void GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list);
void SetInfiniteBulletMode();
bool IsInfiniteBulletMode() { return infinite_bullet_mode_; };
void AddToPostBattleAutoFreeList(xtimer_list* timer);
private:
void ShuaAndroid();
@ -269,6 +270,7 @@ private:
void InitAndroidAI();
void ForwardGasRing(int n);
void InternalRemoveObjectLater(Entity* entity, a8::XTimerAttacher& entity_xtimer_attacher);
void ClearPostBattleAutoFreeList();
#ifdef DEBUG
void InitDebugInfo();
@ -340,6 +342,8 @@ private:
std::vector<ObstacleData> obstacle_datas_;
std::set<xtimer_list*> post_battle_auto_free_list_;
xtimer_list* auto_jump_timer_ = nullptr;
Incubator* incubator_ = nullptr;

@ -1 +1 @@
Subproject commit 8932713766a5c0289966f08a5a0153a1ae493a9d
Subproject commit 5e0a939a89ba97edd371695432ef029eae2c55d5