summaryrefslogtreecommitdiff
path: root/npc/014-5/events.txt
blob: 954f92e1b10e15bb403a005a04e591c459f40f44 (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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// TMW2 scripts.
// Author:
//    Jesusalva
// Description:
//    St. Patrick Day
// Variables:
//	  #PATRICK_DAY
//		When you spinned this
//	  #PATRICK_CTRL
//		Controls rarity, lowering boost
//	  $@PATRICK_DAYMAX
//		Last day in St. Patrick event

014-5,47,53,0	script	St. Patrick Gold Pot	NPC_COOKIE_MASTER,{
    function symbol{
        switch (getarg(0)) {
        case 0:
            mesn "%%0";
            break;
        case 1:
            mesn "%%1";
            break;
        case 2:
            mesn "%%2";
            break;
        case 3:
            mesn "%%3";
            break;
        case 4:
            mesn "%%4";
            break;
        case 5:
            mesn "%%5";
            break;
        case 6:
            mesn "%%6";
            break;
        default:
            mesn "%%@";
            break;
        }
    }

	if ($EVENT$ != "St. Patrick" && !$@GM_OVERRIDE) {
		channelmes("#world", "ERROR, ST. PATRICK GOLD POT: NOEVENT ERROR");
		disablenpc .name$;
		atcommand("@kick "+strcharinfo(0));
		close;
	}
	if (#PATRICK_DAY == gettime(GETTIME_DAYOFMONTH)) {
		mesn;
		mesc l("You already claimed a reward today! Come back tomorrow, and remember to wear GREEN!"), 2;
		close;
	}
	mesn;
	mesc l("Lucky you, you found me! Do you want to SPIN THE WHEEL and gain GREAT rewards?"), 2;
	mesc l("Remember that wearing green BOOSTS the rates at which good stuff will be found!"), 2;
	next;
	select
		l("Spin it!"),
		l("How does spinning works?"),
		l("Don't spin it!");
	mes "";
	if (@menu == 3)
		close;

	if (@menu == 2) {
		mes ("%%0 - "+l("GP"));
		mes ("%%1 - "+getitemlink(CasinoCoins));
		mes ("%%2 - "+getitemlink(Topaz));
		mes ("%%4 - "+getitemlink(GoldOre));
		mes ("%%3 - "+getitemlink(StrangeCoin));
		mes ("%%5 - "+getitemlink(GoldenGift));
		mes ("%%6 - "+getitemlink(GoldenApple));
		close;
	}

	if (@menu == 1) {
		// SPINNING! Set that you can't spin again.
		#PATRICK_DAY=gettime(GETTIME_DAYOFMONTH);

		// Each green accessory raises boost gauge in 25. Full set raises in further 25.
		// Hat, Shirt, Pants, Boots and Gloves. Max boost gauge from dye is 150 atm.
		.@boost=0;
		if (getequipcardid(EQI_HEAD_TOP, 0) == GreenDye)
			.@boost+=25;
		if (getequipcardid(EQI_HEAD_MID, 0) == GreenDye)
			.@boost+=25;
		if (getequipcardid(EQI_HEAD_LOW, 0) == GreenDye)
			.@boost+=25;
		if (getequipcardid(EQI_SHOES, 0) == GreenDye)
			.@boost+=25;
		if (getequipcardid(EQI_GARMENT, 0) == GreenDye)
			.@boost+=25;
		if (.@boost >= 125)
			.@boost+=25;

		// Blv+Jlv gives a small boost. The "maximum" sum is 250, but we divide by 5
		// So this grants a further boost of 4~50 depending on level.
		.@boost+=(BaseLevel+JobLevel)/5;

		// .@boost, right now, is a number from 0 to 200.
		// Randomness factor can make that 20% higher, up to 240.
		.@r=rand(0,20);
		.@boost+=(.@boost*.@r/100);
		// Then it may add or subtract 10 points from boost. Apply a cap to range 0~250.
		.@boost+=rand(-10, 10);

		// Now, you can't get 5 Golden Apples straight, right?
		// You lose boost as you get rewards. You lose boost the farther from
		// event last day you are, too.
		.@boost-=#PATRICK_CTRL;
		.@boost-=($@PATRICK_DAYMAX-#PATRICK_DAY);

		// sanitize boost so it ranges from 0 to 250.
		.@boost=max(0, .@boost);

		// REFERENCE: At release time, max levels ingame were about 60/40.
		// That would give 10~34 (not green) to 160~214 (fully green) boost value.
		mesc l("Spinning!"), 2;

		// .@v holds the reward you'll get
		if (.@boost > 240)
			.@v=6;
		else if (.@boost > 200)
			.@v=5;
		else if (.@boost > 160)
			.@v=4;
		else if (.@boost > 120)
			.@v=3;
		else if (.@boost > 80)
			.@v=2;
		else if (.@boost > 40)
			.@v=1;
		else
			.@v=0;

		// Tell players what they spinned, and lower rarity on next tries
		symbol(.@v);
		#PATRICK_CTRL+=.@v+(.@v/2);

		// Grant players the reward
		switch (.@v) {
			case 0: // GP
				Zeny=Zeny+rand(10, .@boost+10);
				break;
			case 1: // Casino Coins
				getitem CasinoCoins, max(1, .@boost/10);
				break;
			case 2: // Topaz
				getitem Topaz, 1;
				break;
			case 3: // Gold Ore
				getitem GoldOre, 1;
				break;
			case 4: // Strange Coins
				getitem StrangeCoin, max(1, .@boost/10);
				break;
			case 5: // Golden Gift
				getitem GoldenGift, 1;
				break;
			case 6: // Golden Apple (OP)
				getitem GoldenApple, 1;
				break;
		}
		next;
		mesn;
		mesc l("Did you like it? Find me tomorrow, until day @@, for another gift!", $@PATRICK_DAYMAX), 2;
		close;
	}
	// Should not reach here
    close;

OnInit:
    .sex = G_OTHER;
    .distance = 4;

    if ($EVENT$ != "St. Patrick") {
        disablenpc(.name$);
        end;
    }
OnClock0000:
OnForcedMove:
    if ($EVENT$ == "St. Patrick") {
        setarray .@vx, 134, 162, 108, 105, 67, 191, 168, 170, 191, 188, 160, 145, 196, 120;
        setarray .@vy,  36,  61,  45,  96, 76,  74,  72, 111, 113, 129, 125, 119, 143, 104;
        .@r=rand(0,getarraysize(.@vx)-1);
        movenpc .name$, .@vx[.@r], .@vy[.@r];
		debugmes "Warping to %d,%d (seed %d)", .@vx[.@r], .@vy[.@r], .@r;
    }
    end;
}