diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index c42c4499..1f210a60 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -5,6 +5,8 @@ #include "hero.h" #include "obstacle.h" +#include "mt/MapMode.h" + const int BOX_ID = 150001; BoxDrop::BoxDrop(Room* room):room_(room) @@ -14,7 +16,18 @@ BoxDrop::BoxDrop(Room* room):room_(room) void BoxDrop::Init() { - + if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { + get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx + (SERVER_FRAME_RATE * 10, + [this] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { + } + } + }, + &room_->xtimer_attacher_); + } } void BoxDrop::UnInit() @@ -24,12 +37,16 @@ void BoxDrop::UnInit() void BoxDrop::OnHeroDeadDrop(Hero* hero) { - Drop(1, hero->GetPos().ToGlmVec3()); + if (box_num_ > 0) { + Drop(1, hero->GetPos().ToGlmVec3()); + } } void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) { - Drop(1, ob->GetPos().ToGlmVec3()); + if (box_num_ > 0) { + Drop(1, ob->GetPos().ToGlmVec3()); + } } void BoxDrop::Drop(int num, const glm::vec3& center) @@ -39,3 +56,8 @@ void BoxDrop::Drop(int num, const glm::vec3& center) room_->CreateObstacle(BOX_ID, center.x, center.y, center.z); } } + +void BoxDrop::OnBattleStart() +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index b0d4b105..6a3b90e3 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -11,6 +11,7 @@ class BoxDrop : public std::enable_shared_from_this BoxDrop(Room* room); void Init(); void UnInit(); + void OnBattleStart(); void OnHeroDeadDrop(Hero* hero); void OnObstacleDeadDrop(Obstacle* ob); @@ -20,4 +21,6 @@ class BoxDrop : public std::enable_shared_from_this private: Room* room_ = nullptr; + a8::XTimerWp get_box_num_timer_; + int box_num_ = 0; }; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index d8498a37..4a06f5db 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -3216,6 +3216,7 @@ void Room::OnBattleStart() } battle_starting_ = false; SendSMTeamFull(nullptr); + GetBoxDrop()->OnBattleStart(); } bool Room::CanAddObstacle(const glm::vec3& pos, int obstacle_id)