Item holy and all element implementation, still need to work out some of the math for it

Fix bonus defense for weapons
This commit is contained in:
2026-02-05 10:48:24 -08:00
parent 8a99771491
commit 8ea881edb3
18 changed files with 88 additions and 28 deletions

View File

@@ -12,7 +12,6 @@ namespace Zennysoft.Ma.Adapter
calculatedDamage = CalculateDefenseResistance(calculatedDamage, defense);
if (!damage.IgnoreElementalResistance)
calculatedDamage = CalculateElementalResistance(calculatedDamage, elementalResistanceSet.ElementalResistance[damage.ElementType]);
return Mathf.Max(1, calculatedDamage);
}

View File

@@ -7,5 +7,7 @@ public enum ElementType
Telluric,
Hydric,
Igneous,
Ferrum
Ferrum,
Holy,
All
}

View File

@@ -7,9 +7,9 @@ namespace Zennysoft.Ma.Adapter.Entity
[Save("elemental_resist_set")]
public Dictionary<ElementType, double> ElementalResistance { get; }
public static ElementalResistanceSet None => new ElementalResistanceSet(0, 0, 0, 0, 0);
public static ElementalResistanceSet None => new ElementalResistanceSet(0, 0, 0, 0, 0, 0);
public ElementalResistanceSet(double aeolicResistance, double hydricResistance, double igneousResistance, double ferrumResistance, double telluricResistance)
public ElementalResistanceSet(double aeolicResistance, double hydricResistance, double igneousResistance, double ferrumResistance, double telluricResistance, double holyResistance)
{
ElementalResistance = new Dictionary<ElementType, double>
{
@@ -19,6 +19,8 @@ namespace Zennysoft.Ma.Adapter.Entity
{ ElementType.Igneous, igneousResistance },
{ ElementType.Ferrum, ferrumResistance },
{ ElementType.Telluric, telluricResistance },
{ ElementType.Holy, holyResistance },
{ ElementType.All, aeolicResistance + hydricResistance + igneousResistance + ferrumResistance + telluricResistance + holyResistance },
};
}
@@ -29,7 +31,8 @@ namespace Zennysoft.Ma.Adapter.Entity
left.ElementalResistance[ElementType.Hydric] + right.ElementalResistance[ElementType.Hydric],
left.ElementalResistance[ElementType.Igneous] + right.ElementalResistance[ElementType.Igneous],
left.ElementalResistance[ElementType.Ferrum] + right.ElementalResistance[ElementType.Ferrum],
left.ElementalResistance[ElementType.Telluric] + right.ElementalResistance[ElementType.Telluric]);
left.ElementalResistance[ElementType.Telluric] + right.ElementalResistance[ElementType.Telluric],
left.ElementalResistance[ElementType.Holy] + right.ElementalResistance[ElementType.Holy]);
}
}
}

View File

@@ -18,5 +18,5 @@ public abstract partial class EquipableItem : InventoryItem
[Save("bonus_luck_stats")]
public virtual int BonusLuck { get; }
[Save("bonus_elemental_resist_stats")]
public virtual ElementalResistanceSet ElementalResistance { get; } = new ElementalResistanceSet(0, 0, 0, 0, 0);
public virtual ElementalResistanceSet ElementalResistance { get; } = new ElementalResistanceSet(0, 0, 0, 0, 0, 0);
}

View File

