This commit is contained in:
aozhiwei 2021-05-11 13:49:45 +08:00
parent 760d6adac5
commit 503ce124ff
3 changed files with 18 additions and 7 deletions

View File

@ -91,9 +91,7 @@ void InternalShot(Creature* c,
c->aiming = false; c->aiming = false;
c->aiming_frameno = 0; c->aiming_frameno = 0;
c->power_idx = -1; c->power_idx = -1;
if (c->HasBuffEffect(kBET_ShotCharge)) { c->ClearAimingBuffs();
c->RemoveBuffByEffectId(kBET_ShotCharge);
}
} }
} }
@ -1686,3 +1684,11 @@ bool Creature::IsInvincible()
HasBuffEffect(kBET_Passenger) HasBuffEffect(kBET_Passenger)
; ;
} }
void Creature::ClearAimingBuffs()
{
for (int buff_id : aiming_buffs) {
RemoveBuffById(buff_id);
}
aiming_buffs.clear();
}

View File

@ -40,6 +40,7 @@ class Creature : public MoveableEntity
bool real_dead = false; bool real_dead = false;
int team_id = 0; int team_id = 0;
bool aiming = false; bool aiming = false;
std::list<int> aiming_buffs;
long long aiming_frameno = 0; long long aiming_frameno = 0;
a8::Vec2 attack_dir; a8::Vec2 attack_dir;
a8::Vec2 shoot_offset; a8::Vec2 shoot_offset;
@ -154,6 +155,7 @@ class Creature : public MoveableEntity
bool FreezeOperate(); bool FreezeOperate();
void SlaveOnRemove(Entity* slave); void SlaveOnRemove(Entity* slave);
bool IsInvincible(); bool IsInvincible();
void ClearAimingBuffs();
private: private:

View File

@ -1609,16 +1609,18 @@ void Player::UpdateAiming()
long long passed_time = (room->GetFrameNo() - aiming_frameno) * FRAME_RATE_MS; long long passed_time = (room->GetFrameNo() - aiming_frameno) * FRAME_RATE_MS;
if (passed_time >= std::get<0>(p_weapon->meta->power_charge[power_idx + 1])) { if (passed_time >= std::get<0>(p_weapon->meta->power_charge[power_idx + 1])) {
++power_idx; ++power_idx;
RemoveBuffByEffectId(kBET_ShotCharge); ClearAimingBuffs();
MustBeAddBuff(this, std::get<2>(p_weapon->meta->power_charge[power_idx])); int buff_id = std::get<2>(p_weapon->meta->power_charge[power_idx]);
MustBeAddBuff(this, buff_id);
aiming_buffs.push_back(buff_id);
} }
} }
} }
} else { } else {
aiming_frameno = 0; aiming_frameno = 0;
power_idx = -1; power_idx = -1;
if (HasBuffEffect(kBET_ShotCharge)) { if (!aiming_buffs.empty()) {
RemoveBuffByEffectId(kBET_ShotCharge); ClearAimingBuffs();
} }
} }
} }
@ -1652,6 +1654,7 @@ void Player::CheckShotHoldState(Weapon* weapon)
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
Human* hum = (Human*)param.sender.GetUserData(); Human* hum = (Human*)param.sender.GetUserData();
hum->RemoveBuffById(param.param1);
hum->shot_hold_timer = nullptr; hum->shot_hold_timer = nullptr;
}); });
} }