This commit is contained in:
aozhiwei 2021-05-10 20:03:30 +08:00
parent f1072cc7d1
commit c4ec0b0a4e
3 changed files with 38 additions and 0 deletions

View File

@ -114,6 +114,7 @@ class Human : public Creature
bool shot_start = false; bool shot_start = false;
bool shot_hold = false; bool shot_hold = false;
xtimer_list* shot_hold_timer = nullptr;
int series_shot_frames = 0; int series_shot_frames = 0;
float fly_distance = 0.0f; float fly_distance = 0.0f;

View File

@ -212,6 +212,7 @@ void Player::UpdateShot()
} }
if (shot_hold) { if (shot_hold) {
++series_shot_frames; ++series_shot_frames;
CheckShotHoldState(p_weapon);
if (last_shot_frameno_ == 0 || if (last_shot_frameno_ == 0 ||
( (
(room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE)) >= (room->GetFrameNo() - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE)) >=
@ -1621,3 +1622,38 @@ void Player::UpdateAiming()
} }
} }
} }
void Player::CheckShotHoldState(Weapon* weapon)
{
if (weapon->meta->buff_meta && weapon->meta->buff_meta->i->trigger_type() == kBTT_SeriesShot) {
if (shot_hold_timer) {
if (weapon->meta->buff_meta->i->buff_id() !=
room->xtimer.MutableParams(shot_hold_timer)->param1.GetInt()) {
room->xtimer.DeleteTimer(shot_hold_timer);
}
}
//second
if (!shot_hold_timer) {
MustBeAddBuff(this, weapon->meta->buff_meta->i->buff_id());
shot_hold_timer = room->xtimer.AddRepeatTimerAndAttach
(
1,
a8::XParams()
.SetSender(this)
.SetParam1(weapon->meta->buff_meta->i->buff_id()),
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
if (hum->dead || !hum->shot_hold) {
hum->room->xtimer.DeleteTimer(hum->shot_hold_timer);
}
},
&xtimer_attacher.timer_list_,
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->shot_hold_timer = nullptr;
});
}
}
}

View File

@ -125,6 +125,7 @@ private:
void InternalAdOk(); void InternalAdOk();
void InternalUpdate(int delta_time); void InternalUpdate(int delta_time);
std::vector<std::tuple<int, int, int>>* GetBox(int box_id); std::vector<std::tuple<int, int, int>>* GetBox(int box_id);
void CheckShotHoldState(Weapon* weapon);
private: private:
std::map<int, std::vector<std::tuple<int, int, int>>> box_hash_; std::map<int, std::vector<std::tuple<int, int, int>>> box_hash_;