@@ -8,4 +8,5 @@ public enum WeaponTag
IgnoreDefense,
Knockback,
InverseHPAttackPower,
RustChanceSelfAndEnemy
}

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=3 uid="uid://brgi35xj3b4ud"]
[gd_scene load_steps=26 format=3 uid="uid://brgi35xj3b4ud"]
[ext_resource type="Script" uid="uid://cw100tox0ufsy" path="res://src/audio/SfxDatabase.cs" id="1_ojkqd"]
[ext_resource type="AudioStream" uid="uid://cye8wlqbx66h4" path="res://src/audio/sfx/player_heal.ogg" id="2_158j8"]
@@ -11,6 +11,7 @@
[ext_resource type="AudioStream" uid="uid://doeefxilh0luj" path="res://src/audio/sfx/ITEM_SORT.ogg" id="9_l6w22"]
[ext_resource type="AudioStream" uid="uid://4mk4hlse81if" path="res://src/audio/sfx/player_losehealth.ogg" id="10_kac56"]
[ext_resource type="AudioStream" uid="uid://dwp3ep3jddvrr" path="res://src/audio/sfx/UI_SELECT.ogg" id="10_nerso"]
[ext_resource type="AudioStream" uid="uid://ilf2s8ct2stt" path="res://src/audio/sfx/PLAYER_slower_slash.ogg" id="10_vyvit"]
[ext_resource type="AudioStream" uid="uid://oslvh60ec5gc" path="res://src/audio/sfx/UI_CANCEL_BACK.ogg" id="11_rloay"]
[ext_resource type="AudioStream" uid="uid://bo2u1ceci6k1i" path="res://src/audio/sfx/PLAYER_quicker_slash.ogg" id="13_fa8i8"]
[ext_resource type="AudioStream" uid="uid://na0lxb1lib11" path="res://src/audio/sfx/player_crit.ogg" id="14_p5cio"]
@@ -67,11 +68,16 @@ unique_name_in_owner = true
stream = ExtResource("3_kac56")
bus = &"SFX"
[node name="WeaponSwingSound" type="AudioStreamPlayer" parent="Player"]
[node name="WeaponQuickSlashSound" type="AudioStreamPlayer" parent="Player"]
unique_name_in_owner = true
stream = ExtResource("13_fa8i8")
bus = &"SFX"
[node name="WeaponSlowSlashSound" type="AudioStreamPlayer" parent="Player"]
unique_name_in_owner = true
stream = ExtResource("10_vyvit")
bus = &"SFX"
[node name="CritSound" type="AudioStreamPlayer" parent="Player"]
unique_name_in_owner = true
stream = ExtResource("14_p5cio")

View File

@@ -24,7 +24,6 @@ public partial class SfxDatabase : Node
{SoundEffect.TakeDamage, TakeDamageSound },
{SoundEffect.HealVT, HealVTSound },
{SoundEffect.IncreaseStat, IncreaseStatSound },
{SoundEffect.WeaponSwing, WeaponSwingSound },
{SoundEffect.Crit, CritSound },
{SoundEffect.PickupItem, PickupItemSound },
{SoundEffect.OpenInventory, OpenInventorySound },
@@ -42,6 +41,8 @@ public partial class SfxDatabase : Node
{SoundEffect.TeleportToExit, TeleportToExitSound},
{SoundEffect.AbsorbHPFromAllEnemies, AbsorbHPFromAllEnemiesSound},
{SoundEffect.TurnAllEnemiesIntoHealingItems, TurnAllEnemiesIntoHealingItemsSound},
{SoundEffect.WeaponQuickSlash, WeaponQuickSlashSound },
{SoundEffect.WeaponSlowSlash, WeaponSlowSlashSound },
};
}
@@ -49,7 +50,8 @@ public partial class SfxDatabase : Node
[Node] private AudioStreamPlayer TakeDamageSound { get; set; } = default!;
[Node] private AudioStreamPlayer HealVTSound { get; set; } = default!;
[Node] private AudioStreamPlayer IncreaseStatSound { get; set; } = default!;
[Node] private AudioStreamPlayer WeaponSwingSound { get; set; } = default!;
[Node] private AudioStreamPlayer WeaponQuickSlashSound { get; set; } = default!;
[Node] private AudioStreamPlayer WeaponSlowSlashSound { get; set; } = default!;
[Node] private AudioStreamPlayer CritSound { get; set; } = default!;
[Node] private AudioStreamPlayer PickupItemSound { get; set; } = default!;
[Node] private AudioStreamPlayer OpenInventorySound { get; set; }
@@ -85,7 +87,6 @@ public enum SoundEffect
TakeDamage,
HealVT,
IncreaseStat,
WeaponSwing,
Crit,
PickupItem,
OpenInventory,
@@ -104,5 +105,7 @@ public enum SoundEffect
AbsorbHPFromAllEnemies,
SwapHPAndVT,
TurnAllEnemiesIntoHealingItems,
WeaponQuickSlash,
WeaponSlowSlash
}

View File

@@ -55,7 +55,9 @@ public abstract partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLo
[Export] public double TelluricResistance { get; set; }
public ElementalResistanceSet ElementalResistanceSet => new ElementalResistanceSet(AeolicResistance, HydricResistance, IgenousResistance, FerrumResistance, TelluricResistance);
[Export] public double HolyResistance { get; set; }
public ElementalResistanceSet ElementalResistanceSet => new ElementalResistanceSet(AeolicResistance, HydricResistance, IgenousResistance, FerrumResistance, TelluricResistance, HolyResistance);
[Node] private AudioStreamPlayer3D _absorbSFX { get; set; } = default!;
[Node] private AudioStreamPlayer3D _hitSFX { get; set; } = default!;

