SpecificTravelEvents.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. using UnityEngine;
  2. /// <summary>
  3. /// Forest Ambush - Bandits attacking from the woods
  4. /// High probability in forests, lower on roads
  5. /// </summary>
  6. [CreateAssetMenu(fileName = "Forest Ambush", menuName = "RPG/Travel Events/Specific/Forest Ambush")]
  7. public class ForestAmbushEvent : CombatTravelEvent
  8. {
  9. void OnEnable()
  10. {
  11. eventName = "Forest Ambush";
  12. eventDescription = "Bandits leap from the undergrowth to ambush your party!";
  13. eventType = EventType.Combat;
  14. rarity = EventRarity.Common;
  15. // Very likely in forests, unlikely on roads
  16. forestChance = 0.95f;
  17. plainsChance = 0.3f;
  18. mountainChance = 0.6f;
  19. roadChance = 0.15f; // Much safer on roads
  20. townChance = 0.05f;
  21. villageChance = 0.2f;
  22. minEnemies = 2;
  23. maxEnemies = 4;
  24. // TODO: Assign possibleEnemies array with EnemyCharacterData assets
  25. // Example: possibleEnemies = new EnemyCharacterData[] { forestBanditAsset, brigandAsset, outlawAsset };
  26. encounterDescriptions = new string[]
  27. {
  28. "Bandits emerge from behind the trees to surround your party!",
  29. "Your party walks into a carefully planned ambush by forest brigands!",
  30. "Outlaws drop from the canopy above, weapons drawn!",
  31. "A group of bandits blocks the forest path ahead!"
  32. };
  33. canOccurMultipleTimes = true;
  34. cooldownDays = 0.5f; // Can happen again after half a day
  35. }
  36. }
  37. /// <summary>
  38. /// Mountain Ambush - More dangerous encounter in treacherous terrain
  39. /// </summary>
  40. [CreateAssetMenu(fileName = "Mountain Ambush", menuName = "RPG/Travel Events/Specific/Mountain Ambush")]
  41. public class MountainAmbushEvent : CombatTravelEvent
  42. {
  43. void OnEnable()
  44. {
  45. eventName = "Mountain Ambush";
  46. eventDescription = "Mountain bandits use the rocky terrain to their advantage!";
  47. eventType = EventType.Combat;
  48. rarity = EventRarity.Common;
  49. // Most likely in mountains
  50. mountainChance = 0.9f;
  51. forestChance = 0.4f;
  52. plainsChance = 0.2f;
  53. roadChance = 0.1f;
  54. townChance = 0.02f;
  55. villageChance = 0.1f;
  56. minEnemies = 1;
  57. maxEnemies = 3;
  58. // TODO: Assign possibleEnemies array with EnemyCharacterData assets
  59. // Example: possibleEnemies = new EnemyCharacterData[] { mountainBanditAsset, highwaymanAsset, raiderAsset };
  60. encounterDescriptions = new string[]
  61. {
  62. "Mountain bandits rain arrows down from the cliffs above!",
  63. "Your party is caught in a narrow pass by armed raiders!",
  64. "Highwaymen emerge from rocky crevices to block your path!",
  65. "A rockslide reveals it was a trap - bandits attack!"
  66. };
  67. canOccurMultipleTimes = true;
  68. cooldownDays = 1f;
  69. }
  70. }
  71. /// <summary>
  72. /// Traveling Merchant - Friendly trader offering goods
  73. /// Much more likely on roads and near settlements
  74. /// </summary>
  75. [CreateAssetMenu(fileName = "Traveling Merchant", menuName = "RPG/Travel Events/Specific/Traveling Merchant")]
  76. public class TravelingMerchantEvent : TradingTravelEvent
  77. {
  78. void OnEnable()
  79. {
  80. eventName = "Traveling Merchant";
  81. eventDescription = "A friendly merchant offers to trade goods with your party.";
  82. eventType = EventType.Trading;
  83. rarity = EventRarity.Common;
  84. // Very likely on roads and near settlements
  85. roadChance = 0.85f;
  86. townChance = 0.6f;
  87. villageChance = 0.75f;
  88. bridgeChance = 0.7f; // Common at crossings
  89. ferryChance = 0.6f;
  90. // Less likely in wilderness
  91. forestChance = 0.25f;
  92. mountainChance = 0.15f;
  93. plainsChance = 0.4f;
  94. lakeChance = 0.3f;
  95. riverChance = 0.3f;
  96. merchantTypes = new string[] {
  97. "Traveling Merchant",
  98. "Caravan Trader",
  99. "Wandering Peddler",
  100. "Road Merchant"
  101. };
  102. canHaveRareItems = true;
  103. rareItemChance = 0.25f;
  104. priceModifier = 1.1f; // Slightly more expensive than town shops
  105. encounterDescriptions = new string[]
  106. {
  107. "A {merchantType} with a pack full of goods approaches your party.",
  108. "Your party encounters a {merchantType} resting beside the road.",
  109. "A {merchantType} calls out, offering to show you their wares.",
  110. "You come across a {merchantType} leading a pack animal loaded with goods."
  111. };
  112. canOccurMultipleTimes = true;
  113. cooldownDays = 0.25f; // Multiple merchants can be encountered
  114. }
  115. }
  116. /// <summary>
  117. /// Road Patrol - Guards or soldiers patrolling main roads
  118. /// Only occurs on roads, provides safety information
  119. /// </summary>
  120. [CreateAssetMenu(fileName = "Road Patrol", menuName = "RPG/Travel Events/Specific/Road Patrol")]
  121. public class RoadPatrolEvent : TravelEvent
  122. {
  123. [Header("Patrol Event Settings")]
  124. public string[] patrolTypes = { "City Guard Patrol", "Royal Guard", "Local Militia" };
  125. public bool providesInformation = true;
  126. public bool canRestoreHealth = true;
  127. public int healthRestored = 15;
  128. void OnEnable()
  129. {
  130. eventName = "Road Patrol";
  131. eventDescription = "A patrol of guards maintains order on the roads.";
  132. eventType = EventType.Social;
  133. rarity = EventRarity.Common;
  134. // Only on roads and near settlements
  135. roadChance = 0.9f;
  136. townChance = 0.8f;
  137. villageChance = 0.6f;
  138. bridgeChance = 0.5f;
  139. // Never in wilderness
  140. forestChance = 0f;
  141. mountainChance = 0f;
  142. plainsChance = 0.1f;
  143. lakeChance = 0f;
  144. riverChance = 0f;
  145. oceanChance = 0f;
  146. canOccurMultipleTimes = true;
  147. cooldownDays = 1f;
  148. }
  149. public override EventResult ExecuteEvent(TravelEventContext context)
  150. {
  151. string patrolType = patrolTypes[Random.Range(0, patrolTypes.Length)];
  152. string message = $"Your party encounters a {patrolType} maintaining security on the road.";
  153. if (canRestoreHealth && Random.value < 0.4f)
  154. {
  155. message += $" They provide aid, restoring {healthRestored} health to your party.";
  156. return new EventResult(message) { healthChange = healthRestored };
  157. }
  158. else if (providesInformation)
  159. {
  160. string[] infoMessages = {
  161. " They warn you about bandit activity ahead.",
  162. " They share information about safe camping spots nearby.",
  163. " They mention a trading post further down the road.",
  164. " They advise taking the main road for safer travel."
  165. };
  166. message += infoMessages[Random.Range(0, infoMessages.Length)];
  167. }
  168. return new EventResult(message);
  169. }
  170. }
  171. /// <summary>
  172. /// Hidden Cache - Discovery of abandoned supplies
  173. /// More likely off main roads in remote areas
  174. /// </summary>
  175. [CreateAssetMenu(fileName = "Hidden Cache", menuName = "RPG/Travel Events/Specific/Hidden Cache")]
  176. public class HiddenCacheEvent : DiscoveryTravelEvent
  177. {
  178. void OnEnable()
  179. {
  180. eventName = "Hidden Cache";
  181. eventDescription = "Your party discovers a hidden stash of supplies.";
  182. eventType = EventType.Discovery;
  183. rarity = EventRarity.Uncommon;
  184. // More likely in remote areas
  185. forestChance = 0.8f;
  186. mountainChance = 0.9f;
  187. plainsChance = 0.5f;
  188. riverChance = 0.6f;
  189. // Less likely on main routes
  190. roadChance = 0.2f;
  191. townChance = 0.05f;
  192. villageChance = 0.1f;
  193. minGoldFound = 25;
  194. maxGoldFound = 150;
  195. canFindItems = true;
  196. discoveryDescriptions = new string[]
  197. {
  198. "Your party discovers a carefully hidden cache containing {amount} gold!",
  199. "While exploring off the beaten path, you find an old smuggler's stash with {amount} gold pieces.",
  200. "A party member notices disturbed earth that reveals a buried cache worth {amount} gold!",
  201. "Behind some rocks, your party uncovers an abandoned supply cache with {amount} gold."
  202. };
  203. canOccurMultipleTimes = true;
  204. cooldownDays = 2f; // Takes time for new caches to be found
  205. }
  206. }
  207. /// <summary>
  208. /// Wild Animal Encounter - Non-aggressive animal encounter
  209. /// Can be peaceful or turn into combat based on party actions
  210. /// </summary>
  211. [CreateAssetMenu(fileName = "Wild Animal Encounter", menuName = "RPG/Travel Events/Specific/Wild Animal Encounter")]
  212. public class WildAnimalEvent : TravelEvent
  213. {
  214. [Header("Animal Encounter Settings")]
  215. public string[] animalTypes = { "Wolf Pack", "Brown Bear", "Wild Boar", "Mountain Lion" };
  216. public float aggressionChance = 0.3f; // Chance the animal attacks
  217. void OnEnable()
  218. {
  219. eventName = "Wild Animal Encounter";
  220. eventDescription = "Your party encounters wild animals.";
  221. eventType = EventType.Mystery;
  222. rarity = EventRarity.Common;
  223. // More likely in natural areas
  224. forestChance = 0.9f;
  225. mountainChance = 0.8f;
  226. plainsChance = 0.6f;
  227. riverChance = 0.5f;
  228. lakeChance = 0.4f;
  229. // Very unlikely near civilization
  230. roadChance = 0.2f;
  231. townChance = 0.02f;
  232. villageChance = 0.1f;
  233. canOccurMultipleTimes = true;
  234. cooldownDays = 0.5f;
  235. }
  236. public override EventResult ExecuteEvent(TravelEventContext context)
  237. {
  238. string animalType = animalTypes[Random.Range(0, animalTypes.Length)];
  239. if (Random.value < aggressionChance)
  240. {
  241. // Animal attacks
  242. return EventResult.SimpleBattle(
  243. $"A {animalType} attacks your party!",
  244. 1,
  245. animalType
  246. );
  247. }
  248. else
  249. {
  250. // Peaceful encounter
  251. string[] peacefulMessages = {
  252. $"Your party spots a {animalType} in the distance. It notices you but moves away peacefully.",
  253. $"A {animalType} crosses your path but shows no aggression toward your party.",
  254. $"Your party carefully observes a {animalType} before it disappears into the wilderness."
  255. };
  256. return new EventResult(peacefulMessages[Random.Range(0, peacefulMessages.Length)]);
  257. }
  258. }
  259. }