Skip to content

Commit

Permalink
Add beauc glac puzzle npc logic
Browse files Browse the repository at this point in the history
Structure for cutscenes handled by lonely evergreen and goblin grenadier, as well as the
structure of the pips.
  • Loading branch information
Flibe-XI committed Jan 28, 2024
1 parent 45ad07b commit 867b6c9
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 11 deletions.
319 changes: 313 additions & 6 deletions scripts/missions/amk/13_A_Challenge_You_Could_Be_a_Winner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,334 @@ mission.reward =

mission.sections =
{
-- Part 1: Castle Zvahl Baileys
{
check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId
return currentMission >= mission.missionId and
not player:hasKeyItem(xi.ki.GAUNTLET_CHALLENGE_KUPON)
end,

[xi.zone.CASTLE_ZVAHL_BAILEYS] =
{
["Shadowy_Pillar"] =
{
onTrigger = function(player, npc)
return mission:progressEvent(100, 3)
end,
},

onEventFinish =
{
[100] = function(player, csid, option, npc)
player:setCharVar('Mission[10][12]progress', 1)
end,
},
},
},

-- Part 2-a: Beaucidine Glacier
{
check = function(player, currentMission, missionStatus, vars)
return currentMission >= mission.missionId and
player:getCharVar('Mission[10][12]progress') == 1 and
not player:hasKeyItem(xi.ki.POCKET_MOGBOMB) and
not player:hasKeyItem(xi.ki.TRIVIA_CHALLENGE_KUPON) and
player:needToZone() == false
end,

[xi.zone.BEAUCEDINE_GLACIER] =
{
['Lonely_Evergreen'] =
{
onTrigger = function(player, npc)
return mission:progressEvent(504)
end,
},

onEventFinish =
{
[504] = function(player, csid, option, npc)
if option == 1 then
player:needToZone(true)
end
end,
}
},
},

-- Part 2-b: Beaucidine Glacier
{
check = function(player, currentMission, missionStatus, vars)
return currentMission >= mission.missionId and
player:getCharVar('Mission[10][12]progress') == 1 and
not player:hasKeyItem(xi.ki.POCKET_MOGBOMB) and
not player:hasKeyItem(xi.ki.TRIVIA_CHALLENGE_KUPON) and
player:needToZone() == true
end,

[xi.zone.BEAUCEDINE_GLACIER] =
{
['Lonely_Evergreen'] =
{
onTrigger = function(player, npc)
return mission:progressEvent(503)
end,
},
-- !reloadglobal scripts/missions/amk/13_A_Challenge_You_Could_Be_a_Winner I_am_sure
['Goblin_Grenadier'] =
{
onTrigger = function(player, npc)
local answer = player:getLocalVar('Mission[10][12]pipSet') - 1

if answer < 0 then
return mission:progressEvent(508)
else
local today = VanadielDayOfTheWeek()
local tomorrow = (today + 1) % 8
local hintsUsed = player:getLocalVar('Mission[10][12]hintsUsed')

player:messageSpecial(zones[player:getZoneID()].text.GRENADIER_DAY_HINT, today, tomorrow)

return mission:progressEvent(
507,
hintsUsed + 2,
answer,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA,
xi.ki.POCKET_MOGBOMB
)
end
end,
},

['Northwestern_Pip'] =
{
onTrigger = function(player, npc)
local pipSet = player:getLocalVar('Mission[10][12]pipSet') - 1
local pos = npc:getPos()
local element = xi.amk.helpers.pipSets[pipSet][1]

return mission:progressEvent(
510,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
end,
},

['Western_Pip'] =
{
onTrigger = function(player, npc)
local pipSet = player:getLocalVar('Mission[10][12]pipSet') - 1
local pos = npc:getPos()
local element = xi.amk.helpers.pipSets[pipSet][2]

return mission:progressEvent(
510,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
end,
},

['Southwestern_Pip'] =
{
onTrigger = function(player, npc)
local pipSet = player:getLocalVar('Mission[10][12]pipSet') - 1
local pos = npc:getPos()
local element = xi.amk.helpers.pipSets[pipSet][3]

return mission:progressEvent(
510,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
end,
},

['Northeastern_Pip'] =
{
onTrigger = function(player, npc)
local pipSet = player:getLocalVar('Mission[10][12]pipSet') - 1
local pos = npc:getPos()
local element = xi.amk.helpers.pipSets[pipSet][4]

return mission:progressEvent(
510,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
end,
},

['Eastern_Pip'] =
{
onTrigger = function(player, npc)
local pipSet = player:getLocalVar('Mission[10][12]pipSet') - 1
local pos = npc:getPos()
local element = xi.amk.helpers.pipSets[pipSet][5]

return mission:progressEvent(
510,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
end,
},

['Southeastern_Pip'] =
{
onTrigger = function(player, npc)
local pipSet = player:getLocalVar('Mission[10][12]pipSet') - 1
local pos = npc:getPos()
local element = xi.amk.helpers.pipSets[pipSet][6]

return mission:progressEvent(
510,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
end,
},

onEventFinish =
{
[507] = function(player, csid, option, npc)
-- option = 4 when the player chooses to exit the chat, or tries to get a third hint,
-- which doesn't exist. Two hints max
if
option == 1 or -- Used first hint
option == 2 -- Used second hint
then
local hintsUsed = player:getLocalVar('Mission[10][12]hintsUsed')
player:setLocalVar('Mission[10][12]hintsUsed', hintsUsed + 1)
elseif option == 3 then
-- wrong answer, reset puzzle
player:needToZone(false)
elseif
option == 5 or -- Correct answer, no hints used
option == 6 or -- Correct answer, one hint used
option == 7 -- Correct answer, two hints used
then
player:needToZone(false)
npcUtil.giveKeyItem(player, xi.ki.POCKET_MOGBOMB)

-- Add flee affect, base 5 minutes for no hints used, 3 for 1 hint, no flee for 2 hints
local fleeDuration = { [5] = 300, [6] = 180 }
if option == 5 or option == 6 then
player:addStatusEffect(xi.effect.FLEE, 100, 0, fleeDuration[option])
end
end
end,

[508] = function(player, csid, option, npc)
-- Pipset offset by 1 to account for saving 0 as a variable. When retrieving, subtract 1
player:setCharVar('Mission[10][12]pipSet', math.random(1, 10))
end,
},
},
},

-- Part 2-c: Beaucidine Glacier
{
check = function(player, currentMission, missionStatus, vars)
return currentMission >= mission.missionId and
player:getCharVar('Mission[10][12]progress') == 1 and
player:hasKeyItem(xi.ki.POCKET_MOGBOMB)
end,

[xi.zone.UPPER_JEUNO] =
[xi.zone.BEAUCEDINE_GLACIER] =
{
['Inconspicuous_Door'] =
['Lonely_Evergreen'] =
{
onTrigger = function(player, npc)
return mission:progressEvent(502, xi.ki.POCKET_MOGBOMB, xi.ki.TRIVIA_CHALLENGE_KUPON)
end,
},

['Goblin_Grenadier'] =
{
onTrigger = function(player, npc)
return mission:progressEvent(10185)
-- Reminder to take mogbomb to lonely evergreen moogle
player:messageSpecial(zones[player:getZoneID()].text.GRENADIER_TAKE_PRIZE, xi.ki.POCKET_MOGBOMB)
end,
},

onEventFinish =
{
[10185] = function(player, csid, option, npc)
mission:complete(player)
[502] = function(player, csid, option, npc)
player:delKeyItem(xi.ki.POCKET_MOGBOMB)
npcUtil.giveKeyItem(player, xi.ki.TRIVIA_CHALLENGE_KUPON)
player:setCharVar('Mission[10][12]progress', 2)
end,
},
},
},

-- Part 3: Xarcabard
{
check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId and
player:getCharVar('Mission[10][12]progress') == 2 and
player:hasKeyItem(xi.ki.TRIVIA_CHALLENGE_KUPON)
end,

[xi.zone.BEAUCEDINE_GLACIER] =
{
['Lonely_Evergreen'] =
{
onTrigger = function(player, npc)
-- Reminder text
return mission:progressEvent(501, xi.ki.TRIVIA_CHALLENGE_KUPON)
end,
},
},

[xi.zone.XARCABARD] =
{

},
},

-- Part 4: Castle Zvahl Baileys
{
check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId
end,

[xi.zone.CASTLE_ZVAHL_BAILEYS] =
{

},
},

-- Part 5: Castle Zvahl Keep
{
check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId
end,

[xi.zone.CASTLE_ZVAHL_KEEP] =
{

},
},
}

Expand Down
Loading

0 comments on commit 867b6c9

Please sign in to comment.