diff --git a/server/gameserver/aicomponent.cc b/server/gameserver/aicomponent.cc index 4c1d816..809f222 100644 --- a/server/gameserver/aicomponent.cc +++ b/server/gameserver/aicomponent.cc @@ -24,6 +24,7 @@ void AIComponent::SetAiMode(int ai_mode) int AIComponent::GetAiLevel() { + return 1; return ai_level_; } diff --git a/server/gameserver/android.ai.cc b/server/gameserver/android.ai.cc index ce6a220..66b9e93 100644 --- a/server/gameserver/android.ai.cc +++ b/server/gameserver/android.ai.cc @@ -475,15 +475,11 @@ void AndroidNewAI::UpdateThinking() hum->room->IsWaitingStart() || hum->HasBuffEffect(kBET_Jump) || a8::HasBitFlag(hum->status, HS_DisableAttack)) { - #if 1 if (hum->room->IsWaitingStart()) { ChangeToStateNewAI(ASE_Idle); } else { ChangeToStateNewAI(ASE_RandomWalk); } - #else - ChangeToStateNewAI(ASE_RandomWalk); - #endif } else { Human* target = GetTarget(); if (target) { diff --git a/server/gameserver/android.cc b/server/gameserver/android.cc index 5cbc42f..6e4a157 100644 --- a/server/gameserver/android.cc +++ b/server/gameserver/android.cc @@ -60,6 +60,11 @@ void Android::InternalUpdate(int delta_time) if (action_type != AT_None) { UpdateAction(); } + if (HasBuffEffect(kBET_Fly)) { + SetPos(room->plane.curr_pos); + room->grid_service->MoveHuman(this); + return; + } ai->Update(delta_time); } diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 7d1841d..44142f9 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -141,13 +141,15 @@ enum BuffEffectType_e kBET_CliEffect3 = 21, //僵尸被动光环地震(客户端表现用) kBET_CliEffect4 = 22, //被拖拽(客户端表现用) kBET_HunLuan = 23, //混乱,在烟雾弹中不自动瞄准 - kBET_Jump = 24, //跳伞中 - kBET_ThroughWall = 25, //穿墙 - kBET_InGrass = 26, //在草丛 - kBET_InWater = 27, //在水里 - kBET_InIce = 27, //在冰里 - kBET_Driver = 28, //驾驶中 - kBET_Passenger = 29, //乘座 + kBET_Fly = 24, //飞行中 + kBET_Jump = 25, //跳伞中 + kBET_InGrass = 27, //在草丛 + kBET_InWater = 28, //在水里 + kBET_InIce = 29, //在冰里 + kBET_Driver = 30, //驾驶中 + kBET_Passenger = 31, //乘座 + + kBET_ThroughWall = 50, //穿墙 kBET_End }; @@ -400,5 +402,8 @@ const int TURN_OVER_SKILL_ID = 41001; const int HUNLUAN_BUFFID = 6001; -const int DRIVER_BUFFID = 6003; -const int PASSENGER_BUFFID = 6004; +const int kThroughWall_BUFFID = 6003; +const int FLY_BUFFID = 7001; +const int JUMP_BUFFID = 7002; +const int DRIVER_BUFFID = 7003; +const int PASSENGER_BUFFID = 7004; diff --git a/server/gameserver/framemaker.cc b/server/gameserver/framemaker.cc index d409dd4..f6a05eb 100644 --- a/server/gameserver/framemaker.cc +++ b/server/gameserver/framemaker.cc @@ -36,7 +36,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 740a4f5..471a985 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -82,7 +82,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, @@ -1318,21 +1319,25 @@ 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, kThroughWall_BUFFID); + MustBeAddBuff(this, JUMP_BUFFID); jump_frameno_ = room->GetFrameNo(); SyncAroundPlayers(__FILE__, __LINE__, __func__); - room->xtimer.AddDeadLineTimerAndAttach - (MetaMgr::Instance()->jump_time * SERVER_FRAME_RATE, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Human* hum = (Human*)param.sender.GetUserData(); - hum->OnLand(); - }, - &xtimer_attacher.timer_list_); + MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(JUMP_BUFFID); + if (buff_meta) { + room->xtimer.AddDeadLineTimerAndAttach + (buff_meta->i->duration_time() * SERVER_FRAME_RATE, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Human* hum = (Human*)param.sender.GetUserData(); + hum->OnLand(); + }, + &xtimer_attacher.timer_list_); + } } } @@ -1700,18 +1705,36 @@ void Human::RemoveObserver(Human* observer) void Human::SendUpdateMsg() { if (!follow_target_ && !a8::HasBitFlag(status, HS_Disable) && IsPlayer()) { + #ifdef DEBUG + long long begin_tick = a8::XGetTickCount(); + long long end_tick = a8::XGetTickCount(); + #endif cs::MFActivePlayerData* active_player_data_pb = nullptr; if (send_msg_times == 0 || need_sync_active_player) { active_player_data_pb = new cs::MFActivePlayerData(); FillMFActivePlayerData(active_player_data_pb); need_sync_active_player = false; } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); + #endif cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this); if (send_msg_times == 0 || last_sync_gas_frameno < room->GetGasData().gas_start_frameno) { last_sync_gas_frameno = room->GetGasData().gas_start_frameno; FillMFGasData(msg->mutable_gas_data()); } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); + #endif NotifyObservers(msg, active_player_data_pb); delete msg; @@ -2201,7 +2224,7 @@ void Human::ClearFrameData() Human* hum = (Human*)entity; hum->RemovePartObjects(this); } -#ifdef DEBUG +#ifdef DEBUG1 room->CheckPartObjects(); #endif } @@ -2220,7 +2243,7 @@ void Human::ClearFrameData() hum->RemovePartObjects(this); } } -#ifdef DEBUG +#ifdef DEBUG1 room->CheckPartObjects(); #endif } @@ -3044,6 +3067,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) { @@ -4211,6 +4243,7 @@ void Human::OnBuffRemove(const Buff& buff) void Human::OnLand() { //着陆 + RemoveBuffByEffectId(kBET_Jump); RemoveBuffByEffectId(kBET_ThroughWall); if (IsCollisionInMapService()) { a8::Vec2 old_pos = GetPos(); diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 91428f7..2e6140c 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 }; @@ -266,6 +264,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/metamgr.cc b/server/gameserver/metamgr.cc index 37f55ce..55bf459 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -180,7 +180,6 @@ public: } } - MetaMgr::Instance()->jump_time = MetaMgr::Instance()->GetSysParamAsFloat("jump_time"); MetaMgr::Instance()->K = MetaMgr::Instance()->GetSysParamAsFloat("K"); MetaMgr::Instance()->kill_param = MetaMgr::Instance()->GetSysParamAsFloat("kill_parameter"); MetaMgr::Instance()->rank_param = MetaMgr::Instance()->GetSysParamAsFloat("rank_parameter"); diff --git a/server/gameserver/metamgr.h b/server/gameserver/metamgr.h index e3ffdb0..05e307a 100755 --- a/server/gameserver/metamgr.h +++ b/server/gameserver/metamgr.h @@ -61,7 +61,6 @@ class MetaMgr : public a8::Singleton int zbmode_game_duration = 60 * 2; int zbmode_player_num = 15; int zbmode_init_zombie_num = 2; - int jump_time = 10; float K = 100.0f; float kill_param = 0.0f; float rank_param = 0.0f; diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index dfe1fc7..3ed566d 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -56,6 +56,10 @@ void Player::InternalUpdate(int delta_time) if (poisoning) { poisoning_time += delta_time; } + if (HasBuffEffect(kBET_Fly)) { + SetPos(room->plane.curr_pos); + room->grid_service->MoveHuman(this); + } if (HasSpecMove()) { _UpdateSpecMove(); } else { @@ -97,6 +101,9 @@ void Player::InternalUpdate(int delta_time) if (emote) { UpdateEmote(); } + if (jump) { + UpdateJump(); + } if (get_down) { UpdateGetDown(); } @@ -311,7 +318,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; } @@ -326,6 +333,41 @@ void Player::UpdateEmote() emote_id = 0; } +void Player::UpdateJump() +{ + if (HasBuffEffect(kBET_Fly)) { + DoJump(); + if (GetPos().Distance(room->last_player_jump_pos) > 64 * 4) { + size_t num = 2 + rand() % 2; + for (size_t i = 0; i < num; ++i){ + room->xtimer.AddDeadLineTimerAndAttach + (SERVER_FRAME_RATE / 10, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Human* hum = (Human*)param.sender.GetUserData(); + hum->room->TouchHumanList + ( + a8::XParams() + .SetSender(hum), + [] (Human* hum, a8::XParams& param) -> bool + { + if (hum->HasBuffEffect(kBET_Fly) && hum->IsAndroid()) { + hum->DoJump(); + return false; + } + return true; + }); + }, + &xtimer_attacher.timer_list_); + } + } + room->last_player_jump_pos = GetPos(); + } + jump = false; +} + void Player::UpdateGetDown() { DoGetDown(); diff --git a/server/gameserver/player.h b/server/gameserver/player.h index 4d86f00..00b7ec0 100644 --- a/server/gameserver/player.h +++ b/server/gameserver/player.h @@ -55,6 +55,8 @@ class Player : public Human bool emote = false; int emote_id = 0; + bool jump = false; + bool use_skill = false; bool get_down = false; @@ -75,6 +77,7 @@ class Player : public Human void UpdateUseItemId(); void UpdateSpectate(); void UpdateEmote(); + void UpdateJump(); void UpdateGetDown(); void UpdateUseSkill(); void Shot(); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 5ea3997..eb9b5e8 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -127,15 +127,39 @@ void Room::Update(int delta_time) elapsed_time_ += delta_time; while (elapsed_time_ >= 50) { + #ifdef DEBUG + long long begin_tick = a8::XGetTickCount(); + long long end_tick = a8::XGetTickCount(); + #endif if (GetFrameNo() % 2 == 0) { UpdateGas(); } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); + #endif for (auto& pair : moveable_hash_) { pair.second->Update(50); } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); + #endif if (GetFrameNo() % 2 == 0) { SyncFrameData(); } + #ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + #endif ++frameno_; elapsed_time_ -= 50; } @@ -1072,6 +1096,7 @@ void Room::UpdateGas() void Room::UpdateGasInactive() { if (GetFrameNo() - gas_data_.gas_start_frameno >= GetGasInactiveTime() * SERVER_FRAME_RATE) { + long long begin_tick = a8::XGetTickCount(); gas_data_.gas_mode = GasJump; gas_data_.gas_start_frameno = GetFrameNo(); if (human_hash_.size() < GetRoomMaxPlayerNum()) { @@ -1094,7 +1119,7 @@ void Room::UpdateGasInactive() int auto_jump_min_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_min_num"); int auto_jump_max_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_max_num"); int jump_num = a8::RandEx(auto_jump_min_num, auto_jump_max_num); - if (room->last_player_jump_pos_.Distance(room->plane.curr_pos) < 64 * 8) { + if (room->last_player_jump_pos.Distance(room->plane.curr_pos) < 64 * 8) { jump_num = 1 + rand() % 2; } for (int i = 0; i < jump_num; ++i) { @@ -1104,7 +1129,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; @@ -1114,6 +1139,10 @@ void Room::UpdateGasInactive() } }, &xtimer_attacher_.timer_list_); + #if 1 + a8::XPrintf("max_run_delay:%d %d\n", {PerfMonitor::Instance()->max_run_delay_time, + a8::XGetTickCount() - begin_tick}); + #endif } } @@ -1200,7 +1229,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) { @@ -1624,10 +1653,10 @@ void Room::ShuaPlane() plane.dir = plane.end_point - plane.start_point; plane.dir.Normalize(); plane.curr_pos = plane.start_point; - last_player_jump_pos_ = plane.curr_pos; + 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; @@ -2135,6 +2164,7 @@ void Room::NotifyGameStart() } }, &xtimer_attacher_.timer_list_); +#if 0 xtimer.AddDeadLineTimerAndAttach (SERVER_FRAME_RATE * 1, a8::XParams() @@ -2146,7 +2176,7 @@ void Room::NotifyGameStart() room->SecondRandPoint(); }, &xtimer_attacher_.timer_list_); - +#endif if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) { NewBieRoomStart(); } @@ -3235,9 +3265,27 @@ bool Room::CanAddToScene(Human* hum) void Room::SyncFrameData() { +#ifdef DEBUG + long long begin_tick = a8::XGetTickCount(); + long long end_tick = a8::XGetTickCount(); +#endif for (auto& pair : human_hash_) { pair.second->SendUpdateMsg(); +#ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 100) { + abort(); + } + begin_tick = a8::XGetTickCount(); +#endif } +#ifdef DEBUG + end_tick = a8::XGetTickCount(); + if (a8::XGetTickCount() - begin_tick > 1000) { + abort(); + } + begin_tick = a8::XGetTickCount(); +#endif frame_event.Clear(); } diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 8e67b28..7a1a8d9 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -46,6 +46,7 @@ public: MapService* map_service = nullptr; bool debug_trace = false; bool added_to_over_room = false; + a8::Vec2 last_player_jump_pos; ~Room(); void InitData(RoomInitInfo& init_info); @@ -306,5 +307,4 @@ private: std::vector obstacle_datas_; xtimer_list* auto_jump_timer_ = nullptr; - a8::Vec2 last_player_jump_pos_; };