summaryrefslogblamecommitdiff
path: root/npc/functions/daily.txt
blob: c7104e45b27597e4d82b26fc20ed5004000f1b19 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                                            
                      
 
                                   




                                                 
                                        








                                                  
                                
                                            














                                                                                                                                           
                                            
















                                                                                                   

                                                                                          
                                         

                                                                                          
                                        

                                                                                          


                                                                                          
                                            




                                                                       




                                                                        






                                                                             

                                   







                                                                                
                                                           


                                                                                                                                                       







                                                                                                                   
     
 
                                                    


           
// TMW2 Script.
// Authors:
//    Jesusalva
// Description:
//    Daily Login Reward

function	script	daily_login_bonus_handler	{
    // Handle daily login bonus
    // The Strange Coin output wasn't changed, but now it relies on streaks.
    // Variables:
    //  #LOGIN_DAY
    //      Current day
    //  #LOGIN_TABLE
    //      Current month
    //  #LOGIN_STREAK
    //      Number of monthly connections
    //  #LOGIN_ALLTIME
    //      Number of times you claimed the top prize (27 days streak)
    //debugmes "DLBH";

    if (#LOGIN_DAY != gettime(5)) {
        // demure check: Are you on a start area?
        getmapxy(.@m$,.@x,.@y,0);
        if (.@m$ ~= "000")
            return;

        //debugmes "[DLBH] Mapcheck ok";
        // Is it a new month?
        if (#LOGIN_TABLE == gettime(6)) {
            #LOGIN_STREAK=#LOGIN_STREAK+1;
        } else {
            #LOGIN_STREAK=1;
            #LOGIN_TABLE=gettime(6);
        }

        // Update last day you've claimed a reward
        #LOGIN_DAY = gettime(5);
        //debugmes "[DLBH] month checks ok";

        // Handle rewards: Streaks first, daily later. Streak reward prevail over daily reward.
        if (#LOGIN_STREAK > 27) {
            getitem StrangeCoin, 2;
            getitem CasinoCoins, 1;
            dispbottom l("##2 @@ Days login bonus: ##B2x @@, 1x @@##b", #LOGIN_STREAK, getitemlink(StrangeCoin), getitemlink(CasinoCoins));
        } else if (#LOGIN_STREAK == 27) {
            #LOGIN_ALLTIME+=1;
            // Your prize is based on season
            switch (season()) {
                case AUTUMN:
                    .@prize=ElixirOfLife; break;
                case WINTER:
                    .@prize=SilverGift; break;
                case SPRING:
                    .@prize=MercBoxC; break;
                case SUMMER:
                    .@prize=RightEyePatch; break;
            }
            // Some special cases
            if (#LOGIN_ALLTIME == 3)
                .@prize=GoldenGift;
            if (#LOGIN_ALLTIME == 8)
                .@prize=PrismGift;

            if (#LOGIN_ALLTIME == 12) {
                dispbottom l("CONGRATULATIONS! For a year worth of logins, you're getting a pet!");
                makepet Piou; // we must replace this before August 2019. (r18 probably)
            }

            getitem .@prize, 1;
            dispbottom l("##2 27 Days login bonus: ##B1x @@##b", getitemlink(.@prize));
        } else if (#LOGIN_STREAK == 21) {
            getitem BronzeGift, 1;
            dispbottom l("##2 21 Days login bonus: ##B1x @@##b", getitemlink(BronzeGift));
        } else if (#LOGIN_STREAK == 14) {
            getitem BronzeGift, 1;
            dispbottom l("##2 14 Days login bonus: ##B1x @@##b", getitemlink(BronzeGift));
        } else if (#LOGIN_STREAK == 7) {
            getitem StrangeCoin, 3;
            dispbottom l("##2 7 Days login bonus: ##B3x @@##b", getitemlink(StrangeCoin));
        } else if (#LOGIN_STREAK == 3) {
            getitem StrangeCoin, 1;
            dispbottom l("##2 3 Days login bonus: ##B1x @@##b", getitemlink(StrangeCoin));
        } else if (#LOGIN_STREAK % 3 == 0) {
            .@value=max(20, rand(0, (#LOGIN_STREAK*2)));
            .@value+=(BaseLevel+JobLevel);
            Zeny=Zeny+.@value;
            dispbottom l("##2Daily login bonus: ##B@@ GP##b", .@value);
        } else if (#LOGIN_STREAK % 3 == 2) {
            .@value=max(5, rand(0, (#LOGIN_STREAK/4)));
            .@value+=(BaseLevel**2);
            .@value=(.@value/2)+#LOGIN_STREAK;
            getexp .@value, 0;
            dispbottom l("##2Daily login bonus: ##B@@ EXP##b", .@value);
        } else {
            .@value=max(5, rand(0, (#LOGIN_STREAK/4)));
            .@value+=(JobLevel**2);
            .@value=(.@value/3)+#LOGIN_STREAK;
            getexp 0, .@value;
            dispbottom l("##2Daily login bonus: ##B@@ Job Exp.##b", .@value);
        }

        // Handle event login bonus
        if (gettime(6) == JANUARY) {
            if (#TMW2_LOGINBONUS != gettime(GETTIME_YEAR) && gettime(5) == 13) {
                #TMW2_LOGINBONUS=gettime(GETTIME_YEAR);
                getitem StrangeCoin, 10;
                // TMW2 Anniversary is project, not server.
                // Therefore, contributors get an extra reward
                .@m=htget($@CONTRIBUTORS, strtolower(strcharinfo(0)), 0);
                if (.@m)
                    getitem StrangeCoin, min(9, .@m/100)+1;
                dispbottom "##B##2"+l("It's TMW2 Project anniversary!")+" "+l("We thank every developer which helped this project thus far!")+"##b##0";
            }
        }
        if (gettime(6) == DECEMBER) {
            if (!#XMAS_LOGINBONUS && gettime(5) >= 24 && gettime(5) <= 26) {
                #XMAS_LOGINBONUS=1;
                getitem BronzeGift, 1;
                dispbottom "##B##2"+l("Merry Christmas!")+" "+l("You have gained a special login bonus!")+"##b##0";
            }
        }
    // We're done with daily logins
    }

    //debugmes "[DLBH] Finished: "+#LOGIN_DAY+" ok";
    return;
}