Tom_Neverwinter

06/01/2024 chocobo raising test

Jun 1st, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.82 KB | None | 0 0
  1. -----------------------------------
  2. -- Chocobo Raising
  3. -- Dedicated to 'Friend' the Chocobo. RIP.
  4. -----------------------------------
  5. require('scripts/globals/chocobo_names')
  6. require('scripts/globals/utils')
  7. -----------------------------------
  8. xi = xi or {}
  9. xi.chocoboRaising = xi.chocoboRaising or {}
  10. xi.chocoboRaising.chocoState = xi.chocoboRaising.chocoState or {}
  11.  
  12. local debug = utils.getDebugPlayerPrinter(xi.settings.main.DEBUG_CHOCOBO_RAISING)
  13.  
  14. -----------------------------------
  15. -- Settings
  16. -----------------------------------
  17.  
  18. -- Length of a day, in seconds
  19. xi.chocoboRaising.dayLength = 86400
  20.  
  21. xi.chocoboRaising.daysToChick = 4
  22. xi.chocoboRaising.daysToAdolescent = 19
  23. xi.chocoboRaising.daysToAdult1 = 29
  24. xi.chocoboRaising.daysToAdult2 = 43
  25. xi.chocoboRaising.daysToAdult3 = 64
  26. xi.chocoboRaising.daysToAdult4 = 129
  27.  
  28. -- Energy settings for different walks
  29. local walkEnergyRandomness = 5
  30. local walkEnergyAmount = { 25, 33, 50 }
  31. local walkEventChance = 33
  32. local watchOverEnergy = 5
  33.  
  34. -- Chocobo speed and endurance ratings
  35. xi.chocoboRaising.ridingSpeedBase = 80
  36. xi.chocoboRaising.ridingSpeedPerRank = 2.5
  37. xi.chocoboRaising.ridingSpeedCap = 100
  38. xi.chocoboRaising.ridingTimeBase = 17
  39. xi.chocoboRaising.ridingTimePerRank = 4
  40. xi.chocoboRaising.ridingTimeCap = 45
  41.  
  42. local skillRanks = {
  43. F_POOR = 0,
  44. E_SUBSTANDARD = 1,
  45. D_A_BIT_DEFICIENT = 2,
  46. C_AVERAGE = 3,
  47. B_BETTER_THAN_AVERAGE = 4,
  48. A_IMPRESSIVE = 5,
  49. S_OUTSTANDING = 6,
  50. SS_FIRST_CLASS = 7,
  51. }
  52.  
  53. local skillRankBoundaries = {
  54. F_POOR = 31,
  55. E_SUBSTANDARD = 63,
  56. D_A_BIT_DEFICIENT = 95,
  57. C_AVERAGE = 127,
  58. B_BETTER_THAN_AVERAGE = 159,
  59. A_IMPRESSIVE = 191,
  60. S_OUTSTANDING = 223,
  61. SS_FIRST_CLASS = 255,
  62. }
  63.  
  64. local numberToRank = function(skill)
  65. local rank = skillRanks.F_POOR
  66. for idx, boundary in pairs(skillRankBoundaries) do
  67. if skill >= boundary and skillRanks[idx] > rank then
  68. rank = skillRanks[idx]
  69. end
  70. end
  71. return rank
  72. end
  73.  
  74. xi.chocoboRaising.getPlayerRidingSpeedAndTime = function(player)
  75. local baseSpeed = xi.chocoboRaising.ridingSpeedBase
  76. local baseTime = xi.chocoboRaising.ridingTimeBase
  77. local chocoState = player:getChocoboRaisingInfo()
  78. if chocoState == nil then
  79. return baseSpeed, baseTime
  80. end
  81. local strRank = numberToRank(chocoState.strength)
  82. local endRank = numberToRank(chocoState.endurance)
  83. local outSpeed = utils.clamp(baseSpeed + (strRank * xi.chocoboRaising.ridingSpeedPerRank), 0, xi.chocoboRaising.ridingSpeedCap)
  84. local outTime = utils.clamp(baseTime + (endRank * xi.chocoboRaising.ridingTimePerRank), 0, xi.chocoboRaising.ridingTimeCap)
  85. return outSpeed, outTime
  86. end
  87.  
  88. -- Conditions and care plans
  89. local conditions = {
  90. ILL = 0, VERY_ILL = 1, SICK = 2, INJURED = 3, SPOILED = 4, BORED = 5, LOVESICK = 6, RUN_AWAY = 7,
  91. HIGH_SPIRITS = 8, PERKY = 9, EXTREMELY_HAPPY = 10, FULL_OF_ENERGY_1 = 11, FULL_OF_ENERGY_2 = 12, BRIGHT_AND_FOCUSED = 13,
  92. }
  93.  
  94. local hasCondition = function(chocoState)
  95. return chocoState.conditions > 0
  96. end
  97.  
  98. local getCondition = function(chocoState, condition)
  99. return utils.mask.getBit(chocoState.conditions, condition)
  100. end
  101.  
  102. local setCondition = function(chocoState, condition, value)
  103. chocoState.conditions = utils.mask.setBit(chocoState.conditions, condition, value)
  104. end
  105.  
  106. local conditionsHealedByItems = {
  107. [conditions.ILL] = { xi.item.CLUMP_OF_TOKOPEKKO_WILDGRASS, xi.item.CELERITY_SALAD },
  108. [conditions.VERY_ILL] = { xi.item.CLUMP_OF_TOKOPEKKO_WILDGRASS, xi.item.CELERITY_SALAD },
  109. [conditions.SICK] = { xi.item.CLUMP_OF_GARIDAV_WILDGRASS, xi.item.CELERITY_SALAD },
  110. [conditions.INJURED] = { xi.item.CLUMP_OF_GAUSEBIT_WILDGRASS, xi.item.CELERITY_SALAD },
  111. [conditions.SPOILED] = { xi.item.CELERITY_SALAD },
  112. [conditions.BORED] = { xi.item.CELERITY_SALAD },
  113. [conditions.LOVESICK] = { xi.item.CELERITY_SALAD },
  114. }
  115.  
  116. local carePlans = {
  117. BASIC_CARE = 0, RESTING = 1, TAKING_A_WALK = 2, LISTENING_TO_MUSIC = 3, EXERCISING_ALONE = 4, EXERCISING_IN_A_GROUP = 5,
  118. PLAYING_WITH_CHILDREN = 6, PLAYING_WITH_CHOCOBOS = 7, CARRYING_PACKAGES = 8, EXHIBITING_TO_THE_PUBLIC = 9,
  119. DELIVERING_MESSAGES = 10, DIGGING_FOR_TREASURE = 11, ACTING_IN_A_PLAY = 12,
  120. }
  121.  
  122. local carePlanData = {
  123. [carePlans.BASIC_CARE] = { 1, 1, 1, 1, -1, -1, nil },
  124. [carePlans.RESTING] = { 0, 0, 0, 0, 0, 1, nil },
  125. [carePlans.TAKING_A_WALK] = { 1, 1, -1, -1, -1, -1, nil },
  126. [carePlans.LISTENING_TO_MUSIC] = { -1, -1, 1, 1, -1, -1, nil },
  127. [carePlans.EXERCISING_ALONE] = { 1, 0, -1, -1, -1, -1, nil },
  128. [carePlans.EXERCISING_IN_A_GROUP] = { 0, 1, -1, -1, -1, -1, nil },
  129. [carePlans.PLAYING_WITH_CHILDREN] = { -1, -1, 1, 0, -1, -1, nil },
  130. [carePlans.PLAYING_WITH_CHOCOBOS] = { -1, -1, 0, 1, -1, -1, nil },
  131. [carePlans.CARRYING_PACKAGES] = { 5, 5, -5, -5, -10, -5, 100 },
  132. [carePlans.EXHIBITING_TO_THE_PUBLIC] = { -5, -5, 5, 5, -10, -5, 100 },
  133. [carePlans.DELIVERING_MESSAGES] = { 10, 0, 0, -5, -10, -10, 100 },
  134. [carePlans.DIGGING_FOR_TREASURE] = { 0, -5, 10, 0, -10, -10, 100 },
  135. [carePlans.ACTING_IN_A_PLAY] = { -5, 0, 0, 10, -10, -10, 100 },
  136. }
  137.  
  138. local handleStatChange = function(stat, change, max)
  139. if change > 0 then
  140. change = change * xi.settings.main.CHOCOBO_RAISING_STAT_POS_MULTIPLIER
  141. elseif change < 0 then
  142. change = change * xi.settings.main.CHOCOBO_RAISING_STAT_NEG_MULTIPLIER
  143. end
  144. stat = utils.clamp(stat + change, 0, max)
  145. return stat
  146. end
  147.  
  148. local handleCarePlan = function(player, chocoState, carePlan)
  149. chocoState.strength = handleStatChange(chocoState.strength, carePlanData[carePlan][1], 255)
  150. chocoState.endurance = handleStatChange(chocoState.endurance, carePlanData[carePlan][2], 255)
  151. chocoState.discernment = handleStatChange(chocoState.discernment, carePlanData[carePlan][3], 255)
  152. chocoState.receptivity = handleStatChange(chocoState.receptivity, carePlanData[carePlan][4], 255)
  153. chocoState.affection = handleStatChange(chocoState.affection, carePlanData[carePlan][5], 255)
  154. chocoState.energy = handleStatChange(chocoState.energy, carePlanData[carePlan][6], 100)
  155.  
  156. local payment = carePlanData[carePlan][7]
  157. if payment then
  158. payment = payment * xi.settings.main.CHOCOBO_RAISING_GIL_MULTIPLIER
  159. debug(string.format('Care Plan Payment: %d', payment))
  160. -- Handle payment
  161. end
  162. end
  163.  
  164. local validFoods = {
  165. [xi.item.BUNCH_OF_GYSAHL_GREENS] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  166. [xi.item.BUNCH_OF_SHARUG_GREENS] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  167. [xi.item.BUNCH_OF_AZOUPH_GREENS] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  168. [xi.item.CARROT_PASTE] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  169. [xi.item.HERB_PASTE] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  170. [xi.item.VEGETABLE_PASTE] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  171. [xi.item.WORM_PASTE] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  172. [xi.item.VOMP_CARROT] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  173. [xi.item.SAN_DORIAN_CARROT] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.RED },
  174. [xi.item.ZEGHAM_CARROT] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.BLUE },
  175. [xi.item.CLUMP_OF_GAUSEBIT_WILDGRASS] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.YELLOW },
  176. [xi.item.CLUMP_OF_GARIDAV_WILDGRASS] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.YELLOW },
  177. [xi.item.CLUMP_OF_TOKOPEKKO_WILDGRASS] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.YELLOW },
  178. [xi.item.CHOCOLIXIR] = { 50, 0, 100, 0, 0, 0, 0, 0, 0, glow.YELLOW },
  179. [xi.item.HI_CHOCOLIXIR] = { 25, 0, 100, 0, 0, 0, 0, 0, 0, glow.YELLOW },
  180. [xi.item.CHOCOTONIC] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.YELLOW },
  181. [xi.item.CUPID_WORM] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.BLUE },
  182. [xi.item.GREGARIOUS_WORM] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.YELLOW },
  183. [xi.item.PARASITE_WORM] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.BLUE },
  184. [xi.item.TORNADO_SALAD] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.GREEN },
  185. [xi.item.CELERITY_SALAD] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.GREEN },
  186. [xi.item.LETHE_POTAGE] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.GREEN },
  187. [xi.item.LETHE_CONSOMME] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.GREEN },
  188. [xi.item.LA_THEINE_MILLET] = { 25, 10, 0, 0, 0, 0, 0, 0, 0, glow.GREEN },
  189. }
  190.  
  191. -- Items that can be found on a walk in a certain area
  192. local walkItems = {
  193. [xi.zone.WEST_RONFAURE] = { xi.item.BEASTCOIN, xi.item.BRONZE_AXE, xi.item.RONFAURE_CHESTNUT, xi.item.FLINT_STONE, xi.item.CLUMP_OF_GARIDAV_WILDGRASS, xi.item.GOBLIN_MASK, xi.item.LITTLE_WORM, xi.item.PEBBLE, xi.item.SILVER_BEASTCOIN, xi.item.CLUMP_OF_TOKOPEKKO_WILDGRASS, xi.item.BAG_OF_WILDGRASS_SEEDS },
  194. [xi.zone.NORTH_GUSTABERG] = { xi.item.BEASTCOIN, xi.item.FLINT_STONE, xi.item.CLUMP_OF_GARIDAV_WILDGRASS, xi.item.GOBLIN_MASK, xi.item.LITTLE_WORM, xi.item.EAR_OF_MILLIONCORN, xi.item.PEBBLE, xi.item.QUADAV_BACKPLATE, xi.item.SILVER_BEASTCOIN, xi.item.CLUMP_OF_TOKOPEKKO_WILDGRASS, xi.item.BAG_OF_WILDGRASS_SEEDS },
  195. [xi.zone.EAST_SARUTABARUTA] = { xi.item.BEASTCOIN, xi.item.FLINT_STONE, xi.item.CLUMP_OF_GARIDAV_WILDGRASS, xi.item.GOBLIN_MASK, xi.item.GOBLIN_HELM, xi.item.LITTLE_WORM, xi.item.PEBBLE, xi.item.PIECE_OF_ROTTEN_MEAT, xi.item.SILVER_BEASTCOIN, xi.item.BOX_OF_TARUTARU_RICE, xi.item.CLUMP_OF_TOKOPEKKO_WILDGRASS, xi.item.BAG_OF_WILDGRASS_SEEDS, xi.item.YAGUDO_BEAD_NECKLACE },
  196. [xi.zone.LA_THEINE_PLATEAU] = { xi.item.BEASTCOIN, xi.item.CRAB_SHELL, xi.item.CUPID_WORM, xi.item.CHUNK_OF_DARKSTEEL_ORE, xi.item.CLUMP_OF_GARIDAV_WILDGRASS, xi.item.GOBLIN_ARMOR, xi.item.LILAC, xi.item.PEBBLE, xi.item.SILVER_BEASTCOIN, xi.item.CLUMP_OF_TOKOPEKKO_WILDGRASS, xi.item.ZEGHAM_CARROT, xi.item.MYTHRIL_BEASTCOIN },
  197. [xi.zone.KONSCHTAT_HIGHLANDS] = { xi.item.BEASTCOIN, xi.item.CUPID_WORM, xi.item.CLUMP_OF_GARIDAV_WILDGRASS, xi.item.GOBLIN_ARMOR, xi.item.GOBLIN_HELM, xi.item.PEBBLE, xi.item.CHUNK_OF_DARKSTEEL_ORE, xi.item.CHUNK_OF_PLATINUM_ORE, xi.item.RAIN_LILY, xi.item.SHEEP_TOOTH, xi.item.SILVER_BEASTCOIN, xi.item.CLUMP_OF_TOKOPEKKO_WILDGRASS, xi.item.VOMP_CARROT, xi.item.ZEGHAM_CARROT },
  198. [xi.zone.TAHRONGI_CANYON] = { xi.item.AMARYLLIS, xi.item.BEASTCOIN, xi.item.CHICKEN_BONE, xi.item.CUPID_WORM, xi.item.CHUNK_OF_DARKSTEEL_ORE, xi.item.CLUMP_OF_GARIDAV_WILDGRASS, xi.item.GOBLIN_ARMOR, xi.item.PEBBLE, xi.item.CHUNK_OF_PLATINUM_ORE, xi.item.SILVER_BEASTCOIN, xi.item.VOMP_CARROT, xi.item.ZEGHAM_CARROT, xi.item.BAG_OF_TREE_CUTTINGS },
  199. [xi.zone.JUGNER_FOREST] = { xi.item.CHUNK_OF_ADAMAN_ORE, xi.item.GOBLIN_HELM, xi.item.GOLD_BEASTCOIN, xi.item.GREGARIOUS_WORM, xi.item.MYTHRIL_BEASTCOIN, xi.item.OLIVE_FLOWER, xi.item.CHUNK_OF_ORICHALCUM_ORE, xi.item.PEBBLE, xi.item.PIECE_OF_ROTTEN_MEAT, xi.item.SILVER_BEASTCOIN, xi.item.BAG_OF_TREE_CUTTINGS, xi.item.BAG_OF_WILDGRASS_SEEDS },
  200. [xi.zone.PASHHOW_MARSHLANDS] = { xi.item.CHUNK_OF_ADAMAN_ORE, xi.item.CATTLEYA, xi.item.GOBLIN_HELM, xi.item.GREGARIOUS_WORM, xi.item.MYTHRIL_BEASTCOIN, xi.item.CHUNK_OF_ORICHALCUM_ORE, xi.item.PEBBLE, xi.item.PIECE_OF_ROTTEN_MEAT, xi.item.SILVER_BEASTCOIN, xi.item.BAG_OF_TREE_CUTTINGS },
  201. [xi.zone.MERIPHATAUD_MOUNTAINS] = { xi.item.CHUNK_OF_ADAMAN_ORE, xi.item.CASABLANCA, xi.item.GOBLIN_HELM, xi.item.GOLD_BEASTCOIN, xi.item.GREGARIOUS_WORM, xi.item.MYTHRIL_BEASTCOIN, xi.item.PEBBLE, xi.item.PIECE_OF_ROTTEN_MEAT, xi.item.SILVER_BEASTCOIN, xi.item.BAG_OF_TREE_CUTTINGS, xi.item.CHUNK_OF_ORICHALCUM_ORE },
  202. }
  203.  
  204. -----------------------------------
  205. -- Chocobo Growth Stages
  206. -----------------------------------
  207.  
  208. local stage = {
  209. EGG = 1, CHICK = 2, ADOLESCENT = 3, ADULT_1 = 4, ADULT_2 = 5, ADULT_3 = 6, ADULT_4 = 7,
  210. }
  211.  
  212. local colour = {
  213. YELLOW = 0, BLACK = 1, BLUE = 2, RED = 3, GREEN = 4,
  214. }
  215.  
  216. local ageBoundaries = {
  217. { stage.EGG, xi.chocoboRaising.daysToChick, cutscenes.EGG_HATCHING, stage.CHICK },
  218. { stage.CHICK, xi.chocoboRaising.daysToAdolescent, cutscenes.CHICK_TO_ADOLESCENT, stage.ADOLESCENT },
  219. { stage.ADOLESCENT, xi.chocoboRaising.daysToAdult1, cutscenes.ADOLESCENT_TO_ADULT_1, stage.ADULT_1 },
  220. { stage.ADULT_1, xi.chocoboRaising.daysToAdult2, cutscenes.ADULT_1_TO_ADULT_2, stage.ADULT_2 },
  221. { stage.ADULT_2, xi.chocoboRaising.daysToAdult3, cutscenes.ADULT_2_TO_ADULT_3, stage.ADULT_3 },
  222. { stage.ADULT_3, xi.chocoboRaising.daysToAdult4, cutscenes.ADULT_3_TO_ADULT_4, stage.ADULT_4 },
  223. }
  224.  
  225. local ageToStage = function(age)
  226. for _, entry in pairs(ageBoundaries) do
  227. if age <= entry[2] then
  228. return entry[1]
  229. end
  230. end
  231. return stage.ADULT_4
  232. end
  233.  
  234. local updateChocoState = function(player, chocoState)
  235. chocoState.age = math.floor((os.time() - chocoState.created) / xi.chocoboRaising.dayLength) + 1
  236. chocoState.last_update_age = chocoState.age
  237. xi.chocoboRaising.chocoState[player:getID()] = chocoState
  238. player:setChocoboRaisingInfo(chocoState)
  239. return chocoState
  240. end
  241.  
  242. local handleCSUpdate = function(player, chocoState, doEventUpdate)
  243. local csOffset = chocoState.csList[1]
  244. local locationOffset = raisingLocation[player:getZoneID()] * 256
  245. local csToPlay = locationOffset + csOffset
  246. table.remove(chocoState.csList, 1)
  247. local currentAgeOfChocoboDuringCutscene = 0
  248. if csOffset == cutscenes.EGG_HATCHING then
  249. chocoState.stage = stage.CHICK
  250. elseif csOffset == cutscenes.CHICK_TO_ADOLESCENT then
  251. chocoState.stage = stage.ADOLESCENT
  252. elseif csOffset == cutscenes.ADOLESCENT_TO_ADULT_1 then
  253. chocoState.stage = stage.ADULT_1
  254. elseif csOffset == cutscenes.ADULT_1_TO_ADULT_2 then
  255. chocoState.stage = stage.ADULT_2
  256. elseif csOffset == cutscenes.ADULT_2_TO_ADULT_3 then
  257. chocoState.stage = stage.ADULT_3
  258. elseif csOffset == cutscenes.ADULT_3_TO_ADULT_4 then
  259. chocoState.stage = stage.ADULT_4
  260. end
  261. chocoState = onRaisingEventPlayout(player, csOffset, chocoState)
  262. if doEventUpdate then
  263. player:updateEventString(chocoState.first_name, chocoState.last_name, chocoState.first_name, chocoState.first_name, 0, 0, 0, 0, 0, 0, 0, 0)
  264. player:updateEvent(#chocoState.csList, csToPlay, 0, chocoState.colour, chocoState.stage, 0, currentAgeOfChocoboDuringCutscene, 1)
  265. end
  266. return chocoState
  267. end
  268.  
  269. xi.chocoboRaising.initChocoboData = function(player)
  270. local chocoState = player:getChocoboRaisingInfo()
  271. if chocoState == nil then
  272. return chocoState
  273. end
  274. chocoState.age = math.floor((os.time() - chocoState.created) / xi.chocoboRaising.dayLength) + 1
  275. chocoState.affectionRank = affectionRank.LIKES
  276. chocoState.csList = {}
  277. chocoState.foodGiven = {}
  278. chocoState.report = {}
  279. chocoState.report.events = {}
  280. if chocoState.age - chocoState.last_update_age <= 0 then
  281. chocoState.last_update_age = chocoState.age
  282. return chocoState
  283. end
  284. chocoState.report.day_start = chocoState.last_update_age
  285. chocoState.report.day_end = chocoState.age
  286. local reportLength = chocoState.report.day_end - chocoState.report.day_start
  287. chocoState.last_update_age = chocoState.age
  288. local events = {}
  289. local plan1Length = bit.rshift(bit.band(chocoState.care_plan, 0xF0000000), 28)
  290. local plan1Type = bit.rshift(bit.band(chocoState.care_plan, 0x0F000000), 24)
  291. local plan2Length = bit.rshift(bit.band(chocoState.care_plan, 0x00F00000), 20)
  292. local plan2Type = bit.rshift(bit.band(chocoState.care_plan, 0x000F0000), 16)
  293. local plan3Length = bit.rshift(bit.band(chocoState.care_plan, 0x0000F000), 12)
  294. local plan3Type = bit.rshift(bit.band(chocoState.care_plan, 0x00000F00), 8)
  295. local plan4Length = bit.rshift(bit.band(chocoState.care_plan, 0x000000F0), 4)
  296. local plan4Type = bit.rshift(bit.band(chocoState.care_plan, 0x0000000F), 0)
  297. local possibleCarePlanFuture = {}
  298. for _ = 1, plan1Length do
  299. table.insert(possibleCarePlanFuture, plan1Type)
  300. end
  301. for _ = 1, plan2Length do
  302. table.insert(possibleCarePlanFuture, plan2Type)
  303. end
  304. for _ = 1, plan3Length do
  305. table.insert(possibleCarePlanFuture, plan3Type)
  306. end
  307. for _ = 1, plan4Length do
  308. table.insert(possibleCarePlanFuture, plan4Type)
  309. end
  310. chocoState.energy = 100
  311. for idx = 1, reportLength do
  312. local possibleCarePlanEvent = possibleCarePlanFuture[idx]
  313. if possibleCarePlanEvent == nil then
  314. possibleCarePlanEvent = 0
  315. end
  316. local age = chocoState.report.day_start + idx - 1
  317. local currentStage = ageToStage(age)
  318. local event = { age, { possibleCarePlanEvent } }
  319. table.insert(events, event)
  320. if not hasCondition(chocoState) then
  321. for _, condition in pairs(conditions) do
  322. if utils.chance(5) then
  323. setCondition(chocoState, condition, true)
  324. break
  325. end
  326. end
  327. end
  328. for _, condition in pairs(conditions) do
  329. if getCondition(chocoState, condition) then
  330. setCondition(chocoState, condition, false)
  331. break
  332. end
  333. end
  334. chocoState.strength = handleStatChange(chocoState.strength, carePlanData[possibleCarePlanEvent][1], 255)
  335. chocoState.endurance = handleStatChange(chocoState.endurance, carePlanData[possibleCarePlanEvent][2], 255)
  336. chocoState.discernment = handleStatChange(chocoState.discernment, carePlanData[possibleCarePlanEvent][3], 255)
  337. chocoState.receptivity = handleStatChange(chocoState.receptivity, carePlanData[possibleCarePlanEvent][4], 255)
  338. chocoState.affection = handleStatChange(chocoState.affection, carePlanData[possibleCarePlanEvent][5], 255)
  339. chocoState.energy = handleStatChange(chocoState.energy, carePlanData[possibleCarePlanEvent][6], 100)
  340. end
  341. chocoState.report.events = events
  342. chocoState = updateChocoState(player, chocoState)
  343. return chocoState
  344. end
  345.  
Advertisement
Add Comment
Please, Sign In to add comment