Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------
- -- Chocobo Racing
- -- https://www.bg-wiki.com/ffxi/Category:Chocobo_Racing
- -- https://ffxiclopedia.fandom.com/wiki/Chocobo_Racing_Guide
- -----------------------------------
- require('scripts/globals/utils')
- -----------------------------------
- xi = xi or {}
- xi.chocoboRacing = xi.chocoboRacing or {}
- -- FOR HEAVILY-IN-DEVELOPMENT TESTING, you can force these settings:
- -- TODO: When ready for release, publish these to main settings files.
- xi.settings.main.ENABLE_CHOCOBO_RACING = true
- xi.settings.main.DEBUG_CHOCOBO_RACING = true
- -- To Run:
- -- !exec xi.chocoboRacing.startRace()
- local debug = function(player, ...)
- if xi.settings.main.DEBUG_CHOCOBO_RACING then
- local t = { ... }
- print(unpack(t))
- player:printToPlayer(table.concat(t, ' '), xi.msg.channel.SYSTEM_3, '')
- end
- end
- local startRaceImpl = function(player)
- debug(player, 'Starting race')
- player:startEvent(210, 3885177, 3885177, -132554, -14500, 1344, -1, 610862737, 1)
- end
- xi.chocoboRacing.startRace = function()
- local players = GetZone(xi.zone.CHOCOBO_CIRCUIT):getPlayers()
- for _, player in ipairs(players) do
- startRaceImpl(player)
- end
- end
- -- 0x05C
- xi.chocoboRacing.onEventUpdate = function(player, csid, option, npc)
- debug(player, 'update', csid, option, npc)
- local chocobos =
- {
- 'Friend',
- 'Neddy',
- 'Beau',
- 'Grand',
- 'Reppu',
- 'Ace',
- 'Winning',
- 'Northern',
- }
- local winningsPerQuill = 1076
- if csid == 210 then
- if option == 5 then
- debug(player, 'Intro banner')
- player:updateEvent(1, 0, 0xFFFDFA36, 0xFFFFC75C, 0x17345260, 0xFFFFFFFF, 0x24690691, 0xFFFFFFFB)
- elseif option == 274 then
- debug(player, 'Names 1-4')
- player:updateEventString(chocobos[1], chocobos[2], chocobos[3], chocobos[4],
- 0x000060B9, 0x000000B9)
- player:updateEvent(70, 0, 7, 4, 0x17345260, 0xFFFFFFFF, 0x24690691, 0xFFFFFFFB)
- elseif option == 510 or option == 530 then
- debug(player, 'Names 5-8 and Start')
- player:updateEventString(chocobos[5], chocobos[6], chocobos[7], chocobos[8],
- 0x00002928, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00085735)
- player:updateEvent(70, 0, 7, 4, 0x17345260, 0xFFFFFFFF, 0x24690691, 0xFFFFFFFB)
- elseif option == 17 then
- debug(player, 'End and announce winnings')
- player:updateEvent(70, 0, winningsPerQuill, 1, 0, 3, 3, 0xFFFFFFFB)
- end
- elseif csid == 319 then
- if option == 1 then
- debug(player, 'CS Event 319: Gate interaction with Gate: Chocobo Circuit')
- -- Handle gate interaction for event 319
- end
- elseif csid == 374 then
- if option == 1 then
- debug(player, 'CS Event 374: Initial interaction')
- -- Handle initial interaction for event 374
- elseif option == 2 then
- debug(player, 'CS Event 374: Second interaction')
- -- Handle second interaction for event 374
- elseif option == 100 then
- debug(player, 'CS Event 374: Option 100 selected')
- -- Handle option 100 for event 374
- elseif option == 4 then
- debug(player, 'CS Event 374: Option 4 selected')
- -- Handle option 4 for event 374
- end
- end
- end
- xi.chocoboRacing.onEventFinish = function(player, csid, option, npc)
- debug(player, 'finish', csid, option, npc)
- if csid == 210 and option == 17 then
- debug(player, 'Hand out winnings')
- elseif csid == 319 and option == 1 then
- debug(player, 'Finish handling for event 319')
- -- Handle finish interaction for event 319
- elseif csid == 374 and option == 0 then
- debug(player, 'Finish handling for event 374')
- -- Handle finish interaction for event 374
- end
- end
- xi.chocoboRacing.onNPCChat = function(player, npc, message)
- debug(player, 'NPC chat', npc, message)
- if npc == 17064036 then
- if message == 9307 then
- debug(player, 'Handling NPC chat message 9307')
- -- Handle chat message 9307 from NPC 17064036
- elseif message == 9308 then
- debug(player, 'Handling NPC chat message 9308')
- -- Handle chat message 9308 from NPC 17064036
- end
- end
- end
- -- Additional Chocobo Racing Data and Simulation Functions
- local chocobo_race = {
- {
- name = "Speedy",
- speed = 10,
- endurance = 8,
- agility = 9,
- color = "red",
- },
- {
- name = "Blaze",
- speed = 9,
- endurance = 10,
- agility = 8,
- color = "orange",
- },
- {
- name = "Storm",
- speed = 8,
- endurance = 9,
- agility = 10,
- color = "blue",
- },
- {
- name = "Shadow",
- speed = 7,
- endurance = 10,
- agility = 9,
- color = "black",
- },
- {
- name = "Spark",
- speed = 9,
- endurance = 8,
- agility = 10,
- color = "yellow",
- }
- }
- local function getWeather()
- -- Example dynamic weather conditions based on the LandSandBoat server data
- -- This function should interface with the server to get current weather conditions
- -- Placeholder for actual weather data retrieval logic
- local weather_conditions = {
- "sunny",
- "rainy",
- "windy",
- "snowy",
- "stormy"
- }
- -- Simulate getting a random weather condition
- local weather = weather_conditions[math.random(#weather_conditions)]
- return weather
- end
- local function adjustStatsForWeather(chocobo, weather)
- -- Adjust chocobo stats based on weather conditions
- if weather == "rainy" then
- chocobo.speed = chocobo.speed - 1
- chocobo.agility = chocobo.agility - 1
- elseif weather == "windy" then
- chocobo.endurance = chocobo.endurance - 1
- elseif weather == "snowy" then
- chocobo.speed = chocobo.speed - 2
- elseif weather == "stormy" then
- chocobo.endurance = chocobo.endurance - 2
- end
- end
- local function simulateRace()
- local weather = getWeather()
- print("Current weather condition: " .. weather)
- for _, chocobo in ipairs(chocobo_race) do
- adjustStatsForWeather(chocobo, weather)
- chocobo.performance = chocobo.speed + chocobo.endurance + chocobo.agility + math.random(-5, 5)
- end
- table.sort(chocobo_race, function(a, b) return a.performance > b.performance end)
- end
- local function printRaceResults()
- print("Chocobo Race Results:")
- for i, chocobo in ipairs(chocobo_race) do
- print(i .. ". " .. chocobo.name .. " (" .. chocobo.color .. ") - Performance: " .. chocobo.performance)
- end
- end
- local function automateRaces(interval)
- while true do
- simulateRace()
- printRaceResults()
- os.execute("sleep " .. interval)
- end
- end
- -- Run the automated races every 15 minutes (900 seconds)
- automateRaces(900)
Advertisement
Add Comment
Please, Sign In to add comment