using UnityEngine; /// /// Hazard events - natural dangers, traps, environmental challenges /// [CreateAssetMenu(fileName = "New Hazard Event", menuName = "RPG/Travel Events/Hazard Event")] public class HazardTravelEvent : TravelEvent { [Header("Hazard Settings")] public int minHealthLoss = 5; public int maxHealthLoss = 20; public int goldCost = 0; // Cost to avoid the hazard [Header("Hazard Descriptions")] [TextArea(2, 4)] public string[] hazardDescriptions = { "Your party gets caught in a sudden rockslide, losing {damage} health.", "Treacherous terrain causes injuries to your party members, resulting in {damage} health loss.", "A hidden pit trap catches one of your party members, causing {damage} damage." }; public override EventResult ExecuteEvent(TravelEventContext context) { int damage = Random.Range(minHealthLoss, maxHealthLoss + 1); string description = hazardDescriptions[Random.Range(0, hazardDescriptions.Length)]; description = description.Replace("{damage}", damage.ToString()); return new EventResult(description) { healthChange = -damage, goldChange = -goldCost }; } void OnEnable() { eventType = EventType.Hazard; rarity = EventRarity.Common; // More likely in dangerous terrain mountainChance = 0.9f; forestChance = 0.6f; riverChance = 0.7f; oceanChance = 0.8f; // Less likely in safe areas roadChance = 0.2f; townChance = 0.1f; villageChance = 0.2f; plainsChance = 0.4f; } }