This commit is contained in:
aozhiwei 2024-04-01 20:22:22 +08:00
parent 0194e0b3c3
commit 8a2d13568e
2 changed files with 28 additions and 23 deletions

View File

@ -617,7 +617,7 @@ void Room::FillSMJoinedNotify(Human* self_hum, cs::SMJoinedNotify& msg)
msg.set_is_newbie_room(0); 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<int>* items)
{ {
const mt::Drop* drop_meta = mt::Drop::GetById(drop_id); const mt::Drop* drop_meta = mt::Drop::GetById(drop_id);
if (drop_meta) { 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 glm::vec3 pos = center;
const mt::Equip* equip_meta = mt::Equip::GetById(std::get<0>(item)); const mt::Equip* equip_meta = mt::Equip::GetById(std::get<0>(item));
if (equip_meta) { if (equip_meta) {
#if 1
DropItemEx(center, DropItemEx(center,
pos, pos,
std::get<0>(item), std::get<0>(item),
std::get<1>(item), std::get<1>(item),
std::get<2>(item), std::get<2>(item),
true, true,
no_adjust); no_adjust,
#else items);
DropItemEx(center + dir * (5.0f + rand() % 50),
pos,
std::get<0>(item),
std::get<1>(item),
std::get<2>(item),
true,
no_adjust);
#endif
} }
} }
} }
} }
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<int>* 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<int>* items)
{ {
const mt::Equip* equip_meta = mt::Equip::GetById(item_id); const mt::Equip* equip_meta = mt::Equip::GetById(item_id);
if (!equip_meta) { 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; glm::vec3 dir = GlmHelper::UP;
GlmHelper::RotateY(dir, a8::RandAngle()); GlmHelper::RotateY(dir, a8::RandAngle());
CreateLootEx(item_id, int obj_uniid = CreateLootEx(item_id,
born_pos, born_pos,
pos + dir * (25.0f + rand() % 50), pos + dir * (25.0f + rand() % 50),
drop_num, drop_num,
item_lv, item_lv,
show_anim, show_anim,
no_adjust); no_adjust);
if (obj_uniid && items) {
items->push_back(obj_uniid);
}
total_count -= drop_num; total_count -= drop_num;
} }
} }
@ -708,12 +705,14 @@ RoomObstacle* Room::CreateObstacle(int id, float x, float y, float z,
return entity; 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); 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; glm::vec3 real_pos = pos;
if (!no_adjust) { if (!no_adjust) {

View File

@ -156,12 +156,18 @@ public:
void TraverseAlivePlayers(std::function<bool (Human*)> func); void TraverseAlivePlayers(std::function<bool (Human*)> func);
void BroadcastDebugMsg(const std::string& debug_msg); void BroadcastDebugMsg(const std::string& debug_msg);
void ScatterDrop(const glm::vec3& center, int drop_id, bool no_adjust = false); 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); std::vector<int>* 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); void DropItem(const glm::vec3& pos, int item_id, int item_count, int item_lv, bool no_adjust =false,
std::vector<int>* 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<int>* 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 CreateLoot(int equip_id, const glm::vec3& born_pos, const glm::vec3& pos,
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 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, int CreateBullet(Creature* sender,
Creature* passenger, Creature* passenger,
const mt::Equip* weapon_meta, const mt::Equip* weapon_meta,