From b0c0c5d61b70bd0f24d62388deb1425333ac913f Mon Sep 17 00:00:00 2001 From: Balloonpopper Date: Sat, 31 Dec 2022 16:54:02 +1100 Subject: [PATCH] fix: Wizard - NPCs have to be ESCItems instead of ESCPlayers --- addons/escoria-wizard/CharacterCreator.gd | 36 ++++++++++++- addons/escoria-wizard/CharacterCreator.tscn | 60 +++++++++++++++++++-- 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/addons/escoria-wizard/CharacterCreator.gd b/addons/escoria-wizard/CharacterCreator.gd index 85561a7b..fdf4d1ff 100644 --- a/addons/escoria-wizard/CharacterCreator.gd +++ b/addons/escoria-wizard/CharacterCreator.gd @@ -42,6 +42,7 @@ const ANIMATION_SPEED_LABEL = "Animation speed" # Make the code more readable by shortening node references using constants const NAME_NODE = "VBoxContainer/HBoxContainer/configuration/VBoxContainer/node_name/MarginContainer2/GridContainer" const DIR_COUNT_NODE = "VBoxContainer/HBoxContainer/configuration/VBoxContainer/directions/HBoxContainer" +const CHAR_TYPE_NODE = "VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype/HBoxContainer" const ANIM_TYPE_NODE = "VBoxContainer/HBoxContainer/configuration/VBoxContainer/animation/HBoxContainer" const MIRROR_NODE = "VBoxContainer/HBoxContainer/configuration/VBoxContainer/animation/HBoxContainer2/HBoxContainer/MarginContainer3/mirror_checkbox" const ARROWS_NODE = "VBoxContainer/HBoxContainer/configuration/VBoxContainer/animation/HBoxContainer2/HBoxContainer/MarginContainer2/GridContainer" @@ -1248,7 +1249,15 @@ func export_player(scene_name) -> void: else: num_directions = 1 - var new_character = ESCPlayer.new() + var new_character + # NPCs can't be ESCPlayers or the player won't walk up to them when + # you interact with them + if get_node(CHAR_TYPE_NODE).get_node("npc").pressed: + new_character = ESCItem.new() + print("ITEM") + else: + new_character = ESCPlayer.new() + new_character.selectable = true new_character.name = get_node(NAME_NODE).get_node("node_name").text if get_node(NAME_NODE).get_node("global_id").text == null: @@ -1256,7 +1265,7 @@ func export_player(scene_name) -> void: new_character.global_id = get_node(NAME_NODE).get_node("global_id").text new_character.tooltip_name = get_node(NAME_NODE).get_node("node_name").text - new_character.selectable = true + new_character.default_action = "look" var animations_resource = ESCAnimationResource.new() @@ -1335,6 +1344,14 @@ func export_player(scene_name) -> void: dialog_position.position.y = -(export_largest_sprite.y * 1.2) new_character.add_child(dialog_position) + if get_node(CHAR_TYPE_NODE).get_node("npc").pressed: + # Add Interaction Position to an NPC + var interaction_position = ESCLocation.new() + interaction_position.name = "interact_position" + interaction_position.position.y = +(export_largest_sprite.y * 1.2) + new_character.add_child(interaction_position) + interaction_position.set_owner(new_character) + progress_bar_update("Configuring animations") yield(get_tree(), "idle_frame") # Make it so all the nodes can be seen in the scene tree @@ -1697,5 +1714,20 @@ func animation_on_idle_checkbox_pressed() -> void: change_animation_type("idle") +# When Auto storage checkbox is checked func _on_AutoStoreCheckBox_toggled(button_pressed: bool) -> void: autostore = button_pressed + + +# When player checkbox selected +func _on_player_pressed(): +# If player button was already selected, don't let it be unselected. + get_node(CHAR_TYPE_NODE).get_node("player").pressed = true + get_node(CHAR_TYPE_NODE).get_node("npc").pressed = false + + +# When NPC checkbox selected +func _on_npc_pressed(): +# If npc button was already selected, don't let it be unselected. + get_node(CHAR_TYPE_NODE).get_node("npc").pressed = true + get_node(CHAR_TYPE_NODE).get_node("player").pressed = false diff --git a/addons/escoria-wizard/CharacterCreator.tscn b/addons/escoria-wizard/CharacterCreator.tscn index d7ec57f9..068b2673 100644 --- a/addons/escoria-wizard/CharacterCreator.tscn +++ b/addons/escoria-wizard/CharacterCreator.tscn @@ -231,12 +231,64 @@ margin_right = 357.0 margin_bottom = 80.0 text = "Change" -[node name="directions" type="VBoxContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer"] +[node name="charactertype" type="VBoxContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer"] margin_top = 134.0 margin_right = 400.0 margin_bottom = 186.0 rect_min_size = Vector2( 400, 50 ) +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype"] +margin_right = 400.0 +margin_bottom = 24.0 + +[node name="directions_colorrect" type="ColorRect" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype/MarginContainer"] +margin_right = 400.0 +margin_bottom = 24.0 +color = Color( 0.215686, 0.478431, 0.235294, 1 ) + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype/MarginContainer"] +margin_right = 400.0 +margin_bottom = 24.0 +custom_constants/margin_right = 5 +custom_constants/margin_top = 5 +custom_constants/margin_left = 5 +custom_constants/margin_bottom = 5 + +[node name="direction_number_label" type="Label" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype/MarginContainer/MarginContainer"] +margin_left = 5.0 +margin_top = 5.0 +margin_right = 395.0 +margin_bottom = 19.0 +text = "Player or NPC?" + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype"] +margin_top = 28.0 +margin_right = 400.0 +margin_bottom = 52.0 +custom_constants/separation = 50 +alignment = 1 + +[node name="player" type="CheckBox" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype/HBoxContainer"] +margin_left = 116.0 +margin_right = 183.0 +margin_bottom = 24.0 +hint_tooltip = "Create a user-controlled character" +pressed = true +text = "player" + +[node name="npc" type="CheckBox" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype/HBoxContainer"] +margin_left = 233.0 +margin_right = 284.0 +margin_bottom = 24.0 +hint_tooltip = "Create a non-player character" +text = "npc" + +[node name="directions" type="VBoxContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer"] +margin_top = 190.0 +margin_right = 400.0 +margin_bottom = 242.0 +rect_min_size = Vector2( 400, 50 ) + [node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/directions"] margin_right = 400.0 margin_bottom = 24.0 @@ -298,9 +350,9 @@ hint_tooltip = "Create 8 directions of animation" text = "8" [node name="animation" type="VBoxContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer"] -margin_top = 190.0 +margin_top = 246.0 margin_right = 400.0 -margin_bottom = 628.0 +margin_bottom = 684.0 rect_min_size = Vector2( 400, 200 ) [node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer/configuration/VBoxContainer/animation"] @@ -1435,6 +1487,8 @@ you will lose your current character. [connection signal="text_changed" from="VBoxContainer/HBoxContainer/configuration/VBoxContainer/node_name/MarginContainer2/GridContainer/node_name" to="." method="nodename_on_node_name_text_changed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/configuration/VBoxContainer/node_name/MarginContainer2/GridContainer/character_path_change_button" to="." method="_on_character_path_change_button_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype/HBoxContainer/player" to="." method="_on_player_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer/configuration/VBoxContainer/charactertype/HBoxContainer/npc" to="." method="_on_npc_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/configuration/VBoxContainer/directions/HBoxContainer/one_direction" to="." method="directions_on_one_direction_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/configuration/VBoxContainer/directions/HBoxContainer/two_directions" to="." method="directions_on_two_directions_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/configuration/VBoxContainer/directions/HBoxContainer/four_directions" to="." method="directions_on_four_directions_pressed"]