From c1030a59cd367805dc5946527efc30557b0ba093 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 13 May 2021 11:27:57 +0800 Subject: [PATCH] 1 --- server/gameserver/room.cc | 29 +++++++++++++++++++++++++++++ server/gameserver/types.cc | 1 + 2 files changed, 30 insertions(+) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index ae30fe4..2e3f01b 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -64,6 +64,7 @@ void Room::InitData(RoomInitInfo& init_info) map_meta_ = init_info.map_meta; mini_room_spawn_points_ = init_info.mini_room_spawn_points; normal_room_spawn_points_ = init_info.normal_room_spawn_points; + room_monster_spawn_points_ = init_info.room_monster_spawn_points; level0room_born_point_meta_ = init_info.level0room_born_point_meta; level1room_born_point_meta_ = init_info.level1room_born_point_meta; loots_ = init_info.loots; @@ -2086,7 +2087,35 @@ void Room::CreateSpawnPoints() void Room::CreateMonsterSpawnPoints() { if (room_monster_spawn_points_) { + for (auto& thing_tpl : *room_monster_spawn_points_) { + for (int hero_id : thing_tpl->heros) { + MetaData::Player* hero_meta = MetaMgr::Instance()->GetPlayer(hero_id); + if (hero_meta) { + a8::Vec2 left_bottom; + left_bottom.x = thing_tpl->i->x() - thing_tpl->i->width() / 2; + left_bottom.y = thing_tpl->i->y() - thing_tpl->i->height() / 2; + a8::Vec2 hero_pos; + hero_pos.x = left_bottom.x + (rand() % (int)thing_tpl->i->width()); + hero_pos.y = left_bottom.y + (rand() % (int)thing_tpl->i->height()); + + int team_id = 666; + Creature* master = nullptr; + + a8::Vec2 dir = hero_pos; + dir.Normalize(); + + Hero* hero = CreateHero(master, + hero_meta, + hero_pos, + dir, + team_id); + if (!hero) { + abort(); + } + } + } + } } } diff --git a/server/gameserver/types.cc b/server/gameserver/types.cc index d7cb3a0..789966f 100644 --- a/server/gameserver/types.cc +++ b/server/gameserver/types.cc @@ -104,3 +104,4 @@ a8::Vec2 BornPoint::RandPoint() const } return born_point; } +