summaryrefslogblamecommitdiff
path: root/npc/019-4-1/chief.txt
blob: bdd1ddf631b6f9d8a438f5a02170427b9d6fc554 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                                                 







                                         

                                                     










                                                                                                                                                                                                      
                                                                                                                                                                                                      









                                                             
                
                                                          




                                     

                                                           







                                                                                            
         


                                       
                              
 

                                         


                               
                                                         
 
                                               








                                                                                                                                                                                   
 
                                         
                                                                                                                                                                    
 



                                                                             
                                       

                                                 

                                    




                                                                


                                     
















                                          
                          



                                          
                                                         
                              
                                                              
                              
                                                              
                              
                                                              

                               
         
                                                                                              

                



                                

                                                  

                                                                  

              
         


                                                                                                                
                                               

                                                                                                         
                                                                                                                               






















                                                                                                                                              


                







                                                                                                                                                          




                                               
                              



                                                
 







                
// TMW2/LoF scripts.
// Authors:
//    TMW-LoF Team
//    Jesusalva
// Description:
//    Christmas Quest
//      Closed Christmas Boxes have been stolen! Give him any you find for the
//      ranking (and ranking based rewards). The global amount of delivered boxes
//      will determine the gifts (and amount of gifts) handled by Santa!
//
//      Rewards: Santa Hat, Gnome Hat, Santa Bearded Hat, Ugly Christmas Sweater,
//               Turtle Neck Sweater, Santa Globe, Snowman Globe, Red Stocking.
//
//    SQuest_Christmas
//      Current Year
//      Boxes Delivered
//      Money Sponsored
//
//    $XMAS_GIFTS
//      World-wide collected gifts count.