View File

@@ -59,6 +59,10 @@ public abstract partial class InventoryItemStats : Resource
[Save("equipment_ferrum_resist")]
public int FerrumResistance { get; set; } = 0;
[Export]
[Save("equipment_holy_resist")]
public int HolyResistance { get; set; } = 0;
[Export(PropertyHint.Range, "0, 25, 0.1")]
[Save("equipment_throw_speed")]
public float ThrowSpeed { get; set; } = 12.0f;
@@ -74,7 +78,4 @@ public abstract partial class InventoryItemStats : Resource
[Export]
[Save("inventory_item_texture")]
public Texture2D Texture { get; set; }
[Export]
public AudioStream AudioStream { get; set; }
}

View File

@@ -36,7 +36,7 @@ public partial class Accessory : EquipableItem
public override int BonusVT => Stats.BonusVT;
public override ElementalResistanceSet ElementalResistance => new ElementalResistanceSet(Stats.AeolicResistance, Stats.HydricResistance, Stats.IgneousResistance, Stats.FerrumResistance, Stats.TelluricResistance);
public override ElementalResistanceSet ElementalResistance => new ElementalResistanceSet(Stats.AeolicResistance, Stats.HydricResistance, Stats.IgneousResistance, Stats.FerrumResistance, Stats.TelluricResistance, Stats.HolyResistance);
[Save("accessory_tag")]
public AccessoryTag AccessoryTag => Stats.AccessoryTag;

View File

@@ -34,7 +34,7 @@ public partial class Armor : EquipableItem
[Save("bonus_defense")]
private int _bonusDefense { get; set; } = 0;
public override ElementalResistanceSet ElementalResistance => new ElementalResistanceSet(Stats.AeolicResistance, Stats.HydricResistance, Stats.IgneousResistance, Stats.FerrumResistance, Stats.TelluricResistance);
public override ElementalResistanceSet ElementalResistance => new ElementalResistanceSet(Stats.AeolicResistance, Stats.HydricResistance, Stats.IgneousResistance, Stats.FerrumResistance, Stats.TelluricResistance, Stats.HolyResistance);
public void IncreaseArmorDefense(int bonus) => _bonusDefense += bonus;

View File

@@ -29,5 +29,9 @@ public partial class ArmorStats : InventoryItemStats
[Save("armor_ferrum_resistance")]
private double _ferrumResistance { get; set; } = 0;
public ElementalResistanceSet ElementalResistanceSet => new ElementalResistanceSet(_aeolicResistance, _hydricResistance, _igneousResistance, _ferrumResistance, _telluricResistance);
[Export]
[Save("armor_holy_resistance")]
private double _holyResistance { get; set; } = 0;
public ElementalResistanceSet ElementalResistanceSet => new ElementalResistanceSet(_aeolicResistance, _hydricResistance, _igneousResistance, _ferrumResistance, _telluricResistance, _holyResistance);
}

View File

@@ -41,17 +41,26 @@ public partial class Weapon : EquipableItem
[Save("weapon_element")]
public ElementType WeaponElement => Stats.WeaponElement;
public override ElementalResistanceSet ElementalResistance => new ElementalResistanceSet(Stats.AeolicResistance, Stats.HydricResistance, Stats.IgneousResistance, Stats.FerrumResistance, Stats.TelluricResistance);
public override ElementalResistanceSet ElementalResistance => new ElementalResistanceSet(Stats.AeolicResistance, Stats.HydricResistance, Stats.IgneousResistance, Stats.FerrumResistance, Stats.TelluricResistance, Stats.HolyResistance);
public void IncreaseWeaponAttack(int bonus) => _bonusDamage += bonus;
public void SetWeaponAttack(int newBonus) => _bonusDamage = newBonus;
public void IncreaseWeaponDefense(int bonus) => _bonusDefense += bonus;
public void SetWeaponDefense(int newBonus) => _bonusDefense = newBonus;
public override int BonusAttack { get => Stats.BonusAttack + _bonusDamage; }
public override int BonusDefense { get => Stats.BonusDefense + _bonusDefense; }
[Save("weapon_bonus_damage")]
private int _bonusDamage { get; set; } = 0;
[Save("weapon_bonus_damage")]
private int _bonusDefense { get; set; } = 0;
[Export]
[Save("weapon_stats")]
public WeaponStats Stats { get; set; } = new WeaponStats();

