summaryrefslogblamecommitdiff
path: root/npc/006-1/crazyfefe.txt
blob: 197a0f77703c0891285dadd1c950d94907c8d9a3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                                                    
                                                            
                                         
                                                   












                                                                                           


                                                                                



















                                                                                           
                                                                                                                                                                           
         
                                                                                                  


             
                                                 

                                 
 


                                                     
                                                                  




                                                                  

                                                     













                                                                                          



                                            






































                                                                                                                                                                        
 


                                                                                           
                                                               
                                               

                       



                  
            
                                               
                                                                                    
                                                                    

                                                                                                                       



                  
                                            






























                                                       
                                           


                                                    
                                                                                                                        
     
                 
        

          
                                                                                           














                                                                    
                                                                     


                   



                                                                                

        





                                                                        
                                                              
                                                       
              
                                    

                                                                                                                                                                           
                 

        






                 
                     

        
// TMW2 Script
// Author:
//    TMW Org. (original code)
//    Jesusalva
// Description:
//    Crazyfefe will wake up when he smells battle
// Variables:
//      $@FIGHT_CAVE_LEVEL
//          Tracks if a fight is going on, and the current round if true.
//      $@FEFE_DELAY
//          Tracks the delay between challenges. Also used to start the combat.
//      $@FIGHT_CAVE_HERO$
//          Whoever started a fight. Also used to know if a fight is about to begin.
//      $@FIGHT_CAVE_PLAYER_COUNT
//          How many players are there

006-1,47,22,0	script	Crazyfefe	NPC_STATUE_EVILMAN,{
    if ($@FIGHT_CAVE_LEVEL) goto L_Enjoy;
    if ($@FEFE_DELAY > gettimetick(2)) goto L_Wait;
    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 is this place anyway?"), L_Explain;

L_Next:
    mesn;
    mesq l("Very well, but for a fee of @@ GP. There's no free lunch, after all!", .price);
    select
         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!"));

    // Cancel?
    if (@menu == 1)
        goto L_Exit;

    // Already started?
    if ($@FIGHT_CAVE_LEVEL || $@FIGHT_CAVE_HERO$ != "")
        goto L_AlreadyStarted;

    // Enough money?
    if (Zeny < .price)
        goto L_NotEnough;

    Zeny = Zeny - .price;
    // Time delay
    $@FEFE_DELAY = gettimetick(2)+300*(@menu-1);
    $@FIGHT_CAVE_HERO$ = strcharinfo(0);
    initnpctimer;
    announce $@FIGHT_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;

L_StartFight:
    /* to debug, embrace this code in comments */
    if (getmapusers("006-1") < 3)
        goto L_NotEnoughPlayers;

    $@FIGHT_CAVE_LEVEL = 1;
    $@FEFE_DELAY = gettimetick(2)+.delay;
    $@FIGHT_CAVE_PLAYER_COUNT = getmapusers("006-1");
    mapannounce("006-1", "The battle is about to begin!", bc_map);
    initnpctimer;
    end;

L_Enjoy:
    npctalk3 l("Pay attention to the fight, @@!", strcharinfo(0));
    if (is_gm())
        dispbottom l("Round @@", $@FIGHT_CAVE_LEVEL);
    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.", $@FIGHT_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. 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;







// Check if we're ready for next wave. Otherwise, do this check again after 5 seconds.
L_CaveLogic:
    $@FIGHT_CAVE_PLAYER_COUNT = getmapusers("006-1");
    if (mobcount("006-1", "Crazyfefe::OnPetDeath") <= 0)
        goto L_NextRound;

    // Victory conditions: Too few players are alive.
    // WARNING, of dead players still in cave are counted, we might never finish the fight.
    // And a GM might be called to ban everyone inside.
    // To enable debug, comment last part of victory condition.
    if ($@FIGHT_CAVE_PLAYER_COUNT <= rand(1,2))
        goto L_CleanUp;

    // reset timer
    initnpctimer;
    end;

L_NextRound:
    // Prepare next round, and reward survivors
    $@FIGHT_CAVE_LEVEL = $@FIGHT_CAVE_LEVEL + $@FIGHT_CAVE_PLAYER_COUNT + rand(1,3);
    areatimer 0, "006-1", 20, 20, 70, 60, 10, "Crazyfefe::OnReward";

    mapannounce "006-1", "The next round is starting with " + $@FIGHT_CAVE_PLAYER_COUNT + " player(s) left alive." , 0;
    goto L_Summon;

// TODO
L_Summon:
    .@amount=($@FIGHT_CAVE_LEVEL/rand(4,6));
	for (.@i = 0; .@i < .@amount; ++.@i) {
        .@mid=rand(1,15);
        .@monsterId=Piou;
        switch (.@mid) {
            case 1:
                .@monsterId = CaveMaggot ; break;
            case 2:
                .@monsterId = Wolvern ; break;
            case 3:
                .@monsterId = DarkLizard ; break;
            case 4:
                .@monsterId = MagicGoblin ; break;
            case 5:
                .@monsterId = Bandit ; break;
            case 6:
                .@monsterId = GreenSlime ; break;
            case 7:
                .@monsterId = LavaSlime ; break;
            case 8:
                .@monsterId = Snake ; break;
            case 9:
                .@monsterId = DesertBandit ; break;
            case 10:
                .@monsterId = Sarracenus ; break;
            case 11:
                .@monsterId = AngryRedScorpion ; break;
            case 12:
                .@monsterId = BlackScorpion ; break;
            case 13:
                .@monsterId = FallenGuard1 ; break;
            case 14:
                .@monsterId = Yeti ; break;
            default:
                .@monsterId = AngryScorpion ; break;
        }
        areamonster "006-1", 20, 20, 70, 60, strmobinfo(1, .@monsterId), .@monsterId, .@amount, "Crazyfefe::OnPetDeath";
    }
    initnpctimer;
    end;

L_CleanUp:
    mapannounce "006-1", "Game over! Who will be the next to fall on Crazyfefe's Cave?", 0;

    areatimer 0, "006-1", 20, 20, 70, 60, 10, "Crazyfefe::OnReward";
    $@FIGHT_CAVE_LEVEL = 0;
    $@FIGHT_CAVE_HERO$ = "";
    killmonster "006-1", "Crazyfefe::OnPetDeath";
    stopnpctimer;
    end;








// Rewards surviving players between rounds, according to performance
OnReward:
    if (ispcdead())
        end;
    // Player reward is a random number from 1~3 + lvl/50 (1 point ~= 12~8 mobs)
    .@prize=rand(1,3) + ($@FIGHT_CAVE_LEVEL/50);
    Zeny=Zeny+.@prize;
    getexp .@prize, rand(1,3);
    end;

// Every 5 seconds, handle cave, if fighting. Does nothing when waiting.
OnTimer5000:
    if ($@FIGHT_CAVE_LEVEL)
        goto L_CaveLogic;
    end;

// Announces and attempts to start the fight once time run out
//OnTimer30000: // to enable debug, uncomment this line
OnTimer300000:
    if ($@FIGHT_CAVE_LEVEL > 0) end;
    if ($@FEFE_DELAY <= gettimetick(2)) goto L_StartFight;
    announce $@FIGHT_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;
    initnpctimer;
    end;

OnPetDeath:
    end;

OnInit:
    .sex=G_OTHER;
    .distance=5;
    .price=8000;
    .delay=(60*60*1);
    end;
}