019-4-1,56,33,0	script	Christmas Chief	NPC_GNOME_A,{
    function	ScoreXMAS {
	    .@nb = query_sql("SELECT c.name, i.count2 FROM `quest` AS i, `char` AS c WHERE i.quest_id="+SQuest_Christmas+" AND i.char_id=c.char_id ORDER BY i.count2 DESC LIMIT 5", .@name$, .@value);

        mes "##B"+l("Top 5 - Christmas Box Donation Event")+"##b";
	    mes("1."+.@name$[0]+" ("+.@value[0]+")");
	    mes("2."+.@name$[1]+" ("+.@value[1]+")");
	    mes("3."+.@name$[2]+" ("+.@value[2]+")");
	    mes("4."+.@name$[3]+" ("+.@value[3]+")");
	    mes("5."+.@name$[4]+" ("+.@value[4]+")");
        next;

	    .@nb = query_sql("SELECT c.name, i.count3 FROM `quest` AS i, `char` AS c WHERE i.quest_id="+SQuest_Christmas+" AND i.char_id=c.char_id ORDER BY i.count3 DESC LIMIT 5", .@name$, .@value);

        mes "##B"+l("Top 5 - Golbarez Seasonal Quest")+"##b";
	    mes("1."+.@name$[0]+" ("+.@value[0]+" GP)");
	    mes("2."+.@name$[1]+" ("+.@value[1]+" GP)");
	    mes("3."+.@name$[2]+" ("+.@value[2]+" GP)");
	    mes("4."+.@name$[3]+" ("+.@value[3]+" GP)");
	    mes("5."+.@name$[4]+" ("+.@value[4]+" GP)");
        next;
    }

    // Last year
    if (getq(SQuest_Christmas) == gettime(GETTIME_YEAR)-1)
        goto L_Reward;
    // Not on season
    if ($EVENT$ != "Christmas")
        goto L_OutOfSeason;
    // Start Event for the first time
    if (getq(SQuest_Christmas) < gettime(GETTIME_YEAR))
        setq SQuest_Christmas, gettime(GETTIME_YEAR), 0, 0;
    // Main Loop
    goto L_Main;

L_OutOfSeason:
    mesn;
    mesq l("This workshop doesn't gets too many tasks from Santa outside the Christmas...");
    close;

L_Reward:
    inventoryplace NPCEyes, 5, Iten, 1;
    .@q1=getq2(SQuest_Christmas);
    .@q2=getq3(SQuest_Christmas);
    setq1 SQuest_Christmas, 0;

    /* Handle Christmas Quest Rewards */
    /* The top 5 gets special rewards! */
    //    #1  :  White Cat Pet
    // #2 - #3: Red Stocking
    // #4 - #5: Extra xmas gift
    /* You get Christmas Gift Box, which contain rares */

    .@gifts=min(15, log2(($XMAS_GIFTS/100)+1));
    if (.@q1 > .@gifts)
        getitem XmasGift, .@gifts;
	    .@nb = query_sql("SELECT c.name FROM `quest` AS i, `char` AS c WHERE i.quest_id="+SQuest_Christmas+" AND i.char_id=c.char_id ORDER BY i.count2 DESC LIMIT 5", .@name$);
        if (strcharinfo(0) == .@name$[0])
            makepet CattyCat;
        else if (strcharinfo(0) == .@name$[1] || strcharinfo(0) == .@name$[2])
            getitem RedStocking, 1;
        else if (strcharinfo(0) == .@name$[3] || strcharinfo(0) == .@name$[4])
            getitem XmasGift, 1;

        if (strcharinfo(0) == .@name$[0])
            mesc l("You gained a @@ for the #1 place on the event. Remember to feed it @@, or it may run away from you.", getitemlink(CattyCat), getitemlink(Milk));

    /////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////
    /* Handle Golbarez Quest Rewards */
    /* Mostly Coins, some Merc Boxes, EXP/JExp */
    /* Gift the best people at this quest, too */
    getexp .@q2/4, (.@q2/1000)+.@q1;
    .@coins=.@q2/10000;
    if (.@coins)
        getitem CasinoCoins, .@coins;
    if (.@coins > 3)
        getitem StrangeCoin, .@coins/3;
    // Mercenary boxes (requires certain global donation values)
    .@mc_boxc=.@q2/100000;
    .@mc_boxb=(.@q2/60000)-.@mc_boxc;
    .@mc_boxa=(.@q2/40000)-.@mc_boxb;

    // Event: Good
    if ($XMAS_MONEY >= 750000) {
        if (.@mc_boxc)
            getitem MercBoxC, .@mc_boxb;
        if (.@mc_boxb)
            getitem MercBoxB, .@mc_boxb;
        if (.@mc_boxa)
            getitem MercBoxA, .@mc_boxa+1;
    // Event: Average
    } else if ($XMAS_MONEY >= 250000) {
        if (.@mc_boxb)
            getitem MercBoxB, .@mc_boxb;
        if (.@mc_boxa)
            getitem MercBoxA, .@mc_boxa;
    // Event: Bad (must aid players)
    } else if ($XMAS_MONEY >= 100000) {
        if (.@q2 >= 10000)
            getitem MercBoxA, .@mc_boxa+1;
    }

    // MVP Awards
    if ((.@q2*100)/$XMAS_MONEY >= 80) // 80% contribution
        getitem GoldenGift, 1;
    else if ((.@q2*100)/$XMAS_MONEY >= 60) // 60% contribution
        getitem SilverGift, 1;
    else if ((.@q2*100)/$XMAS_MONEY >= 40) // 40% contribution
        getitem BronzeGift, 1;
    else if ((.@q2*100)/$XMAS_MONEY >= 20) // 20% contribution
        getitem CasinoCoins, 1;

    mesn;
    mesq l("Thanks for helping us the last year. I hope to have your help by the next year.");
    next;
    ScoreXMAS();
    close;

L_Main:
    .@q=getq2(SQuest_Christmas);
    // How did you even reach here in first place?
    if (BaseLevel < 20) {
    mesn;
    mesq l("The stolen christmas boxes!! Christmas is RUINED!!!");
        close;
    }
    mesn;
    mesq l("We only managed to recover @@ stolen @@ thus far...", $XMAS_GIFTS, getitemlink(ClosedChristmasBox));
    // Same formula from 2007 event. (max: 3.276.800 boxes delivered, an ABSURD amount)
    // You need to give at least this many boxes yourself to be eligible for rewards, though.
    .@gifts=min(15, log2(($XMAS_GIFTS/100)+1));
    mesq l("If things keep like this, we will only manage to give @@ gifts to every player...", .@gifts);
    if (.@q < .@gifts)
        mesc l("WARNING: You must give at least @@ boxes more before event ends to be eligible for a reward!", .@gifts-.@q), 1;
    next;
    if (.@q) {
        mesn;
        switch (.@gifts) {
            case  0: mesq l("There isn't enough, not even for NPCs. We need at least 100."); break;
            case  1: mesq l("Santa can give one present for all players. Maybe if we got 200..."); break;
            case  2: mesq l("Hey, two gifts is very nice. But if we delivered 400. Think on it."); break;
            case  3: mesq l("Wow, three gifts! Good job! With 800, an extra gift for everyone!"); break;
            case  4: mesq l("Hahah, four gifts, neat! Can we get to 1600 boxes?"); break;
            case  5: mesq l("Amazing. Five gifts for all. With 3200, we could supply nomad tribes..."); break;
            case  6: mesq l("Atonishing. Six gifts is the real deal. Easy to guess: 6400 is the next milestone."); break;
            case  7: mesq l("Impressive. Seven gifts! Now, 12800 is not easy. I understand if everyone gives up."); break;
            case  8: mesq l("Eight gifts. Let's double the goal. 25600 gifts. Did you guys hire some chinese gold farmers, anyway?"); break;
            case  9: mesq l("How did you got that much? Nine gifts, and 512000 if you want even more."); break;
            case 10: mesq l("Want to break the hundredthousand item limit?? Ten gifts, for more, bring 102,400 boxes here."); break;
            case 11: mesq l("Elevel gifts? You guys really have no live! For 204,800 I'll give an extra one."); break;
            case 12: mesq l("Twelve... There is no way people collected this many gifts. Anyway. 404,800 is the next milestone."); break;
            case 13: mesq l("What the f...? Four Hundred Thousand??? Must be a bug. Next milestone is 819,200. Cheaters."); break;
            case 14: mesq l("I must report this to Jesusalva. The inventory system can't handle that much. Want more? Try 1,638,400."); break;
            default: mesq l("ENOUGH! LAME CHEATERS, GET OFF THIS GAME %%a That's 15 gifts, and it is final."); break;
        }
        next;
    }
    goto L_Loop;

L_Loop:
    mesn;
    mesq l("Well, if you want to donate @@, you'll be ranked. There's gift for everyone, and rewards for top 5 donors.", getitemlink(ClosedChristmasBox));
    mes "";
    select
        rif(countitem(ClosedChristmasBox), l("Return @@ boxes", countitem(ClosedChristmasBox))),
        l("Scoreboards"),
        l("Leave");
    mes "";
    switch (@menu) {
        case 1:
            .@am=countitem(ClosedChristmasBox);
            delitem ClosedChristmasBox, .@am;
            .@q=getq2(SQuest_Christmas);
            $XMAS_GIFTS+=.@am;
            setq2 SQuest_Christmas, .@q+.@am;
            break;
        case 2: ScoreXMAS(); goto L_Loop; break;
    }

    close;

OnInit:
    .sex=G_MALE;
    .distance=5;
    end;
}