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_frameno = 0;
c->power_idx = -1;
if (c->HasBuffEffect(kBET_ShotCharge)) {
c->RemoveBuffByEffectId(kBET_ShotCharge);
}
c->ClearAimingBuffs();
}
}
@ -1686,3 +1684,11 @@ bool Creature::IsInvincible()
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;
int team_id = 0;
bool aiming = false;
std::list<int> aiming_buffs;
long long aiming_frameno = 0;
a8::Vec2 attack_dir;
a8::Vec2 shoot_offset;
@ -154,6 +155,7 @@ class Creature : public MoveableEntity
bool FreezeOperate();
void SlaveOnRemove(Entity* slave);
bool IsInvincible();
void ClearAimingBuffs();
private:

View File

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