View File

@@ -22,5 +22,5 @@ public partial class WeaponStats : InventoryItemStats
public WeaponTag WeaponTag { get; set; } = WeaponTag.None;
[Export]
public SoundEffect SoundEffect { get; set; } = SoundEffect.WeaponSwing;
public SoundEffect SoundEffect { get; set; } = SoundEffect.WeaponQuickSlash;
}

View File

@@ -7,8 +7,9 @@
[resource]
script = ExtResource("1_kbje7")
AttackSpeed = 1.0
WeaponElement = 0
WeaponElement = 5
WeaponTag = 0
SoundEffect = 4
Name = "Kubel"
Description = "+9 ATK
A very powerful spear.

View File

@@ -1,14 +1,14 @@
[gd_resource type="Resource" script_class="WeaponStats" load_steps=4 format=3 uid="uid://ckj1m4iv4m02r"]
[gd_resource type="Resource" script_class="WeaponStats" load_steps=3 format=3 uid="uid://ckj1m4iv4m02r"]
[ext_resource type="AudioStream" uid="uid://ilf2s8ct2stt" path="res://src/audio/sfx/PLAYER_slower_slash.ogg" id="1_eh5k4"]
[ext_resource type="Texture2D" uid="uid://740syoj0w14p" path="res://src/items/weapons/textures/PALM OF HEAVEN.PNG" id="1_hi6xm"]
[ext_resource type="Script" uid="uid://cc7byqeolw5y4" path="res://src/items/weapons/WeaponStats.cs" id="1_pwwg7"]
[resource]
script = ExtResource("1_pwwg7")
AttackSpeed = 1.0
WeaponElement = 0
WeaponElement = 7
WeaponTag = 0
SoundEffect = 22
Name = "Palm of Heaven"
Description = "+10 ATK
Very Powerful.
@@ -24,8 +24,8 @@ TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_hi6xm")
AudioStream = ExtResource("1_eh5k4")

View File

@@ -0,0 +1,30 @@
[gd_resource type="Resource" script_class="WeaponStats" load_steps=4 format=3 uid="uid://bdjji8ento6on"]
[ext_resource type="AudioStream" uid="uid://ilf2s8ct2stt" path="res://src/audio/sfx/PLAYER_slower_slash.ogg" id="1_nr6vs"]
[ext_resource type="Texture2D" uid="uid://b8c7kd436tg4" path="res://src/items/weapons/textures/RONDO.PNG" id="2_nr6vs"]
[ext_resource type="Script" uid="uid://cc7byqeolw5y4" path="res://src/items/weapons/WeaponStats.cs" id="3_2ykeu"]
[resource]
script = ExtResource("3_2ykeu")
AttackSpeed = 1.0
WeaponElement = 5
WeaponTag = 6
SoundEffect = 4
Name = "Rusted Blade"
Description = "Small chance to give enemy and self a lethal infection."
SpawnRate = 0.1
BonusAttack = 0
BonusDefense = 0
BonusLuck = 0.05
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("2_nr6vs")
AudioStream = ExtResource("1_nr6vs")

View File

@@ -1,7 +1,6 @@
[gd_resource type="Resource" script_class="WeaponStats" load_steps=4 format=3 uid="uid://dj6i0em2a3hj8"]
[gd_resource type="Resource" script_class="WeaponStats" load_steps=3 format=3 uid="uid://dj6i0em2a3hj8"]
[ext_resource type="Texture2D" uid="uid://cixq2naufiuhv" path="res://src/items/weapons/textures/spaded staff.PNG" id="1_6tifm"]
[ext_resource type="AudioStream" uid="uid://ilf2s8ct2stt" path="res://src/audio/sfx/PLAYER_slower_slash.ogg" id="1_n7ptf"]
[ext_resource type="Script" uid="uid://cc7byqeolw5y4" path="res://src/items/weapons/WeaponStats.cs" id="2_w4n0u"]
[resource]
@@ -9,6 +8,7 @@ script = ExtResource("2_w4n0u")
AttackSpeed = 0.75
WeaponElement = 0
WeaponTag = 0
SoundEffect = 23
Name = "Monk's Spade"
Description = "+5 ATK, Slow"
SpawnRate = 0.3
@@ -26,4 +26,3 @@ ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_6tifm")
AudioStream = ExtResource("1_n7ptf")