From a440a60383fc9c59e42a91d28cda17f19a3263c6 Mon Sep 17 00:00:00 2001 From: Nolan A Casey Date: Thu, 2 May 2024 15:39:04 -0400 Subject: [PATCH] More spells and started on cast indicator --- Resources/Spellbooks/oldBook.tres | 5 ++- Resources/Spellbooks/wizardSpellbook.tres | 12 ++++++ Resources/Spells/fireball.tres | 19 ++++++++++ Resources/Spells/firebolt.tres | 4 ++ Resources/Spells/rockThrow.tres | 4 ++ Scenes/UI/castIndicator.tscn | 46 +++++++++++++++++++++++ Scripts/castIndicator.gd | 13 +++++++ Scripts/playerController.gd | 12 +++++- 8 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 Resources/Spellbooks/wizardSpellbook.tres create mode 100644 Resources/Spells/fireball.tres create mode 100644 Scenes/UI/castIndicator.tscn create mode 100644 Scripts/castIndicator.gd diff --git a/Resources/Spellbooks/oldBook.tres b/Resources/Spellbooks/oldBook.tres index 3bd5d65..5ce6f1a 100644 --- a/Resources/Spellbooks/oldBook.tres +++ b/Resources/Spellbooks/oldBook.tres @@ -1,14 +1,15 @@ -[gd_resource type="Resource" script_class="Spellbook" load_steps=4 format=3 uid="uid://bxtiv2esuer8v"] +[gd_resource type="Resource" script_class="Spellbook" load_steps=5 format=3 uid="uid://bxtiv2esuer8v"] [ext_resource type="Script" path="res://Resources/spellbook.gd" id="1_t8h8m"] [ext_resource type="Resource" uid="uid://1xbik4qndtkh" path="res://Resources/Spells/firebolt.tres" id="2_ln222"] [ext_resource type="Resource" uid="uid://dl6nv6lp460n3" path="res://Resources/Spells/rockThrow.tres" id="3_ocgmh"] +[ext_resource type="Resource" uid="uid://bmpu6k55bckdv" path="res://Resources/Spells/fireball.tres" id="4_kv0hs"] [resource] script = ExtResource("1_t8h8m") name = "Old Book" description = "An old spellbook you found on the side of the road" -spells = Array[Resource("res://Resources/spell.gd")]([ExtResource("2_ln222"), ExtResource("3_ocgmh"), null]) +spells = Array[Resource("res://Resources/spell.gd")]([ExtResource("2_ln222"), ExtResource("3_ocgmh"), ExtResource("4_kv0hs")]) damageMod = 1.0 defenseMod = 1.0 element = 0 diff --git a/Resources/Spellbooks/wizardSpellbook.tres b/Resources/Spellbooks/wizardSpellbook.tres new file mode 100644 index 0000000..b8ed12f --- /dev/null +++ b/Resources/Spellbooks/wizardSpellbook.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="Spellbook" load_steps=2 format=3 uid="uid://g86hap7s43n8"] + +[ext_resource type="Script" path="res://Resources/spellbook.gd" id="1_pn4te"] + +[resource] +script = ExtResource("1_pn4te") +name = "Wizard Spellbook" +description = "A spellbook used by wizards" +spells = Array[Resource("res://Resources/spell.gd")]([null, null, null, null, null, null]) +damageMod = 1.2 +defenseMod = 1.2 +element = 0 diff --git a/Resources/Spells/fireball.tres b/Resources/Spells/fireball.tres new file mode 100644 index 0000000..9d784c1 --- /dev/null +++ b/Resources/Spells/fireball.tres @@ -0,0 +1,19 @@ +[gd_resource type="Resource" script_class="Spell" load_steps=3 format=3 uid="uid://bmpu6k55bckdv"] + +[ext_resource type="Texture2D" uid="uid://c3e14oly7elf3" path="res://Sprites/Spells/Ice & Fire Spells Pack by Captainskeleto/Fire Spell Pack by Captainskeleto/Fire Spells/Fire Spell Pack52.png" id="1_8gs1u"] +[ext_resource type="Script" path="res://Resources/spell.gd" id="1_iewgb"] + +[resource] +script = ExtResource("1_iewgb") +icon = ExtResource("1_8gs1u") +name = "Fireball" +description = "An enourmous ball of fire" +animation = "" +damage = 8.0 +backfireStrength = 6.0 +castCombo = Array[String](["up", "down", "down", "left", "right", "left", "right", "up"]) +castProgress = 0 +element = 1 +stunning = true +timeout = 5.0 +cooldown = 10.0 diff --git a/Resources/Spells/firebolt.tres b/Resources/Spells/firebolt.tres index 38e8463..801edef 100644 --- a/Resources/Spells/firebolt.tres +++ b/Resources/Spells/firebolt.tres @@ -10,6 +10,10 @@ name = "Firebolt" description = "Cast a small line of fire at your opponent" animation = "" damage = 1.0 +backfireStrength = 1.0 castCombo = Array[String](["up", "down", "down"]) +castProgress = 0 element = 1 stunning = false +timeout = 10.0 +cooldown = 1.0 diff --git a/Resources/Spells/rockThrow.tres b/Resources/Spells/rockThrow.tres index 0213495..2596586 100644 --- a/Resources/Spells/rockThrow.tres +++ b/Resources/Spells/rockThrow.tres @@ -10,6 +10,10 @@ name = "Rock Throw" description = "Throw a rock at your opponent" animation = "" damage = 0.5 +backfireStrength = 1.0 castCombo = Array[String](["down", "up", "up"]) +castProgress = 0 element = 4 stunning = true +timeout = 10.0 +cooldown = 1.0 diff --git a/Scenes/UI/castIndicator.tscn b/Scenes/UI/castIndicator.tscn new file mode 100644 index 0000000..399850d --- /dev/null +++ b/Scenes/UI/castIndicator.tscn @@ -0,0 +1,46 @@ +[gd_scene load_steps=3 format=3 uid="uid://dbhep5cgrqipa"] + +[ext_resource type="Texture2D" uid="uid://1duikwr2bln8" path="res://Sprites/Misc/WEAPON PACK by captainskeleto/weapon9.png" id="1_25tp1"] +[ext_resource type="Script" path="res://Scripts/castIndicator.gd" id="1_jkb2f"] + +[node name="CastIndicator" type="Control"] +layout_mode = 3 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_jkb2f") + +[node name="TextureRect2" type="TextureRect" parent="."] +modulate = Color(1, 1, 1, 0.345098) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -94.0 +offset_top = -94.0 +offset_right = 94.0 +offset_bottom = 94.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_25tp1") + +[node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_25tp1") diff --git a/Scripts/castIndicator.gd b/Scripts/castIndicator.gd new file mode 100644 index 0000000..3c16897 --- /dev/null +++ b/Scripts/castIndicator.gd @@ -0,0 +1,13 @@ +extends Control + +@onready var data = get_node("/root/Arena/Data") +@onready var primary = $TextureRect +@onready var secondary = $TextureRect2 + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass diff --git a/Scripts/playerController.gd b/Scripts/playerController.gd index a370e32..1728899 100644 --- a/Scripts/playerController.gd +++ b/Scripts/playerController.gd @@ -1,9 +1,11 @@ extends Node @onready var data = get_node("/root/Arena/Data") +@onready var castIndicator = get_node("/root/Arena/CanvasLayer/CastIndicator") @export var avatar: Combatant var casting = false var spell: Spell +var spellIndex: int var timer: float = 0 # Called when the node enters the scene tree for the first time. @@ -14,9 +16,10 @@ func _ready(): func _process(delta): if !casting: for i in range(data.spellbook.spells.size()): - if Input.is_action_just_pressed("Spell" + str(i)): + if Input.is_action_just_pressed("Spell" + str(i)) && data.spellbook.cooldowns[i] == 0: casting = true spell = data.spellbook.spells[i] + spellIndex = i avatar.particleSystem.emitting = true timer = 0 else: @@ -28,8 +31,13 @@ func _process(delta): avatar.particleSystem.emitting = false spell.castProgress = 0 avatar.renderer.play("attack1") + data.spellbook.cooldowns[spellIndex] = spell.cooldown elif (timer >= spell.timeout || Input.is_action_just_pressed("up") || Input.is_action_just_pressed("down") || Input.is_action_just_pressed("left") || Input.is_action_just_pressed("right")): avatar.alterHealth(-spell.backfireStrength, true) casting = false avatar.particleSystem.emitting = false - + data.spellbook.cooldowns[spellIndex] = spell.cooldown * (spell.castProgress / spell.castCombo.size()) + + for i in range(data.spellbook.cooldowns.size()): + data.spellbook.cooldowns[i] -= delta + if data.spellbook.cooldowns[i] < 0: data.spellbook.cooldowns[i] = 0