From e02dbe69a7fdbe2bca956c80427d2b7923c75542 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 20 Mar 2020 03:32:44 +0100 Subject: [PATCH] Implemented profile based class levelling. Update HEADS to grab the changes from the ESS side. --- game/autoload/Entities.gd | 8 +-- game/data/xp/xp_data.tres | 102 ++++++++++++++++++++------- game/menu/CharacterEntry.gd | 14 +++- game/project.godot | 2 + game/scenes/CharacterCreationMenu.gd | 3 +- game/scenes/CharacterSelectorMenu.gd | 20 +++++- game/scenes/Menu.tscn | 6 +- game/ui/windows/SpellBookWindow.gd | 2 - 8 files changed, 119 insertions(+), 38 deletions(-) diff --git a/game/autoload/Entities.gd b/game/autoload/Entities.gd index 886f62f2..11f1176e 100644 --- a/game/autoload/Entities.gd +++ b/game/autoload/Entities.gd @@ -112,9 +112,9 @@ func load_player(file_name : String, position : Vector3, network_owner : int) -> func spawn_player_for_menu(class_id : int, name : String, parent : Node) -> Entity: var createinfo : EntityCreateInfo = EntityCreateInfo.new() var cls : EntityData = EntityDataManager.get_player_character_data(class_id) - var class_profile : ClassProfile = ProfileManager.get_class_profile(class_id) + var class_profile : ClassProfile = ProfileManager.getc_player_profile().get_class_profile(class_id) - var level : int = class_profile.level + var level : int = 1 if default_level_override > 0: level = default_level_override @@ -122,8 +122,8 @@ func spawn_player_for_menu(class_id : int, name : String, parent : Node) -> Enti createinfo.class_id = class_id createinfo.entity_data = cls createinfo.player_name = name - createinfo.character_level = 1 - createinfo.class_level = level + createinfo.character_level = level + createinfo.class_level = class_profile.level createinfo.character_xp = 0 createinfo.class_xp = class_profile.xp createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER diff --git a/game/data/xp/xp_data.tres b/game/data/xp/xp_data.tres index 115b61d3..51425d75 100644 --- a/game/data/xp/xp_data.tres +++ b/game/data/xp/xp_data.tres @@ -4,28 +4,80 @@ character_level_1 = 22 character_level_2 = 34 character_level_3 = 43 -character_level_4 = 4345 -character_level_5 = 554 -character_level_6 = 545 -character_level_7 = 45 -character_level_8 = 45 -character_level_9 = 4 -character_level_10 = 45 -character_level_11 = 54 -character_level_12 = 56 -character_level_13 = 56 -character_level_14 = 56 -class_level_1 = 355 -class_level_2 = 5 -class_level_3 = 5 -class_level_4 = 5 -class_level_5 = 5555 -class_level_6 = 555 -class_level_7 = 555 -class_level_8 = 55 -class_level_9 = 55 -class_level_10 = 5 -class_level_11 = 5 -class_level_12 = 5 -class_level_13 = 5 -class_level_14 = 55 +character_level_4 = 200 +character_level_5 = 200 +character_level_6 = 200 +character_level_7 = 200 +character_level_8 = 200 +character_level_9 = 200 +character_level_10 = 200 +character_level_11 = 200 +character_level_12 = 200 +character_level_13 = 200 +character_level_14 = 200 +character_level_15 = 200 +character_level_16 = 200 +character_level_17 = 200 +character_level_18 = 200 +character_level_19 = 200 +character_level_20 = 200 +class_level_1 = 100 +class_level_2 = 200 +class_level_3 = 300 +class_level_4 = 400 +class_level_5 = 500 +class_level_6 = 600 +class_level_7 = 700 +class_level_8 = 800 +class_level_9 = 1000 +class_level_10 = 1000 +class_level_11 = 1000 +class_level_12 = 1000 +class_level_13 = 1000 +class_level_14 = 1000 +class_level_15 = 1000 +class_level_16 = 1000 +class_level_17 = 1000 +class_level_18 = 1000 +class_level_19 = 1000 +class_level_20 = 1000 +class_level_21 = 1000 +class_level_22 = 1000 +class_level_23 = 1000 +class_level_24 = 1000 +class_level_25 = 1000 +class_level_26 = 1000 +class_level_27 = 1000 +class_level_28 = 1000 +class_level_29 = 1000 +class_level_30 = 1000 +class_level_31 = 1000 +class_level_32 = 1000 +class_level_33 = 1000 +class_level_34 = 1000 +class_level_35 = 1000 +class_level_36 = 1000 +class_level_37 = 1000 +class_level_38 = 1000 +class_level_39 = 1000 +class_level_40 = 1000 +class_level_41 = 1000 +class_level_42 = 1000 +class_level_43 = 1000 +class_level_44 = 1000 +class_level_45 = 1000 +class_level_46 = 1000 +class_level_47 = 1000 +class_level_48 = 1000 +class_level_49 = 1000 +class_level_50 = 1000 +class_level_51 = 1000 +class_level_52 = 1000 +class_level_53 = 1000 +class_level_54 = 1000 +class_level_55 = 1000 +class_level_56 = 1000 +class_level_57 = 1000 +class_level_58 = 1000 +class_level_59 = 1000 +class_level_60 = 1000 diff --git a/game/menu/CharacterEntry.gd b/game/menu/CharacterEntry.gd index a862ea79..0f35016c 100644 --- a/game/menu/CharacterEntry.gd +++ b/game/menu/CharacterEntry.gd @@ -26,16 +26,20 @@ export(NodePath) var level_label_path : NodePath var id : int var file_name : String + var name_label : Label var class_label : Label var level_label : Label + var entity : Entity +var class_profile : ClassProfile func _ready(): name_label = get_node(name_label_path) as Label class_label = get_node(class_label_path) as Label level_label = get_node(level_label_path) as Label - + + connect("visibility_changed", self, "on_visibility_changed") func setup(pfile_name : String, name : String, cls_name : String, level : int, class_level : int, pentity : Entity) -> void: file_name = pfile_name @@ -44,6 +48,12 @@ func setup(pfile_name : String, name : String, cls_name : String, level : int, c level_label.text = str(level) entity = pentity -func set_class_name(name : String, level : int) -> void: +func set_class_name(name : String, level : int, pclass_profile : ClassProfile) -> void: name_label.text = name level_label.text = str(level) + class_profile = pclass_profile + +func on_visibility_changed(): + if visible and class_profile != null: + level_label.text = str(class_profile.level) + diff --git a/game/project.godot b/game/project.godot index 1d1f4dbe..86bec42a 100644 --- a/game/project.godot +++ b/game/project.godot @@ -360,6 +360,8 @@ enabled=PoolStringArray( "ess_data" ) [ess] +spells/allow_class_spell_learning=true +spells/allow_class_recipe_learning=true level/use_class_xp=true data/xp_data_path="res://data/xp/xp_data.tres" data/entity_resources_folder="res://data/entity_resources" diff --git a/game/scenes/CharacterCreationMenu.gd b/game/scenes/CharacterCreationMenu.gd index f475dc92..f642a5e5 100644 --- a/game/scenes/CharacterCreationMenu.gd +++ b/game/scenes/CharacterCreationMenu.gd @@ -50,7 +50,8 @@ func _ready(): ce.owner = container ce.id = d.id - ce.set_class_name(d.entity_class_data.text_name, profile.get_class_profile(d.id).class_id) + var class_profile : ClassProfile = profile.get_class_profile(d.id) + ce.set_class_name(d.entity_class_data.text_name, class_profile.level, class_profile) ce.group = character_creation_button_group if fb != null: diff --git a/game/scenes/CharacterSelectorMenu.gd b/game/scenes/CharacterSelectorMenu.gd index 3795de6d..fac3dfde 100644 --- a/game/scenes/CharacterSelectorMenu.gd +++ b/game/scenes/CharacterSelectorMenu.gd @@ -110,12 +110,29 @@ func clear() -> void: for e in player_display_container_node.get_children(): e.queue_free() -func delete_character() -> void: +func retire_character() -> void: var b : BaseButton = character_button_group.get_pressed_button() if b == null: return + + var class_profile : ClassProfile = ProfileManager.getc_player_profile().get_class_profile(b.entity.characterclass_id) + var xp_data : XPData = EntityDataManager.get_xp_data() + + if xp_data.can_class_level_up(class_profile.level): + class_profile.xp += b.entity.sclass_xp + + var xpr : int = xp_data.get_class_xp(class_profile.level) + + while xp_data.can_class_level_up(class_profile.level) and class_profile.xp >= xpr: + class_profile.level += 1 + class_profile.xp -= xpr + + xpr = xp_data.get_class_xp(class_profile.level) + + ProfileManager.save() + var file_name : String = "user://" + character_folder + "/" + b.file_name var f : File = File.new() @@ -161,3 +178,4 @@ func character_selection_changed() -> void: e.get_body().hide() b.entity.get_body().show() + diff --git a/game/scenes/Menu.tscn b/game/scenes/Menu.tscn index 666c6bdd..58ad0f44 100644 --- a/game/scenes/Menu.tscn +++ b/game/scenes/Menu.tscn @@ -164,12 +164,12 @@ margin_top = 526.0 margin_right = 261.0 margin_bottom = 552.0 -[node name="Delete" type="Button" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer"] +[node name="Retire" type="Button" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer"] margin_right = 128.0 margin_bottom = 26.269 size_flags_horizontal = 3 size_flags_vertical = 3 -text = "Delete" +text = "Retire" [node name="Create" type="Button" parent="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer"] margin_left = 132.0 @@ -589,7 +589,7 @@ light_specular = 0.65 shadow_bias = 0.07 script = ExtResource( 19 ) [connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/Load" to="CharacterSelectorMenu" method="load_character"] -[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer/Delete" to="CharacterSelectorMenu" method="delete_character"] +[connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer/Retire" to="CharacterSelectorMenu" method="retire_character"] [connection signal="pressed" from="CharacterSelectorMenu/CharacterSelector/CharacterSelector/VBoxContainer/HBoxContainer/Create" to="." method="switch_to_menu" binds= [ 1 ]] [connection signal="pressed" from="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer/Create" to="CharacterCreationMenu" method="create"] [connection signal="pressed" from="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer/Back" to="." method="switch_to_menu" binds= [ 0 ]] diff --git a/game/ui/windows/SpellBookWindow.gd b/game/ui/windows/SpellBookWindow.gd index 7404c805..192c4613 100644 --- a/game/ui/windows/SpellBookWindow.gd +++ b/game/ui/windows/SpellBookWindow.gd @@ -116,8 +116,6 @@ func refresh_all() -> void: if _player == null: return - - if _character_class == null: return