diff --git a/game/modules/planets/test_planet/biomes/simple_biome.gd b/game/modules/planets/test_planet/biomes/simple_biome.gd index 824ae78f..3bb5f5b9 100644 --- a/game/modules/planets/test_planet/biomes/simple_biome.gd +++ b/game/modules/planets/test_planet/biomes/simple_biome.gd @@ -155,5 +155,13 @@ func spawn_dungeon(chunk: TerraChunk) -> void: var dt : Spatial = dungeon_teleporter.instance() chunk.voxel_world.add_child(dt) dt.owner_chunk = chunk + + var level : int = 2 + + if chunk.get_voxel_world().has_method("get_mob_level"): + level = chunk.get_voxel_world().get_mob_level() + + dt.min_level = level - 1 + dt.max_level = level + 1 dt.transform = Transform(Basis().scaled(Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale)), Vector3(x, vwh, z)) diff --git a/game/modules/planets/test_planet/dungeons/dung_teleporter.gd b/game/modules/planets/test_planet/dungeons/dung_teleporter.gd index f5013b5a..12cefd90 100644 --- a/game/modules/planets/test_planet/dungeons/dung_teleporter.gd +++ b/game/modules/planets/test_planet/dungeons/dung_teleporter.gd @@ -7,6 +7,9 @@ export(float) var use_range : float = 5 export(PackedScene) var dungeon : PackedScene export(PackedScene) var dungeon_back_teleporter : PackedScene +var min_level : int = 1 +var max_level : int = 2 + var owner_chunk : TerraChunk = null var _dungeon : Spatial = null var _dungeon_back_teleporter : Spatial = null @@ -69,6 +72,8 @@ func teleport(): var t : Transform = global_transform t = t.translated(Vector3(0, -500, 0)) _dungeon.transform = t + _dungeon.min_level = min_level + _dungeon.max_level = max_level get_parent().add_child(_dungeon) teleport_to = t.xform(Vector3()) diff --git a/game/scripts/dungeons/dungeon.gd b/game/scripts/dungeons/dungeon.gd index 17c20f3e..1f296b88 100644 --- a/game/scripts/dungeons/dungeon.gd +++ b/game/scripts/dungeons/dungeon.gd @@ -6,6 +6,11 @@ export(PropData) var start_room : PropData export(Array, PropData) var rooms : Array export(PropData) var plug : PropData export(bool) var generate : bool setget set_generate, get_generate +export(bool) var spawn_mobs : bool = true + +export(int) var min_level : int = 1 +export(int) var max_level : int = 2 + #todo calc aabbs and store in PropData during prop conversion var room_hulls : Dictionary @@ -162,6 +167,19 @@ func spawn_room(room_lworld_transform : Transform, room : PropData, level : int current_aabbs.push_back(ctfab) + if spawn_mobs && level > 0 && ctfab.size() > 0: + if randi() % 3 == 0: + var v2 : Vector2 = ctfab[0] + + for i in range(1, ctfab.size()): + v2 = v2.linear_interpolate(ctfab[i], 0.5) + + var gt : Transform = global_transform + var scale : Vector3 = gt.basis.get_scale() + v2 *= Vector2(scale.x, scale.z) + + ESS.entity_spawner.spawn_mob(0, min_level + (randi() % (max_level - min_level)), Vector3(v2.x, gt.origin.y, v2.y)) + #if Engine.editor_hint and debug: # sr.owner = get_tree().edited_scene_root diff --git a/game/test_rooms/Room2.tres b/game/test_rooms/Room2.tres index c9efb426..e6abea4d 100644 --- a/game/test_rooms/Room2.tres +++ b/game/test_rooms/Room2.tres @@ -39,6 +39,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636 width = 5 heigth = 6 data = ExtResource( 5 ) +collision = false [sub_resource type="PropDataTiledWall" id=7] transform = Transform( 1, 0, 5.56363e-08, 0, 1, 0, -5.56363e-08, 0, 1, 0, 0, 0 ) diff --git a/game/test_rooms/Room2.tscn b/game/test_rooms/Room2.tscn index 9faace5f..90897950 100644 --- a/game/test_rooms/Room2.tscn +++ b/game/test_rooms/Room2.tscn @@ -71,6 +71,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636 width = 5 heigth = 6 data = ExtResource( 10 ) +collision = false [node name="wallzp" type="Spatial" parent="."] diff --git a/game/test_rooms/Room3.tres b/game/test_rooms/Room3.tres index 6133fb6a..46463fef 100644 --- a/game/test_rooms/Room3.tres +++ b/game/test_rooms/Room3.tres @@ -27,6 +27,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636 width = 5 heigth = 10 data = ExtResource( 3 ) +collision = false [sub_resource type="PropDataTiledWall" id=5] transform = Transform( 1, 0, 5.56363e-08, 0, 1, 0, -5.56363e-08, 0, 1, 0, 0, 0 ) diff --git a/game/test_rooms/Room3.tscn b/game/test_rooms/Room3.tscn index 5aa5fa0e..379af012 100644 --- a/game/test_rooms/Room3.tscn +++ b/game/test_rooms/Room3.tscn @@ -33,6 +33,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636 width = 5 heigth = 10 data = ExtResource( 10 ) +collision = false [node name="wallzp" type="Spatial" parent="."] diff --git a/game/test_rooms/Room4.tres b/game/test_rooms/Room4.tres index d2ebe452..92edeac3 100644 --- a/game/test_rooms/Room4.tres +++ b/game/test_rooms/Room4.tres @@ -27,6 +27,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636 width = 5 heigth = 16 data = ExtResource( 3 ) +collision = false [sub_resource type="PropDataTiledWall" id=5] transform = Transform( 1, 0, 5.56363e-08, 0, 1, 0, -5.56363e-08, 0, 1, 0, 0, 0 ) diff --git a/game/test_rooms/Room4.tscn b/game/test_rooms/Room4.tscn index 52579061..51e1beee 100644 --- a/game/test_rooms/Room4.tscn +++ b/game/test_rooms/Room4.tscn @@ -33,6 +33,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636 width = 5 heigth = 16 data = ExtResource( 10 ) +collision = false [node name="wallzp" type="Spatial" parent="."] diff --git a/game/test_rooms/Room5.tres b/game/test_rooms/Room5.tres index 9aea8dea..fa94b3ec 100644 --- a/game/test_rooms/Room5.tres +++ b/game/test_rooms/Room5.tres @@ -15,6 +15,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636 width = 5 heigth = 6 data = ExtResource( 3 ) +collision = false [sub_resource type="PropDataTiledWall" id=3] transform = Transform( 1, 0, 5.56363e-08, 0, 1, 0, -5.56363e-08, 0, 1, 0, 0, 0 ) diff --git a/game/test_rooms/Room5.tscn b/game/test_rooms/Room5.tscn index 661c3458..1e86ede4 100644 --- a/game/test_rooms/Room5.tscn +++ b/game/test_rooms/Room5.tscn @@ -21,6 +21,7 @@ transform = Transform( -1, 0, 3.17865e-08, 3.17865e-08, 5.96046e-08, 1, -1.77636 width = 5 heigth = 6 data = ExtResource( 10 ) +collision = false [node name="wallzp" type="Spatial" parent="."]