Explorar o código

Small fix for the item range for healing and mana

Axel Nordh hai 8 meses
pai
achega
48e6dec7d1

+ 21 - 29
Assets/Scenes/MapScene2.unity

@@ -287,20 +287,6 @@ MonoBehaviour:
   combatEventPopup: {fileID: 0}
   combatEventPopupUXML: {fileID: 1319078988}
   combatPopupPrefab: {fileID: 0}
-  allowRunningAway: 1
-  runAwaySuccessChance: 0.75
-  runAwayHealthPenalty: 5
-  successfulRunAwayMessages:
-  - Your party successfully escapes from the enemies!
-  - Quick thinking allows your party to avoid the confrontation!
-  - Your party slips away unnoticed by the enemies.
-  failedRunAwayMessages:
-  - The enemies catch up to your party! You take {damage} damage while trying to
-    escape.
-  - Your escape attempt fails! The enemies pursue and wound your party for {damage}
-    damage.
-  - The enemies block your escape route! Your party suffers {damage} damage in the
-    failed attempt.
 --- !u!1 &1243674619
 GameObject:
   m_ObjectHideFlags: 0
@@ -482,6 +468,7 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 1319078986}
+  - component: {fileID: 1319078989}
   - component: {fileID: 1319078988}
   m_Layer: 0
   m_Name: CombatEventUI
@@ -517,11 +504,30 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: caf20a4e9c141924eabbd10f4e254d11, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  uiDocument: {fileID: 591284417}
+  uiDocument: {fileID: 1319078989}
   popupTemplate: {fileID: 9197481963319205126, guid: 8f2fc644fa775e045b9398ea420ce032, type: 3}
   popupStyleSheet: {fileID: 7433441132597879392, guid: ec08bffc7fd7d4f4caf1ea5e3fdf50d8, type: 3}
   animationDuration: 0.3
   backgroundBlurIntensity: 0.5
+--- !u!114 &1319078989
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1319078984}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_PanelSettings: {fileID: 11400000, guid: 0d7125098b341c74d868b72a1bacddf4, type: 2}
+  m_ParentUI: {fileID: 0}
+  sourceAsset: {fileID: 9197481963319205126, guid: 8f2fc644fa775e045b9398ea420ce032, type: 3}
+  m_SortingOrder: 10
+  m_WorldSpaceSizeMode: 1
+  m_WorldSpaceWidth: 1920
+  m_WorldSpaceHeight: 1080
 --- !u!1 &1581552013
 GameObject:
   m_ObjectHideFlags: 0
@@ -633,20 +639,6 @@ MonoBehaviour:
   combatEventPopup: {fileID: 0}
   combatEventPopupUXML: {fileID: 1319078988}
   combatPopupPrefab: {fileID: 0}
-  allowRunningAway: 1
-  runAwaySuccessChance: 0.75
-  runAwayHealthPenalty: 5
-  successfulRunAwayMessages:
-  - Your party successfully escapes from the enemies!
-  - Quick thinking allows your party to avoid the confrontation!
-  - Your party slips away unnoticed by the enemies.
-  failedRunAwayMessages:
-  - The enemies catch up to your party! You take {damage} damage while trying to
-    escape.
-  - Your escape attempt fails! The enemies pursue and wound your party for {damage}
-    damage.
-  - The enemies block your escape route! Your party suffers {damage} damage in the
-    failed attempt.
 --- !u!1 &1953346056
 GameObject:
   m_ObjectHideFlags: 0

+ 31 - 0
Assets/Scripts/Objects/Armour/LeatherPants.asset

@@ -0,0 +1,31 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d37416b822a924a4ca8b3d4daafd98b5, type: 3}
+  m_Name: LeatherPants
+  m_EditorClassIdentifier: 
+  itemName: Leather pants
+  description: Simeple Leather pants
+  icon: {fileID: 0}
+  model3D: {fileID: 0}
+  itemType: 1
+  rarity: 0
+  goldCost: 0
+  silverCost: 0
+  copperCost: 0
+  searchTags: []
+  armorClass: 1
+  strengthModifier: 0
+  dexterityModifier: 0
+  constitutionModifier: 0
+  wisdomModifier: 0
+  armorType: 0
+  armorSlot: 2

+ 33 - 0
Assets/Scripts/Objects/Armour/LetherChestPiece.asset

@@ -0,0 +1,33 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d37416b822a924a4ca8b3d4daafd98b5, type: 3}
+  m_Name: LetherChestPiece
+  m_EditorClassIdentifier: 
+  itemName: Chest Lether Armour
+  description: A simple leather armour for some protection
+  icon: {fileID: 0}
+  model3D: {fileID: 0}
+  itemType: 1
+  rarity: 0
+  goldCost: 5
+  silverCost: 0
+  copperCost: 0
+  searchTags:
+  - lether
+  - chest
+  armorClass: 1
+  strengthModifier: 0
+  dexterityModifier: 0
+  constitutionModifier: 0
+  wisdomModifier: 0
+  armorType: 0
+  armorSlot: 1

+ 181 - 5
Assets/Scripts/Objects/Items/MiscellaneousItem.cs

