Mob AIv2 and player speed cap
This commit is contained in:
@@ -5,11 +5,15 @@ namespace DataServer.Data.Entities;
|
||||
/// </summary>
|
||||
public static class DungeonCharacterStats
|
||||
{
|
||||
private const float BaseSpeed = 100f;
|
||||
private const float DexSpeedModifier = 0.5f; // Reduced from 2f
|
||||
private const float MaxSpeed = 500f;
|
||||
|
||||
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 GetMoveSpeed(DungeonCharacter c) => Math.Min(MaxSpeed, BaseSpeed + (c.Dexterity * DexSpeedModifier));
|
||||
public static float GetAttackSpeed(DungeonCharacter c) => 1.0f + (c.Dexterity * 0.02f);
|
||||
public static float GetRegenRate(DungeonCharacter c) => 1.0f + (c.Endurance * 0.1f);
|
||||
|
||||
@@ -45,7 +49,7 @@ public static class DungeonCharacterStats
|
||||
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.MoveSpeed = Math.Min(MaxSpeed, BaseSpeed + (stats.Dexterity * DexSpeedModifier));
|
||||
stats.AttackSpeed = 1.0f + (stats.Dexterity * 0.02f);
|
||||
stats.RegenRate = 1.0f + (stats.Endurance * 0.1f);
|
||||
stats.PhysicalDamageMultiplier = 1.0f + (stats.Strength * 0.05f);
|
||||
|
||||
@@ -24,6 +24,11 @@ public class DungeonMobDefinition
|
||||
public MobType Type { get; set; } = MobType.Normal;
|
||||
public MobCategory Category { get; set; } = MobCategory.Undead;
|
||||
|
||||
/// <summary>
|
||||
/// AI behavior pattern for this mob
|
||||
/// </summary>
|
||||
public MobBehavior Behavior { get; set; } = MobBehavior.Aggressive;
|
||||
|
||||
public int MinTier { get; set; } = 1; // Minimum dungeon tier to spawn
|
||||
public int MaxTier { get; set; } = 99; // Maximum tier (for progression gating)
|
||||
|
||||
@@ -49,6 +54,21 @@ public class DungeonMobDefinition
|
||||
public float AggroRange { get; set; } = 150f; // Detection radius
|
||||
public float LeashRange { get; set; } = 400f; // Max chase distance before reset
|
||||
|
||||
/// <summary>
|
||||
/// Preferred combat distance (for ranged/skirmisher behaviors)
|
||||
/// </summary>
|
||||
public float PreferredRange { get; set; } = 40f;
|
||||
|
||||
/// <summary>
|
||||
/// Flee threshold - if HP drops below this %, mob may flee (for skirmisher/defensive)
|
||||
/// </summary>
|
||||
public float FleeThreshold { get; set; } = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// Call for help radius - alerts nearby mobs when engaged
|
||||
/// </summary>
|
||||
public float CallForHelpRadius { get; set; } = 0f;
|
||||
|
||||
// Scaling per dungeon tier (multipliers)
|
||||
public float HealthPerTier { get; set; } = 1.2f;
|
||||
public float DamagePerTier { get; set; } = 1.15f;
|
||||
@@ -69,32 +89,38 @@ public class DungeonMobDefinition
|
||||
public string ResistancesJson { get; set; } = "{}";
|
||||
|
||||
/// <summary>
|
||||
/// JSON block for special abilities/behaviors
|
||||
/// Example: {"canFlee": true, "fleeHealthPercent": 0.2, "callsForHelp": true}
|
||||
/// JSON block for boss phases (for multi-phase bosses)
|
||||
/// Example: [{"hpThreshold": 0.75, "behavior": "Enrage"}, {"hpThreshold": 0.25, "behavior": "Summoner"}]
|
||||
/// </summary>
|
||||
[MaxLength(1024)]
|
||||
public string AbilitiesJson { get; set; } = "{}";
|
||||
[MaxLength(2048)]
|
||||
public string? PhasesJson { get; set; }
|
||||
|
||||
// Visuals
|
||||
/// <summary>
|
||||
/// JSON configuration for mob sprites and animations
|
||||
/// Example: {
|
||||
/// "sprites": {
|
||||
/// "idle_front": "assets/sprites/skeleton_idle_front.png",
|
||||
/// "idle_back": "assets/sprites/skeleton_idle_back.png",
|
||||
/// "run_front": "assets/sprites/skeleton_run_front.png"
|
||||
/// },
|
||||
/// Structure: {
|
||||
/// "spriteSheet": "textures/mobs/skeleton.png",
|
||||
/// "frameWidth": 64,
|
||||
/// "frameHeight": 64,
|
||||
/// "fps": 8,
|
||||
/// "animations": {
|
||||
/// "idle_front": {"frames": 8, "loop": true},
|
||||
/// "run_front": {"frames": 8, "loop": true}
|
||||
/// "idle_down": {"row": 0, "frames": 4, "fps": 4, "loop": true},
|
||||
/// "idle_up": {"row": 1, "frames": 4, "fps": 4, "loop": true},
|
||||
/// "idle_left": {"row": 2, "frames": 4, "fps": 4, "loop": true},
|
||||
/// "idle_right": {"row": 3, "frames": 4, "fps": 4, "loop": true},
|
||||
/// "walk_down": {"row": 4, "frames": 8, "fps": 8, "loop": true},
|
||||
/// "walk_up": {"row": 5, "frames": 8, "fps": 8, "loop": true},
|
||||
/// "walk_left": {"row": 6, "frames": 8, "fps": 8, "loop": true},
|
||||
/// "walk_right": {"row": 7, "frames": 8, "fps": 8, "loop": true},
|
||||
/// "attack_down": {"row": 8, "frames": 6, "fps": 12, "loop": false},
|
||||
/// "attack_up": {"row": 9, "frames": 6, "fps": 12, "loop": false},
|
||||
/// "attack_left": {"row": 10, "frames": 6, "fps": 12, "loop": false},
|
||||
/// "attack_right": {"row": 11, "frames": 6, "fps": 12, "loop": false},
|
||||
/// "cast_down": {"row": 12, "frames": 8, "fps": 10, "loop": false},
|
||||
/// "death": {"row": 16, "frames": 6, "fps": 8, "loop": false}
|
||||
/// }
|
||||
/// }
|
||||
/// If null/empty, client uses fallback placeholder shape
|
||||
/// </summary>
|
||||
[MaxLength(4096)]
|
||||
[MaxLength(8192)]
|
||||
public string? SpriteConfigJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -112,6 +138,12 @@ public class DungeonMobDefinition
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
// === Navigation Properties ===
|
||||
/// <summary>
|
||||
/// Abilities assigned to this mob
|
||||
/// </summary>
|
||||
public ICollection<MobAbilityAssignment> AbilityAssignments { get; set; } = new List<MobAbilityAssignment>();
|
||||
|
||||
// Helper to get parsed sprite config
|
||||
[NotMapped]
|
||||
public Dictionary<string, object>? SpriteConfig
|
||||
@@ -137,18 +169,17 @@ public class DungeonMobDefinition
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<string, object> Abilities
|
||||
public List<MobPhaseConfig>? Phases
|
||||
{
|
||||
get
|
||||
{
|
||||
try { return JsonSerializer.Deserialize<Dictionary<string, object>>(AbilitiesJson) ?? new(); }
|
||||
catch { return new(); }
|
||||
if (string.IsNullOrEmpty(PhasesJson)) return null;
|
||||
try { return JsonSerializer.Deserialize<List<MobPhaseConfig>>(PhasesJson); }
|
||||
catch { return null; }
|
||||
}
|
||||
set { AbilitiesJson = JsonSerializer.Serialize(value); }
|
||||
set { PhasesJson = value != null ? JsonSerializer.Serialize(value) : null; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calculate scaled stats for a specific level bracket
|
||||
/// Level bracket scaling: each bracket adds 15% to base stats
|
||||
@@ -178,3 +209,24 @@ public class DungeonMobDefinition
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for a boss phase
|
||||
/// </summary>
|
||||
public class MobPhaseConfig
|
||||
{
|
||||
/// <summary>HP threshold to trigger this phase (0-1)</summary>
|
||||
public float HpThreshold { get; set; }
|
||||
|
||||
/// <summary>New behavior for this phase</summary>
|
||||
public MobBehavior Behavior { get; set; }
|
||||
|
||||
/// <summary>Speed multiplier for this phase</summary>
|
||||
public float SpeedMultiplier { get; set; } = 1.0f;
|
||||
|
||||
/// <summary>Damage multiplier for this phase</summary>
|
||||
public float DamageMultiplier { get; set; } = 1.0f;
|
||||
|
||||
/// <summary>Optional message to display when entering phase</summary>
|
||||
public string? PhaseMessage { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DataServer.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Junction table linking mobs to their abilities
|
||||
/// A mob can have multiple abilities, and abilities can be shared
|
||||
/// </summary>
|
||||
[Table("dungeon_mob_ability_assignments")]
|
||||
public class MobAbilityAssignment
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>The mob definition this ability is assigned to</summary>
|
||||
public int MobDefinitionId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(MobDefinitionId))]
|
||||
public DungeonMobDefinition? MobDefinition { get; set; }
|
||||
|
||||
/// <summary>The ability definition</summary>
|
||||
public int AbilityDefinitionId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(AbilityDefinitionId))]
|
||||
public MobAbilityDefinition? AbilityDefinition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Override cooldown for this mob (null = use ability default)
|
||||
/// </summary>
|
||||
public float? CooldownOverride { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Override damage for this mob (null = use ability default)
|
||||
/// </summary>
|
||||
public int? DamageOverride { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Priority override for AI selection (null = use ability default)
|
||||
/// </summary>
|
||||
public int? PriorityOverride { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Phase this ability is available in (for multi-phase bosses)
|
||||
/// 0 = all phases, 1 = phase 1 only, etc.
|
||||
/// </summary>
|
||||
public int Phase { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum HP percentage for this ability to be available (0-1)
|
||||
/// </summary>
|
||||
public float? MinHpPercent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum HP percentage for this ability to be available (0-1)
|
||||
/// </summary>
|
||||
public float? MaxHpPercent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is this ability enabled for this mob
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using DataServer.Data.Enums;
|
||||
|
||||
namespace DataServer.Data.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Definition for a mob ability that can be assigned to mobs
|
||||
/// </summary>
|
||||
[Table("dungeon_mob_abilities")]
|
||||
public class MobAbilityDefinition
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[MaxLength(256)]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Internal key for referencing (e.g., "skeleton_arrow", "boss_slam")
|
||||
/// </summary>
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public string Key { get; set; } = "";
|
||||
|
||||
public MobAbilityType AbilityType { get; set; } = MobAbilityType.MeleeAttack;
|
||||
public MobAbilityTargeting Targeting { get; set; } = MobAbilityTargeting.CurrentTarget;
|
||||
|
||||
// === Damage/Healing ===
|
||||
/// <summary>Base damage or healing amount</summary>
|
||||
public int BaseDamage { get; set; } = 10;
|
||||
|
||||
/// <summary>Damage scaling per dungeon tier</summary>
|
||||
public float DamagePerTier { get; set; } = 1.15f;
|
||||
|
||||
/// <summary>Damage type key (references DamageResistanceType)</summary>
|
||||
[MaxLength(32)]
|
||||
public string DamageTypeKey { get; set; } = "physical";
|
||||
|
||||
// === Range & Area ===
|
||||
/// <summary>Maximum range to use ability</summary>
|
||||
public float Range { get; set; } = 40f;
|
||||
|
||||
/// <summary>AOE radius (0 for single target)</summary>
|
||||
public float AoeRadius { get; set; } = 0f;
|
||||
|
||||
/// <summary>Cone angle in degrees (for cone attacks)</summary>
|
||||
public float ConeAngle { get; set; } = 0f;
|
||||
|
||||
// === Timing ===
|
||||
/// <summary>Cooldown in seconds between uses</summary>
|
||||
public float Cooldown { get; set; } = 5f;
|
||||
|
||||
/// <summary>Cast time in seconds (0 for instant)</summary>
|
||||
public float CastTime { get; set; } = 0f;
|
||||
|
||||
/// <summary>Animation duration in seconds</summary>
|
||||
public float AnimationDuration { get; set; } = 0.5f;
|
||||
|
||||
// === Projectile (if applicable) ===
|
||||
/// <summary>Projectile speed (if projectile type)</summary>
|
||||
public float ProjectileSpeed { get; set; } = 300f;
|
||||
|
||||
/// <summary>Projectile sprite path</summary>
|
||||
[MaxLength(256)]
|
||||
public string? ProjectileSprite { get; set; }
|
||||
|
||||
// === Status Effects ===
|
||||
/// <summary>Duration of any applied status effect</summary>
|
||||
public float EffectDuration { get; set; } = 3f;
|
||||
|
||||
/// <summary>Damage per tick for DOT effects</summary>
|
||||
public int DotDamagePerTick { get; set; } = 5;
|
||||
|
||||
/// <summary>Tick interval for DOT effects</summary>
|
||||
public float DotTickInterval { get; set; } = 1f;
|
||||
|
||||
/// <summary>Slow/speed modifier (0.5 = 50% slow)</summary>
|
||||
public float SpeedModifier { get; set; } = 0.5f;
|
||||
|
||||
/// <summary>Knockback/pull distance</summary>
|
||||
public float DisplacementDistance { get; set; } = 100f;
|
||||
|
||||
// === Summoning ===
|
||||
/// <summary>Mob definition ID to summon</summary>
|
||||
public int? SummonMobId { get; set; }
|
||||
|
||||
/// <summary>Number of mobs to summon</summary>
|
||||
public int SummonCount { get; set; } = 1;
|
||||
|
||||
// === Buff/Debuff ===
|
||||
/// <summary>Stat modifier percentage (1.5 = +50%, 0.5 = -50%)</summary>
|
||||
public float StatModifier { get; set; } = 1.0f;
|
||||
|
||||
/// <summary>Which stat to modify (damage, defense, speed, etc.)</summary>
|
||||
[MaxLength(32)]
|
||||
public string? AffectedStat { get; set; }
|
||||
|
||||
// === Conditions ===
|
||||
/// <summary>Only usable below this HP percentage (0-1)</summary>
|
||||
public float? HpThresholdBelow { get; set; }
|
||||
|
||||
/// <summary>Only usable above this HP percentage (0-1)</summary>
|
||||
public float? HpThresholdAbove { get; set; }
|
||||
|
||||
/// <summary>Minimum number of targets in range to use</summary>
|
||||
public int? MinTargetsInRange { get; set; }
|
||||
|
||||
/// <summary>Priority for AI ability selection (higher = more likely)</summary>
|
||||
public int Priority { get; set; } = 1;
|
||||
|
||||
// === Mana/Resource Cost ===
|
||||
public int ManaCost { get; set; } = 0;
|
||||
|
||||
// === Animation ===
|
||||
/// <summary>
|
||||
/// Animation key to play (e.g., "attack", "cast", "special1")
|
||||
/// Client will look for [animation]_[direction] sprites
|
||||
/// </summary>
|
||||
[MaxLength(32)]
|
||||
public string AnimationKey { get; set; } = "attack";
|
||||
|
||||
/// <summary>
|
||||
/// Sound effect key to play
|
||||
/// </summary>
|
||||
[MaxLength(64)]
|
||||
public string? SoundEffectKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Visual effect to spawn (particle effect key)
|
||||
/// </summary>
|
||||
[MaxLength(64)]
|
||||
public string? VisualEffectKey { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
Reference in New Issue
Block a user