子弹战前无伤害
This commit is contained in:
parent
9759132ed6
commit
0c51f6badb
@ -33,6 +33,7 @@ void Bullet::Initialize()
|
|||||||
RecalcSelfCollider();
|
RecalcSelfCollider();
|
||||||
ability_ = sender.Get()->GetAbility();
|
ability_ = sender.Get()->GetAbility();
|
||||||
is_curr_weapon = sender.Get()->GetCurrWeapon()->meta == gun_meta;
|
is_curr_weapon = sender.Get()->GetCurrWeapon()->meta == gun_meta;
|
||||||
|
create_frameno_ = room->GetFrameNo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bullet::Update(int delta_time)
|
void Bullet::Update(int delta_time)
|
||||||
@ -588,3 +589,8 @@ void Bullet::AddGunBuff()
|
|||||||
sender.Get()->context_ability = old_context_ability;
|
sender.Get()->context_ability = old_context_ability;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Bullet::IsPreBattleBullet()
|
||||||
|
{
|
||||||
|
return create_frameno_ <= room->GetBattleStartFrameNo();
|
||||||
|
}
|
||||||
|
@ -41,6 +41,7 @@ class Bullet : public MoveableEntity
|
|||||||
float GetAtk();
|
float GetAtk();
|
||||||
float GetExplosionRange();
|
float GetExplosionRange();
|
||||||
bool IsCurrWeapon();
|
bool IsCurrWeapon();
|
||||||
|
bool IsPreBattleBullet();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Bullet();
|
Bullet();
|
||||||
@ -67,6 +68,7 @@ private:
|
|||||||
std::shared_ptr<Ability> ability_;
|
std::shared_ptr<Ability> ability_;
|
||||||
bool is_curr_weapon = false;
|
bool is_curr_weapon = false;
|
||||||
std::set<int> hit_objects_;
|
std::set<int> hit_objects_;
|
||||||
|
long long create_frameno_ = 0;
|
||||||
|
|
||||||
friend class EntityFactory;
|
friend class EntityFactory;
|
||||||
};
|
};
|
||||||
|
@ -291,10 +291,12 @@ void Car::OnBulletHit(Bullet* bullet)
|
|||||||
if (bullet->meta->buff_meta) {
|
if (bullet->meta->buff_meta) {
|
||||||
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
|
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
|
||||||
}
|
}
|
||||||
|
if (!bullet->IsPreBattleBullet()) {
|
||||||
DecHP(finaly_dmg,
|
DecHP(finaly_dmg,
|
||||||
bullet->sender.Get()->GetUniId(),
|
bullet->sender.Get()->GetUniId(),
|
||||||
bullet->sender.Get()->GetName(),
|
bullet->sender.Get()->GetName(),
|
||||||
bullet->gun_meta->i->id());
|
bullet->gun_meta->i->id());
|
||||||
|
}
|
||||||
if (bullet->meta->buff_meta) {
|
if (bullet->meta->buff_meta) {
|
||||||
MustBeAddBuff(this, bullet->meta->i->buffid());
|
MustBeAddBuff(this, bullet->meta->i->buffid());
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,8 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
|||||||
}
|
}
|
||||||
if (bullet_info.delay_time <= 0) {
|
if (bullet_info.delay_time <= 0) {
|
||||||
int bullet_uniid = 0;
|
int bullet_uniid = 0;
|
||||||
if (c->room->BattleStarted() ||
|
if (MetaMgr::Instance()->prebattle_can_use_skill ||
|
||||||
(c->room->GetGasData().gas_mode == GasJump &&
|
!(c->HasBuffEffect(kBET_Jump) || c->HasBuffEffect(kBET_Fly))) {
|
||||||
!c->HasBuffEffect(kBET_Jump))) {
|
|
||||||
bullet_uniid = c->room->CreateBullet
|
bullet_uniid = c->room->CreateBullet
|
||||||
(c,
|
(c,
|
||||||
c->shot_passenger,
|
c->shot_passenger,
|
||||||
@ -56,9 +55,7 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
|||||||
bullet_info.fly_distance,
|
bullet_info.fly_distance,
|
||||||
bullet_info.is_tank_skin);
|
bullet_info.is_tank_skin);
|
||||||
}
|
}
|
||||||
if (bullet_uniid == 0) {
|
bullet_uniid = bullet_uniid ? bullet_uniid : c->room->AllocUniid();
|
||||||
bullet_uniid = c->room->AllocUniid();
|
|
||||||
}
|
|
||||||
c->room->frame_event.AddBullet
|
c->room->frame_event.AddBullet
|
||||||
(bullet_uniid,
|
(bullet_uniid,
|
||||||
c->GetWeakPtrRef(),
|
c->GetWeakPtrRef(),
|
||||||
@ -70,7 +67,7 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
|||||||
} else {
|
} else {
|
||||||
BulletInfo* info_copy = new BulletInfo();
|
BulletInfo* info_copy = new BulletInfo();
|
||||||
*info_copy = bullet_info;
|
*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,
|
bullet_info.delay_time / FRAME_RATE_MS,
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
@ -88,6 +85,9 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
|||||||
delete info_copy;
|
delete info_copy;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if (!c->room->BattleStarted()) {
|
||||||
|
c->room->AddToPostBattleAutoFreeList(timer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,12 +131,14 @@ void Hero::OnBulletHit(Bullet* bullet)
|
|||||||
if (bullet->meta->buff_meta) {
|
if (bullet->meta->buff_meta) {
|
||||||
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
|
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
|
||||||
}
|
}
|
||||||
|
if (!bullet->IsPreBattleBullet()) {
|
||||||
DecHP(finaly_dmg,
|
DecHP(finaly_dmg,
|
||||||
bullet->sender.Get()->GetUniId(),
|
bullet->sender.Get()->GetUniId(),
|
||||||
bullet->sender.Get()->GetName(),
|
bullet->sender.Get()->GetName(),
|
||||||
bullet->gun_meta->i->id());
|
bullet->gun_meta->i->id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float Hero::GetSpeed()
|
float Hero::GetSpeed()
|
||||||
{
|
{
|
||||||
|
@ -3618,16 +3618,20 @@ void Human::OnBulletHit(Bullet* bullet)
|
|||||||
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
|
MustBeAddBuff(bullet->sender.Get(), bullet->meta->i->buffid());
|
||||||
}
|
}
|
||||||
if (bullet->sender.Get() && bullet->sender.Get()->IsCar() && bullet->passenger.Get()) {
|
if (bullet->sender.Get() && bullet->sender.Get()->IsCar() && bullet->passenger.Get()) {
|
||||||
|
if (!bullet->IsPreBattleBullet()) {
|
||||||
DecHP(finaly_dmg,
|
DecHP(finaly_dmg,
|
||||||
bullet->passenger.Get()->GetUniId(),
|
bullet->passenger.Get()->GetUniId(),
|
||||||
bullet->passenger.Get()->GetName(),
|
bullet->passenger.Get()->GetName(),
|
||||||
bullet->gun_meta->i->id());
|
bullet->gun_meta->i->id());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (!bullet->IsPreBattleBullet()) {
|
||||||
DecHP(finaly_dmg,
|
DecHP(finaly_dmg,
|
||||||
bullet->sender.Get()->GetUniId(),
|
bullet->sender.Get()->GetUniId(),
|
||||||
bullet->sender.Get()->GetName(),
|
bullet->sender.Get()->GetName(),
|
||||||
bullet->gun_meta->i->id());
|
bullet->gun_meta->i->id());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bullet->sender.Get()->SendDebugMsg
|
bullet->sender.Get()->SendDebugMsg
|
||||||
(a8::Format("bullet uniid:%d weapon_id:%d atk:%f def:%f finaly_dmg:%f old_hp:%f old_maxhp:%f cur_hp:%f",
|
(a8::Format("bullet uniid:%d weapon_id:%d atk:%f def:%f finaly_dmg:%f old_hp:%f old_maxhp:%f cur_hp:%f",
|
||||||
|
@ -472,6 +472,9 @@ void Obstacle::OnBulletHit(Bullet* bullet)
|
|||||||
if (meta->i->bullet_hit() == kBulletHitEatDmg) {
|
if (meta->i->bullet_hit() == kBulletHitEatDmg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (bullet->IsPreBattleBullet()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!IsDead(bullet->room) &&
|
if (!IsDead(bullet->room) &&
|
||||||
!IsTerminatorAirDropBox(bullet->room)) {
|
!IsTerminatorAirDropBox(bullet->room)) {
|
||||||
if (meta->receive_special_damage_type != 0 &&
|
if (meta->receive_special_damage_type != 0 &&
|
||||||
|
@ -1399,6 +1399,7 @@ void Room::UpdateGasJump()
|
|||||||
InitAirDrop();
|
InitAirDrop();
|
||||||
InitAirRaid();
|
InitAirRaid();
|
||||||
}
|
}
|
||||||
|
ClearPostBattleAutoFreeList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4000,3 +4001,33 @@ void Room::AirRaid(int airraid_id)
|
|||||||
raid_cb,
|
raid_cb,
|
||||||
&xtimer_attacher_.timer_list_);
|
&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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -188,6 +188,7 @@ public:
|
|||||||
void GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list);
|
void GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list);
|
||||||
void SetInfiniteBulletMode();
|
void SetInfiniteBulletMode();
|
||||||
bool IsInfiniteBulletMode() { return infinite_bullet_mode_; };
|
bool IsInfiniteBulletMode() { return infinite_bullet_mode_; };
|
||||||
|
void AddToPostBattleAutoFreeList(xtimer_list* timer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ShuaAndroid();
|
void ShuaAndroid();
|
||||||
@ -269,6 +270,7 @@ private:
|
|||||||
void InitAndroidAI();
|
void InitAndroidAI();
|
||||||
void ForwardGasRing(int n);
|
void ForwardGasRing(int n);
|
||||||
void InternalRemoveObjectLater(Entity* entity, a8::XTimerAttacher& entity_xtimer_attacher);
|
void InternalRemoveObjectLater(Entity* entity, a8::XTimerAttacher& entity_xtimer_attacher);
|
||||||
|
void ClearPostBattleAutoFreeList();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void InitDebugInfo();
|
void InitDebugInfo();
|
||||||
@ -340,6 +342,8 @@ private:
|
|||||||
|
|
||||||
std::vector<ObstacleData> obstacle_datas_;
|
std::vector<ObstacleData> obstacle_datas_;
|
||||||
|
|
||||||
|
std::set<xtimer_list*> post_battle_auto_free_list_;
|
||||||
|
|
||||||
xtimer_list* auto_jump_timer_ = nullptr;
|
xtimer_list* auto_jump_timer_ = nullptr;
|
||||||
|
|
||||||
Incubator* incubator_ = nullptr;
|
Incubator* incubator_ = nullptr;
|
||||||
|
2
third_party/a8engine
vendored
2
third_party/a8engine
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 8932713766a5c0289966f08a5a0153a1ae493a9d
|
Subproject commit 5e0a939a89ba97edd371695432ef029eae2c55d5
|
Loading…
x
Reference in New Issue
Block a user