From a055a9e52576b5486723c8d362bd82447da207db Mon Sep 17 00:00:00 2001 From: WarrentyExpired Date: Thu, 15 Oct 2026 11:44:39 -0400 Subject: [PATCH] #W# Traps: New region traps tweaked. Also give skill gains. Settings to disable messages. --- .../UOContent/Engines/RegionDungeonTraps.cs | 61 +++++++++++++------ .../Regions/Custom/GreetingDungeonRegion.cs | 7 +-- Projects/UOContent/Settings.cs | 4 +- 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/Projects/UOContent/Engines/RegionDungeonTraps.cs b/Projects/UOContent/Engines/RegionDungeonTraps.cs index 04433c960..bd4badd9b 100644 --- a/Projects/UOContent/Engines/RegionDungeonTraps.cs +++ b/Projects/UOContent/Engines/RegionDungeonTraps.cs @@ -23,25 +23,41 @@ namespace Server.Engines.DungeonTraps // The master method called when a region step roll succeeds public virtual void Trigger(PlayerMobile pm) { - // 1. Remove Trap Check (Absolute Disarm) - double removeTrap = pm.Skills[SkillName.RemoveTrap].Value; - if (removeTrap > 0 && removeTrap >= Utility.RandomDouble() * 100.0) + // 1. Detect Hidden Check (Spot and Avoid) + // Uses CheckSkill to allow for skill gains. 0.0 to 100.0 means the success chance scales exactly with their skill. + if (pm.Skills[SkillName.DetectHidden].Value > 0 && pm.CheckSkill(SkillName.DetectHidden, 0.0, 100.0)) { - pm.SendMessage(0x35, $"You hear a click and instinctively jam the {Name} mechanism before it fires."); - pm.PlaySound(0x3A4); // Click sound + if (Settings.S_TrapDetected) + { + pm.SendMessage(0x42, $"You spot a concealed {Name} and carefully step around it."); + } return; } - // 2. Evasion Check: (Dex + Int) * 0.25 + // 2. Remove Trap Check (Absolute Disarm) + if (pm.Skills[SkillName.RemoveTrap].Value > 0 && pm.CheckSkill(SkillName.RemoveTrap, 0.0, 100.0)) + { + if (Settings.S_TrapDetected) + { + pm.SendMessage(0x35, $"You hear a click and instinctively jam the {Name} mechanism before it fires."); + pm.PlaySound(0x3A4); // Click sound + } + return; + } + + // 3. Evasion Check: (Dex + Int) * 0.25 double evasionChance = (pm.Dex + pm.Int) * 0.25; if (evasionChance >= Utility.RandomDouble() * 100.0) { - pm.SendMessage(0x59, $"A {Name} triggers, but your quick reflexes allow you to dodge it!"); - PlayTrapEffect(pm); // Trap goes off, but misses + if (Settings.S_TrapDetected) + { + pm.SendMessage(0x59, $"A {Name} triggers, but your quick reflexes allow you to dodge it!"); + PlayTrapEffect(pm); // Trap goes off, but misses + } return; } - // 3. Mitigation Check (AR for Physical, Magic Resist for Magical) + // 4. Mitigation Check (AR for Physical, Magic Resist for Magical) PlayTrapEffect(pm); bool mitigated = false; @@ -55,22 +71,29 @@ namespace Server.Engines.DungeonTraps } else // Magical { - if (pm.Skills[SkillName.MagicResist].Value >= Utility.RandomDouble() * 100.0) + // Magic Resist check with skill gain opportunity + if (pm.Skills[SkillName.MagicResist].Value > 0 && pm.CheckSkill(SkillName.MagicResist, 0.0, 100.0)) { mitigated = true; } } - // 4. Resolve Impact + // 5. Resolve Impact if (mitigated) { - pm.SendMessage(0x22, $"Your defenses absorb the {Name}, but your equipment takes a beating!"); - DamageRandomArmor(pm); + if (Settings.S_TrapDamageMitigated) + { + pm.SendMessage(0x22, $"Your defenses absorb the {Name}, but your equipment takes a beating!"); + DamageRandomArmor(pm); + } } else { - pm.SendMessage(0x22, $"You are struck by a {Name}!"); - ApplyDamage(pm); + if (Settings.S_TrapDamageMitigated) + { + pm.SendMessage(0x22, $"You are struck by a {Name}!"); + ApplyDamage(pm); + } } } @@ -142,8 +165,8 @@ namespace Server.Engines.DungeonTraps { public override string Name => "hidden explosive"; public override TrapDamageType DamageType => TrapDamageType.Physical; - public override int MinDamage => 20; - public override int MaxDamage => 40; + public override int MinDamage => 15; + public override int MaxDamage => 30; public override void PlayTrapEffect(PlayerMobile pm) { @@ -156,8 +179,8 @@ namespace Server.Engines.DungeonTraps { public override string Name => "flame jet"; public override TrapDamageType DamageType => TrapDamageType.Magical; - public override int MinDamage => 20; - public override int MaxDamage => 40; + public override int MinDamage => 15; + public override int MaxDamage => 30; public override void PlayTrapEffect(PlayerMobile pm) { diff --git a/Projects/UOContent/Regions/Custom/GreetingDungeonRegion.cs b/Projects/UOContent/Regions/Custom/GreetingDungeonRegion.cs index d17e1dd33..438308228 100644 --- a/Projects/UOContent/Regions/Custom/GreetingDungeonRegion.cs +++ b/Projects/UOContent/Regions/Custom/GreetingDungeonRegion.cs @@ -95,15 +95,10 @@ namespace Server.Regions return; // Player is still in their grace period } - // 5. Calculate Trigger Chance (Base 5% chance per step) - // Detect Hidden actively reduces this chance. - // At 0 DH = 5% chance. At 100 DH = 1% chance. double baseChance = ValidSettings.RegionDungeonTrapsChance(); - double detectHidden = pm.Skills[SkillName.DetectHidden].Value; - double finalChance = Math.Max(1.0, baseChance - (detectHidden / 25.0)); // 6. Roll for Trap Trigger - if (Utility.RandomDouble() * 100.0 <= finalChance) + if (Utility.RandomDouble() * 100.0 <= baseChance) { // Pick a random trap from the pool BaseRegionTrap trap = _dungeonTraps[Utility.Random(_dungeonTraps.Length)]; diff --git a/Projects/UOContent/Settings.cs b/Projects/UOContent/Settings.cs index 2ad963c0c..f3a0f0897 100644 --- a/Projects/UOContent/Settings.cs +++ b/Projects/UOContent/Settings.cs @@ -11,6 +11,8 @@ namespace Server public static int S_DungeonBountyRefusalDelay = 10; // 1-1440 minutes delay between refusing a quest public static bool S_DungeonTraps = false; // Spawns Dugeon floor traps public static bool S_RegionDungeonTraps = true; // Step activated dungeon traps - public static int S_RegionDungeonTrapsChance = 5; // 1-100 Chance to get a trap check per step + public static int S_RegionDungeonTrapsChance = 3; // 1-100 Chance to get a trap check per step + public static bool S_TrapDetected = false; // Get a message if the trap gets detected + public static bool S_TrapDamageMitigated = true; // Get a message if the trap damage gets mitigated } }