@@ -1,5 +1,21 @@
 using UnityEngine;
 
+/// <summary>
+/// Miscellaneous items with dice-based restoration effects
+/// 
+/// EXAMPLES:
+/// Small Health Potion (1d6+1 = 2-7 health):
+/// - healthDiceCount: 1, healthDiceType: 6, healthBonus: 1
+/// 
+/// Large Health Potion (2d8+2 = 4-18 health):
+/// - healthDiceCount: 2, healthDiceType: 8, healthBonus: 2
+/// 
+/// Simple range-based (5-10 health):
+/// - healthDiceCount: 0, healthRestoreMin: 5, healthRestoreMax: 10
+/// 
+/// Weak Mana Potion (1d4 = 1-4 mana):
+/// - manaDiceCount: 1, manaDiceType: 4, manaBonus: 0
+/// </summary>
 [CreateAssetMenu(fileName = "New Misc Item", menuName = "RPG/Items/Miscellaneous")]
 [System.Serializable]
 public class MiscellaneousItem : Item
@@ -10,8 +26,29 @@ public class MiscellaneousItem : Item
     public int maxStackSize = 99;
 
     [Header("Effects (if consumable)")]
-    public int healthRestore;
-    public int manaRestore;
+    [Header("Health Restoration")]
+    [Tooltip("Minimum health restored (used when dice count is 0)")]
+    public int healthRestoreMin = 0;
+    [Tooltip("Maximum health restored (used when dice count is 0)")]
+    public int healthRestoreMax = 0;
+    [Tooltip("Number of dice to roll (e.g., 2 for 2d6). Leave 0 to use min/max directly")]
+    public int healthDiceCount = 0;
+    [Tooltip("Dice type (4, 6, 8, 10, 12, 20, etc.)")]
+    public int healthDiceType = 6;
+    [Tooltip("Flat bonus added to dice roll (can be negative)")]
+    public int healthBonus = 0;
+
+    [Header("Mana Restoration")]
+    [Tooltip("Minimum mana restored (used when dice count is 0)")]
+    public int manaRestoreMin = 0;
+    [Tooltip("Maximum mana restored (used when dice count is 0)")]
+    public int manaRestoreMax = 0;
+    [Tooltip("Number of dice to roll (e.g., 1 for 1d4). Leave 0 to use min/max directly")]
+    public int manaDiceCount = 0;
+    [Tooltip("Dice type (4, 6, 8, 10, 12, 20, etc.)")]
+    public int manaDiceType = 4;
+    [Tooltip("Flat bonus added to dice roll (can be negative)")]
+    public int manaBonus = 0;
     public int temporaryStrengthBonus;
     public int temporaryDexterityBonus;
     public int temporaryConstitutionBonus;
@@ -32,10 +69,21 @@ public class MiscellaneousItem : Item
         }
 
         // Apply effects
-        if (healthRestore > 0)
+        if (healthRestoreMax > 0 || healthDiceCount > 0)
+        {
+            int healthRestored = CalculateHealthRestore();
+            character.CurrentHealth = Mathf.Min(character.MaxHealth, character.CurrentHealth + healthRestored);
+            
+            string rollInfo = GetHealthRollDescription();
+            Debug.Log($"{character.CharacterName} restored {healthRestored} health from {itemName} {rollInfo}");
+        }
+
+        if (manaRestoreMax > 0 || manaDiceCount > 0)
         {
-            character.CurrentHealth = Mathf.Min(character.MaxHealth, character.CurrentHealth + healthRestore);
-            Debug.Log($"{character.CharacterName} restored {healthRestore} health from {itemName}");
+            int manaRestored = CalculateManaRestore();
+            string rollInfo = GetManaRollDescription();
+            Debug.Log($"{character.CharacterName} restored {manaRestored} mana from {itemName} {rollInfo}");
+            // TODO: Apply mana restoration when mana system is implemented
         }
 
         // Add temporary stat bonuses (would need a buff system to implement properly)
@@ -46,4 +94,132 @@ public class MiscellaneousItem : Item
             // TODO: Implement temporary buff system
         }
     }
