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 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",
- "hot",
- "rainy",
- "sandstorm",
- "windy",
- "snow",
- "thunder",
- "auroras",
- "dark"
- }
- -- 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 == "hot" then
- chocobo.speed = chocobo.speed - 1
- chocobo.endurance = chocobo.endurance - 1
- elseif weather == "sandstorm" then
- chocobo.endurance = chocobo.endurance - 1
- elseif weather == "rainy" then
- chocobo.speed = chocobo.speed - 1
- chocobo.agility = chocobo.agility - 1
- elseif weather == "windy" then
- chocobo.agility = chocobo.agility + 1
- elseif weather == "snow" then
- chocobo.speed = chocobo.speed - 2
- elseif weather == "thunder" then
- chocobo.endurance = chocobo.endurance - 2
- elseif weather == "auroras" then
- chocobo.endurance = chocobo.endurance + 1
- elseif weather == "dark" then
- chocobo.speed = chocobo.speed - 1
- elseif weather == "sunny" then
- chocobo.speed = chocobo.speed + 1
- chocobo.agility = chocobo.agility + 1
- end
- end
- local function simulateRace(player, chocobos)
- local weather = getWeather()
- debug(player, "Current weather:", weather)
- for _, chocobo in ipairs(chocobos) do
- adjustStatsForWeather(chocobo, weather)
- end
- table.sort(chocobos, function(a, b)
- return (a.speed + a.agility + a.endurance) > (b.speed + b.agility + b.endurance)
- end)
- return chocobos
- end
- local function printRaceResults(player, chocobos)
- debug(player, "Race Results:")
- for i, chocobo in ipairs(chocobos) do
- debug(player, string.format("%d. %s", i, chocobo.name))
- end
- end
- local function startRaceImpl(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()
- local chocobos = {
- { name = 'Friend', speed = 5, agility = 4, endurance = 5 },
- { name = 'Neddy', speed = 4, agility = 5, endurance = 4 },
- { name = 'Beau', speed = 5, agility = 3, endurance = 5 },
- { name = 'Grand', speed = 4, agility = 4, endurance = 5 },
- { name = 'Reppu', speed = 5, agility = 4, endurance = 4 },
- { name = 'Ace', speed = 4, agility = 5, endurance = 3 },
- { name = 'Winning', speed = 5, agility = 4, endurance = 4 },
- { name = 'Northern', speed = 4, agility = 4, endurance = 5 }
- }
- for _, player in ipairs(players) do
- local raceResults = simulateRace(player, chocobos)
- printRaceResults(player, raceResults)
- 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
Advertisement
Add Comment
Please, Sign In to add comment