This commit is contained in:
aozhiwei 2023-11-14 15:47:53 +08:00
parent b2188464fd
commit 263c14ba32
6 changed files with 53 additions and 27 deletions

View File

@ -107,15 +107,7 @@ void Android::Update(int delta_time)
}
#endif
InternalUpdate(delta_time);
if (shot_hold) {
if (!HasBuffEffect(kBET_HoldGun)) {
TryAddBuffAndSetTime(this, kHoldGunBuffId, 10 * 1000);
}
} else {
if (HasBuffEffect(kBET_HoldGun)) {
RemoveBuffByEffectId(kBET_HoldGun);
}
}
CheckShotHold();
++updated_times_;
}

View File

@ -3754,3 +3754,26 @@ void Creature::SetSkillLocalVar(int skill_id, int idx, float val)
itr->second[idx] = val;
}
}
void Creature::CheckShotHold()
{
if (shot_hold) {
if (!remove_shot_hold_timer.expired()) {
room->xtimer.Delete(remove_shot_hold_timer);
}
Buff* buff = GetBuffByEffectId(kBET_HoldGun);
if (buff) {
if (buff->GetLeftTime() < 500) {
room->xtimer.ModifyTime(buff->remover_timer, 10 * 1000);
}
} else {
TryAddBuffAndSetTime(this, kHoldGunBuffId, 10 * 1000);
}
} else {
if (HasBuffEffect(kBET_HoldGun)) {
if (remove_shot_hold_timer.expired()) {
} else {
}
}
}
}

View File

@ -128,6 +128,7 @@ class Creature : public MoveableEntity
std::vector<int> gemstone_hold_buffs;
bool shot_start = false;
bool shot_hold = false;
a8::XTimerWp remove_shot_hold_timer;
a8::XTimerWp craze_mode_timer;
a8::XTimerWp nature_recover_hp_idle_timer;
@ -392,6 +393,7 @@ class Creature : public MoveableEntity
void ClearSkillLocalVars(int skill_id);
float GetSkillLocalVar(int skill_id, int idx);
void SetSkillLocalVar(int skill_id, int idx, float val);
void CheckShotHold();
protected:
virtual void OnBuffRemove(Buff& buff);

View File

@ -123,6 +123,7 @@ void Hero::Update(int delta_time)
if (playing_skill) {
UpdateSkill();
}
CheckShotHold();
if (room->IsNewBieRoom()) {
} else {

View File

@ -143,15 +143,7 @@ void Player::Update(int delta_time)
}
}
InternalUpdate(delta_time);
if (shot_hold) {
if (!HasBuffEffect(kBET_HoldGun)) {
TryAddBuffAndSetTime(this, kHoldGunBuffId, 10 * 1000);
}
} else {
if (HasBuffEffect(kBET_HoldGun)) {
RemoveBuffByEffectId(kBET_HoldGun);
}
}
CheckShotHold();
++updated_times_;
}
@ -342,7 +334,7 @@ void Player::UpdateShot()
HasBuffEffect(kBET_Jump) ||
HasBuffEffect(kBET_Fly)) {
shot_start = false;
shot_hold = false;
SetShotHold(false);
series_shot_frames = 0;
return;
}
@ -352,19 +344,19 @@ void Player::UpdateShot()
HasBuffEffect(kBET_MachineGun)
)) {
shot_start = false;
shot_hold = false;
SetShotHold(false);
series_shot_frames = 0;
return;
}
if (HasBuffEffect(kBET_HoldShield)) {
shot_start = false;
shot_hold = false;
SetShotHold(false);
series_shot_frames = 0;
return;
}
if (HasBuffEffect(kBET_Sprint)) {
shot_start = false;
shot_hold = false;
SetShotHold(false);
series_shot_frames = 0;
return;
}
@ -374,7 +366,7 @@ void Player::UpdateShot()
}
if (!p_weapon->meta->_power_charge.empty() && power_idx < 1) {
shot_start = false;
shot_hold = false;
SetShotHold(false);
series_shot_frames = 0;
return;
}
@ -402,7 +394,7 @@ void Player::UpdateShot()
if (shot_hold) {
++series_shot_frames;
if (room->GetFrameNo() - last_cmmove_frameno >= 4) {
shot_hold = false;
SetShotHold(false);
series_shot_frames = 0;
}
}
@ -424,7 +416,7 @@ void Player::UpdateShot()
Shot();
}
if (room->GetFrameNo() - last_cmmove_frameno >= 4) {
shot_hold = false;
SetShotHold(false);
series_shot_frames = 0;
}
}
@ -929,6 +921,13 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
{
});
}
#endif
#ifdef DEBUG1
a8::XPrintf("CMMove.Shot shot_sart%d shot_hold:%d\n",
{
msg.shot_start(),
msg.shot_hold()
});
#endif
long long pre_frameno = last_cmmove_frameno_;
last_cmmove_frameno_ = room->GetFrameNo();
@ -1060,7 +1059,7 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
} else {
if (!HasBuffEffect(kBET_AutoShot)) {
shot_start = msg.shot_start();
shot_hold = msg.shot_hold();
SetShotHold(msg.shot_hold());
}
}
fly_distance = std::min(500.0f, msg.fly_distance());
@ -1216,7 +1215,7 @@ void Player::_CMImmediateMsg(f8::MsgHdr& hdr, const cs::CMImmediateMsg& msg)
}
if (msg.stop_shot()) {
shot_start = false;
shot_hold = false;
SetShotHold(false);
series_shot_frames = 0;
}
}
@ -1835,3 +1834,11 @@ void Player::_CMGetSettlementTeamList(f8::MsgHdr& hdr, const cs::CMGetSettlement
}
SendNotifyMsg(rspmsg);
}
void Player::SetShotHold(bool hold)
{
if (!hold && shot_hold) {
int i = 0;
}
shot_hold = hold;
}

View File

@ -149,6 +149,7 @@ private:
std::vector<std::tuple<int, int, int>>* GetBox(int box_id);
void CheckShotHoldState(Weapon* weapon);
void InternalRevive(int target_uniid, int revive_coin);
void SetShotHold(bool hold);
private:
long long last_cmmove_frameno_ = 0;