summaryrefslogtreecommitdiff
path: root/npc/functions/daily.txt
blob: d7842086516bae6bc1de8f69e53d2ea9fb0d0d52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// 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 (compare(.@m$, "000-0"))
            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);
            #TMW2_LOGINBONUS=0;
        }

        // 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 ($@NOUPDATES) {
            dispbottom col(l("Updates were disabled"), 1);
        } else {
            .@value=max(20, rand2(#LOGIN_STREAK, #LOGIN_STREAK*2));
            .@value+=(BaseLevel*5/2)+rand2(JobLevel, JobLevel*7/20);
            .@value=.@value * 5 / 4; // Bonus 25%
            Zeny=Zeny+.@value;
            dispbottom l("##2Daily login bonus: ##B%d GP##b", .@value);
        }

        if (gettime(6) == JULY) {
            if (#TMW2_LOGINBONUS != gettime(GETTIME_YEAR) && gettime(5) == 7) {
                #TMW2_LOGINBONUS=gettime(GETTIME_YEAR);
                getitem ChocolateBar, 1;
                dispbottom "##B##2"+l("It's International Chocolate Day!")+"##b "+l("All monsters may drop chocolate during this period. And here is one for you!")+"##0";
            }
        }
        if (gettime(6) == SEPTEMBER) {
            if (#TMW2_LOGINBONUS != gettime(GETTIME_YEAR) && gettime(5) == 9) {
                #TMW2_LOGINBONUS=gettime(GETTIME_YEAR);
                getitem any(ScentGrenade, Grenade, SmokeGrenade), 2;
                dispbottom "##B##2"+l("It's the Free Software Day!")+" "+l("Licensing was one of the worst hassle we had. Enjoy!")+"##b##0";
            }
        }
        if (gettime(6) == OCTOBER) {
            if (#TMW2_LOGINBONUS != gettime(GETTIME_YEAR) && gettime(5) == 1) {
                #TMW2_LOGINBONUS=gettime(GETTIME_YEAR);
                getitem Coffee, 2;
                dispbottom "##B##2"+l("It's the International Coffee Day!")+" "+l("Have a warm cup of Coffee on the house, and enjoy!")+"##b##0";
            }
        }
        if (gettime(6) == DECEMBER) {
            if (!#XMAS_LOGINBONUS && gettime(5) >= 24 && gettime(5) <= 26) {
                #XMAS_LOGINBONUS=1;
                Zeny+=1500;
                dispbottom "##B##2"+l("Merry Christmas!")+" "+l("You have gained a special login bonus!")+"##b##0";
            }
        }

    }

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

// Gives you guild coins, but weekly (based on Guild Level)
function	script	guild_login_bonus	{
    .@g=getcharid(2);
    if (.@g < 1)
        return;

    .@c=min(5, getguildavg(.@g)/20) + min(1+getguildlvl(.@g)/5, 10);
    if (#LOGIN_GUILD_WEEK != gettimeparam(GETTIME_WEEKDAY)) {
        #LOGIN_GUILD_WEEK=gettimeparam(GETTIME_WEEKDAY);
        getitem GuildCoin, .@c;
        dispbottom l("##2Guild's Weekly login bonus: ##B%d %s##b", .@c, getitemlink(GuildCoin));
    }
    return;
}