+
+    /// <summary>
+    /// Calculate health restoration using dice rolls or min/max range
+    /// </summary>
+    private int CalculateHealthRestore()
+    {
+        if (healthDiceCount > 0 && healthDiceType > 0)
+        {
+            // Use dice system: XdY + bonus
+            int total = healthBonus;
+            for (int i = 0; i < healthDiceCount; i++)
+            {
+                total += Random.Range(1, healthDiceType + 1);
+            }
+            return total;
+        }
+        else if (healthRestoreMax > 0)
+        {
+            // Use min/max range
+            return Random.Range(healthRestoreMin, healthRestoreMax + 1);
+        }
+        return 0;
+    }
+
+    /// <summary>
+    /// Calculate mana restoration using dice rolls or min/max range
+    /// </summary>
+    private int CalculateManaRestore()
+    {
+        if (manaDiceCount > 0 && manaDiceType > 0)
+        {
+            // Use dice system: XdY + bonus
+            int total = manaBonus;
+            for (int i = 0; i < manaDiceCount; i++)
+            {
+                total += Random.Range(1, manaDiceType + 1);
+            }
+            return total;
+        }
+        else if (manaRestoreMax > 0)
+        {
+            // Use min/max range
+            return Random.Range(manaRestoreMin, manaRestoreMax + 1);
+        }
+        return 0;
+    }
+
+    /// <summary>
+    /// Get a description of the item's effects for tooltips
+    /// </summary>
+    public string GetEffectDescription()
+    {
+        string description = "";
+        
+        if (healthDiceCount > 0 && healthDiceType > 0)
+        {
+            description += $"Restores {healthDiceCount}d{healthDiceType}";
+            if (healthBonus > 0) description += $"+{healthBonus}";
+            else if (healthBonus < 0) description += $"{healthBonus}";
+            description += " health";
+        }
+        else if (healthRestoreMax > 0)
+        {
+            if (healthRestoreMin == healthRestoreMax)
+                description += $"Restores {healthRestoreMax} health";
+            else
+                description += $"Restores {healthRestoreMin}-{healthRestoreMax} health";
+        }
+
+        if (manaDiceCount > 0 && manaDiceType > 0)
+        {
+            if (description.Length > 0) description += "\n";
+            description += $"Restores {manaDiceCount}d{manaDiceType}";
+            if (manaBonus > 0) description += $"+{manaBonus}";
+            else if (manaBonus < 0) description += $"{manaBonus}";
+            description += " mana";
+        }
+        else if (manaRestoreMax > 0)
+        {
+            if (description.Length > 0) description += "\n";
+            if (manaRestoreMin == manaRestoreMax)
+                description += $"Restores {manaRestoreMax} mana";
+            else
+                description += $"Restores {manaRestoreMin}-{manaRestoreMax} mana";
+        }
+
+        return description;
+    }
+
+    /// <summary>
+    /// Get description of the health roll for debug/UI purposes
+    /// </summary>
+    private string GetHealthRollDescription()
+    {
+        if (healthDiceCount > 0 && healthDiceType > 0)
+        {
+            string desc = $"({healthDiceCount}d{healthDiceType}";
+            if (healthBonus > 0) desc += $"+{healthBonus}";
+            else if (healthBonus < 0) desc += $"{healthBonus}";
+            desc += ")";
+            return desc;
+        }
+        else if (healthRestoreMax > 0)
+        {
+            return $"({healthRestoreMin}-{healthRestoreMax})";
+        }
+        return "";
+    }
+
+    /// <summary>
+    /// Get description of the mana roll for debug/UI purposes
+    /// </summary>
+    private string GetManaRollDescription()
+    {
+        if (manaDiceCount > 0 && manaDiceType > 0)
+        {
+            string desc = $"({manaDiceCount}d{manaDiceType}";
+            if (manaBonus > 0) desc += $"+{manaBonus}";
+            else if (manaBonus < 0) desc += $"{manaBonus}";
+            desc += ")";
+            return desc;
+        }
+        else if (manaRestoreMax > 0)
+        {
+            return $"({manaRestoreMin}-{manaRestoreMax})";
+        }
+        return "";
+    }
 }

+ 45 - 0
Assets/Scripts/Objects/Items/SmalHealthPotion.asset

@@ -0,0 +1,45 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 43b6eb6d169fa44439fbdc878d83e78b, type: 3}
+  m_Name: SmalHealthPotion
+  m_EditorClassIdentifier: 
+  itemName: Small Health potion
+  description: A small health potion 1d6 + 1
+  icon: {fileID: 0}
+  model3D: {fileID: 0}
+  itemType: 2
+  rarity: 0
+  goldCost: 4
+  silverCost: 0
+  copperCost: 0
+  searchTags:
+  - helath
+  - potion
+  - healing
+  isConsumable: 1
+  isStackable: 1
+  maxStackSize: 99
+  healthRestoreMin: 0
+  healthRestoreMax: 0
+  healthDiceCount: 1
+  healthDiceType: 6
+  healthBonus: 1
+  manaRestoreMin: 0
+  manaRestoreMax: 0
+  manaDiceCount: 0
+  manaDiceType: 0
+  manaBonus: 0
+  temporaryStrengthBonus: 0
+  temporaryDexterityBonus: 0
+  temporaryConstitutionBonus: 0
+  temporaryWisdomBonus: 0
+  effectDuration: 0

+ 4 - 2
Assets/Scripts/Utilities/SampleItemCreator.cs

@@ -128,8 +128,10 @@ public class SampleItemCreator : MonoBehaviour
         healthPotion.isConsumable = true;
         healthPotion.isStackable = true;
         healthPotion.maxStackSize = 10;
-        healthPotion.healthRestore = 15;
-        healthPotion.goldCost = 3;
+        healthPotion.healthDiceType = 6;
+        healthPotion.healthDiceCount = 1;
+        healthPotion.healthBonus = 1;
+        healthPotion.goldCost = 4;
         healthPotion.searchTags = new string[] { "potion", "health", "healing", "consumable" };
 
         // Rope