Now spawned mobs will match the player's level. (For testing.)

This commit is contained in:
Relintai 2020-08-03 21:51:09 +02:00
parent d37e190c2f
commit adad0c0778
3 changed files with 30 additions and 3 deletions

View File

@ -58,7 +58,13 @@ func _generate_chunk(chunk: VoxelChunk, spawn_mobs: bool) -> void:
get_dungeon(i).generate_chunk(chunk, spawn_mobs)
if not Engine.editor_hint and chunk.position_y == 0 and spawn_mobs and randi() % 4 == 0:
ESS.entity_spawner.spawn_mob(0, randi() % 3, Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\
var level : int = 1
if chunk.get_voxel_world().has_method("get_mob_level"):
level = chunk.get_voxel_world().get_mob_level()
ESS.entity_spawner.spawn_mob(0, level, \
Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\
(chunk.position_y + 1) * chunk.size_y * chunk.voxel_scale, \
chunk.position_z * chunk.size_z * chunk.voxel_scale + chunk.size_z / 2))
@ -133,7 +139,13 @@ func generate_terrarin(chunk : VoxelChunk, spawn_mobs: bool) -> void:
# chunk.build()
if not Engine.editor_hint and chunk.position_y == 0 and spawn_mobs:
ESS.entity_spawner.spawn_mob(0, randi() % 3, Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\
var level : int = 1
if chunk.get_voxel_world().has_method("get_mob_level"):
level = chunk.get_voxel_world().mob_level
ESS.entity_spawner.spawn_mob(0, level, \
Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\
(chunk.position_y + 1) * chunk.size_y * chunk.voxel_scale, \
chunk.position_z * chunk.size_z * chunk.voxel_scale + chunk.size_z / 2))

View File

@ -30,7 +30,14 @@ func _process(delta):
if Input.is_action_just_pressed("sheath"):
get_character_skeleton().toggle_sheath()
func _notification_slevel_up(value):
._notification_slevel_up(value)
var world : Node = get_node_or_null("..")
if world:
if world.has_method("set_mob_level"):
world.set_mob_level(gets_level())
func _from_dict(dict):
._from_dict(dict)

View File

@ -36,6 +36,8 @@ export(bool) var use_global_chunk_settings : bool = true
export(PropData) var test_prop : PropData
var mob_level : int = 1
var initial_generation : bool = true
var spawned : bool = false
@ -295,3 +297,9 @@ func save() -> void:
return
ESS.entity_spawner.save_player(_player, _player_file_name)
func get_mob_level() -> int:
return mob_level
func set_mob_level(level : int) -> void:
mob_level = level