From 6f42e127f1d7e41353b4f3f4e0fdab483200fe4e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 11 Mar 2021 20:02:26 +0800 Subject: [PATCH] 1 --- server/gameserver/constant.h | 3 +++ server/gameserver/framemaker.cc | 2 +- server/gameserver/human.cc | 18 ++++++++++++++---- server/gameserver/human.h | 3 +-- server/gameserver/player.cc | 2 +- server/gameserver/room.cc | 6 +++--- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index d1a3f8a..4dc88c2 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -148,6 +148,7 @@ enum BuffEffectType_e kBET_InIce = 27, //在冰里 kBET_Driver = 28, //驾驶中 kBET_Passenger = 29, //乘座 + kBET_Fly = 30, //飞行中 kBET_End }; @@ -397,3 +398,5 @@ const int TERMINATOR_BUFF_ID = 1033; const int TURN_OVER_SKILL_ID = 41001; const int HUNLUAN_BUFFID = 6001; +const int FLY_BUFFID = 7001; +const int JUMP_BUFFID = 7002; diff --git a/server/gameserver/framemaker.cc b/server/gameserver/framemaker.cc index 204ca91..483f5cb 100644 --- a/server/gameserver/framemaker.cc +++ b/server/gameserver/framemaker.cc @@ -35,7 +35,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum) if (room->GetGasData().gas_mode == GasJump && entity != hum && entity->GetEntityType() == ET_Player && - a8::HasBitFlag(((Human*)entity)->status, HS_Fly)) { + ((Human*)entity)->HasBuffEffect(kBET_Fly)) { continue; } } diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index a1c706e..6aa6d88 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -79,7 +79,8 @@ void InternalShot(Human* hum, bullet_dir, fly_distance); if (hum->room->BattleStarted() || - (hum->room->GetGasData().gas_mode == GasJump && !a8::HasBitFlag(hum->status, HS_Jump))) { + (hum->room->GetGasData().gas_mode == GasJump && + !hum->HasBuffEffect(kBET_Jump))) { hum->room->CreateBullet(hum, weapon_meta, weapon_upgrade_meta, @@ -1348,9 +1349,9 @@ bool Human::CanUseSkill() void Human::DoJump() { - if (a8::HasBitFlag(status, HS_Fly)) { - a8::UnSetBitFlag(status, HS_Fly); - a8::SetBitFlag(status, HS_Jump); + if (HasBuffEffect(kBET_Fly)) { + RemoveBuffByEffectId(kBET_Fly); + MustBeAddBuff(this, JUMP_BUFFID); jump_frameno_ = room->GetFrameNo(); SyncAroundPlayers(__FILE__, __LINE__, __func__); room->xtimer.AddDeadLineTimerAndAttach @@ -3103,6 +3104,15 @@ void Human::AddBuff(Human* caster, #endif } +void Human::MustBeAddBuff(Human* caster, int buff_id) +{ + MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(buff_id); + if (!buff_meta) { + abort(); + } + AddBuff(caster, buff_meta, 1); +} + bool Human::IsImmuneBuffEffect(int buff_effect) { for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index f80bfd6..c7925a7 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -23,8 +23,6 @@ enum HumanStatus HS_AlreadyProcNewBieLogic = 6, HS_LastAndroid = 7, HS_DisableAttack = 8, - HS_Fly = 9, - HS_Jump = 10, HS_End }; @@ -264,6 +262,7 @@ class Human : public MoveableEntity MetaData::Buff* buff_meta, int skill_lv, MetaData::Skill* buff_skill_meta = nullptr); + void MustBeAddBuff(Human* caster, int buff_id); bool IsImmuneBuffEffect(int buff_effect); void RemoveBuffById(int buff_id); void RemoveBuffByEffectId(int buff_effect_id); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index a6de82f..6d2954e 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -312,7 +312,7 @@ void Player::UpdateSpectate() { if (room->GetGasData().gas_mode == GasInactive || room->GetGasData().gas_mode == GasJump || - a8::HasBitFlag(status, HS_Fly)) { + HasBuffEffect(kBET_Fly)) { spectate = false; return; } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 1f23dc5..9cb96de 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1078,7 +1078,7 @@ void Room::UpdateGasInactive() .SetSender(room), [] (Human* hum, a8::XParams& param) -> bool { - if (a8::HasBitFlag(hum->status, HS_Fly) && + if (hum->HasBuffEffect(kBET_Fly) && hum->GetEntitySubType() != EST_Player) { hum->DoJump(); return false; @@ -1174,7 +1174,7 @@ void Room::UpdateGasJump() a8::XParams(), [] (Human* hum, a8::XParams& param) -> bool { - if (a8::HasBitFlag(hum->status, HS_Fly)) { + if (hum->HasBuffEffect(kBET_Fly)) { hum->DoJump(); } if (hum->GetEntitySubType() == EST_Player) { @@ -1601,7 +1601,7 @@ void Room::ShuaPlane() last_player_jump_pos_ = plane.curr_pos; for (auto& pair : human_hash_) { - a8::SetBitFlag(pair.second->status, HS_Fly); + pair.second->MustBeAddBuff(pair.second, FLY_BUFFID); pair.second->SetPos(plane.curr_pos); pair.second->attack_dir = plane.dir; pair.second->move_dir = plane.dir;