From c9ffc5a821e28558fae986ed79ab3245b26e45b2 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 10 Mar 2020 15:33:48 +0100 Subject: [PATCH] Added 2 spells to Naturalist, implemented range, and started implementing mana. --- .../auras/10_aspect_of_scorpions_rank_1.tres | 8 ++-- game/data/entities/1_naturalist.tres | 3 +- game/data/entity_classes/1_naturalist.tres | 8 ++-- game/data/spells/35_strike.tres | 42 +++++++++++++++++++ game/data/spells/36_regrow.tres | 24 +++++++++++ game/project.godot | 2 +- .../{ManResource.gd => ManaResource.gd} | 0 game/scripts/resources/ManaResourceData.gd | 1 + game/scripts/spells/gd_spell_script.gd | 21 ++++++++++ game/ui/unitframes/UnitframeBase.gd | 30 +++++++++++++ game/ui/unitframes/UnitframeBase.tscn | 2 + 11 files changed, 131 insertions(+), 10 deletions(-) create mode 100644 game/data/spells/35_strike.tres create mode 100644 game/data/spells/36_regrow.tres rename game/scripts/resources/{ManResource.gd => ManaResource.gd} (100%) diff --git a/game/data/auras/10_aspect_of_scorpions_rank_1.tres b/game/data/auras/10_aspect_of_scorpions_rank_1.tres index 581d1013..669c9b55 100644 --- a/game/data/auras/10_aspect_of_scorpions_rank_1.tres +++ b/game/data/auras/10_aspect_of_scorpions_rank_1.tres @@ -11,15 +11,15 @@ icon = ExtResource( 2 ) time = 30.0 tick = 3.0 debuff = true -rank = 10 +rank = 1 aura_type = 1 aura_group = ExtResource( 3 ) text_name = "Aspect of Scorpions" -text_description = "Deals 340 to 380 damage every 3 sec, and increases damage taken by 10% for 30 sec." +text_description = "Deals %%damage_min to %%damage_max damage every %%tick sec, and increases damage taken by 10% for 30 sec." damage_enabled = true damage_type = 8 -damage_min = 340 -damage_max = 355 +damage_min = 4 +damage_max = 5 attribute_count = 1 StatModAttribute_0/stat = 24 StatModAttribute_0/base_mod = 0.0 diff --git a/game/data/entities/1_naturalist.tres b/game/data/entities/1_naturalist.tres index a562d3c3..a3cf3feb 100644 --- a/game/data/entities/1_naturalist.tres +++ b/game/data/entities/1_naturalist.tres @@ -1,8 +1,7 @@ -[gd_resource type="EntityData" load_steps=5 format=2] +[gd_resource type="EntityData" load_steps=4 format=2] [ext_resource path="res://data/entity_classes/1_naturalist.tres" type="EntityClassData" id=1] [ext_resource path="res://scripts/entities/EntityDataGD.gd" type="Script" id=2] -[ext_resource path="res://data/item_templates/2_test.tres" type="ItemTemplate" id=3] [sub_resource type="LootDataBase" id=1] diff --git a/game/data/entity_classes/1_naturalist.tres b/game/data/entity_classes/1_naturalist.tres index 38379740..066ec250 100644 --- a/game/data/entity_classes/1_naturalist.tres +++ b/game/data/entity_classes/1_naturalist.tres @@ -1,4 +1,4 @@ -[gd_resource type="EntityClassData" load_steps=74 format=2] +[gd_resource type="EntityClassData" load_steps=76 format=2] [ext_resource path="res://data/spells/26_rest.tres" type="Spell" id=1] [ext_resource path="res://data/spells/21_strength_of_nature_rank_1.tres" type="Spell" id=2] @@ -22,6 +22,8 @@ [ext_resource path="res://scripts/ai/EntityAIGD.gd" type="Script" id=20] [ext_resource path="res://data/auras/13_aspect_of_bees_rank_1.tres" type="Aura" id=21] [ext_resource path="res://data/auras/15_close_wounds_rank_1.tres" type="Aura" id=22] +[ext_resource path="res://data/spells/35_strike.tres" type="Spell" id=23] +[ext_resource path="res://data/spells/36_regrow.tres" type="Spell" id=24] [ext_resource path="res://data/entity_resources/1_mana_resource.tres" type="EntityResourceData" id=27] [sub_resource type="EntityAI" id=1] @@ -252,8 +254,8 @@ stat_data = SubResource( 50 ) player_resource_type = 2 entity_resources = [ ExtResource( 27 ) ] specs = [ SubResource( 4 ) ] -spells = [ ExtResource( 4 ), ExtResource( 6 ), ExtResource( 16 ), ExtResource( 5 ), ExtResource( 3 ), ExtResource( 10 ), ExtResource( 8 ), ExtResource( 11 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 13 ), ExtResource( 2 ), ExtResource( 12 ), ExtResource( 14 ), ExtResource( 15 ), ExtResource( 17 ), ExtResource( 1 ) ] -start_spells = [ ExtResource( 4 ) ] +spells = [ ExtResource( 4 ), ExtResource( 6 ), ExtResource( 16 ), ExtResource( 5 ), ExtResource( 3 ), ExtResource( 10 ), ExtResource( 8 ), ExtResource( 11 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 13 ), ExtResource( 2 ), ExtResource( 12 ), ExtResource( 14 ), ExtResource( 15 ), ExtResource( 17 ), ExtResource( 1 ), ExtResource( 23 ), ExtResource( 24 ) ] +start_spells = [ ExtResource( 4 ), ExtResource( 23 ), ExtResource( 24 ) ] auras = [ ExtResource( 18 ) ] ais = [ SubResource( 1 ) ] script = ExtResource( 19 ) diff --git a/game/data/spells/35_strike.tres b/game/data/spells/35_strike.tres new file mode 100644 index 00000000..39a79ee5 --- /dev/null +++ b/game/data/spells/35_strike.tres @@ -0,0 +1,42 @@ +[gd_resource type="Spell" load_steps=7 format=2] + +[ext_resource path="res://scripts/spells/amplify_pain.gd" type="Script" id=1] +[ext_resource path="res://data/icons/naturalist/amplify_pain.tres" type="Texture" id=2] +[ext_resource path="res://scripts/resources/spell_effect_visual_basic.gd" type="Script" id=3] +[ext_resource path="res://data/spell_effects/nature/AmplifyPain.tscn" type="PackedScene" id=4] +[ext_resource path="res://data/spell_effects/nature/NatureCast.tscn" type="PackedScene" id=5] + +[sub_resource type="SpellEffectVisual" id=1] +script = ExtResource( 3 ) +spell_cast_effect_left_hand = ExtResource( 5 ) +spell_cast_effect_right_hand = ExtResource( 5 ) +torso_aura_effect_time = 0.0 +root_aura_effect_time = 0.0 +torso_spell_cast_finish_effect = ExtResource( 4 ) +torso_spell_cast_finish_effect_time = 0.4 +root_spell_cast_finish_effect_time = 1.0 + +[resource] +resource_name = "Strike" +id = 35 +spell_type = 1 +rank = 1 +icon = ExtResource( 2 ) +needs_target = true +visual_spell_effects = SubResource( 1 ) +text_name = "Strike" +text_description = "Range: Melee +Strike the target with your weapon, dealing weapon damage, and an additional %%damage_min - %%damage_max ." +cooldown_cooldown = 3.0 +range_enabled = true +range_range = 3.0 +cast_cast_time = 1.5 +damage_enabled = true +damage_type = 1 +damage_min = 19 +damage_max = 25 +damage_scale_stat = 41 +damage_scale_coeff = 1.0 +aoe_targetType = -1910718371 +aoe_colliderType = 1065353216 +script = ExtResource( 1 ) diff --git a/game/data/spells/36_regrow.tres b/game/data/spells/36_regrow.tres new file mode 100644 index 00000000..498b58ab --- /dev/null +++ b/game/data/spells/36_regrow.tres @@ -0,0 +1,24 @@ +[gd_resource type="Spell" load_steps=3 format=2] + +[ext_resource path="res://scripts/spells/gd_spell_script.gd" type="Script" id=1] +[ext_resource path="res://data/icons/naturalist/root.tres" type="Texture" id=2] + +[resource] +resource_name = "Regrow" +id = 36 +spell_type = 8 +target_relation_type = 5 +rank = 1 +icon = ExtResource( 2 ) +text_name = "Regrow" +text_description = "Heals you for %%heal_min to %%heal_max ." +range_enabled = true +range_range = 30.0 +cast_enabled = true +cast_cast_time = 2.0 +heal_enabled = true +heal_min = 12 +heal_max = 18 +heal_scale_stat = 14 +heal_scale_coeff = 0.1 +script = ExtResource( 1 ) diff --git a/game/project.godot b/game/project.godot index 6752df86..601ee1b4 100644 --- a/game/project.godot +++ b/game/project.godot @@ -212,7 +212,7 @@ _global_script_classes=[ { "base": "EntityResource", "class": "ManaResource", "language": "GDScript", -"path": "res://scripts/resources/ManResource.gd" +"path": "res://scripts/resources/ManaResource.gd" }, { "base": "Control", "class": "Menu", diff --git a/game/scripts/resources/ManResource.gd b/game/scripts/resources/ManaResource.gd similarity index 100% rename from game/scripts/resources/ManResource.gd rename to game/scripts/resources/ManaResource.gd diff --git a/game/scripts/resources/ManaResourceData.gd b/game/scripts/resources/ManaResourceData.gd index c8e15c8f..68143866 100644 --- a/game/scripts/resources/ManaResourceData.gd +++ b/game/scripts/resources/ManaResourceData.gd @@ -22,3 +22,4 @@ extends EntityResourceData func _get_entity_resource_instance() -> EntityResource: return ManaResource.new() + diff --git a/game/scripts/spells/gd_spell_script.gd b/game/scripts/spells/gd_spell_script.gd index 12511e2f..3debc0da 100644 --- a/game/scripts/spells/gd_spell_script.gd +++ b/game/scripts/spells/gd_spell_script.gd @@ -42,6 +42,10 @@ func _sstart_casting(info : SpellCastInfo) -> void: if target_relation_type & TARGET_FRIENDLY or target_relation_type & TARGET_SELF: if entity_relation_type == EntityEnums.ENTITY_RELATION_TYPE_FRIENDLY or entity_relation_type == EntityEnums.ENTITY_RELATION_TYPE_NEUTRAL: ok = true + else: + if entity_relation_type == EntityEnums.ENTITY_RELATION_TYPE_HOSTILE: + info.target = info.caster + ok = true if target_relation_type & TARGET_ENEMY: if entity_relation_type == EntityEnums.ENTITY_RELATION_TYPE_HOSTILE: @@ -49,6 +53,14 @@ func _sstart_casting(info : SpellCastInfo) -> void: if !ok: return + + if range_enabled: + if info.caster != info.target: + var c : Vector3 = info.caster.get_body().transform.origin + var t : Vector3 = info.target.get_body().transform.origin + + if (c - t).length() > range_range: + return if cast_enabled: info.caster.sstart_casting(info) @@ -133,6 +145,15 @@ func handle_effect(info : SpellCastInfo) -> void: handle_spell_damage(sdi) + if heal_enabled and info.target: + var shi : SpellHealInfo = SpellHealInfo.new() + + shi.heal_source = self + shi.dealer = info.caster + shi.receiver = info.target + + handle_spell_heal(shi) + for aura in caster_aura_applys: var ainfo : AuraApplyInfo = AuraApplyInfo.new() diff --git a/game/ui/unitframes/UnitframeBase.gd b/game/ui/unitframes/UnitframeBase.gd index 1e5eae13..40816e0a 100644 --- a/game/ui/unitframes/UnitframeBase.gd +++ b/game/ui/unitframes/UnitframeBase.gd @@ -24,21 +24,29 @@ export (NodePath) var name_text_path : NodePath export (NodePath) var level_text_path : NodePath export (NodePath) var health_range_path : NodePath export (NodePath) var health_text_path : NodePath +export (NodePath) var resource_range_path : NodePath +export (NodePath) var resource_text_path : NodePath export (NodePath) var xp_range_path : NodePath var _name_text : Label var _level_text : Label var _health_range : Range var _health_text : Label +var _resource_range : Range +var _resource_text : Label var _xp_range : Range var _player : Entity +var _mana : ManaResource + func _ready() -> void: _name_text = get_node(name_text_path) _level_text = get_node(level_text_path) _health_range = get_node(health_range_path) _health_text = get_node(health_text_path) + _resource_range = get_node(resource_range_path) + _resource_text = get_node(resource_text_path) _xp_range = get_node(xp_range_path) func set_player(p_player: Entity) -> void: @@ -63,6 +71,12 @@ func set_player(p_player: Entity) -> void: _player.connect("con_xp_gained", self, "con_xp_gained") _player.connect("centity_data_changed", self, "centity_data_changed") + if _player.getc_resource_count() > 0: + var mana : ManaResource = _player.getc_resource_index(0) as ManaResource + + if mana != null: + mana.connect("changed", self, "_on_mana_changed") + var health = _player.get_health() _on_player_health_changed(health) health.connect("c_changed", self, "_on_player_health_changed") @@ -89,6 +103,22 @@ func _on_player_health_changed(health: Stat) -> void: _health_text.text = str(health.ccurrent) + "/" + str(health.cmax) +func _on_mana_changed(resource: EntityResource) -> void: + if resource.max == 0: + _resource_range.min_value = 0 + _resource_range.max_value = 1 + _resource_range.value = 0 + + _resource_range.text = "" + + return + + _resource_range.min_value = 0 + _resource_range.max_value = resource.cmax + _resource_range.value = resource.ccurrent + + _resource_range.text = str(resource.ccurrent) + "/" + str(resource.cmax) + func cname_changed(entity: Entity) -> void: _name_text.text = _player.centity_name diff --git a/game/ui/unitframes/UnitframeBase.tscn b/game/ui/unitframes/UnitframeBase.tscn index 60cab943..806ccda0 100644 --- a/game/ui/unitframes/UnitframeBase.tscn +++ b/game/ui/unitframes/UnitframeBase.tscn @@ -15,6 +15,8 @@ name_text_path = NodePath("VBoxContainer/HBoxContainer/Label") level_text_path = NodePath("VBoxContainer/HBoxContainer/Label2") health_range_path = NodePath("VBoxContainer/MarginContainer/ProgressBar") health_text_path = NodePath("VBoxContainer/MarginContainer/Label") +resource_range_path = NodePath("VBoxContainer/MarginContainer2/ResourceBar") +resource_text_path = NodePath("VBoxContainer/MarginContainer2/Label") xp_range_path = NodePath("VBoxContainer/XPBar") [node name="VBoxContainer" type="VBoxContainer" parent="."]