Index: scripts/zones/Lower_Jeuno/npcs/Chululu.lua =================================================================== --- scripts/zones/Lower_Jeuno/npcs/Chululu.lua (revision 3100) +++ scripts/zones/Lower_Jeuno/npcs/Chululu.lua (working copy) @@ -2,6 +2,7 @@ -- Area: Lower Jeuno -- NPC: Chululu -- Starts and Finishes Quest: Collect Tarut Cards, Rubbish Day +-- Optional Cutscene at end of Quest: Searching for the Right Words -- @zone 245 -- @pos -13 -6 -42 ----------------------------------- @@ -32,9 +33,11 @@ ----------------------------------- function onTrigger(player,npc) - CollectTarutCards = player:getQuestStatus(JEUNO,COLLECT_TARUT_CARDS); - RubbishDay = player:getQuestStatus(JEUNO,RUBBISH_DAY); + local CollectTarutCards = player:getQuestStatus(JEUNO,COLLECT_TARUT_CARDS); + local RubbishDay = player:getQuestStatus(JEUNO,RUBBISH_DAY); + local SearchingForTheRightWords = player:getQuestStatus(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS); + if(player:getFameLevel(JEUNO) >= 3 and CollectTarutCards == QUEST_AVAILABLE) then player:startEvent(0x001C); -- Start quest "Collect Tarut Cards" with option elseif(CollectTarutCards == QUEST_ACCEPTED) then @@ -52,8 +55,17 @@ player:startEvent(0x0031); -- During quest "Rubbish Day" elseif(RubbishDay == QUEST_ACCEPTED and player:getVar("RubbishDayVar") == 1) then player:startEvent(0x00c5); -- Finish quest "Rubbish Day" + + elseif(SearchingForTheRightWords == QUEST_COMPLETED) then + if (player:getVar("SearchingForRightWords_postcs") < -1) then + player:startEvent(0x0038); + else + player:startEvent(0x0057); -- final state, after all quests complete + end + elseif(RubbishDay == QUEST_COMPLETED) then - player:startEvent(0x0038); -- New standard dialog + player:startEvent(0x0057); -- New standard dialog + else player:startEvent(0x001A); -- Standard dialog end Index: scripts/zones/Lower_Jeuno/npcs/Kurou-Morou.lua =================================================================== --- scripts/zones/Lower_Jeuno/npcs/Kurou-Morou.lua (revision 3100) +++ scripts/zones/Lower_Jeuno/npcs/Kurou-Morou.lua (working copy) @@ -34,11 +34,19 @@ ----------------------------------- function onTrigger(player,npc) - YourCrystalBall = player:getQuestStatus(JEUNO,YOUR_CRYSTAL_BALL); - JFame = player:getFameLevel(JEUNO) - + printf("Ontrigger completed"); + local YourCrystalBall = player:getQuestStatus(JEUNO,YOUR_CRYSTAL_BALL); + local SearchingForTheRightWords = player:getQuestStatus(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS); + local ACandlelightVigil = player:getQuestStatus(JEUNO,A_CANDLELIGHT_VIGIL); + local RubbishDay = player:getQuestStatus(JEUNO,RUBBISH_DAY); + local NeverToReturn = player:getQuestStatus(JEUNO,NEVER_TO_RETURN); + local JFame = player:getFameLevel(JEUNO); + local SearchingForWords_prereq = player:getVar("QuestSearchRightWords_prereq"); + + if (JFame >= 2 and YourCrystalBall == QUEST_AVAILABLE) then player:startEvent(0x00C2); -- Start "Your Crystal Ball" quest + elseif(JFame >= 5 and YourCrystalBall == QUEST_COMPLETED and player:getQuestStatus(JEUNO,NEVER_TO_RETURN) == QUEST_AVAILABLE and player:getVar("QuestNeverToReturn_day") ~= VanadielDayOfTheYear()) then prog = player:getVar("QuestNeverToReturn_prog"); if(prog <= 2) then @@ -47,6 +55,28 @@ elseif(prog == 3) then player:startEvent(0x00Ca); -- Start "Never to return" quest end + + --if searching for right words *prereq* CS has been activated + elseif(SearchingForWords_prereq == 1) then + player:startEvent(0x0026); + + elseif(player:getVar("QuestSearchRightWords_denied") == 1) then + player:startEvent(0x0024); + + elseif(SearchingForTheRightWords == QUEST_ACCEPTED) then + player:startEvent(0x0027); + + elseif(player:getVar("SearchingForRightWords_postcs") == -2) then + player:startEvent(0x009a); + + elseif(SearchingForTheRightWords == QUEST_COMPLETED) then --final state, after all quests complete + player:startEvent(0x0025); + + --conditions for searching for the right words + elseif(JFame >= 7 and ACandlelightVigil == QUEST_COMPLETED and RubbishDay == QUEST_COMPLETED and + NeverToReturn == QUEST_COMPLETED and SearchingForTheRightWords == QUEST_AVAILABLE) then + player:startEvent(0x0011); + else player:startEvent(0x00C1); -- Standard dialog end @@ -94,5 +124,9 @@ player:tradeComplete(trade); player:completeQuest(JEUNO,NEVER_TO_RETURN); end + elseif(csid == 0x0011) then + player:setVar("QuestSearchRightWords_prereq", 1); + elseif(csid == 0x009a) then + player:setVar("SearchingForRightWords_postcs", -1); end end; \ No newline at end of file Index: scripts/zones/The_Boyahda_Tree/mobs/Agas.lua =================================================================== --- scripts/zones/The_Boyahda_Tree/mobs/Agas.lua (revision 0) +++ scripts/zones/The_Boyahda_Tree/mobs/Agas.lua (working copy) @@ -0,0 +1,24 @@ +----------------------------------- +-- Area: The Boyahda Tree +-- NPC: Agas +----------------------------------- + +require("scripts/globals/quests"); +require("scripts/globals/keyitems"); + +----------------------------------- +-- onMobSpawn Action +----------------------------------- + +function OnMobSpawn(mob) +end; + +----------------------------------- +-- onMobDeath +----------------------------------- +function onMobDeath(mob, killer) + if (killer:getQuestStatus(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS) == QUEST_ACCEPTED and not killer:hasKeyItem(MOONDROP)) then + printf("Agas successfully killed!"); + killer:setVar("Searching_AgasKilled", 1); + end +end; \ No newline at end of file Index: scripts/zones/The_Boyahda_Tree/npcs/qm2.lua =================================================================== --- scripts/zones/The_Boyahda_Tree/npcs/qm2.lua (revision 0) +++ scripts/zones/The_Boyahda_Tree/npcs/qm2.lua (working copy) @@ -0,0 +1,77 @@ +----------------------------------- +-- Area: The Boyahda Tree +-- NPC: ??? +-- Involved in Quest: Searching for the Right Words +----------------------------------- + +package.loaded["scripts/zones/The_Boyahda_Tree/TextIDs"] = nil; +require("scripts/zones/The_Boyahda_Tree/TextIDs"); +require("scripts/globals/quests"); +require("scripts/globals/keyitems"); + +----------------------------------- +-- onTrade Action +----------------------------------- + +function onTrade(player,npc,trade) +end; + +----------------------------------- +-- onTrigger Action +-- does ??? depop when Agas is spawned? +-- current implementation: when Agas is active, triggering ??? will result in detarget +----------------------------------- + +function onTrigger(player,npc) + + local SearchingForWords = player:getQuestStatus(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS); + local zoneHour = VanadielHour(); + local zoneMinute = VanadielMinute(); + local correctTime = zoneHour >= 19 or zoneHour < 4 or (zoneHour == 4 and zoneMinute == 0); + + if(GetMobAction(17404339) == 0) then + if (player:hasKeyItem(MOONDROP)) then + player:messageSpecial(CAN_SEE_SKY); + + elseif (SearchingForWords == QUEST_ACCEPTED) then + + if (IsMoonNew() or not correctTime) then + player:messageSpecial(CANNOT_SEE_MOON); + + elseif (player:getVar("Searching_AgasKilled") == 1) then + player:startEvent(0x000e); + + else + player:messageSpecial(SOMETHING_NOT_RIGHT); + SpawnMob(17404339,288):updateEnmity(player); --missing repop timer for Agas due to errors with SpawnMob + end + + else + player:messageSpecial(CAN_SEE_SKY); + end + end +end; + +----------------------------------- +-- onEventUpdate +----------------------------------- + +function onEventUpdate(player,csid,option) +--printf("CSID: %u",csid); +--printf("RESULT: %u",option); +end; + +----------------------------------- +-- onEventFinish +----------------------------------- + +function onEventFinish(player,csid,option) +--printf("CSID: %u",csid); +--printf("RESULT: %u",option); + if (csid == 0x000e) then + player:addKeyItem(MOONDROP); + player:messageSpecial(KEYITEM_OBTAINED, MOONDROP); + player:setVar("Searching_AgasKilled", 0); + end + +end; \ No newline at end of file Index: scripts/zones/The_Boyahda_Tree/TextIDs.lua =================================================================== --- scripts/zones/The_Boyahda_Tree/TextIDs.lua (revision 3100) +++ scripts/zones/The_Boyahda_Tree/TextIDs.lua (working copy) @@ -16,3 +16,8 @@ CHEST_MOOGLE = 7098; -- You cannot open the chest while participating in the moogle event. CHEST_ILLUSION = 7099; -- The chest was but an illusion... CHEST_LOCKED = 7100; -- The chest appears to be locked. + +-- Searching for the Right Words Quest Dialog + CAN_SEE_SKY = 7106; -- You can see the sky from here. +SOMETHING_NOT_RIGHT = 7107; -- Something is not right! + CANNOT_SEE_MOON = 7108; -- You cannot see the moon right now. \ No newline at end of file Index: scripts/zones/Upper_Jeuno/npcs/Ilumida.lua =================================================================== --- scripts/zones/Upper_Jeuno/npcs/Ilumida.lua (revision 3100) +++ scripts/zones/Upper_Jeuno/npcs/Ilumida.lua (working copy) @@ -27,15 +27,45 @@ ----------------------------------- function onTrigger(player,npc) - aCandlelightVigil = player:getQuestStatus(JEUNO,A_CANDLELIGHT_VIGIL); + local aCandlelightVigil = player:getQuestStatus(JEUNO,A_CANDLELIGHT_VIGIL); + local SearchingForWords = player:getQuestStatus(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS); + + --this variable implicitly stores: JFame >= 7 and ACandlelightVigil == QUEST_COMPLETED and RubbishDay == QUEST_COMPLETED and + --NeverToReturn == QUEST_COMPLETED and SearchingForTheRightWords == QUEST_AVAILABLE and prereq CS complete + local SearchingForWords_prereq = player:getVar("QuestSearchRightWords_prereq"); + + if (player:getFameLevel(JEUNO) >= 4 and aCandlelightVigil == QUEST_AVAILABLE) then player:startEvent(0x00c0); --Start quest : Ilumida asks you to obtain a candle ... elseif (aCandlelightVigil == QUEST_ACCEPTED) then if (player:hasKeyItem(HOLY_CANDLE) == true) then player:startEvent(0x00c2); --Finish quest : CS NOT FOUND. else - player:startEvent(0x00c1); -- During quest + player:startEvent(0x00bf); --quest accepted dialog end + + elseif (player:getVar("QuestACandlelightVigil_denied") == 1) then + player:startEvent(0x00c1); --quest denied dialog, asks again for A Candlelight Vigil + + elseif (SearchingForWords_prereq == 1) then --has player completed prerequisite cutscene with Kurou-Morou? + player:startEvent(0x00c5); --SearchingForTheRightWords intro CS + + elseif (player:getVar("QuestSearchRightWords_denied") == 1) then + player:startEvent(0x00c9); --asks player again, SearchingForTheRightWords accept/deny + + elseif (SearchingForWords == QUEST_ACCEPTED) then + if (player:hasKeyItem(MOONDROP) == true) then + player:startEvent(0x00c6); + else + player:startEvent(0x00c7); -- SearchingForTheRightWords quest accepted dialog + end + + elseif (player:getVar("SearchingForRightWords_postcs") == -1) then + player:startEvent(0x00c4); + + elseif(SearchingForWords == QUEST_COMPLETED) then + player:startEvent(0x00c8); + else player:startEvent(0x00BD); --Standard dialog end @@ -57,8 +87,13 @@ function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); - if(csid == 0x00c0 and option == 1) then --just start quest + if((csid == 0x00c0 and option == 1) or (csid == 0x00c1 and option == 1)) then --just start quest player:addQuest(JEUNO,A_CANDLELIGHT_VIGIL); + player:setVar("QuestACandlelightVigil_denied", 0); + + elseif(csid == 0x00c0 and option == 0) then --quest denied, special eventIDs available + player:setVar("QuestACandlelightVigil_denied", 1); + elseif(csid == 0x00c2) then --finish quest if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,13094); @@ -71,5 +106,29 @@ player:addFame(JEUNO,30); player:completeQuest(JEUNO,A_CANDLELIGHT_VIGIL); end + + elseif(csid == 0x00c5 and option == 0) then --quest denied, special eventIDs available + player:setVar("QuestSearchRightWords_prereq", 0); --remove charVar from memory + player:setVar("QuestSearchRightWords_denied", 1); + + elseif((csid == 0x00c5 and option == 1) or (csid == 0x00c9 and option == 1)) then + player:setVar("QuestSearchRightWords_prereq", 0); --remove charVar from memory + player:setVar("QuestSearchRightWords_denied", 0); + player:addQuest(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS); + + elseif(csid == 0x00c6) then --finish quest, note: no title granted + if (player:getFreeSlotsCount() == 0) then + player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,4882); + else + player:delKeyItem(MOONDROP); + player:messageSpecial(GIL_OBTAINED, GIL_RATE*3000) + player:addItem(4882); + player:messageSpecial(ITEM_OBTAINED,4882); + player:addFame(JEUNO,30); + player:completeQuest(JEUNO,SEARCHING_FOR_THE_RIGHT_WORDS); + player:setVar("SearchingForRightWords_postcs", -2); + end + elseif(csid == 0x00c4) then + player:setVar("SearchingForRightWords_postcs", 0); end end; \ No newline at end of file Index: sql/mob_spawn_points.sql =================================================================== --- sql/mob_spawn_points.sql (revision 3100) +++ sql/mob_spawn_points.sql (working copy) @@ -39922,7 +39922,7 @@ INSERT INTO `mob_spawn_points` VALUES ('17404336', 'Bark_Tarantula', '8141', '-139.648', '5.398', '170.288', '127'); INSERT INTO `mob_spawn_points` VALUES ('17404337', 'Bark_Tarantula', '8141', '-141.047', '5.051', '153.710', '64'); INSERT INTO `mob_spawn_points` VALUES ('17404338', 'Mimic', '8155', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17404339', 'Agas', '8137', '0.000', '0.000', '0.000', '0'); +INSERT INTO `mob_spawn_points` VALUES ('17404339', 'Agas', '8197', '32.000', '-20.000', '-65.000', '238'); INSERT INTO `mob_spawn_points` VALUES ('17404340', 'Beet_Leafhopper', '8142', '0.000', '0.000', '0.000', '0'); INSERT INTO `mob_spawn_points` VALUES ('17404384', 'Zonpa-Zippa', '8170', '189.414', '-32.840', '-157.059', '92'); INSERT INTO `mob_spawn_points` VALUES ('17404241', 'Snaggletooth Peapuk', '10744', '-191.151', '8.487', '-235.017', '127'); Index: src/map/lua/luautils.cpp =================================================================== --- src/map/lua/luautils.cpp (revision 3100) +++ src/map/lua/luautils.cpp (working copy) @@ -97,6 +97,8 @@ lua_register(LuaHandle,"VanadielMoonPhase",luautils::VanadielMoonPhase); lua_register(LuaHandle,"VanadielMoonDirection", luautils::VanadielMoonDirection); lua_register(LuaHandle,"SetVanadielTimeOffset",luautils::SetVanadielTimeOffset); + + lua_register(LuaHandle,"IsMoonNew",luautils::IsMoonNew); lua_register(LuaHandle,"RunElevator",luautils::StartElevator); lua_register(LuaHandle,"GetServerVariable",luautils::GetServerVariable); lua_register(LuaHandle,"SetServerVariable",luautils::SetServerVariable); @@ -441,7 +443,43 @@ return 1; } + /************************************************************************ +* * +* is new moon? * +* * +************************************************************************/ + +int32 IsMoonNew(lua_State* L) +{ + // New moon occurs when: + // Waning (decreasing) from 10% to 0%, + // Waxing (increasing) from 0% to 5%. + + uint8 phase = CVanaTime::getInstance()->getMoonPhase(); + + switch (CVanaTime::getInstance()->getMoonDirection()) + { + case 0: // None + lua_pushboolean(L, false); + return 0; + + case 1: // Waning (decending) + if (phase <= 10 && phase >= 0) { + lua_pushboolean(L, true); + return 1; + } + + case 2: // Waxing (increasing) + if (phase >= 0 && phase <= 5) { + lua_pushboolean(L, true); + return 1; + } + } + lua_pushboolean(L, false); + return 0; +} +/************************************************************************ * * * Spawn a mob using mob ID. * * * Index: src/map/lua/luautils.h =================================================================== --- src/map/lua/luautils.h (revision 3100) +++ src/map/lua/luautils.h (working copy) @@ -77,6 +77,7 @@ int32 VanadielMoonPhase(lua_State*); // Gets the current Vanadiel Moon Phase int32 VanadielMoonDirection(lua_State* L); // Gets the current Vanadiel Moon Phasing direction (waxing, waning, neither) int32 SetVanadielTimeOffset(lua_State* L); + int32 IsMoonNew(lua_State* L); // Returns true if the moon is new int32 StartElevator(lua_State*); int32 GetServerVariable(lua_State*); int32 SetServerVariable(lua_State *);