From 4b2c057fc2cea88047d3356da3345f8f69a02fff Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 25 May 2019 17:10:13 -0300 Subject: Drafts about Pyry - NOT READY AND BUGGY --- npc/020-7-1/core.txt | 249 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 247 insertions(+), 2 deletions(-) (limited to 'npc/020-7-1/core.txt') 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; -- cgit v1.2.3-60-g2f50