// Blue Sage quest
// The mansion of the Sage is in disarray, because a magic experiment with the slimes went wrong,
// the white and blue slimes got out of control, ate most of the books in the library
// and most of the slimes escaped to the outside world
// Variable used: QUEST_BlueSage
// Author: Jenalya
// Subquests:
// Byte 0:
// Bit 0 - 4: Collect missing book pages
// some of the helpers are working on recreating the more valuable books
// they need the missing bookpages for that
// value gives the number of new pages given to the helpers (up to 31)
// bit 5: got Grimoire as reward for collecting the bookpages and bringing material to repair the books
// Bit 6: got reward for defeating the remaining slimes in the library
// Bit 7: unused
// Nibble 2 as flags: Bring material to repair the books and make new books
// Bit 0: Reed Bundles
// Bit 1: Silk Cocoons
// Bit 2: Yeti Claws
// Bit 3: Inks (Bottle of Water, Iron Powder, Wisp Powder, Spectre Powder, Poltergeist Powder)
// Nibble 3: Investigation of how the accident could have happened
// state 1: helper who is considered to have caused the accident asks the player to talk to the chief helper to find out if he's going to loose his job
// state 2: talked to chief and get the mission to investigate about what exactly happened
// there are two independent circumstances to gather information about, one is about how the helpers did their job (a) and another about a suspicious visitor shortly before the accident happened (b)
// this is saved as described here:
// (a) (b)
// 0 0 (state 2) started investigation
// 0 1 (state 3) talked to Janitor
// 0 2 (state 4) got more information about visitor
// 1 0 (state 5) talked to Peetu
// 1 1 (state 6) talked to Peetu and talked to Janitor
// 1 2 (state 7) talked to Peetu and got more information about visitor
// 2 0 (state 8) got more information about Peetu
// 2 1 (state 9) got more information about Peetu and talked to Janitor
// 2 2 (state 10) got more information about Peetu and got more information about visitor
// (a) first talk to the helper in the bedroom, who describes how careful he has been
// (a) and then to at least one of the helpers in the library, who supports that
// (a) it's possible to talk to more helpers, who will support too, but it suffices to talk to one
// (b) first talk to the janitor in the entrance room, who mentions the suspicious visitor
// (b) then talk to at least one of the helpers in the entrance room/library who give more information about the visitor
// (b) it's possible to talk to more helpers, who will give redundant information, but it suffices to talk to one
// so to have somed progress in (a) add three to the variable, and for progress in (b) add one
// state 11: reported to chief helper and got a reward
// state 12: told Peetu about the result and eventually got another small reward
// Byte 2: Hunt some remaining slimes between the bookshelves
// Bit 0: started the subquest
// Bit 1 - 7: each spawn point is unique and saved with a flag
-|script|#bluesageconfig|32767
{
end;
OnInit:
set $@Q_BlueSageMinimumLevel, 60;
set $@Q_BlueSageBookPages_MASK, 0x1F;
set $@Q_BlueSageBookPages_SHIFT, 0;
set $@Q_BlueSageGrimoire, 0x20;
set $@Q_BlueSageIceSword, 0x40;
set $@Q_BlueSageMaterial_MASK, NIBBLE_2_MASK;
set $@Q_BlueSageMaterial_SHIFT, NIBBLE_2_SHIFT;
set $@Q_BlueSageMaterialReed, 0x100;
set $@Q_BlueSageMaterialSilk, 0x200;
set $@Q_BlueSageMaterialClaw, 0x400;
set $@Q_BlueSageMaterialInk, 0x800;
set $@Q_BlueSageInvestigate_MASK, NIBBLE_3_MASK;
set $@Q_BlueSageInvestigate_SHIFT, NIBBLE_3_SHIFT;
set $@Q_BlueSageSlimes_MASK, BYTE_2_MASK;
set $@Q_BlueSageSlimes_SHIFT, BYTE_2_SHIFT;
set $@Q_BlueSageSlimesStart, 0x010000;
set $@Q_BlueSageSlime0, 0x020000;
set $@Q_BlueSageSlime1, 0x040000;
set $@Q_BlueSageSlime2, 0x080000;
set $@Q_BlueSageSlime3, 0x100000;
set $@Q_BlueSageSlime4, 0x200000;
set $@Q_BlueSageSlime5, 0x400000;
set $@Q_BlueSageSlime6, 0x800000;
//white
set $@BlueSageSlime0_Amount, 6;
set $@BlueSageSlime1_Amount, 5;
set $@BlueSageSlime2_Amount, 4;
set $@BlueSageSlime3_Amount, 3;
// blue
set $@BlueSageSlime4_Amount, 3;
set $@BlueSageSlime5_Amount, 2;
set $@BlueSageSlime6_Amount, 1;
end;
}
function|script|updateBlueSageBookPages
{
set QUEST_BlueSage, (QUEST_BlueSage & ~($@Q_BlueSageBookPages_MASK) | (@bookpages << $@Q_BlueSageBookPages_SHIFT));
return;
}
function|script|updateBlueSageInvestigate
{
set QUEST_BlueSage, (QUEST_BlueSage & ~($@Q_BlueSageInvestigate_MASK) | (@investigate << $@Q_BlueSageInvestigate_SHIFT));
return;
}
function|script|blueSageNumberOfClearedNests
{
set @slimenests, 0;
if (QUEST_BlueSage & $@Q_BlueSageSlime0)
set @slimenests, @slimenests+1;
if (QUEST_BlueSage & $@Q_BlueSageSlime1)
set @slimenests, @slimenests+1;
if (QUEST_BlueSage & $@Q_BlueSageSlime2)
set @slimenests, @slimenests+1;
if (QUEST_BlueSage & $@Q_BlueSageSlime3)
set @slimenests, @slimenests+1;
if (QUEST_BlueSage & $@Q_BlueSageSlime4)
set @slimenests, @slimenests+1;
if (QUEST_BlueSage & $@Q_BlueSageSlime5)
set @slimenests, @slimenests+1;
if (QUEST_BlueSage & $@Q_BlueSageSlime6)
set @slimenests, @slimenests+1;
return;
}