90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
|
|
// --- Supporting Data Structures ---
|
|
|
|
[System.Serializable]
|
|
public struct LootDrop
|
|
{
|
|
public Item item;
|
|
[Range(0f, 1f)]
|
|
[Tooltip("The chance of this item dropping, from 0.0 (0%) to 1.0 (100%).")]
|
|
public float dropChance;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public struct DamageModifier
|
|
{
|
|
public DamageType type;
|
|
[Tooltip("Multiplier for damage taken. e.g., 2.0 for vulnerability, 0.5 for resistance, 0 for immunity.")]
|
|
public float multiplier;
|
|
}
|
|
|
|
// --- Main NPC Profile ---
|
|
|
|
[CreateAssetMenu(fileName = "New NPC Profile", menuName = "RPGbook/NPC Profile")]
|
|
public class NPCProfile : ScriptableObject
|
|
{
|
|
[Header("Basic Info")]
|
|
public string npcName = "New NPC";
|
|
public enum NPCType { Human, Creature, Undead, Elemental }
|
|
public NPCType type;
|
|
public enum Disposition { Friendly, Neutral, Hostile }
|
|
public Disposition disposition;
|
|
|
|
[Tooltip("The prefab to spawn for this NPC's visual representation.")]
|
|
public GameObject characterPrefab;
|
|
|
|
[Header("Stats")]
|
|
public int level = 1;
|
|
public int maxHealth = 10;
|
|
public int maxMana = 0;
|
|
public int armorClass = 10;
|
|
public int strength = 10;
|
|
public int dexterity = 10;
|
|
|
|
[Header("Combat")]
|
|
[Tooltip("The list of attacks this NPC can choose from.")]
|
|
public List<AttackDefinition> attacks;
|
|
public enum AttackPattern { Aggressive, Defensive, Caster, Balanced }
|
|
[Tooltip("A hint for the AI on how to behave in combat.")]
|
|
public AttackPattern attackStyle;
|
|
|
|
[Header("Strengths & Weaknesses")]
|
|
[Tooltip("A list of damage types this NPC is resistant or vulnerable to.")]
|
|
public List<DamageModifier> damageModifiers;
|
|
|
|
[Header("Rewards")]
|
|
[Tooltip("Experience points awarded for defeating this NPC.")]
|
|
public int experienceAwarded = 5;
|
|
|
|
[Tooltip("Items that are guaranteed to drop.")]
|
|
public List<Item> guaranteedLoot;
|
|
|
|
[Tooltip("Items that have a chance to drop.")]
|
|
public List<LootDrop> randomLootTable;
|
|
|
|
public List<Item> GetLootDrops()
|
|
{
|
|
List<Item> droppedItems = new List<Item>();
|
|
if (guaranteedLoot != null) { droppedItems.AddRange(guaranteedLoot); }
|
|
|
|
if (randomLootTable != null)
|
|
{
|
|
foreach (var drop in randomLootTable)
|
|
{
|
|
if (Random.value <= drop.dropChance) { droppedItems.Add(drop.item); }
|
|
}
|
|
}
|
|
return droppedItems;
|
|
}
|
|
|
|
public float GetDamageMultiplier(DamageType type)
|
|
{
|
|
foreach (var modifier in damageModifiers)
|
|
{
|
|
if (modifier.type == type) { return modifier.multiplier; }
|
|
}
|
|
return 1.0f;
|
|
}
|
|
} |