summaryrefslogtreecommitdiff
path: root/npc/functions/dailyquest.txt
blob: 6f39e59dcf18e15485d3a60619a6d53762ac37d9 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
function	script	DailyQuestPointsFunc	{
    @dq_earliest = gettimetick(2) - 86400;
    if (DailyQuestTime < @dq_earliest)
        DailyQuestTime = @dq_earliest;

    // how many whole daily quest points the player has earned
    // we increment DailyQuestTime by the number of seconds in that many increments
    @dq_increments = (gettimetick(2) - DailyQuestTime)*BaseLevel / 86400;
    DailyQuestTime = DailyQuestTime + @dq_increments*86400/BaseLevel;

    // player can't regenerate any quest points, but might have a bonus
    if (DailyQuestPoints >= BaseLevel)
        goto L_Bonus;

    // normal recharging case - increment, but don't let it recharge more than a day's worth
    DailyQuestPoints = DailyQuestPoints + @dq_increments;
    if (DailyQuestPoints > BaseLevel)
        DailyQuestPoints = BaseLevel;
    // fallthrough to bonus, which *is* allowed to push DailyQuestPoints above BaseLevel
    goto L_Bonus;

L_Bonus:
    DailyQuestPoints = DailyQuestPoints + DailyQuestBonus;
    DailyQuestBonus = 0;

    return;
}

function	script	DailyQuest	{
    callfunc "DailyQuestPointsFunc";

    if (BaseLevel < @dq_level)
        goto L_Low_Level;
    if (DailyQuestPoints < @dq_cost)
        goto L_Not_Enough_Points;

    mes "\"If you bring me " + @dq_count + " " + @dq_friendly_name$ + ", I will give you a reward.\"";
    menu
        "I have what you want.", L_Trade,
        "Take all you need.", L_All,
        "Ok, I'll get to work.", L_Next,
        "Nah, I'm not going to help you.", L_Next;

L_Next:
    @dq_return = 1;
    goto L_Exit;

L_Trade:
    if (countitem(@dq_name$) < @dq_count)
        goto L_Not_Enough;
    delitem @dq_name$, @dq_count;

    Zeny = Zeny + @dq_money;
    getexp @dq_exp, 0;

    DailyQuestPoints = DailyQuestPoints - @dq_cost;

    if (@dq_handle_return)
        goto L_Exit_Good;

    mes "\"Thank you!\"";
    callsub S_SayPhrase;
    mes "";
    mes "[" + @dq_money + " money]";
    mes "[" + @dq_exp + " experience points]";
    goto L_Exit_Good;

L_All:
    if (countitem(@dq_name$) < @dq_count)
        goto L_Not_Enough;

    @item_multiple = (countitem(@dq_name$) / @dq_count);
    @dp_multiple = (DailyQuestPoints / @dq_cost);

    if (@dp_multiple > @item_multiple)
        @multipler = @item_multiple;
    if (@item_multiple >= @dp_multiple)
        @multipler = @dp_multiple;

    DailyQuestPoints = DailyQuestPoints - (@dq_cost * @multipler);

    delitem @dq_name$, (@dq_count * @multipler);

    Zeny = Zeny + (@dq_money * @multipler);
    getexp (@dq_exp * @multipler), 0;

    if (@dq_handle_return)
        goto L_Exit_Good;

    mes "\"Thank you!\"";
    callsub S_SayPhrase;
    mes "";
    mes "[" + (@dq_money * @multipler) + " money]";
    mes "[" + (@dq_exp * @multipler) + " experience points]";
    goto L_Exit_Good;

L_Exit_Good:
    @dq_return = 4;
    goto L_Exit;

L_Not_Enough:
    if (!@dq_handle_return)
        mes "\"I said " + @dq_count + " " + @dq_friendly_name$ + "; you should learn to count.\"";
    @dq_return = 3;
    goto L_Exit;

L_Low_Level:
    if (!@dq_handle_return)
        mes "\"Hey, you should go kill some things to get stronger first.\"";
    @dq_return = 0;
    goto L_Exit;

L_Not_Enough_Points:
    mes "\"You look exhausted, maybe you should rest a bit.\"";
    @dq_return = 2;
    goto L_Exit;

L_Exit:
    set @dq_handle_return, 0;  // Incase they forget
    return;

S_SayPhrase:
    if (@dq_handle_return)
        goto L_Return;
    if (DailyQuestPoints < @dq_cost)
        goto L_Exhausted;
    if (DailyQuestPoints > BaseLevel)
        goto L_Over;
    if (DailyQuestPoints > (BaseLevel*9)/10)
        goto L_P90;
    if (DailyQuestPoints > (BaseLevel*7)/10)
        goto L_P70;
    if (DailyQuestPoints > (BaseLevel*5)/10)
        goto L_P50;
    goto L_Low;

L_Over:
    mes "\"Woah, you're bursting with power.\"";
    return;
L_P90:
    mes "\"You're in a very good shape.\"";
    return;
L_P70:
    mes "\"You don't seem very exhausted by my tasks.\"";
    return;
L_P50:
    mes "\"Aren't you getting weary yet?\"";
    return;
L_Low:
    mes "\"You look a little tired.\"";
    return;
L_Exhausted:
    mes "\"You look exhausted, maybe you should rest a bit.\"";
    return;

L_Return:
    return;
}