summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/constants.conf13
-rw-r--r--npc/020-7-1/core.txt249
-rw-r--r--npc/020-7-1/janitors.txt52
-rw-r--r--npc/functions/hub.txt4
4 files changed, 306 insertions, 12 deletions
diff --git a/db/constants.conf b/db/constants.conf
index 00bf0248d..171b83abc 100644
--- a/db/constants.conf
+++ b/db/constants.conf
@@ -4341,7 +4341,18 @@ constants_db: {
BS_SNEST6: 32
BS_SNEST7: 64
BS_SNEST8: 128
- BS_SNESTALL: 255
+ BS_SNEST9: 256
+ BS_SNESTALL: 511
+ // K - Nest Kills
+ BS_KNEST1: 3
+ BS_KNEST2: 2
+ BS_KNEST3: 1
+ BS_KNEST4: 3
+ BS_KNEST5: 2
+ BS_KNEST6: 1
+ BS_KNEST7: 3
+ BS_KNEST8: 2
+ BS_KNEST9: 1
comment__: "Being actions"
ACTION_STAND: 0
diff --git a/npc/020-7-1/core.txt b/npc/020-7-1/core.txt
index 4155fa637..02ed4e812 100644
--- a/npc/020-7-1/core.txt
+++ b/npc/020-7-1/core.txt
@@ -29,8 +29,120 @@ function script BSQuestion {
}
+// Clear a Nest ID
+// BSClearNest( ID )
+function script BSClearNest {
+ .@id=getarg(0);
+ switch (.@id) {
+ case BS_SNEST1:
+ $@BS_NEST1=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill1");
+ break;
+ case BS_SNEST2:
+ $@BS_NEST2=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill2");
+ break;
+ case BS_SNEST3:
+ $@BS_NEST3=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill3");
+ break;
+ case BS_SNEST4:
+ $@BS_NEST4=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill4");
+ break;
+ case BS_SNEST5:
+ $@BS_NEST5=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill5");
+ break;
+ case BS_SNEST6:
+ $@BS_NEST6=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill6");
+ break;
+ case BS_SNEST7:
+ $@BS_NEST7=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill7");
+ break;
+ case BS_SNEST8:
+ $@BS_NEST8=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill8");
+ break;
+ case BS_SNEST9:
+ $@BS_NEST9=0;
+ killmonster("020-7-1", "#BlueSageHUB::OnSlimeKill9");
+ break;
+ }
+ if (playerattached()) {
+ @nestid=0;
+ setq2 NivalisQuest_BlueSageSlimes, 0;
+ }
+ return;
+}
+
+// Return the Nest ID
+// BSNestID( x, y )
+function script BSNestID {
+ .@xa=getarg(0);
+ .@ya=getarg(1);
+ switch (.@xa) {
+ case 1:
+ if (.@ya == 1)
+ return BS_SNEST1;
+ else if (.@ya == 2)
+ return BS_SNEST2;
+ else if (.@ya == 3)
+ return BS_SNEST3;
+ break;
+ case 2:
+ if (.@ya == 1)
+ return BS_SNEST4;
+ else if (.@ya == 2)
+ return BS_SNEST5;
+ else if (.@ya == 3)
+ return BS_SNEST6;
+ break;
+ case 3:
+ if (.@ya == 1)
+ return BS_SNEST7;
+ else if (.@ya == 2)
+ return BS_SNEST8;
+ else if (.@ya == 3)
+ return BS_SNEST9;
+ break;
+ }
+ Exception("Invalid BS Nest Quadrands: ("+.@xa+", "+.@ya+")");
+ return 0;
+}
+
+// Return the Nest Quadrands
+// BSQuadrand( NestID )
+function script BSQuadrand {
+ .@nx=getarg(0);
+ switch (.@nx) {
+ case BS_SNEST1:
+ return 1;
+ case BS_SNEST2:
+ return 2;
+ case BS_SNEST3:
+ return 3;
+ case BS_SNEST4:
+ return 4;
+ case BS_SNEST5:
+ return 5;
+ case BS_SNEST6:
+ return 6;
+ case BS_SNEST7:
+ return 7;
+ case BS_SNEST8:
+ return 8;
+ case BS_SNEST9:
+ return 9;
+ }
+ Exception("Invalid BS Nest ID: ("+.@nx+")");
+ return 0;
+}
+
// Proccess the slime type and amount
-// BSProccess( SlimeNestID )
+// BSProccess( )
function script BSProccess {
.@b1=getq(NivalisQuest_BlueSageSlimes);
.@b2=getq2(NivalisQuest_BlueSageSlimes);
@@ -40,7 +152,103 @@ function script BSProccess {
if (!.@b1)
return;
- // TODO
+ // Fix your coordinates
+ getmapxy(.@m$, .@xc, .@yc,0);
+ .@x=.@xc-63;
+ .@y=.@yc-31;
+
+ // Check if you're off the library area
+ if (.@x <= 0 || .@y <= 0)
+ return;
+
+ // Calculate quadrand
+ // The map goes from (64,32) to (139,83)
+ // There is a 3x3 area, totalizing nine nests
+ // The useful area is 75 x 51, divided by 3 we have
+ // 25 x 17 quadrands.
+ // Anything beyond these quadrands is not regarded
+ .@x=(.@x/25)+1;
+ .@y=(.@y/17)+1;
+ if (.@x > 3 || .@y > 3)
+ return;
+
+ // We want the Quadrand ID to know if it was cleared or not
+ .@nest=BSNestID(.@x,.@y);
+ .@id=BSQuadrand(.@nest);
+
+ // Check if the nest was triggered
+ if (@nestid == .@nest)
+ return;
+
+ // Check if it was cleared already
+ if (getq3(NivalisQuest_BlueSageSlimes) & .@nest)
+ return;
+
+ // Check if we should spawn or if the quadrand is active
+ if (getd("$@BS_NEST"+str(.@id)))
+ return;
+
+ // Let's see if something should happen
+ .@chance=rand(30);
+ if (.@chance <= 16) {
+ return;
+ } else if (.@chance == 27) {
+ dispbottom l("A slime drips in front of you and explodes!");
+ percentheal -40, 0;
+ }
+
+ // If it haven't returned yet: It's good to go!
+ // Reserve the nest ID for us, and clear the previous.
+ BSClearNest(@nestid);
+ @nestid=.@nest;
+ BSClearNest(@nestid);
+ setd(getd("$@BS_NEST"+.@id), getcharid(0));
+
+ // We spawn monsters
+ if (.@id % 4 == 0)
+ .@mid=WhiteSlime;
+ else
+ .@mid=BlueSlime;
+
+ // Does getd() works against a constant?
+ areamonster .@m$, .@xc-2, .@yc-2, .@xc+2, .@yc+2, "", .@mid, getd("BS_KNEST"+.@id), "#BlueSageHUB::OnSlimeKill"+.@id;
+
+ dispbottom l("You notice a group of slimes emerging from the debris among the shelves.");
+
+ return;
+}
+
+// Proccess the slime death
+// BSProccessDeath( nestid, total )
+function script BSProccessDeath {
+ .@nest=getarg(0);
+ .@ammo=getarg(1);
+ .@id=BSQuadrand(.@nest);
+
+ if (playerattached()) {
+ // Mark the score if appliable
+ if (@nestid == .@nest) {
+ .@q2=getq2(NivalisQuest_BlueSageSlimes)+1;
+ setq2 NivalisQuest_BlueSageSlimes, .@q2;
+ }
+ }
+
+ if (!mobcount("020-7-1", "#BlueSageHUB::OnSlimeKill"+.@id)) {
+ if (playerattached()) {
+ // Did you killed all slimes? Or did they explode themselves?
+ // You have some chance to win even if you failed to kill all
+ // Will not work if this was not your nest
+ if ((.@q2 == .@ammo || rand(0,9000) == 255) && @nestid == .@nest) {
+ .@q3=getq3(NivalisQuest_BlueSageSlimes);
+ setq3 NivalisQuest_BlueSageSlimes, .@q3 | .@nest;
+ dispbottom l("It wasn't easy, but you think that you extinguished this nest.");
+ } else {
+ dispbottom l("You don't see any slimes from that nest anymore. But did you really get all of them?");
+ }
+ }
+ // Regardless of player attached or not, this nest must be clean
+ BSClearNest(.@nest);
+ }
return;
}
@@ -48,11 +256,48 @@ function script BSProccess {
020-7-1,24,84,0 script #BlueSageHUB NPC_HIDDEN,2,2,{
end;
+OnSlimeKill1:
+ BSProccessDeath(BS_SNEST1, BS_KNEST1);
+ end;
+
+OnSlimeKill2:
+ BSProccessDeath(BS_SNEST2, BS_KNEST2);
+ end;
+
+OnSlimeKill3:
+ BSProccessDeath(BS_SNEST3, BS_KNEST3);
+ end;
+
+OnSlimeKill4:
+ BSProccessDeath(BS_SNEST4, BS_KNEST4);
+ end;
+
+OnSlimeKill5:
+ BSProccessDeath(BS_SNEST5, BS_KNEST5);
+ end;
+
+OnSlimeKill6:
+ BSProccessDeath(BS_SNEST6, BS_KNEST6);
+ end;
+
+OnSlimeKill7:
+ BSProccessDeath(BS_SNEST7, BS_KNEST7);
+ end;
+
+OnSlimeKill8:
+ BSProccessDeath(BS_SNEST8, BS_KNEST8);
+ end;
+
+OnSlimeKill9:
+ BSProccessDeath(BS_SNEST9, BS_KNEST9);
+ end;
+
OnTouch:
addtimer2(1000, "#BlueSageHUB::OnCycle");
end;
OnCycle:
+ BSProccess();
addtimer(1000, "#BlueSageHUB::OnCycle");
end;
diff --git a/npc/020-7-1/janitors.txt b/npc/020-7-1/janitors.txt
index 72a4b5a0b..4606ef5b2 100644
--- a/npc/020-7-1/janitors.txt
+++ b/npc/020-7-1/janitors.txt
@@ -12,9 +12,16 @@
// 3: Killed Nests Control
020-7-1,50,63,6 script Pyry NPC_BLUESAGEWORKER_MB,{
- npctalk3 l("I warn about dangers and controls the fights.");
function askQuestion;
- mesc l("ERROR TODO blame Jesusalva"), 1;
+ .@qt=getq3(NivalisQuest_BlueSageSlimes);
+ mesn;
+ if (.@qt == BS_SNESTALL)
+ mesq l("It seems all of the slimes are gone now. I'm so glad! Thanks for your help. I mentioned your assistance to Nikolai.");
+ else if (.@qt > 0)
+ mesq l("It's very brave of you to fight against those slimes deeper in the library. Remember that you have to kill the entire group to prevent them from breeding. And do it @@!", b(l("Alone")));
+ else
+ mesq l("Welcome to the library of Sage Nikolai. I'm very sorry, but as you see it's not in a good shape at the moment. Most of the books were eaten by the slimes or damaged and we're working hard on cleaning up the mess.");
+
askQuestion();
close;
@@ -24,7 +31,8 @@ function askQuestion {
.@q2=getq2(NivalisQuest_BlueSage);
.@q3=getq3(NivalisQuest_BlueSage);
.@qs=BSQuestion(getq(NivalisQuest_BlueSage));
- .@qt=getq2(NivalisQuest_BlueSageSlimes);
+ .@qo=getq(NivalisQuest_BlueSageSlimes);
+ .@qt=getq3(NivalisQuest_BlueSageSlimes);
next;
mes "";
select
@@ -36,7 +44,33 @@ function askQuestion {
switch (@menu) {
case 1:
mesn;
- mesq l("TODO!");
+ mesq l("Resting. I've been slaying slime nests the whole day.");
+ next;
+ if (.@qo) {
+ mesn;
+ mesq l("There are some slimes around in the deeper parts of the library. Remember to kill them alone, and beware, if they kill themselves it won't count.");
+ } else {
+ mesn;
+ mesq l("Do you want to help? I promise you no reward, so you will do it of your own will.");
+ next;
+ if (askyesno() == ASK_YES) {
+ mesn;
+ mesq l("Great! Now, listen carefully: This library is laid out in nine squares.");
+ next;
+ mesn;
+ mesq l("You have to kill, alone, and this means without the help of the slimes either, nine nests. One in each quadrant.");
+ next;
+ mesn;
+ mesq l("Be careful when walking, because you may change quadrands and then... It won't count. You'll need to start over again.");
+ next;
+ mesn;
+ mesq l("I wish you good luck!");
+ setq NivalisQuest_BlueSageSlimes, 1, 0, 0;
+ } else {
+ mesn;
+ mesq l("Alright. Then please don't go too deep on the library, it is dangerous.");
+ }
+ }
break;
case 2:
mesn;
@@ -123,7 +157,7 @@ function askQuestion {
.@q2=getq2(NivalisQuest_BlueSage);
.@q3=getq3(NivalisQuest_BlueSage);
.@qs=BSQuestion(getq(NivalisQuest_BlueSage));
- .@qt=getq2(NivalisQuest_BlueSageSlimes);
+ .@qt=getq3(NivalisQuest_BlueSageSlimes);
next;
if (.@qt >= 255) {
mesn;
@@ -241,7 +275,7 @@ function askQuestion {
.@q2=getq2(NivalisQuest_BlueSage);
.@q3=getq3(NivalisQuest_BlueSage);
.@qs=BSQuestion(getq(NivalisQuest_BlueSage));
- .@qt=getq2(NivalisQuest_BlueSageSlimes);
+ .@qt=getq3(NivalisQuest_BlueSageSlimes);
next;
mes "";
select
@@ -331,7 +365,7 @@ function askQuestion {
.@q2=getq2(NivalisQuest_BlueSage);
.@q3=getq3(NivalisQuest_BlueSage);
.@qs=BSQuestion(getq(NivalisQuest_BlueSage));
- .@qt=getq2(NivalisQuest_BlueSageSlimes);
+ .@qt=getq3(NivalisQuest_BlueSageSlimes);
next;
if (.@qt >= 255) {
mesn;
@@ -433,7 +467,7 @@ function askQuestion {
.@q2=getq2(NivalisQuest_BlueSage);
.@q3=getq3(NivalisQuest_BlueSage);
.@qs=BSQuestion(getq(NivalisQuest_BlueSage));
- .@qt=getq2(NivalisQuest_BlueSageSlimes);
+ .@qt=getq3(NivalisQuest_BlueSageSlimes);
next;
mes "";
select
@@ -446,7 +480,7 @@ function askQuestion {
case 1:
mesn;
mesq l("Not yet, blame Jesusalva, your reward was with them");
- //setq2 NivalisQuest_BlueSageSlimes, 256; // TODO
+ //setq2 NivalisQuest_BlueSageSlimes, 256; // TODO Give reward
break;
case 2:
mesn;
diff --git a/npc/functions/hub.txt b/npc/functions/hub.txt
index e3ee6d26c..2c178da98 100644
--- a/npc/functions/hub.txt
+++ b/npc/functions/hub.txt
@@ -57,6 +57,10 @@ function script HUB_Logout {
@deathpenalty_realvalue=readparam(BaseExp);
@deathpenalty_realvaljob=readparam(JobExp);
}
+ // Died or logged out on Blue Sage House
+ if (.@mapa$ == "020-7-1") {
+ callfunc("BSClearNest", @nestid);
+ }
// First death produces a warning message
if (PC_DIE_COUNTER <= 1 && .@dead) {
dispbottom l("Dying outside a town square will cause EXP loss.");