diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index c0338e6..28b4410 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -61,8 +61,14 @@ int Room::AliveCount() void Room::AddPlayer(Player* hum) { - hum->pos.x = 100 + rand() % 100; - hum->pos.y = 200 + rand() % 200; + { + hum->pos.x = 100 + rand() % 100; + hum->pos.y = 200 + rand() % 200; + hum->attack_dir = hum->pos; + hum->attack_dir.Normalize(); + float angle = ((float)rand() / RAND_MAX) * 2.0f; + hum->attack_dir.Rotate(angle); + } hum->room = this; uniid_hash_[hum->entity_uniid] = hum; moveable_hash_[hum->entity_uniid] = hum; @@ -97,8 +103,14 @@ void Room::ShuaAndroid() hum->name = a8::Format("机器人%d", {i+1}); hum->meta = hum_meta; hum->entity_uniid = AllocUniid(); - hum->pos.x = 100 + rand() % 400; - hum->pos.y = 200 + rand() % 500; + { + hum->pos.x = 100 + rand() % 400; + hum->pos.y = 200 + rand() % 500; + hum->attack_dir = hum->pos; + hum->attack_dir.Normalize(); + float angle = ((float)rand() / RAND_MAX) * 2.0f; + hum->attack_dir.Rotate(angle); + } hum->room = this; hum->Initialize(); uniid_hash_[hum->entity_uniid] = hum;