Skip to content

Commit

Permalink
puzzle 3 triva challenge implementation
Browse files Browse the repository at this point in the history
Almost all logic for determining cutscenes is handled by event arguments
I've done my best to make all the arguments self-explanatory via their names
  • Loading branch information
Flibe-XI committed Feb 2, 2024
1 parent 2f71f2e commit 19ca916
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 90 deletions.
125 changes: 46 additions & 79 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 @@ -74,7 +74,7 @@ mission.sections =
player:needToZone(true)
end
end,
}
},
},
},

Expand All @@ -100,14 +100,14 @@ mission.sections =
['Goblin_Grenadier'] =
{
onTrigger = function(player, npc)
local answer = player:getLocalVar('Mission[10][12]pipSet') - 1
local answer = player:getLocalVar('Mission[10][12][p1]pipSet') - 1

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

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

Expand All @@ -126,108 +126,42 @@ mission.sections =
['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
)
return xi.amk.helpers.puzzleOneOnTrigger(player, npc, mission, 1)
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(
511,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
return xi.amk.helpers.puzzleOneOnTrigger(player, npc, mission, 2)
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(
512,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
return xi.amk.helpers.puzzleOneOnTrigger(player, npc, mission, 3)
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(
513,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
return xi.amk.helpers.puzzleOneOnTrigger(player, npc, mission, 4)
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(
514,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
return xi.amk.helpers.puzzleOneOnTrigger(player, npc, mission, 5)
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(
515,
pos.x * 1000,
pos.z * 1000,
pos.y * 1000,
element,
xi.ki.MAP_OF_THE_NORTHLANDS_AREA
)
return xi.amk.helpers.puzzleOneOnTrigger(player, npc, mission, 6)
end,
},

Expand All @@ -249,8 +183,8 @@ mission.sections =
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)
local hintsUsed = player:getLocalVar('Mission[10][12][p1]hintsUsed')
player:setLocalVar('Mission[10][12][p1]hintsUsed', hintsUsed + 1)
elseif option == 3 then
-- wrong answer, reset puzzle
player:needToZone(false)
Expand Down Expand Up @@ -280,7 +214,7 @@ mission.sections =

[508] = function(player, csid, option, npc)
-- Pipset offset by 1 to account for saving 0 as a variable. When retrieving, subtract 1
player:setLocalVar('Mission[10][12]pipSet', math.random(1, 10)) -- range: 0 - 9
player:setLocalVar('Mission[10][12][p1]pipSet', math.random(1, 10)) -- range: 0 - 9
end,
},
},
Expand Down Expand Up @@ -325,7 +259,7 @@ mission.sections =
-- Part 3: Xarcabard
{
check = function(player, currentMission, missionStatus, vars)
return currentMission == mission.missionId and
return currentMission >= mission.missionId and
player:getCharVar('Mission[10][12]progress') == 2 and
player:hasKeyItem(xi.ki.TRIVIA_CHALLENGE_KUPON)
end,
Expand All @@ -343,7 +277,40 @@ mission.sections =

[xi.zone.XARCABARD] =
{
['Option_One'] =
{
onTrigger = function(player, npc)
return xi.amk.helpers.puzzleTwoOnTrigger(player, npc, mission)
end,
},

['Option_Two'] =
{
onTrigger = function(player, npc)
return xi.amk.helpers.puzzleTwoOnTrigger(player, npc, mission)
end,
},

['Option_Three'] =
{
onTrigger = function(player, npc)
return xi.amk.helpers.puzzleTwoOnTrigger(player, npc, mission)
end,
},

onEventUpdate =
{
[200] = function(player, csid, option, npc)
xi.amk.helpers.puzzleTwoOnEventUpdate(player, csid, option, npc, mission)
end,
},

onEventFinish =
{
[200] = function(player, csid, option, npc)
xi.amk.helpers.puzzleTwoOnEventFinish(player, csid, option, npc, mission)
end
},
},
},

Expand Down
Loading

0 comments on commit 19ca916

Please sign in to comment.