summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-13 11:06:46 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-13 11:06:46 -0300
commit539fd4820f37aa54df8878091db9680d89ee027a (patch)
tree41f9f5d6aa123058e3549c1baba4155fa5a85279
parentb8962990ddb75b874a49c83d8eeaba7b7e45c196 (diff)
pergaminho
-rw-r--r--assets/definitions/Items/mana_bolt_scroll.tres14
-rw-r--r--assets/definitions/spells/little_damage.tres8
-rw-r--r--assets/definitions/spells/mana_bolt.tres14
-rw-r--r--assets/sprites/items/fire.pngbin0 -> 871 bytes
-rw-r--r--assets/sprites/items/fire.png.import34
-rw-r--r--scenes/Game.tscn1
-rw-r--r--scripts/Entities/Actions/SpellAction.cs33
-rw-r--r--scripts/Entities/Actions/SpellAction.cs.uid1
-rw-r--r--scripts/Entities/Actors/Actor.cs3
-rw-r--r--scripts/Entities/Items/ConsumableItem.cs2
-rw-r--r--scripts/Entities/Items/ScrollConsumable.cs25
-rw-r--r--scripts/Entities/Items/ScrollConsumable.cs.uid1
-rw-r--r--scripts/Entities/Items/ScrollConsumableDefinition.cs11
-rw-r--r--scripts/Entities/Items/ScrollConsumableDefinition.cs.uid1
-rw-r--r--scripts/Magic/DamageEffect.cs18
-rw-r--r--scripts/Magic/DamageEffect.cs.uid1
-rw-r--r--scripts/Magic/Spell.cs.uid1
-rw-r--r--scripts/Magic/SpellBook.cs20
-rw-r--r--scripts/Magic/SpellBook.cs.uid1
-rw-r--r--scripts/Magic/SpellEffect.cs10
-rw-r--r--scripts/Magic/SpellEffect.cs.uid1
-rw-r--r--scripts/Magic/SpellResource.cs36
-rw-r--r--scripts/Magic/SpellResource.cs.uid1
-rw-r--r--scripts/Map/DungeonGenerator.cs8
24 files changed, 242 insertions, 3 deletions
diff --git a/assets/definitions/Items/mana_bolt_scroll.tres b/assets/definitions/Items/mana_bolt_scroll.tres
new file mode 100644
index 0000000..0812d4d
--- /dev/null
+++ b/assets/definitions/Items/mana_bolt_scroll.tres
@@ -0,0 +1,14 @@
+[gd_resource type="Resource" script_class="ScrollConsumableDefinition" load_steps=4 format=3 uid="uid://xbjfp7d6qoyj"]
+
+[ext_resource type="Resource" uid="uid://boi8svlb0e8l" path="res://assets/definitions/spells/mana_bolt.tres" id="1_eaxr2"]
+[ext_resource type="Script" uid="uid://2lk5w2po81gy" path="res://scripts/Entities/Items/ScrollConsumableDefinition.cs" id="1_jtnuc"]
+[ext_resource type="Texture2D" uid="uid://dwky8qc2y602k" path="res://assets/sprites/actors/player.png" id="3_si3hv"]
+
+[resource]
+script = ExtResource("1_jtnuc")
+Spell = ExtResource("1_eaxr2")
+name = "Pergaminho de flecha de mana"
+texture = ExtResource("3_si3hv")
+Type = 1
+blocksMovement = false
+metadata/_custom_type_script = "uid://2lk5w2po81gy"
diff --git a/assets/definitions/spells/little_damage.tres b/assets/definitions/spells/little_damage.tres
new file mode 100644
index 0000000..0c5436d
--- /dev/null
+++ b/assets/definitions/spells/little_damage.tres
@@ -0,0 +1,8 @@
+[gd_resource type="Resource" script_class="DamageEffect" load_steps=2 format=3 uid="uid://2121t34hbxck"]
+
+[ext_resource type="Script" uid="uid://cmgtdh2kdo1rq" path="res://scripts/Magic/DamageEffect.cs" id="1_rnhwa"]
+
+[resource]
+script = ExtResource("1_rnhwa")
+Damage = 5
+metadata/_custom_type_script = "uid://cmgtdh2kdo1rq"
diff --git a/assets/definitions/spells/mana_bolt.tres b/assets/definitions/spells/mana_bolt.tres
new file mode 100644
index 0000000..da209fb
--- /dev/null
+++ b/assets/definitions/spells/mana_bolt.tres
@@ -0,0 +1,14 @@
+[gd_resource type="Resource" script_class="SpellResource" load_steps=4 format=3 uid="uid://boi8svlb0e8l"]
+
+[ext_resource type="Script" uid="uid://brhihikhjtc6e" path="res://scripts/Magic/SpellEffect.cs" id="1_ux3o7"]
+[ext_resource type="Script" uid="uid://bi6jdrduu76de" path="res://scripts/Magic/SpellResource.cs" id="2_uq8o1"]
+[ext_resource type="Resource" uid="uid://2121t34hbxck" path="res://assets/definitions/spells/little_damage.tres" id="2_yltt7"]
+
+[resource]
+script = ExtResource("2_uq8o1")
+SpellName = "Flecha de mana"
+Cost = 8
+Type = 0
+Range = 7
+Effects = Array[ExtResource("1_ux3o7")]([ExtResource("2_yltt7")])
+metadata/_custom_type_script = "uid://bi6jdrduu76de"
diff --git a/assets/sprites/items/fire.png b/assets/sprites/items/fire.png
new file mode 100644
index 0000000..8b96601
--- /dev/null
+++ b/assets/sprites/items/fire.png
Binary files differ
diff --git a/assets/sprites/items/fire.png.import b/assets/sprites/items/fire.png.import
new file mode 100644
index 0000000..09c58b8
--- /dev/null
+++ b/assets/sprites/items/fire.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://di7wi728svlel"
+path="res://.godot/imported/fire.png-bb0d4b2241e34a55047b4d8e5d147305.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://assets/sprites/items/fire.png"
+dest_files=["res://.godot/imported/fire.png-bb0d4b2241e34a55047b4d8e5d147305.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/scenes/Game.tscn b/scenes/Game.tscn
index 09e9825..fa0f687 100644
--- a/scenes/Game.tscn
+++ b/scenes/Game.tscn
@@ -22,6 +22,7 @@ script = ExtResource("3_cpr0p")
[node name="Generator" type="Node" parent="Map"]
script = ExtResource("4_78awf")
UseSeed = false
+Iterations = 7
[node name="FieldOfView" type="Node" parent="Map"]
script = ExtResource("5_s0nni")
diff --git a/scripts/Entities/Actions/SpellAction.cs b/scripts/Entities/Actions/SpellAction.cs
new file mode 100644
index 0000000..086a52a
--- /dev/null
+++ b/scripts/Entities/Actions/SpellAction.cs
@@ -0,0 +1,33 @@
+using Godot;
+using TheLegendOfGustav.Entities.Actors;
+using TheLegendOfGustav.Magic;
+
+namespace TheLegendOfGustav.Entities.Actions;
+
+public partial class SpellCommand(Actor actor, Vector2I offset, SpellResource spell) : DirectionalAction(actor, offset)
+{
+ private SpellResource spell = spell;
+
+ public override bool Perform()
+ {
+ Actor target = null;
+
+ if (GetTarget() is Actor actor)
+ {
+ target = actor;
+ }
+
+ if (spell.Type == SpellType.Ranged && target == null) return false;
+
+ if (Actor.Mp < spell.Cost)
+ {
+ return false;
+ }
+
+ foreach (SpellEffect effect in spell.Effects)
+ {
+ effect.Apply(Actor, target);
+ }
+ return true;
+ }
+}
diff --git a/scripts/Entities/Actions/SpellAction.cs.uid b/scripts/Entities/Actions/SpellAction.cs.uid
new file mode 100644
index 0000000..6f85025
--- /dev/null
+++ b/scripts/Entities/Actions/SpellAction.cs.uid
@@ -0,0 +1 @@
+uid://b18wblvggpev0
diff --git a/scripts/Entities/Actors/Actor.cs b/scripts/Entities/Actors/Actor.cs
index 7e6685f..8eee4e2 100644
--- a/scripts/Entities/Actors/Actor.cs
+++ b/scripts/Entities/Actors/Actor.cs
@@ -1,4 +1,5 @@
using Godot;
+using TheLegendOfGustav.Magic;
using TheLegendOfGustav.Map;
using TheLegendOfGustav.Utils;
@@ -132,6 +133,8 @@ public partial class Actor : Entity
get;
set;
}
+
+ public SpellBook SpellBook { get; private set; } = new();
#endregion
#region Methods
diff --git a/scripts/Entities/Items/ConsumableItem.cs b/scripts/Entities/Items/ConsumableItem.cs
index f70983a..4078bd3 100644
--- a/scripts/Entities/Items/ConsumableItem.cs
+++ b/scripts/Entities/Items/ConsumableItem.cs
@@ -9,7 +9,7 @@ namespace TheLegendOfGustav.Entities.Items;
/// Classe para itens consumíveis.
/// Itens consumíveis são itens de uso limitado.
/// </summary>
-public abstract partial class ConsumableItem(Vector2I initialPosition, MapData map, EntityDefinition definition) : Entity(initialPosition, map, definition)
+public abstract partial class ConsumableItem(Vector2I initialPosition, MapData map, ConsumableItemDefinition definition) : Entity(initialPosition, map, definition)
{
/// <summary>
diff --git a/scripts/Entities/Items/ScrollConsumable.cs b/scripts/Entities/Items/ScrollConsumable.cs
new file mode 100644
index 0000000..d260263
--- /dev/null
+++ b/scripts/Entities/Items/ScrollConsumable.cs
@@ -0,0 +1,25 @@
+using Godot;
+using TheLegendOfGustav.Entities.Actions;
+using TheLegendOfGustav.Entities.Actors;
+using TheLegendOfGustav.Magic;
+using TheLegendOfGustav.Map;
+using TheLegendOfGustav.Utils;
+
+namespace TheLegendOfGustav.Entities.Items;
+
+public partial class ScrollConsumable(Vector2I initialPosition, MapData map, ScrollConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition)
+{
+ private ScrollConsumableDefinition definition = definition;
+
+ public SpellResource Spell { get; private set; } = definition.Spell;
+
+
+ public override bool Activate(ItemAction action)
+ {
+ Player consumer = action.Player;
+
+ MessageLogData.Instance.AddMessage("Foste cuckado");
+ ConsumedBy(consumer);
+ return true;
+ }
+} \ No newline at end of file
diff --git a/scripts/Entities/Items/ScrollConsumable.cs.uid b/scripts/Entities/Items/ScrollConsumable.cs.uid
new file mode 100644
index 0000000..ba79f47
--- /dev/null
+++ b/scripts/Entities/Items/ScrollConsumable.cs.uid
@@ -0,0 +1 @@
+uid://dsp0ryh6fctv1
diff --git a/scripts/Entities/Items/ScrollConsumableDefinition.cs b/scripts/Entities/Items/ScrollConsumableDefinition.cs
new file mode 100644
index 0000000..c9f50a5
--- /dev/null
+++ b/scripts/Entities/Items/ScrollConsumableDefinition.cs
@@ -0,0 +1,11 @@
+using Godot;
+using TheLegendOfGustav.Magic;
+
+namespace TheLegendOfGustav.Entities.Items;
+
+[GlobalClass]
+public partial class ScrollConsumableDefinition : ConsumableItemDefinition
+{
+ [Export]
+ public SpellResource Spell { get; set; }
+} \ No newline at end of file
diff --git a/scripts/Entities/Items/ScrollConsumableDefinition.cs.uid b/scripts/Entities/Items/ScrollConsumableDefinition.cs.uid
new file mode 100644
index 0000000..8cadd79
--- /dev/null
+++ b/scripts/Entities/Items/ScrollConsumableDefinition.cs.uid
@@ -0,0 +1 @@
+uid://2lk5w2po81gy
diff --git a/scripts/Magic/DamageEffect.cs b/scripts/Magic/DamageEffect.cs
new file mode 100644
index 0000000..abd2cca
--- /dev/null
+++ b/scripts/Magic/DamageEffect.cs
@@ -0,0 +1,18 @@
+using Godot;
+using TheLegendOfGustav.Entities.Actors;
+
+namespace TheLegendOfGustav.Magic;
+
+[GlobalClass]
+public partial class DamageEffect : SpellEffect
+{
+ [Export]
+ public int Damage { get; set; }
+
+ public override void Apply(Actor caster, Actor target)
+ {
+ int damageDealt = Damage - target.Men;
+
+ target.Hp -= damageDealt;
+ }
+} \ No newline at end of file
diff --git a/scripts/Magic/DamageEffect.cs.uid b/scripts/Magic/DamageEffect.cs.uid
new file mode 100644
index 0000000..be2d36b
--- /dev/null
+++ b/scripts/Magic/DamageEffect.cs.uid
@@ -0,0 +1 @@
+uid://cmgtdh2kdo1rq
diff --git a/scripts/Magic/Spell.cs.uid b/scripts/Magic/Spell.cs.uid
new file mode 100644
index 0000000..78c0570
--- /dev/null
+++ b/scripts/Magic/Spell.cs.uid
@@ -0,0 +1 @@
+uid://byo6rbhx6nlgh
diff --git a/scripts/Magic/SpellBook.cs b/scripts/Magic/SpellBook.cs
new file mode 100644
index 0000000..8ccba71
--- /dev/null
+++ b/scripts/Magic/SpellBook.cs
@@ -0,0 +1,20 @@
+using Godot;
+
+namespace TheLegendOfGustav.Magic;
+
+public partial class SpellBook : Node
+{
+ public Godot.Collections.Array<SpellResource> KnownSpells { get; private set; } = [];
+
+ public bool KnowsSpell(SpellResource spell) => KnownSpells.Contains(spell);
+
+ public void LearnSpell(SpellResource spell) {
+ if (!KnownSpells.Contains(spell)) {
+ KnownSpells.Add(spell);
+ }
+ }
+
+ public void ForgetSpell(SpellResource spell) {
+ KnownSpells.Remove(spell);
+ }
+} \ No newline at end of file
diff --git a/scripts/Magic/SpellBook.cs.uid b/scripts/Magic/SpellBook.cs.uid
new file mode 100644
index 0000000..d18055c
--- /dev/null
+++ b/scripts/Magic/SpellBook.cs.uid
@@ -0,0 +1 @@
+uid://bn3q4xypi2ogf
diff --git a/scripts/Magic/SpellEffect.cs b/scripts/Magic/SpellEffect.cs
new file mode 100644
index 0000000..482a64f
--- /dev/null
+++ b/scripts/Magic/SpellEffect.cs
@@ -0,0 +1,10 @@
+using Godot;
+using TheLegendOfGustav.Entities.Actors;
+
+namespace TheLegendOfGustav.Magic;
+
+[GlobalClass]
+public abstract partial class SpellEffect : Resource
+{
+ public abstract void Apply(Actor caster, Actor target);
+} \ No newline at end of file
diff --git a/scripts/Magic/SpellEffect.cs.uid b/scripts/Magic/SpellEffect.cs.uid
new file mode 100644
index 0000000..4fc1573
--- /dev/null
+++ b/scripts/Magic/SpellEffect.cs.uid
@@ -0,0 +1 @@
+uid://brhihikhjtc6e
diff --git a/scripts/Magic/SpellResource.cs b/scripts/Magic/SpellResource.cs
new file mode 100644
index 0000000..bb3fd15
--- /dev/null
+++ b/scripts/Magic/SpellResource.cs
@@ -0,0 +1,36 @@
+using Godot;
+using TheLegendOfGustav.Entities.Actions;
+using TheLegendOfGustav.Entities.Actors;
+
+namespace TheLegendOfGustav.Magic;
+
+public enum SpellType
+{
+ Ranged,
+ Self
+}
+[GlobalClass]
+public partial class SpellResource : Resource
+{
+ /// <summary>
+ /// Ícone do feitiço na interface gráfica.
+ /// </summary>
+ [ExportCategory("Visuals")]
+ [Export]
+ public Texture2D Icon { get; set; }
+ /// <summary>
+ /// Nome do feitiço na interface gráfica.
+ /// </summary>
+ [Export]
+ public string SpellName { get; set; } = "unnamed spell";
+
+ [ExportCategory("Mechanics")]
+ [Export]
+ public int Cost { get; set; }
+ [Export]
+ public SpellType Type { get; set; }
+ [Export]
+ public int Range { get; set; }
+ [Export]
+ public Godot.Collections.Array<SpellEffect> Effects { get; set; } = [];
+} \ No newline at end of file
diff --git a/scripts/Magic/SpellResource.cs.uid b/scripts/Magic/SpellResource.cs.uid
new file mode 100644
index 0000000..7472e6b
--- /dev/null
+++ b/scripts/Magic/SpellResource.cs.uid
@@ -0,0 +1 @@
+uid://bi6jdrduu76de
diff --git a/scripts/Map/DungeonGenerator.cs b/scripts/Map/DungeonGenerator.cs
index 9a44d33..6f239ac 100644
--- a/scripts/Map/DungeonGenerator.cs
+++ b/scripts/Map/DungeonGenerator.cs
@@ -22,7 +22,8 @@ public partial class DungeonGenerator : Node
];
private static readonly Godot.Collections.Array<ConsumableItemDefinition> items = [
- GD.Load<HealingConsumableDefinition>("res://assets/definitions/Items/small_healing_potion.tres")
+ GD.Load<HealingConsumableDefinition>("res://assets/definitions/Items/small_healing_potion.tres"),
+ GD.Load<ScrollConsumableDefinition>("res://assets/definitions/Items/mana_bolt_scroll.tres")
];
#endregion
@@ -274,7 +275,6 @@ public partial class DungeonGenerator : Node
Rng.RandiRange(room.Position.Y, room.End.Y - 1)
);
- // Só podemos colocar um ator por ponto no espaço.
bool canPlace = true;
foreach (Entity entity in data.Entities)
{
@@ -293,6 +293,10 @@ public partial class DungeonGenerator : Node
{
HealingConsumable item = new(position, data, hcDefinition);
data.InsertEntity(item);
+ } else if (definition is ScrollConsumableDefinition scroll)
+ {
+ ScrollConsumable item = new(position, data, scroll);
+ data.InsertEntity(item);
}
}
}