root/npc/custom/eAAC_Scripts/banker.txt @ 25

Revision 1, 15.5 kB (checked in by jinshiro, 17 years ago)
Line 
1//| ~~~~~~~~~~~ Information ~~~~~~~~~~~~~
2//| | This is a simple banking npc,     |
3//| | instead of using those global     |
4//| | variables :P                      |
5//| |                                   |
6//| | It's fully customizable, you      |
7//| | can exchange the coin ID used     |
8//| | at will, it won't affect the      |
9//| | script whatsoever =3              |
10//| |                                   |
11//| | The prices can also be set, the   |
12//| | way you like the most, as they    |
13//| | won't affect the script either    |
14//| |                                   |
15//| | No db/client files modification   |
16//| | needed, just "Plug&Play" ;P       |
17//| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18
19//| Revision:
20//| v.1.0: Released script. No problems or bugs found, at least :P
21//|     It's your duty to find them now if there are.
22//|     @minvalue must contain the coin price of the lowest coin value
23//|     in order for the script to work correctly. By default it's set
24//|     to the bronze coin
25
26//| Revision:
27//| v.2.0: Added a Mix option in the Zeny to Coin function,
28//|     where it allows you to split your desired Zeny into
29//|     the coins you wish to obtain, without having to go
30//|     through the other functions to obtain them all. That way
31//|     you can get them all at once ;3
32//|
33//|     It also displays the total zeny being exchanged,
34//|     the total coins obtained and the difference between
35//|     the amount of zeny you've inputted and the sum of
36//|     the coin's values.
37
38//| Revision:
39//| v.2.5: Replaced all the coin names with a variable that has
40//|   getitemname(<coin_id), for more customization of the script.
41//|   
42//|   Fixed aswell a 0 at the mixing function, it had an unexistant
43//|   variable plus it was rendering a message to 0. Pretty bad =/
44//|   
45//|   The implementation of the getitemname was because some people
46//|   complaining that those items seemed to be wrong, that the name
47//|   in the db was Platinum while the script had Silver, so well,
48//|   there you have it. No more silver coins, thanks to you :)
49
50//| Revision:
51//| v.2.6: Added another Weight check to prevent coins from dropping
52//|     to the ground because A) Too many coins (more than 30,000 ea)
53//|     B) Your current weight + total coins weight were greater than
54//|     your max weight, causing them to drop due to "over-weight".
55//|             Thanks to Niktout for spotting it.
56
57//| Revision:
58//| v.2.7: Added a check to the Zeny -> Coin Mix label. It seems you
59//|             can trade with negative zeny (meh...). This should prevent it.
60//|             Thanks to Niktout.
61
62//| Revision:
63//| v.2.8: Added a n00b check for the Zeny -> Coin function. Should
64//|     prevent zeny overflow. Also added a variable cleaning section
65//|     at the beginning of the Mix function, to prevent old values
66//|     to be used as a payout.
67
68//| Revision:
69//| v.2.8.1 Removed the 'conflicting' switch with variables as case options,
70//|     and moved the color names to the function, so now it executes once.
71//|     Did other optimizations and cleanups all around the code. Meh.
72
73//| Upcomming possible updates:
74//| v.3.0: Adding a refining system, so you can gather ore and the likes
75//|     to make your own coins. They will have a failure chance
76//|     of course. You will need, for now: 10 ores of the type of
77//|     coin you wish, a mini furnace, an anvil depending on what
78//|     You're crafting, and a hammer according to it.
79
80//| Copyright © 2006-2007 erKURITA. All Rights Reserved
81
82prontera,155,188,3      script  Zacariath Madhat        872,{
83
84//|~~~~~~~~~~~~~ Settings of the NPC: ~~~~~~~~~~~~~~~~~
85        set @npcname$,"^999999[Zach]^000000";           //|
86        set @bronzeprice,10000;                                         //|
87        set @silverprice,100000;                                        //|
88        set @goldprice,1000000;                                         //|
89        set @mithrilprice,10000000;                                     //|
90        set @bronzecoinid,673;                                          //|
91        set @silvercoinid,677;                                          //|
92        set @goldcoinid,671;                                            //|
93        set @mithrilcoinid,674;                                         //|
94        set @minvalue,@bronzeprice;                                     //|
95        set @name1$,getitemname(@bronzecoinid);         //|
96        set @name2$,getitemname(@silvercoinid);         //|
97        set @name3$,getitemname(@goldcoinid);           //|
98        set @name4$,getitemname(@mithrilcoinid);        //|
99        set @MAX_ZENY,1000000000;                                       //|
100//|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
102        mes @npcname$;
103        mes "Hi "+strcharinfo(0)+", I'm this town's banker";
104        mes "I can allow you to exchange your zeny into useful and handy coins, which you can use to make trades between players, or just save them";
105        next;
106        mes @npcname$;
107        mes "^996600"+@name1$+"s^000000 are worth "+@bronzeprice+"z, ^999999"+@name2$+"s^000000 are worth "+@silverprice+"z, ^FFCC00"+@name3$+"s^000000 "+@goldprice+"z, ^CCCCCC"+@name4$+"s^000000 are worth "+@mithrilprice+"z";
108        next;
109        goto L_Menu;
110
111        L_Menu:
112        mes @npcname$;
113        mes "What do you want to do then?";
114        menu "Exchange my coins into zeny",-,"Exchange my zeny into coins",L_ZenyCoin,"Nothing for now, sorry",L_End;
115
116//| Here starts the Coin to Zeny Exchange
117        L_CoinZeny:
118                next;
119                mes @npcname$;
120                mes "First than anything, what kind of coins are you going to exchange?";
121                menu @name1$+"s",L_Bronze,@name2$+"s",L_Silver,@name3$+"s",L_Gold,@name4$+"s",L_Mithril,"None for now",L_Menu;
122                L_Bronze:
123                        callsub L_Coincheckout,@bronzecoinid,@bronzeprice,"^996600";
124                        goto L_CoinZeny;
125                L_Silver:
126                        callsub L_Coincheckout,@silvercoinid,@silverprice,"^999999";
127                        goto L_CoinZeny;
128                L_Gold:
129                        callsub L_Coincheckout,@goldcoinid,@goldprice,"^FFCC00";
130                        goto L_CoinZeny;
131                L_Mithril:
132                        callsub L_Coincheckout,@mithrilcoinid,@mithrilprice,"^CCCCCC";
133                        goto L_CoinZeny;
134        L_Coincheckout:
135                set @coinname$,getarg(2)+getitemname(getarg(0))+"^000000";
136                next;
137                mes @npcname$;
138                mes "Let's see, how many coins do you want to exchange?";
139                next;
140        L_Inputing:
141                input @coinamount;
142                if (@coinamount <= 0) {
143                        mes @npcname$;
144                        mes "You didn't input any amount, please retry";
145                        next;
146                        goto L_Inputing;
147                } else if (countitem(getarg(0)) < @coinamount) {
148                        mes @npcname$;
149                        mes "You don't have enough coins, please get some";
150                        next;
151                        goto L_Menu;
152                } else if (@coinamount*getarg(1) > @MAX_ZENY) {
153                        mes @npcname$;
154                        mes "I'm sorry, the quantity you inputted gives a bigger zeny amount than the max allowed. I can't allow this.";
155                        next;
156                        goto L_Menu;
157                }
158                next;
159                mes @npcname$;
160                mes "So, you want to exchange "+@coinamount+" "+@coinname$+" ?";
161                menu "Yes, I want to exchange this much",-,"No, I want to exchange something else",L_CoinZeny,"No, I want to input another number",L_Inputing,"No, I dont want to exchange anything",L_Menu;
162                next;
163                set @price,getarg(1)*@coinamount;
164                set Zeny,Zeny+@price;
165                delitem getarg(0),@coinamount;
166                mes @npcname$;
167                mes "There we go, here's your money";
168                next;
169                return;
170
171//| Here starts the Zeny to Coin exchange.
172
173        L_ZenyCoin:
174                next;
175                if (MaxWeight*50/100 < Weight) {
176                        if (MaxWeight*90/100 < Weight) {
177                                mes @npcname$;
178                                mes "Sorry but you have more than 90% weight. Your coins might drop. I can't give you anything.";
179                                next;
180                                goto L_Menu;
181                        }
182                        mes @npcname$;
183                        mes "You have 50% or more weight, do you still want to continue?";
184                        menu "Yes",L_ContinueZenyCoin,"No, thanks",L_Menu;
185                }
186        L_ContinueZenyCoin:
187                mes @npcname$;
188                mes "First, how much zeny do you want to exchange";
189                callsub L_Inputingzeny;
190                set @bronzezeny,@zenyamount/@bronzeprice;
191                set @silverzeny,@zenyamount/@silverprice;
192                set @goldzeny,@zenyamount/@goldprice;
193                set @mithrilzeny,@zenyamount/@mithrilprice;
194                next;
195                mes @npcname$;
196                mes "You can have, with "+@zenyamount+":";
197                mes "^996600"+@bronzezeny+"^000000 "+@name1$+"s";
198                mes "^999999"+@silverzeny+"^000000 "+@name2$+"s";
199                mes "^FFCC00"+@goldzeny+"^000000 "+@name3$+"s";
200                mes "or";
201                mes "^CCCCCC"+@mithrilzeny+"^000000 "+@name4$+"s";
202                next;
203                if (@zenyamount < @minvalue) goto L_Moremoney;
204                goto L_ZenyCoin2;
205
206                L_ZenyCoin2:
207                        mes @npcname$;
208                        mes "Which coins do you want? Or do you want a mix of them?";
209                        menu "I want the "+@name1$+"s",-,"I want the "+@name2$+"s",L_Silvers,"I want the "+@name3$+"s",L_Golds,"I want the "+@name4$+"s",L_Mithrils,"I want a mix of them",L_Mix,"Nothing for now, sorry",L_Menu;
210                        if (@bronzezeny == 0) goto L_Moremoney;
211                        callsub L_Zenycheckout,@bronzecoinid,@bronzeprice,@bronzezeny;
212                        goto L_Menu;
213
214                        L_Silvers:
215                                if (@silverzeny == 0) goto L_Moremoney;
216                                callsub L_Zenycheckout,@silvercoinid,@silverprice,@silverzeny;
217                                goto L_Menu;
218
219                        L_Golds:
220                                if (@goldzeny == 0) goto L_Moremoney;
221                                callsub L_Zenycheckout,@goldcoinid,@goldprice,@goldzeny;
222                                goto L_Menu;
223
224                        L_Mithrils:
225                                if (@mithrilzeny == 0) goto L_Moremoney;
226                                callsub L_Zenycheckout,@mithrilcoinid,@mithrilprice,@mithrilzeny;
227                                goto L_Menu;
228
229        L_Zenycheckout:
230                next;
231                if (((getiteminfo(getarg(0),6))*getarg(2)) > (MaxWeight-Weight)) {
232                        mes @npcname$;
233                        mes "Sorry, your max weight does not allow me to give you this much of zeny coins";
234                        mes "Either choose another type of coins or a lower quantity, thanks";
235                        close;
236                }
237                if (getarg(2) > 30000) {
238                        mes @npcname$;
239                        mes "Sorry, I can't give you more than 30,000 ea";
240                        mes "Pick another coin type";
241                        close;
242                }
243                set @itemid,getarg(0);
244                set @pricea,getarg(1)*getarg(2);
245                getitem @itemid,getarg(2);
246                set Zeny,Zeny-@pricea;
247                mes @npcname$;
248                mes "There you go, here's your coins";
249                next;
250                return;
251        L_Inputingzeny:
252                input @zenyamount;
253                if (Zeny == 0) {
254                        mes @npcname$;
255                        mes "You don't have any Zeny left. I can't do anything. Get some Zeny first";
256                        next;
257                        goto L_Menu;
258                } else if (@zenyamount <= 0) {
259                        mes @npcname$;
260                        mes "You didn't input any amount, please retry";
261                        next;
262                        goto L_Inputingzeny;
263                } else if (@zenyamount > Zeny) {
264                        mes @npcname$;
265                        mes "The inputted zeny amount is bigger than your actual zeny amount";
266                        mes "Please re-entry another amount";
267                        next;
268                        goto L_Inputingzeny;
269                } else return;
270
271//| Mix function
272        L_Mix:
273                set @totalzeny,0;
274                set @totalcoins,0;
275                set @bronzecoins,0;
276                set @silvercoins,0;
277                set @goldcoins,0;
278                set @mithrilcoins,0;
279                next;
280                mes @npcname$;
281                mes "Ok, let's start with ^996600"+@name1$+"s^000000";
282                next;
283                mes @npcname$;
284                mes "How many coins do you want?";
285                input @bronzecoins;
286                next;
287                set @totalzeny,@bronzecoins*@bronzeprice;
288                set @totalcoins,@bronzecoins;
289                mes "Zeny Amount Inputted:   ^000066"+@zenyamount+"^000000";
290                mes "Coins:";
291                mes "   ^996600"+@name1$+"s^000000:   "+@bronzecoins+"       ^CC0000"+@bronzecoins*@bronzeprice+"^000000";
292                mes "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯";
293                if (@totalzeny > @zenyamount || @totalzeny < 0) {
294                        mes "TOTAL Zeny:   "+@totalcoins+"   - ^CC0000"+@totalzeny+"^000000";
295                        mes "Zeny Left:  "+(@zenyamount-@totalzeny);
296                        goto L_Overzeny;
297                }
298                mes "TOTAL Zeny:   "+@totalcoins+"     ^00CC00"+@totalzeny+"^000000";
299                mes "Zeny Left:  "+(@zenyamount-@totalzeny);
300                next;
301                if (@totalzeny > @zenyamount || @totalzeny < 0) goto L_Overzeny;
302                mes @npcname$;
303                mes "Is this enough or do you want more?";
304                menu "It's enough, thanks",L_Payoff,"No, I want some more",-;
305                next;
306                mes @npcname$;
307                mes "Now ^999999"+@name2$+"s^000000. How many coins do you want?";
308                next;
309                input @silvercoins;
310                next;
311                set @totalzeny,@totalzeny+@silvercoins*@silverprice;
312                set @totalcoins,@totalcoins+@silvercoins;
313                mes "Zeny Amount Inputted:   ^000066"+@zenyamount+"^000000";
314                mes "Coins:";
315                mes "   ^996600"+@name1$+"s^000000:   "+@bronzecoins+"       ^CC0000"+@bronzecoins*@bronzeprice+"^000000";
316                mes "   ^999999"+@name2$+"s^000000:   "+@silvercoins+"      ^CC0000"+@silvercoins*@silverprice+"^000000";
317                mes "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯";
318                if (@totalzeny > @zenyamount || @totalzeny < 0) {
319                        mes "TOTAL Zeny:  "+@totalcoins+"   - ^CC0000"+@totalzeny+"^000000";
320                        mes "Zeny Left:  "+(@zenyamount-@totalzeny);
321                        goto L_Overzeny;
322                }
323                mes "TOTAL Zeny:   "+@totalcoins+"     ^00CC00"+@totalzeny+"^000000";
324                mes "Zeny Left:  "+(@zenyamount-@totalzeny);
325                next;
326                if (@totalzeny > @zenyamount || @totalzeny < 0) goto L_Overzeny;
327                mes @npcname$;
328                mes "Is this enough or do you want more?";
329                menu "It's enough, thanks",L_Payoff,"No, I want some more",-;
330                next;
331                mes @npcname$;
332                mes "Now ^FFCC00"+@name3$+"s^000000. How many coins do you want?";
333                input @goldcoins;
334                next;
335                set @totalzeny,@totalzeny+@goldcoins*@goldprice;
336                set @totalcoins,@totalcoins+@goldcoins;
337                mes "Zeny Amount Inputted:      ^000066"+@zenyamount+"^000000";
338                mes "Coins:";
339                mes "   ^996600"+@name1$+"s^000000:   "+@bronzecoins+"       ^CC0000"+@bronzecoins*@bronzeprice+"^000000";
340                mes "   ^999999"+@name2$+"s^000000:   "+@silvercoins+"      ^CC0000"+@silvercoins*@silverprice+"^000000";
341                mes "   ^FFCC00"+@name3$+"s^000000:   "+@goldcoins+"         ^CC0000"+@goldcoins*@goldprice+"^000000";
342                mes "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯";
343                if (@totalzeny > @zenyamount || @totalzeny < 0) {
344                        mes "TOTAL Zeny:   "+@totalcoins+"   - ^CC0000"+@totalzeny+"^000000";
345                        mes "Zeny Left:  "+(@zenyamount-@totalzeny);
346                        goto L_Overzeny;
347                }
348                mes "TOTAL Zeny:   "+@totalcoins+"     ^00CC00"+@totalzeny+"^000000";
349                mes "Zeny Left:  "+(@zenyamount-@totalzeny);
350                next;
351                if (@totalzeny > @zenyamount || @totalzeny < 0) goto L_Overzeny;
352                mes @npcname$;
353                mes "Is this enough or do you want more?";
354                menu "It's enough, thanks",L_Payoff,"No, I want some more",-;
355                next;
356                mes @npcname$;
357                mes "Now ^CCCCCC"+@name4$+"s^000000. How many coins do you want?";
358                input @mithrilcoins;
359                next;
360                set @totalzeny,@totalzeny+@mithrilcoins*@mithrilprice;
361                set @totalcoins,@totalcoins+@mithrilcoins;
362                mes "Zeny Amount Inputted:      ^000066"+@zenyamount+"^000000";
363                mes "Coins:";
364                mes "   ^996600"+@name1$+"s^000000:   "+@bronzecoins+"       ^CC0000"+@bronzecoins*@bronzeprice+"^000000";
365                mes "   ^999999"+@name2$+"s^000000:   "+@silvercoins+"      ^CC0000"+@silvercoins*@silverprice+"^000000";
366                mes "   ^FFCC00"+@name3$+"s^000000:   "+@goldcoins+"         ^CC0000"+@goldcoins*@goldprice+"^000000";
367                mes "   ^CCCCCC"+@name4$+"s^000000:   "+@mithrilcoins+"    ^CC0000"+@mithrilcoins*@mithrilprice+"^000000";
368                mes "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯";
369                if (@totalzeny > @zenyamount || @totalzeny < 0) {
370                        mes "TOTAL Zeny:   "+@totalcoins+"   - ^CC0000"+@totalzeny+"^000000";
371                        mes "Zeny Left:  "+(@zenyamount-@totalzeny);   
372                        goto L_Overzeny;
373                }
374                mes "TOTAL:   "+@totalcoins+"     ^00CC00"+@totalzeny+"^000000";
375                mes "Zeny Left:  "+(@zenyamount-@totalzeny);
376                next;
377                if (@totalzeny > @zenyamount || @totalzeny < 0) goto L_Overzeny;
378                mes @npcname$;
379                mes "Is this ok?: "+@bronzecoins+" "+@name1$+"s, "+@silvercoins+" "+@name2$+"s, "+@goldcoins+" "+@name3$+"s, "+@mithrilcoins+" "+@name4$+"s, for a total amount of "+@totalzeny;
380                menu "Yes, it's ok",-,"No, I want to re-intro them",L_Mix,"Sorry, I dont want anything",L_Menu;
381
382        L_Payoff:
383                next;
384                if (@zenyamount > Zeny) goto L_Overzeny;
385                set Zeny,Zeny-@totalzeny;
386                getitem @bronzecoinid,@bronzecoins;
387                getitem @silvercoinid,@silvercoins;
388                getitem @goldcoinid,@goldcoins;
389                getitem @mithrilcoinid,@mithrilcoins;
390                mes @npcname$;
391                mes "There you go, here's your coins";
392                next;
393                set @bronzecoins,0;
394                set @silvercoins,0;
395                set @goldcoins,0;
396                set @mithrilcoins,0;
397                goto L_End;
398
399        L_Overzeny:
400                next;
401                mes @npcname$;
402                mes "Sorry, I can't do anything else. Either the sum of all the coins you inputted is bigger than the zeny amount inputted, or the inputted amout of zeny is bigger that your total Zeny. Please retry.";
403                next;
404                goto L_Menu;
405
406//| Other labels
407
408        L_Moremoney:
409                mes @npcname$;
410                mes "You need to get more zeny, I can't give you anything with "+@zenyamount+"z, sorry";
411                next;
412                goto L_Menu;
413
414        L_End:
415                next;
416                mes @npcname$;
417                mes "Good to see you and hope to see you again. Bye";
418                close;
419               
420        OnInit:
421                setitemscript 671,"{}";
422                end;
423}
Note: See TracBrowser for help on using the browser.