From 78c09a98994cbe284ad6f3a07970eed0b94f9ddb Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Wed, 3 Apr 2019 15:07:59 -0300 Subject: Convert CrazyFefe script to use functions instead of labels in several places --- npc/006-1/crazyfefe.txt | 192 ++++++++++++++++++++++++++---------------------- 1 file changed, 105 insertions(+), 87 deletions(-) (limited to 'npc/006-1') diff --git a/npc/006-1/crazyfefe.txt b/npc/006-1/crazyfefe.txt index 375867667..1f6c95cf8 100644 --- a/npc/006-1/crazyfefe.txt +++ b/npc/006-1/crazyfefe.txt @@ -6,7 +6,7 @@ // Crazyfefe will wake up when he smells battle // Variables: // $@FEFE_CAVE_LEVEL -// Tracks if a fight is going on, and the magic number to determine how many mobs show up. +// Tracks if a fight is going on, and the magic number to determine how many mobs show up. // $@FEFE_DELAY // Tracks the delay between challenges. Also used to start the combat. Set it to zero so you can start fight at once. // $@FEFE_CAVE_HERO$ @@ -19,71 +19,139 @@ // Only possible with @set command, overrides the co-op requeriment. Affects other scripts. 006-1,47,22,0 script Crazyfefe NPC_STATUE_EVILMAN,{ - goto L_Main; + function pleaseWait; + function Scoreboard; + function Challenge; + function aboutCandor; + function StartFight; + function CleanUp; + + // Battle already begun + if ($@FEFE_WAVE) + { + npctalk3 l("Pay attention to the fight, @@!", strcharinfo(0)); + dispbottom l("Round @@", $@FEFE_WAVE); + end; + } -L_Main: - if ($@FEFE_CAVE_LEVEL) goto L_Enjoy; - if ($@FEFE_DELAY > gettimetick(2)) goto L_Wait; + // Main Loop mesn; mesq l("Who dares to disturb my slumber?"); next; - menu - l("Sorry, sorry! Please rest, great Crazyfefe!"), L_Exit, - l("I do. I want to challenge the Candor Cave!"), L_Next, - l("What are current leaderboard?"), L_Scoreboard, - l("What is this place anyway?"), L_Explain; + do + { + select + l("Sorry, sorry! Please rest, great Crazyfefe!"), + l("I do. I want to challenge the Candor Cave!"), + l("What are current leaderboard?"), + l("What is this place anyway?"); + mes ""; + switch (@menu) { + case 1: close; break; + case 2: Challenge(); break; + case 3: Scoreboard(); break; + case 4: aboutCandor(); break; + } + } while (true); + close; + +/// Functions +function pleaseWait { + // Battle in delay (either to begin or to allow new challenges) + if ($@FEFE_DELAY > gettimetick(2)) + { + .@time$=FuzzyTime($@FEFE_DELAY,2,2); + // Less than 30 seconds left, do not open a message window. + if ($@FEFE_DELAY-gettimetick(2) <= 30) { + npctalk3 l("@@!", .@time$); + end; + } + mesn; + mesq l("Be Patient... You still need to wait @@.", .@time$); + close; + } + return; +} -L_Scoreboard: +function Scoreboard { mesc l("All leaderboards are refreshed hourly."), 1; mesc l("Your current score: @@", CRAZYPOINTS), 3; HallOfCandor(); next; - goto L_Main; + return; +} -L_Next: +function aboutCandor { + mesn; + mesq l("I am @@, guardian of Candor Cave. Below this cave, lies the legendary Fefe, arch-wizard from the Great War.", .name$); + next; + mesn; + mesq l("During the war, the Monster King cursed the place where he died, but he fought back, and cursed the curse."); + next; + mesn; + mesq l("For short, they had a fight with curses, and now there's a talking statue over his grave which can spawn monsters here."); + next; + mesn; + mesq l("If you pay the fee, I'll spawn them, for no longer than 20 minutes. You should not fight alone, instead, you need a group of at least three, because, you know, the curse. Or something."); + next; + return; +} + +function Challenge { mesn; mesq l("Very well, but for a fee of @@ GP. There's no free lunch, after all!", .price); - select - rif(is_gm(), l("I'm GM and got the money. START THIS CRAP ALREADY!")), - l("Sorry, I misclicked the first button. Have a nice nap, great Crazyfefe!"), - l("Yeah, I have the money. Give me FIVE minutes, and Bring it on!"), - l("Yeah, I have the money. Give me TEN minutes, and Bring it on!"), - l("Yeah, I have the money. Give me FIFTEEN minutes, and Bring it on!"), - "","", - rif(is_gm(), l("I'm GM and got the money. Gimme HALF HOUR to invite everybody!")); + + // Not enough money? We end here. + if (Zeny < .price) + close; + + menuint + l("Sorry, I misclicked the first button. Have a nice nap, great Crazyfefe!"), -1, + rif(is_gm(), l("I'm GM and got the money. START THIS CRAP ALREADY!")), 0, + l("Yeah, I have the money. Give me FIVE minutes, and Bring it on!"), 5, + l("Yeah, I have the money. Give me TEN minutes, and Bring it on!"), 10, + l("Yeah, I have the money. Give me FIFTEEN minutes, and Bring it on!"), 15, + rif(is_gm(), l("I'm GM and got the money. Gimme HALF HOUR to invite everybody!")), 30; // Cancel? - if (@menu == 2) - goto L_Exit; + if (@menuret < 0) + close; // Already started? - if ($@FEFE_CAVE_LEVEL || $@FEFE_CAVE_HERO$ != "") - goto L_AlreadyStarted; - - // Enough money? - if (Zeny < .price) - goto L_NotEnough; + if ($@FEFE_WAVE || $@FEFE_CAVE_HERO$ != "") + { + mesn; + mesq l("Sorry, @@ already started the fight.", $@FEFE_CAVE_HERO$); + close; + } + // Use the money Zeny = Zeny - .price; // Time delay $@FEFE_DELAY = gettimetick(2)+300*(@menu-2); $@FEFE_CAVE_HERO$ = strcharinfo(0); - if (@menu == 1) { + // We must begin at once, so ignore normal procedure + if (!@menuret) { closeclientdialog; goto L_StartFight; } + // Give you a bonus for starting the fight, and announce the fight. @crazypoints=1; initnpctimer; announce $@FEFE_CAVE_HERO$+" invites everyone to a challenge against Candor Cave. It'll start in "+FuzzyTime($@FEFE_DELAY,2,2)+". Prepare yourselves!", bc_all|bc_npc; mesn; mesq l("Please wait, the fight will start in @@, as requested.", FuzzyTime($@FEFE_DELAY,2,2)); close; + return; +} -L_StartFight: - if (getmapusers("006-1") < 3 && !$@GM_OVERRIDE) - goto L_NotEnoughPlayers; +function StartFight { + if (getmapusers("006-1") < 3 && !$@GM_OVERRIDE) { + mapannounce("006-1", "Oh noes! There's not enough players. Fight aborted, no refunds!", bc_map); + CleanUp(); + } $@FEFE_CAVE_LEVEL = 1; $@FEFE_DELAY = gettimetick(2)+.delay; @@ -95,57 +163,7 @@ L_StartFight: areatimer "006-1", 20, 20, 70, 60, 10, "Crazyfefe::OnSumLevel"; initnpctimer; end; - -L_Enjoy: - npctalk3 l("Pay attention to the fight, @@!", strcharinfo(0)); - if (is_gm()) - dispbottom l("Round @@", $@FEFE_WAVE); - end; - -L_NotEnough: - mesn; - mesq l("You lack money. Go sell your stuff. And don't ask why a statue needs money!"); - close; - -L_AlreadyStarted: - mesn; - mesq l("Sorry, @@ already started the fight.", $@FEFE_CAVE_HERO$); - close; - -L_Wait: - .@time$=FuzzyTime($@FEFE_DELAY,2,2); - if ($@FEFE_DELAY-gettimetick(2) <= 30) { - npctalk3 l("@@!", .@time$); - end; - } - mesn; - mesq l("Be Patient... You still need to wait @@.", .@time$); - goto L_Exit; - -L_NotEnoughPlayers: - mapannounce("006-1", "Oh noes! There's not enough players. Fight aborted, no refunds!", bc_map); - goto L_CleanUp; - -L_Explain: - mesn; - mesq l("I am @@, guardian of Candor Cave. Below this cave, lies the legendary Fefe, arch-wizard from the Great War.", .name$); - next; - mesn; - mesq l("During the war, the Monster King cursed the place where he died, but he fought back, and cursed the curse."); - next; - mesn; - mesq l("For short, they had a fight with curses, and now there's a talking statue over his grave which can spawn monsters here."); - next; - mesn; - mesq l("If you pay the fee, I'll spawn them, for no longer than 20 minutes. You should not fight alone, instead, you need a group of at least three, because, you know, the curse. Or something."); - next; - menu - l("I need to think about this."), L_Exit, - l("I'm interested."), L_Next; - -L_Exit: - close; - +} @@ -168,7 +186,7 @@ L_CaveLogic: // WARNING, dead players still in cave are counted, we might never finish the fight. // And a GM might be called to ban everyone inside. if ($@FEFE_CAVE_PLAYER_COUNT <= 1 && !$@GM_OVERRIDE || gettimetick(2) >= $@FEFE_DELAY - (60*20)) { - goto L_CleanUp; + CleanUp(); } // Recalculate difficulty @@ -251,7 +269,7 @@ L_Summon: initnpctimer; end; -L_CleanUp: +function CleanUp { mapannounce "006-1", "Game over! Who will be the next to fall on Crazyfefe's Cave?", 0; areatimer "006-1", 20, 20, 70, 60, 10, "Crazyfefe::OnReward2"; @@ -264,7 +282,7 @@ L_CleanUp: initnpctimer; stopnpctimer; end; - +} -- cgit v1.2.3-60-g2f50