big changes
This commit is contained in:
@@ -0,0 +1,228 @@
|
||||
using Server.Data.Enums;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Default mob templates for seeding the database
|
||||
/// </summary>
|
||||
public static class DefaultDungeonMobs
|
||||
{
|
||||
public static List<DungeonMobDefinition> GetDefaultMobs() => new()
|
||||
{
|
||||
// Tier 1 - Basic enemies
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Skeleton",
|
||||
Description = "A reanimated pile of bones",
|
||||
Type = MobType.Normal,
|
||||
Category = MobCategory.Undead,
|
||||
MinTier = 1,
|
||||
BaseHealth = 40,
|
||||
BasePhysicalDamage = 5,
|
||||
BaseArmor = 5,
|
||||
MoveSpeed = 55f,
|
||||
AttackRange = 40f,
|
||||
AttackSpeed = 0.8f,
|
||||
AggroRange = 120f,
|
||||
BaseXp = 15,
|
||||
ResistancesJson = """{"poison": 1.0, "holy": -0.5}""",
|
||||
SpriteSheet = "mobs/skeleton.png"
|
||||
},
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 2,
|
||||
Name = "Zombie",
|
||||
Description = "A shambling corpse",
|
||||
Type = MobType.Normal,
|
||||
Category = MobCategory.Undead,
|
||||
MinTier = 1,
|
||||
BaseHealth = 60,
|
||||
BasePhysicalDamage = 8,
|
||||
BaseArmor = 0,
|
||||
MoveSpeed = 35f,
|
||||
AttackRange = 35f,
|
||||
AttackSpeed = 0.5f,
|
||||
AggroRange = 100f,
|
||||
BaseXp = 12,
|
||||
ResistancesJson = """{"poison": 1.0, "fire": -0.25, "holy": -0.5}""",
|
||||
SpriteSheet = "mobs/zombie.png"
|
||||
},
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 3,
|
||||
Name = "Giant Rat",
|
||||
Description = "An oversized rodent",
|
||||
Type = MobType.Swarm,
|
||||
Category = MobCategory.Beast,
|
||||
MinTier = 1,
|
||||
BaseHealth = 20,
|
||||
BasePhysicalDamage = 3,
|
||||
BaseArmor = 0,
|
||||
MoveSpeed = 80f,
|
||||
AttackRange = 30f,
|
||||
AttackSpeed = 1.5f,
|
||||
AggroRange = 80f,
|
||||
BaseXp = 5,
|
||||
ResistancesJson = """{"poison": 0.5}""",
|
||||
SpriteSheet = "mobs/rat.png"
|
||||
},
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 4,
|
||||
Name = "Giant Spider",
|
||||
Description = "A venomous arachnid",
|
||||
Type = MobType.Normal,
|
||||
Category = MobCategory.Beast,
|
||||
MinTier = 1,
|
||||
BaseHealth = 35,
|
||||
BasePhysicalDamage = 4,
|
||||
BaseMagicDamage = 3, // Poison
|
||||
BaseArmor = 2,
|
||||
MoveSpeed = 70f,
|
||||
AttackRange = 35f,
|
||||
AttackSpeed = 1.2f,
|
||||
AggroRange = 130f,
|
||||
BaseXp = 18,
|
||||
ResistancesJson = """{"poison": 1.0}""",
|
||||
AbilitiesJson = """{"poisonOnHit": true, "poisonDamage": 2, "poisonDuration": 3}""",
|
||||
SpriteSheet = "mobs/spider.png"
|
||||
},
|
||||
|
||||
// Tier 1 Elite
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 10,
|
||||
Name = "Skeleton Knight",
|
||||
Description = "An armored skeleton warrior",
|
||||
Type = MobType.Elite,
|
||||
Category = MobCategory.Undead,
|
||||
MinTier = 1,
|
||||
BaseHealth = 120,
|
||||
BasePhysicalDamage = 12,
|
||||
BaseArmor = 20,
|
||||
MoveSpeed = 50f,
|
||||
AttackRange = 45f,
|
||||
AttackSpeed = 0.7f,
|
||||
AggroRange = 150f,
|
||||
BaseXp = 50,
|
||||
ResistancesJson = """{"poison": 1.0, "holy": -0.5, "physical": 0.1}""",
|
||||
SpriteSheet = "mobs/skeleton_knight.png"
|
||||
},
|
||||
|
||||
// Tier 1 Boss
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 100,
|
||||
Name = "The Bone Lord",
|
||||
Description = "A massive skeleton wielding dark magic",
|
||||
Type = MobType.Boss,
|
||||
Category = MobCategory.Undead,
|
||||
MinTier = 1,
|
||||
MaxTier = 2,
|
||||
BaseHealth = 500,
|
||||
BaseMana = 100,
|
||||
BasePhysicalDamage = 20,
|
||||
BaseMagicDamage = 15,
|
||||
BaseArmor = 30,
|
||||
BaseMagicResist = 20,
|
||||
MoveSpeed = 40f,
|
||||
AttackRange = 50f,
|
||||
AttackSpeed = 0.6f,
|
||||
AggroRange = 300f,
|
||||
LeashRange = 800f,
|
||||
BaseXp = 500,
|
||||
ResistancesJson = """{"poison": 1.0, "dark": 0.5, "holy": -0.75}""",
|
||||
AbilitiesJson = """{"summonSkeletons": true, "summonCount": 3, "summonCooldown": 15}""",
|
||||
SpriteSheet = "mobs/bone_lord.png",
|
||||
SpriteWidth = 64,
|
||||
SpriteHeight = 64
|
||||
},
|
||||
|
||||
// Tier 2 - Intermediate enemies
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 20,
|
||||
Name = "Imp",
|
||||
Description = "A small demonic creature",
|
||||
Type = MobType.Normal,
|
||||
Category = MobCategory.Demon,
|
||||
MinTier = 2,
|
||||
BaseHealth = 45,
|
||||
BaseMagicDamage = 8,
|
||||
BaseMagicResist = 15,
|
||||
MoveSpeed = 75f,
|
||||
AttackRange = 100f, // Ranged
|
||||
AttackSpeed = 1.0f,
|
||||
AggroRange = 180f,
|
||||
BaseXp = 25,
|
||||
ResistancesJson = """{"fire": 0.75, "holy": -0.5}""",
|
||||
SpriteSheet = "mobs/imp.png"
|
||||
},
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 21,
|
||||
Name = "Cultist",
|
||||
Description = "A dark magic practitioner",
|
||||
Type = MobType.Normal,
|
||||
Category = MobCategory.Humanoid,
|
||||
MinTier = 2,
|
||||
BaseHealth = 50,
|
||||
BaseMagicDamage = 10,
|
||||
BaseArmor = 5,
|
||||
BaseMagicResist = 10,
|
||||
MoveSpeed = 55f,
|
||||
AttackRange = 120f, // Ranged
|
||||
AttackSpeed = 0.8f,
|
||||
AggroRange = 200f,
|
||||
BaseXp = 30,
|
||||
ResistancesJson = """{"dark": 0.25, "holy": -0.25}""",
|
||||
SpriteSheet = "mobs/cultist.png"
|
||||
},
|
||||
|
||||
// Tier 3 - Advanced enemies
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 30,
|
||||
Name = "Stone Golem",
|
||||
Description = "An animated statue",
|
||||
Type = MobType.Elite,
|
||||
Category = MobCategory.Construct,
|
||||
MinTier = 3,
|
||||
BaseHealth = 300,
|
||||
BasePhysicalDamage = 25,
|
||||
BaseArmor = 50,
|
||||
BaseMagicResist = 30,
|
||||
MoveSpeed = 30f,
|
||||
AttackRange = 50f,
|
||||
AttackSpeed = 0.4f,
|
||||
AggroRange = 100f,
|
||||
BaseXp = 100,
|
||||
ResistancesJson = """{"poison": 1.0, "physical": 0.3, "lightning": -0.25}""",
|
||||
SpriteSheet = "mobs/golem.png",
|
||||
SpriteWidth = 48,
|
||||
SpriteHeight = 48
|
||||
},
|
||||
new DungeonMobDefinition
|
||||
{
|
||||
Id = 31,
|
||||
Name = "Fire Elemental",
|
||||
Description = "A living flame",
|
||||
Type = MobType.Normal,
|
||||
Category = MobCategory.Elemental,
|
||||
MinTier = 3,
|
||||
BaseHealth = 80,
|
||||
BaseMagicDamage = 18,
|
||||
BaseMagicResist = 25,
|
||||
MoveSpeed = 65f,
|
||||
AttackRange = 80f,
|
||||
AttackSpeed = 1.2f,
|
||||
AggroRange = 160f,
|
||||
BaseXp = 45,
|
||||
ResistancesJson = """{"fire": 1.0, "ice": -0.75, "physical": 0.5}""",
|
||||
AbilitiesJson = """{"burnOnHit": true, "burnDamage": 5, "burnDuration": 4}""",
|
||||
SpriteSheet = "mobs/fire_elemental.png",
|
||||
TintColor = "#ff6600"
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Persistent player character with stats and equipment for dungeon crawler
|
||||
/// </summary>
|
||||
[Table("dungeon_characters")]
|
||||
public class DungeonCharacter
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public ulong AccountId { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(32)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime LastPlayedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Progression
|
||||
public int Level { get; set; } = 1;
|
||||
public long Experience { get; set; } = 0;
|
||||
public int UnspentStatPoints { get; set; } = 5; // Start with 5 points
|
||||
|
||||
// Core Stats (5 points per level to distribute)
|
||||
public int Strength { get; set; } = 1; // Physical damage, heavy equipment
|
||||
public int Intelligence { get; set; } = 1; // Spell damage, magical equipment
|
||||
public int Wisdom { get; set; } = 1; // Max mana, XP bonus, spell learning
|
||||
public int Endurance { get; set; } = 1; // Max HP, max stamina, regen rate
|
||||
public int Dexterity { get; set; } = 1; // Move speed, attack speed, light equipment
|
||||
|
||||
// Derived stats (calculated from base stats)
|
||||
[NotMapped] public int MaxHealth => 50 + (Endurance * 10);
|
||||
[NotMapped] public int MaxMana => 20 + (Wisdom * 8);
|
||||
[NotMapped] public int MaxStamina => 50 + (Endurance * 5);
|
||||
[NotMapped] public float XpBonus => 1.0f + (Wisdom * 0.02f); // 2% per WIS
|
||||
[NotMapped] public float MoveSpeed => 100f + (Dexterity * 2f);
|
||||
[NotMapped] public float AttackSpeed => 1.0f + (Dexterity * 0.02f);
|
||||
[NotMapped] public float RegenRate => 1.0f + (Endurance * 0.1f); // HP/Mana/Stamina regen multiplier
|
||||
|
||||
// Current state (saved on logout/death)
|
||||
public int CurrentHealth { get; set; } = 50;
|
||||
public int CurrentMana { get; set; } = 20;
|
||||
|
||||
// Equipment slots (ItemId references, null = empty)
|
||||
public ulong? EquippedWeapon { get; set; }
|
||||
public ulong? EquippedOffhand { get; set; }
|
||||
public ulong? EquippedHead { get; set; }
|
||||
public ulong? EquippedChest { get; set; }
|
||||
public ulong? EquippedLegs { get; set; }
|
||||
public ulong? EquippedBoots { get; set; }
|
||||
public ulong? EquippedGloves { get; set; }
|
||||
public ulong? EquippedAccessory { get; set; }
|
||||
|
||||
// Lifetime stats
|
||||
public int TotalKills { get; set; }
|
||||
public int TotalDeaths { get; set; }
|
||||
public int PlayersKilled { get; set; }
|
||||
public int DungeonsCompleted { get; set; }
|
||||
public int BossesKilled { get; set; }
|
||||
|
||||
// Soft delete
|
||||
public bool IsDeleted { get; set; } = false;
|
||||
|
||||
// Navigation
|
||||
public virtual Account? Account { get; set; }
|
||||
public virtual ICollection<DungeonCharacterItem> Inventory { get; set; } = new List<DungeonCharacterItem>();
|
||||
public virtual ICollection<DungeonStashItem> Stash { get; set; } = new List<DungeonStashItem>();
|
||||
public virtual ICollection<DungeonLearnedSpell> LearnedSpells { get; set; } = new List<DungeonLearnedSpell>();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
public class DungeonCharacterCombatStats
|
||||
{
|
||||
public int Strength { get; set; }
|
||||
public int Intelligence { get; set; }
|
||||
public int Wisdom { get; set; }
|
||||
public int Endurance { get; set; }
|
||||
public int Dexterity { get; set; }
|
||||
public int MaxHealth { get; set; }
|
||||
public int MaxMana { get; set; }
|
||||
public int MaxStamina { get; set; }
|
||||
public int BonusHealth { get; set; }
|
||||
public int BonusMana { get; set; }
|
||||
public int Armor { get; set; }
|
||||
public int MagicResist { get; set; }
|
||||
public float MoveSpeed { get; set; }
|
||||
public float AttackSpeed { get; set; }
|
||||
public float RegenRate { get; set; }
|
||||
public float PhysicalDamageMultiplier { get; set; }
|
||||
public float SpellDamageMultiplier { get; set; }
|
||||
public float XpBonus { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Actual item instance owned by a character (inventory or equipped)
|
||||
/// </summary>
|
||||
[Table("dungeon_character_items")]
|
||||
public class DungeonCharacterItem
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
public ulong CharacterId { get; set; }
|
||||
public int ItemDefinitionId { get; set; }
|
||||
|
||||
public int Quantity { get; set; } = 1;
|
||||
public int SlotIndex { get; set; } // Inventory position (0-29 for example)
|
||||
|
||||
public DateTime AcquiredAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation
|
||||
public virtual DungeonCharacter? Character { get; set; }
|
||||
public virtual DungeonItemDefinition? Definition { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Derived stats calculator - used at runtime
|
||||
/// </summary>
|
||||
public static class DungeonCharacterStats
|
||||
{
|
||||
public static int GetMaxHealth(DungeonCharacter c) => 50 + (c.Endurance * 10);
|
||||
public static int GetMaxMana(DungeonCharacter c) => 20 + (c.Wisdom * 8);
|
||||
public static int GetMaxStamina(DungeonCharacter c) => 50 + (c.Endurance * 5);
|
||||
public static float GetXpBonus(DungeonCharacter c) => 1.0f + (c.Wisdom * 0.02f);
|
||||
public static float GetMoveSpeed(DungeonCharacter c) => 100f + (c.Dexterity * 2f);
|
||||
public static float GetAttackSpeed(DungeonCharacter c) => 1.0f + (c.Dexterity * 0.02f);
|
||||
public static float GetRegenRate(DungeonCharacter c) => 1.0f + (c.Endurance * 0.1f);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate combat stats including equipment bonuses
|
||||
/// </summary>
|
||||
public static DungeonCharacterCombatStats GetCombatStats(DungeonCharacter c, List<DungeonItemDefinition>? equippedItems = null)
|
||||
{
|
||||
var stats = new DungeonCharacterCombatStats
|
||||
{
|
||||
Strength = c.Strength,
|
||||
Intelligence = c.Intelligence,
|
||||
Wisdom = c.Wisdom,
|
||||
Endurance = c.Endurance,
|
||||
Dexterity = c.Dexterity
|
||||
};
|
||||
|
||||
if (equippedItems != null)
|
||||
{
|
||||
foreach (var item in equippedItems)
|
||||
{
|
||||
stats.Strength += item.BonusStrength;
|
||||
stats.Intelligence += item.BonusIntelligence;
|
||||
stats.Wisdom += item.BonusWisdom;
|
||||
stats.Endurance += item.BonusEndurance;
|
||||
stats.Dexterity += item.BonusDexterity;
|
||||
stats.BonusHealth += item.BonusHealth;
|
||||
stats.BonusMana += item.BonusMana;
|
||||
stats.Armor += item.Armor;
|
||||
stats.MagicResist += item.MagicResist;
|
||||
}
|
||||
}
|
||||
|
||||
stats.MaxHealth = 50 + (stats.Endurance * 10) + stats.BonusHealth;
|
||||
stats.MaxMana = 20 + (stats.Wisdom * 8) + stats.BonusMana;
|
||||
stats.MaxStamina = 50 + (stats.Endurance * 5);
|
||||
stats.MoveSpeed = 100f + (stats.Dexterity * 2f);
|
||||
stats.AttackSpeed = 1.0f + (stats.Dexterity * 0.02f);
|
||||
stats.RegenRate = 1.0f + (stats.Endurance * 0.1f);
|
||||
stats.PhysicalDamageMultiplier = 1.0f + (stats.Strength * 0.05f);
|
||||
stats.SpellDamageMultiplier = 1.0f + (stats.Intelligence * 0.05f);
|
||||
stats.XpBonus = 1.0f + (stats.Wisdom * 0.02f);
|
||||
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Server.Data.Enums;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Item template/definition - what an item IS
|
||||
/// </summary>
|
||||
[Table("dungeon_item_definitions")]
|
||||
public class DungeonItemDefinition
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[MaxLength(256)]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public ItemType Type { get; set; }
|
||||
public ItemRarity Rarity { get; set; } = ItemRarity.Common;
|
||||
public DungeonEquipmentSlot? EquipSlot { get; set; } // Null if not equippable
|
||||
|
||||
// Stat requirements to equip/use
|
||||
public int RequiredStrength { get; set; } = 0;
|
||||
public int RequiredIntelligence { get; set; } = 0;
|
||||
public int RequiredWisdom { get; set; } = 0;
|
||||
public int RequiredDexterity { get; set; } = 0;
|
||||
public int RequiredLevel { get; set; } = 1;
|
||||
|
||||
// Stat bonuses when equipped
|
||||
public int BonusStrength { get; set; } = 0;
|
||||
public int BonusIntelligence { get; set; } = 0;
|
||||
public int BonusWisdom { get; set; } = 0;
|
||||
public int BonusEndurance { get; set; } = 0;
|
||||
public int BonusDexterity { get; set; } = 0;
|
||||
public int BonusHealth { get; set; } = 0;
|
||||
public int BonusMana { get; set; } = 0;
|
||||
|
||||
// Weapon stats
|
||||
public int MinDamage { get; set; } = 0;
|
||||
public int MaxDamage { get; set; } = 0;
|
||||
public float AttackRange { get; set; } = 0; // 0 = melee
|
||||
public DamageType DamageType { get; set; } = DamageType.Physical;
|
||||
|
||||
// Armor stats
|
||||
public int Armor { get; set; } = 0;
|
||||
public int MagicResist { get; set; } = 0;
|
||||
|
||||
// Consumable effects
|
||||
public int HealAmount { get; set; } = 0;
|
||||
public int ManaRestore { get; set; } = 0;
|
||||
public int StaminaRestore { get; set; } = 0;
|
||||
|
||||
// Special
|
||||
public bool IsTeleportScroll { get; set; } = false;
|
||||
public int? TeachesSpellId { get; set; } // For spell tomes
|
||||
|
||||
// Stacking
|
||||
public bool Stackable { get; set; } = false;
|
||||
public int MaxStack { get; set; } = 1;
|
||||
|
||||
// Visuals
|
||||
public int SpriteId { get; set; } = 0;
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Spells a character has learned
|
||||
/// </summary>
|
||||
[Table("dungeon_learned_spells")]
|
||||
public class DungeonLearnedSpell
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
public ulong CharacterId { get; set; }
|
||||
public int SpellDefinitionId { get; set; }
|
||||
|
||||
public DateTime LearnedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Could add spell levels/upgrades later
|
||||
public int SpellLevel { get; set; } = 1;
|
||||
|
||||
// Navigation
|
||||
public virtual DungeonCharacter? Character { get; set; }
|
||||
public virtual DungeonSpellDefinition? Definition { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using Server.Data.Enums;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Runtime combat stats for a mob instance
|
||||
/// </summary>
|
||||
public class DungeonMobCombatStats
|
||||
{
|
||||
public int MaxHealth { get; set; }
|
||||
public int PhysicalDamage { get; set; }
|
||||
public int MagicDamage { get; set; }
|
||||
public int Armor { get; set; }
|
||||
public int MagicResist { get; set; }
|
||||
public float MoveSpeed { get; set; }
|
||||
public float AttackRange { get; set; }
|
||||
public float AttackSpeed { get; set; }
|
||||
public float AggroRange { get; set; }
|
||||
public float LeashRange { get; set; }
|
||||
public int XpReward { get; set; }
|
||||
public Dictionary<string, float> Resistances { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Calculate damage after resistances
|
||||
/// </summary>
|
||||
public int CalculateDamage(int rawDamage, DamageType damageType)
|
||||
{
|
||||
string typeKey = damageType.ToString().ToLower();
|
||||
|
||||
// Check for resistance/weakness
|
||||
if (Resistances.TryGetValue(typeKey, out float resistance))
|
||||
{
|
||||
if (resistance >= 1.0f) return 0; // Immune
|
||||
return (int)(rawDamage * (1.0f - resistance));
|
||||
}
|
||||
|
||||
// Physical/Magic armor reduction
|
||||
if (damageType == DamageType.Physical && Armor > 0)
|
||||
{
|
||||
// Armor formula: damage reduction = armor / (armor + 100)
|
||||
float reduction = Armor / (float)(Armor + 100);
|
||||
return (int)(rawDamage * (1.0f - reduction));
|
||||
}
|
||||
|
||||
if (damageType != DamageType.Physical && MagicResist > 0)
|
||||
{
|
||||
float reduction = MagicResist / (float)(MagicResist + 100);
|
||||
return (int)(rawDamage * (1.0f - reduction));
|
||||
}
|
||||
|
||||
return rawDamage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json;
|
||||
using Server.Data.Enums;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Monster/NPC template definition stored in database
|
||||
/// </summary>
|
||||
[Table("dungeon_mob_definitions")]
|
||||
public class DungeonMobDefinition
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[MaxLength(256)]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public MobType Type { get; set; } = MobType.Normal;
|
||||
public MobCategory Category { get; set; } = MobCategory.Undead;
|
||||
|
||||
public int MinTier { get; set; } = 1; // Minimum dungeon tier to spawn
|
||||
public int MaxTier { get; set; } = 99; // Maximum tier (for progression gating)
|
||||
|
||||
// Base Combat Stats
|
||||
public int BaseHealth { get; set; } = 50;
|
||||
public int BaseMana { get; set; } = 0;
|
||||
public int BasePhysicalDamage { get; set; } = 5;
|
||||
public int BaseMagicDamage { get; set; } = 0;
|
||||
public int BaseArmor { get; set; } = 0;
|
||||
public int BaseMagicResist { get; set; } = 0;
|
||||
|
||||
// Movement & Combat
|
||||
public float MoveSpeed { get; set; } = 60f;
|
||||
public float AttackRange { get; set; } = 40f; // Melee range ~40, ranged 150+
|
||||
public float AttackSpeed { get; set; } = 1.0f; // Attacks per second
|
||||
public float AggroRange { get; set; } = 150f; // Detection radius
|
||||
public float LeashRange { get; set; } = 400f; // Max chase distance before reset
|
||||
|
||||
// Scaling per dungeon tier (multipliers)
|
||||
public float HealthPerTier { get; set; } = 1.2f;
|
||||
public float DamagePerTier { get; set; } = 1.15f;
|
||||
public float ArmorPerTier { get; set; } = 1.1f;
|
||||
|
||||
// Experience & Loot
|
||||
public int BaseXp { get; set; } = 10;
|
||||
public float XpPerTier { get; set; } = 1.25f;
|
||||
public int LootTableId { get; set; } = 0; // Reference to loot_tables
|
||||
public float DropChanceMultiplier { get; set; } = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// JSON block for resistances/weaknesses
|
||||
/// Example: {"fire": -0.25, "ice": 0.5, "poison": 1.0}
|
||||
/// Negative = weakness (takes more damage), Positive = resistance (takes less), 1.0 = immune
|
||||
/// </summary>
|
||||
[MaxLength(1024)]
|
||||
public string ResistancesJson { get; set; } = "{}";
|
||||
|
||||
/// <summary>
|
||||
/// JSON block for special abilities/behaviors
|
||||
/// Example: {"canFlee": true, "fleeHealthPercent": 0.2, "callsForHelp": true}
|
||||
/// </summary>
|
||||
[MaxLength(1024)]
|
||||
public string AbilitiesJson { get; set; } = "{}";
|
||||
|
||||
// Visuals - reference to sprite/animation
|
||||
[MaxLength(128)]
|
||||
public string SpriteSheet { get; set; } = "mobs/skeleton.png";
|
||||
public int SpriteIndex { get; set; } = 0; // Index in spritesheet
|
||||
public int SpriteWidth { get; set; } = 32;
|
||||
public int SpriteHeight { get; set; } = 32;
|
||||
|
||||
[MaxLength(16)]
|
||||
public string TintColor { get; set; } = "#ffffff"; // Color tint for variants
|
||||
|
||||
// Animation frames (JSON array of frame indices)
|
||||
[MaxLength(256)]
|
||||
public string IdleFrames { get; set; } = "[0]";
|
||||
[MaxLength(256)]
|
||||
public string WalkFrames { get; set; } = "[0,1,2,3]";
|
||||
[MaxLength(256)]
|
||||
public string AttackFrames { get; set; } = "[4,5]";
|
||||
[MaxLength(256)]
|
||||
public string DeathFrames { get; set; } = "[6,7]";
|
||||
|
||||
public float AnimationSpeed { get; set; } = 8f; // Frames per second
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
// Helper methods for JSON parsing
|
||||
[NotMapped]
|
||||
public Dictionary<string, float> Resistances
|
||||
{
|
||||
get
|
||||
{
|
||||
try { return JsonSerializer.Deserialize<Dictionary<string, float>>(ResistancesJson) ?? new(); }
|
||||
catch { return new(); }
|
||||
}
|
||||
set { ResistancesJson = JsonSerializer.Serialize(value); }
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<string, object> Abilities
|
||||
{
|
||||
get
|
||||
{
|
||||
try { return JsonSerializer.Deserialize<Dictionary<string, object>>(AbilitiesJson) ?? new(); }
|
||||
catch { return new(); }
|
||||
}
|
||||
set { AbilitiesJson = JsonSerializer.Serialize(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate scaled stats for a specific dungeon tier
|
||||
/// </summary>
|
||||
public DungeonMobCombatStats GetStatsForTier(int tier)
|
||||
{
|
||||
return new DungeonMobCombatStats
|
||||
{
|
||||
MaxHealth = (int)(BaseHealth * Math.Pow(HealthPerTier, tier - 1)),
|
||||
PhysicalDamage = (int)(BasePhysicalDamage * Math.Pow(DamagePerTier, tier - 1)),
|
||||
MagicDamage = (int)(BaseMagicDamage * Math.Pow(DamagePerTier, tier - 1)),
|
||||
Armor = (int)(BaseArmor * Math.Pow(ArmorPerTier, tier - 1)),
|
||||
MagicResist = (int)(BaseMagicResist * Math.Pow(ArmorPerTier, tier - 1)),
|
||||
MoveSpeed = MoveSpeed,
|
||||
AttackRange = AttackRange,
|
||||
AttackSpeed = AttackSpeed,
|
||||
AggroRange = AggroRange,
|
||||
LeashRange = LeashRange,
|
||||
XpReward = (int)(BaseXp * Math.Pow(XpPerTier, tier - 1)),
|
||||
Resistances = Resistances
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Server.Data.Enums;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Spell definition - learnable abilities
|
||||
/// </summary>
|
||||
[Table("dungeon_spell_definitions")]
|
||||
public class DungeonSpellDefinition
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[MaxLength(256)]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public SpellType Type { get; set; }
|
||||
|
||||
// Requirements
|
||||
public int RequiredWisdom { get; set; } = 1;
|
||||
public int RequiredIntelligence { get; set; } = 0;
|
||||
public int RequiredLevel { get; set; } = 1;
|
||||
|
||||
// Costs
|
||||
public int ManaCost { get; set; } = 10;
|
||||
public float Cooldown { get; set; } = 1.0f; // Seconds
|
||||
|
||||
// Effects
|
||||
public int BaseDamage { get; set; } = 0; // Scales with INT
|
||||
public int BaseHealing { get; set; } = 0; // Scales with WIS
|
||||
public float Range { get; set; } = 100f;
|
||||
public float AreaOfEffect { get; set; } = 0; // 0 = single target
|
||||
|
||||
// Special
|
||||
public bool IsTeleport { get; set; } = false;
|
||||
public bool IsShield { get; set; } = false;
|
||||
public int ShieldAmount { get; set; } = 0;
|
||||
|
||||
// Visuals
|
||||
public int SpriteId { get; set; } = 0;
|
||||
public string EffectColor { get; set; } = "#ffffff";
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Items stored in character's stash (safe storage in hub)
|
||||
/// </summary>
|
||||
[Table("dungeon_stash_items")]
|
||||
public class DungeonStashItem
|
||||
{
|
||||
[Key]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
public ulong CharacterId { get; set; }
|
||||
public int ItemDefinitionId { get; set; }
|
||||
|
||||
public int Quantity { get; set; } = 1;
|
||||
public int SlotIndex { get; set; }
|
||||
|
||||
public DateTime StoredAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation
|
||||
public virtual DungeonCharacter? Character { get; set; }
|
||||
public virtual DungeonItemDefinition? Definition { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace Server.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Experience required per level (exponential curve)
|
||||
/// </summary>
|
||||
public static class LevelSystem
|
||||
{
|
||||
public static long GetXpForLevel(int level)
|
||||
{
|
||||
// Base 100 XP for level 2, scaling exponentially
|
||||
return (long)(100 * Math.Pow(1.15, level - 1));
|
||||
}
|
||||
|
||||
public static long GetTotalXpForLevel(int level)
|
||||
{
|
||||
long total = 0;
|
||||
for (int i = 1; i < level; i++)
|
||||
total += GetXpForLevel(i);
|
||||
return total;
|
||||
}
|
||||
|
||||
public static int GetLevelForXp(long totalXp)
|
||||
{
|
||||
int level = 1;
|
||||
long xpNeeded = 0;
|
||||
while (xpNeeded <= totalXp)
|
||||
{
|
||||
xpNeeded += GetXpForLevel(level);
|
||||
if (xpNeeded <= totalXp) level++;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user