Tom_Neverwinter

chatgpt further chocobo racing items 6/1/2024

Jun 1st, 2024 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.30 KB | None | 0 0
  1. -----------------------------------
  2. -- Chocobo Racing
  3. -- https://www.bg-wiki.com/ffxi/Category:Chocobo_Racing
  4. -- https://ffxiclopedia.fandom.com/wiki/Chocobo_Racing_Guide
  5. -----------------------------------
  6. require('scripts/globals/utils')
  7. -----------------------------------
  8. xi = xi or {}
  9. xi.chocoboRacing = xi.chocoboRacing or {}
  10.  
  11. -- FOR HEAVILY-IN-DEVELOPMENT TESTING, you can force these settings:
  12. -- TODO: When ready for release, publish these to main settings files.
  13. xi.settings.main.ENABLE_CHOCOBO_RACING = true
  14. xi.settings.main.DEBUG_CHOCOBO_RACING = true
  15.  
  16. -- To Run:
  17. -- !exec xi.chocoboRacing.startRace()
  18.  
  19. local debug = function(player, ...)
  20. if xi.settings.main.DEBUG_CHOCOBO_RACING then
  21. local t = { ... }
  22. print(unpack(t))
  23. player:printToPlayer(table.concat(t, ' '), xi.msg.channel.SYSTEM_3, '')
  24. end
  25. end
  26.  
  27. local function getWeather()
  28. -- Example dynamic weather conditions based on the LandSandBoat server data
  29. -- This function should interface with the server to get current weather conditions
  30. -- Placeholder for actual weather data retrieval logic
  31. local weather_conditions = {
  32. "sunny",
  33. "hot",
  34. "rainy",
  35. "sandstorm",
  36. "windy",
  37. "snow",
  38. "thunder",
  39. "auroras",
  40. "dark"
  41. }
  42. -- Simulate getting a random weather condition
  43. local weather = weather_conditions[math.random(#weather_conditions)]
  44. return weather
  45. end
  46.  
  47. local function adjustStatsForWeather(chocobo, weather)
  48. -- Adjust chocobo stats based on weather conditions
  49. if weather == "hot" then
  50. chocobo.speed = chocobo.speed - 1
  51. chocobo.endurance = chocobo.endurance - 1
  52. elseif weather == "sandstorm" then
  53. chocobo.endurance = chocobo.endurance - 1
  54. elseif weather == "rainy" then
  55. chocobo.speed = chocobo.speed - 1
  56. chocobo.agility = chocobo.agility - 1
  57. elseif weather == "windy" then
  58. chocobo.agility = chocobo.agility + 1
  59. elseif weather == "snow" then
  60. chocobo.speed = chocobo.speed - 2
  61. elseif weather == "thunder" then
  62. chocobo.endurance = chocobo.endurance - 2
  63. elseif weather == "auroras" then
  64. chocobo.endurance = chocobo.endurance + 1
  65. elseif weather == "dark" then
  66. chocobo.speed = chocobo.speed - 1
  67. elseif weather == "sunny" then
  68. chocobo.speed = chocobo.speed + 1
  69. chocobo.agility = chocobo.agility + 1
  70. end
  71. end
  72.  
  73. local function simulateRace(player, chocobos)
  74. local weather = getWeather()
  75. debug(player, "Current weather:", weather)
  76.  
  77. for _, chocobo in ipairs(chocobos) do
  78. adjustStatsForWeather(chocobo, weather)
  79. end
  80.  
  81. table.sort(chocobos, function(a, b)
  82. return (a.speed + a.agility + a.endurance) > (b.speed + b.agility + b.endurance)
  83. end)
  84.  
  85. return chocobos
  86. end
  87.  
  88. local function printRaceResults(player, chocobos)
  89. debug(player, "Race Results:")
  90. for i, chocobo in ipairs(chocobos) do
  91. debug(player, string.format("%d. %s", i, chocobo.name))
  92. end
  93. end
  94.  
  95. local function startRaceImpl(player)
  96. debug(player, 'Starting race')
  97. player:startEvent(210, 3885177, 3885177, -132554, -14500, 1344, -1, 610862737, 1)
  98. end
  99.  
  100. xi.chocoboRacing.startRace = function()
  101. local players = GetZone(xi.zone.CHOCOBO_CIRCUIT):getPlayers()
  102. local chocobos = {
  103. { name = 'Friend', speed = 5, agility = 4, endurance = 5 },
  104. { name = 'Neddy', speed = 4, agility = 5, endurance = 4 },
  105. { name = 'Beau', speed = 5, agility = 3, endurance = 5 },
  106. { name = 'Grand', speed = 4, agility = 4, endurance = 5 },
  107. { name = 'Reppu', speed = 5, agility = 4, endurance = 4 },
  108. { name = 'Ace', speed = 4, agility = 5, endurance = 3 },
  109. { name = 'Winning', speed = 5, agility = 4, endurance = 4 },
  110. { name = 'Northern', speed = 4, agility = 4, endurance = 5 }
  111. }
  112.  
  113. for _, player in ipairs(players) do
  114. local raceResults = simulateRace(player, chocobos)
  115. printRaceResults(player, raceResults)
  116. startRaceImpl(player)
  117. end
  118. end
  119.  
  120. -- 0x05C
  121. xi.chocoboRacing.onEventUpdate = function(player, csid, option, npc)
  122. debug(player, 'update', csid, option, npc)
  123.  
  124. local chocobos =
  125. {
  126. 'Friend',
  127. 'Neddy',
  128. 'Beau',
  129. 'Grand',
  130. 'Reppu',
  131. 'Ace',
  132. 'Winning',
  133. 'Northern'
  134. }
  135.  
  136. local winningsPerQuill = 1076
  137.  
  138. if csid == 210 then
  139. if option == 5 then
  140. debug(player, 'Intro banner')
  141. player:updateEvent(1, 0, 0xFFFDFA36, 0xFFFFC75C, 0x17345260, 0xFFFFFFFF, 0x24690691, 0xFFFFFFFB)
  142. elseif option == 274 then
  143. debug(player, 'Names 1-4')
  144. player:updateEventString(chocobos[1], chocobos[2], chocobos[3], chocobos[4],
  145. 0x000060B9, 0x000000B9)
  146. player:updateEvent(70, 0, 7, 4, 0x17345260, 0xFFFFFFFF, 0x24690691, 0xFFFFFFFB)
  147. elseif option == 510 or option == 530 then
  148. debug(player, 'Names 5-8 and Start')
  149. player:updateEventString(chocobos[5], chocobos[6], chocobos[7], chocobos[8],
  150. 0x00002928, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00085735)
  151. player:updateEvent(70, 0, 7, 4, 0x17345260, 0xFFFFFFFF, 0x24690691, 0xFFFFFFFB)
  152. elseif option == 17 then
  153. debug(player, 'End and announce winnings')
  154. player:updateEvent(70, 0, winningsPerQuill, 1, 0, 3, 3, 0xFFFFFFFB)
  155. end
  156. elseif csid == 319 then
  157. if option == 1 then
  158. debug(player, 'CS Event 319: Gate interaction with Gate: Chocobo Circuit')
  159. -- Handle gate interaction for event 319
  160. end
  161. elseif csid == 374 then
  162. if option == 1 then
  163. debug(player, 'CS Event 374: Initial interaction')
  164. -- Handle initial interaction for event 374
  165. elseif option == 2 then
  166. debug(player, 'CS Event 374: Second interaction')
  167. -- Handle second interaction for event 374
  168. elseif option == 100 then
  169. debug(player, 'CS Event 374: Option 100 selected')
  170. -- Handle option 100 for event 374
  171. elseif option == 4 then
  172. debug(player, 'CS Event 374: Option 4 selected')
  173. -- Handle option 4 for event 374
  174. end
  175. end
  176. end
  177.  
  178. xi.chocoboRacing.onEventFinish = function(player, csid, option, npc)
  179. debug(player, 'finish', csid, option, npc)
  180. if csid == 210 and option == 17 then
  181. debug(player, 'Hand out winnings')
  182. elseif csid == 319 and option == 1 then
  183. debug(player, 'Finish handling for event 319')
  184. -- Handle finish interaction for event 319
  185. elseif csid == 374 and option == 0 then
  186. debug(player, 'Finish handling for event 374')
  187. -- Handle finish interaction for event 374
  188. end
  189. end
  190.  
  191. xi.chocoboRacing.onNPCChat = function(player, npc, message)
  192. debug(player, 'NPC chat', npc, message)
  193. if npc == 17064036 then
  194. if message == 9307 then
  195. debug(player, 'Handling NPC chat message 9307')
  196. -- Handle chat message 9307 from NPC 17064036
  197. elseif message == 9308 then
  198. debug(player, 'Handling NPC chat message 9308')
  199. -- Handle chat message 9308 from NPC 17064036
  200. end
  201. end
  202. end
  203.  
Advertisement
Add Comment
Please, Sign In to add comment