From 8a2d13568ef9242a3ea06fc1e917c07f4bae7560 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 1 Apr 2024 20:22:22 +0800 Subject: [PATCH] 1 --- server/gameserver/room.cc | 35 +++++++++++++++++------------------ server/gameserver/room.h | 16 +++++++++++----- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 1efc166a..e9c0ea58 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -617,7 +617,7 @@ void Room::FillSMJoinedNotify(Human* self_hum, cs::SMJoinedNotify& msg) msg.set_is_newbie_room(0); } -void Room::ScatterDrop(const glm::vec3& center, int drop_id, bool no_adjust) +void Room::ScatterDrop(const glm::vec3& center, int drop_id, bool no_adjust, std::vector* items) { const mt::Drop* drop_meta = mt::Drop::GetById(drop_id); if (drop_meta) { @@ -629,34 +629,28 @@ void Room::ScatterDrop(const glm::vec3& center, int drop_id, bool no_adjust) const glm::vec3 pos = center; const mt::Equip* equip_meta = mt::Equip::GetById(std::get<0>(item)); if (equip_meta) { - #if 1 DropItemEx(center, pos, std::get<0>(item), std::get<1>(item), std::get<2>(item), true, - no_adjust); - #else - DropItemEx(center + dir * (5.0f + rand() % 50), - pos, - std::get<0>(item), - std::get<1>(item), - std::get<2>(item), - true, - no_adjust); - #endif + no_adjust, + items); } } } } -void Room::DropItem(const glm::vec3& pos, int item_id, int item_count, int item_lv, bool no_adjust) +void Room::DropItem(const glm::vec3& pos, int item_id, int item_count, int item_lv, bool no_adjust, + std::vector* items) { - DropItemEx(pos, pos, item_id, item_count, item_lv, false, no_adjust); + DropItemEx(pos, pos, item_id, item_count, item_lv, false, no_adjust, items); } -void Room::DropItemEx(const glm::vec3& born_pos, const glm::vec3& pos, int item_id, int item_count, int item_lv, bool show_anim, bool no_adjust) +void Room::DropItemEx(const glm::vec3& born_pos, const glm::vec3& pos, + int item_id, int item_count, int item_lv, bool show_anim, bool no_adjust, + std::vector* items) { const mt::Equip* equip_meta = mt::Equip::GetById(item_id); if (!equip_meta) { @@ -681,13 +675,16 @@ void Room::DropItemEx(const glm::vec3& born_pos, const glm::vec3& pos, int item_ } glm::vec3 dir = GlmHelper::UP; GlmHelper::RotateY(dir, a8::RandAngle()); - CreateLootEx(item_id, + int obj_uniid = CreateLootEx(item_id, born_pos, pos + dir * (25.0f + rand() % 50), drop_num, item_lv, show_anim, no_adjust); + if (obj_uniid && items) { + items->push_back(obj_uniid); + } total_count -= drop_num; } } @@ -708,12 +705,14 @@ RoomObstacle* Room::CreateObstacle(int id, float x, float y, float z, return entity; } -int Room::CreateLoot(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos, int count, int equip_lv, bool no_adjust) +int Room::CreateLoot(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos, int count, + int equip_lv, bool no_adjust) { return CreateLootEx(equip_id, born_pos, pos, count, equip_lv, false, no_adjust); } -int Room::CreateLootEx(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos, int count, int equip_lv, bool show_anim, bool no_adjust) +int Room::CreateLootEx(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos, int count, + int equip_lv, bool show_anim, bool no_adjust) { glm::vec3 real_pos = pos; if (!no_adjust) { diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 951456aa..a4e42b71 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -156,12 +156,18 @@ public: void TraverseAlivePlayers(std::function func); void BroadcastDebugMsg(const std::string& debug_msg); - void ScatterDrop(const glm::vec3& center, int drop_id, bool no_adjust = false); - void DropItem(const glm::vec3& pos, int item_id, int item_count, int item_lv, bool no_adjust =false); - void DropItemEx(const glm::vec3& born_pos, const glm::vec3& pos, int item_id, int item_count, int item_lv, bool show_anim, bool no_adjust = false); + void ScatterDrop(const glm::vec3& center, int drop_id, bool no_adjust = false, + std::vector* items = nullptr); + void DropItem(const glm::vec3& pos, int item_id, int item_count, int item_lv, bool no_adjust =false, + std::vector* items = nullptr); + void DropItemEx(const glm::vec3& born_pos, const glm::vec3& pos, int item_id, + int item_count, int item_lv, bool show_anim, bool no_adjust = false, + std::vector* items = nullptr); - int CreateLoot(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos, int count, int equip_lv, bool no_adjust = false); - int CreateLootEx(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos, int count, int equip_lv, bool show_anim, bool no_adjust = false); + int CreateLoot(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos, + int count, int equip_lv, bool no_adjust = false); + int CreateLootEx(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos, + int count, int equip_lv, bool show_anim, bool no_adjust = false); int CreateBullet(Creature* sender, Creature* passenger, const mt::Equip* weapon_meta,