summaryrefslogtreecommitdiff
path: root/npc/kafras/functions_kafras.txt
blob: ecbdc1f451386e6f259cd5fd2514786e0b5677e6 (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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
//================= Hercules Script =======================================
//=       _   _                     _
//=      | | | |                   | |
//=      | |_| | ___ _ __ ___ _   _| | ___  ___
//=      |  _  |/ _ \ '__/ __| | | | |/ _ \/ __|
//=      | | | |  __/ | | (__| |_| | |  __/\__ \
//=      \_| |_/\___|_|  \___|\__,_|_|\___||___/
//================= License ===============================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2012-2020 Hercules Dev Team
//= Copyright (C) Dastgir
//= Copyright (C) Haru
//= Copyright (C) rAthena Dev Team
//= Copyright (C) Euphy
//= Copyright (C) Joseph
//= Copyright (C) eAthena Dev Team
//= Copyright (C) Daegaladh
//= Copyright (C) brianluau
//= Copyright (C) Kisuka
//= Copyright (C) Evera
//= Copyright (C) erKURITA
//= Copyright (C) Silentdragon
//= Copyright (C) Nexon
//= Copyright (C) L0ne_W0lf
//= Copyright (C) kobra_k88
//= Copyright (C) Lupu
//= Copyright (C) Syrus22
//= Copyright (C) Darkchild
//= Copyright (C) Darlskies
//=
//= Hercules is free software: you can redistribute it and/or modify
//= it under the terms of the GNU General Public License as published by
//= the Free Software Foundation, either version 3 of the License, or
//= (at your option) any later version.
//=
//= This program is distributed in the hope that it will be useful,
//= but WITHOUT ANY WARRANTY; without even the implied warranty of
//= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//= GNU General Public License for more details.
//=
//= You should have received a copy of the GNU General Public License
//= along with this program.  If not, see <http://www.gnu.org/licenses/>.
//=========================================================================
//= Kafra Functions
//================= Description ===========================================
//= These functions handle save, storage, cart rental, teleport, and Free
//= Teleport/Warp/Rent Cart options for all Kafra NPCs.
//================= Current Version =======================================
//= 6.9
//=========================================================================

//== Main Function =========================================
// Arguments:
// - 0: Used to determine which welcome message to show.
// - 1: Used to determine which menu to display.
// - 2: Used to determine if the info menu is shown in F_KafInfo.
// - 3: Cost to use Storage
// - 4: Cost to Rent a Pushcart
function	script	F_Kafra	{
	callfunc "F_ClearGarbage"; // Clear outdated, unused variables
	// Display Kafra Welcome Message
	switch (getarg(0)) {
		default:
		case 0:
			// Default message (obsolete)
			mes "[Kafra Employee]";
			mes "Welcome to the";
			mes "Kafra Corporation.";
			mes "The Kafra services";
			mes "are always on your side.";
			mes "How may I assist you?";
			break;
		case 1:
			// Niflheim specific message
			mes "[Kafra Employee]";
			mes "^666666W-weeeelc-c-come";
			mes "to th-the K-kaaafrrrra";
			mes "C-coorpoor-r-ratioooonn...^000000";
			break;
		case 2:
			// Guild Castle Kafra message
			@GID = getcharid(CHAR_ID_GUILD);
			mes "[Kafra Employee]";
			mes "Welcome. ^ff0000" + getguildinfo(GUILDINFO_NAME, @GID) + "^000000 Member.";
			mes "The Kafra Coporation will stay with you wherever you go.";
			break;
		case 3:
			// Amatsu specific message (obsolete)
			mes "[Kafra Employee]";
			mes "So, have you come from a faraway land to study our culture, or are you just sightseeing?";
			mes "In either case, why not stay awhile?";
			mes "The air is eternally heavy with the";
			mes "scent of pleasant wildflowers.";
			break;
		case 4:
			// Louyang and Ayothaya specific message (obsolete)
			mes "[Kafra Employee]";
			mes "With our many Kafra";
			mes "service locations, you're never";
			mes "far from home.";
			break;
		case 5:
			// NPC has it's own welcome message. (Display nothing)
			break;
	}
	next;
	while (true) {
		deletearray @K_Menu0$;
		if (getarg(0) == 2) {
			// Guild Kafra Menu override (free Teleport, free Storage, Free Cart)
			setarray @K_Menu0$[0],"Use Storage","Use Guild Storage","Rent a Pushcart","Use Teleport Service","Cancel";
		} else {
			switch (getarg(1)) {
				// Save and Storage only
				case 1:	setarray @K_Menu0$[0],"Save","Use Storage","Cancel"; break;
				// Storage only
				case 2:	setarray @K_Menu0$[0],"Use Storage","Cancel"; break;
				// No Teleport (Common)
				case 3: setarray @K_Menu0$[0],"Save","Use Storage","Rent a Pushcart","Check Other Information","Cancel"; break;
				// Case 4 is Einbroch no tele message.
				// No save, or teleport. (Common)
				case 5:	setarray @K_Menu0$[0],"Use Storage","Rent a Pushcart","Check Other Information","Cancel"; break;
				// Storage and Check Other Information only.
				case 6:	setarray @K_Menu0$[0],"Use Storage","Check Other Information","Cancel"; break;
				// Save, Storage, and Pushcart only (Kafra Warehouse)
				case 7:	setarray @K_Menu0$[0],"Save","Use Storage","Rent a Pushcart","Cancel"; break;
				// Save, Storage, Other Check information. (Turbo track)
				case 8: setarray @K_Menu0$[0],"Save","Use Storage","Check Other Information","Cancel"; break;
				// No Save (Rune Knight)
				case 9: setarray @K_Menu0$[0],"Use Storage","Rent a Pushcart","Use Teleport Service","Check Other Information","Cancel"; break;
				// Storage, Save, and Pushcart (Dewata, reorder of case 7)
				case 10: setarray @K_Menu0$[0],"Use Storage","Save","Rent a Pushcart","Cancel"; break;
				// Default message (obsolete)
				default: setarray @K_Menu0$[0],"Save","Use Storage","Use Teleport Service","Rent a Pushcart","Check Other Information","Cancel"; break;
			}
		}
		.@menu$ = "";
		for (.@i = 0; .@i < getarraysize(@K_Menu0$); ++.@i)
			.@menu$ += @K_Menu0$[.@i] + ":";
		.@j = select(.@menu$) - 1;
		if (@K_Menu0$[.@j] == "Save") {
			return;
		} else if (@K_Menu0$[.@j] == "Use Storage") {
			// Do not charge for Guild Storage
			if(getarg(0) == 2)
				callfunc "F_KafStor",2,0,0,"[Kafra Employee]";
			else
				callfunc "F_KafStor",0,getarg(3),getarg(0),"[Kafra Employee]";
			next;
		} else if (@K_Menu0$[.@j] == "Use Teleport Service") {
			// Display Einbroch "No Teleport Service" notice.
			if (getarg(1) != 4) {
				callfunc "F_KafTele",getarg(0),"[Kafra Employee]";
			} else {
				mes "[Kafra Employee]";
				mes "Because of the ^FF0000Limited";
				mes "Transport Agreement^000000, the";
				mes "Kafra Corporation cannot";
				mes "provide Teleport Services";
				mes "in the Schwaltzvalt Republic.";
				next;
				mes "[Kafra Employee]";
				mes "We ask that you please";
				mes "use the Airship Service";
				mes "instead. Thank you for your";
				mes "understanding and cooperation.";
			}
			next;
		} else if (@K_Menu0$[.@j] == "Rent a Pushcart") {
			if(callfunc("F_KafCart",getarg(0),getarg(4),"[Kafra Employee]") == 1)
				next;
		} else if (@K_Menu0$[.@j] == "Check Other Information") {
			callfunc "F_KafInfo",getarg(2);
			next;
		} else if (@K_Menu0$[.@j] == "Cancel"){
			callfunc "F_KafEnd",getarg(0),0;
			end;
		} else if (@K_Menu0$[.@j] == "Use Guild Storage") {
			callfunc "F_KafStor",1,0,0,"[Kafra Employee]";
			next;
		}
	}
}

//== Storage Function ======================================
// Arguments:
// - 0: Specifies the type of storage that has been requested:
//      0 = Regular storage
//      1 = Guild storage
//      2 = Regular storage, in a castle (free of charge)
// - 1: Cost to use storage.
// - 2: The type of NPC this is being called from. Notable values:
//      0,2-5 = Regular Kafra
//      1 = Niflheim Kafra (special messages)
//      6 = Zonda/Cool Event Staff (no RESRVPTS)
// - 3: NPC title to display.
function	script	F_KafStor	{
	// Unable to access Guild Storage (Busy)
	if (getarg(0) == 1) {
		if (guildopenstorage()) {
			mes getarg(3);
			mes "I'm sorry but another guild member is using the guild storage";
			mes "right now.  Please wait until that person is finished.";
			close2;
			cutin "", 255;
			end;
		}
		cutin "", 255;
		close;
	}
	// Unable to access Normal Storage (Insufficient Basic Skills)
	if (basicskillcheck() && getskilllv(NV_BASIC) < 6 && getskilllv(SU_BASIC_SKILL) == 0) {
		mes getarg(3);
		// Niflheim Specific Message
		if (getarg(2) == 1) {
			mes "^666666S-s-ssoooorry,";
			if (Class == Job_Summoner) {
				mes "y-you n-neeed";
				mes "N-new b-basic sssskill...^000000";
			} else {
				mes "y-you're a-a-aaaa";
				mes "Nooviiice... N-neeeds";
				mes "B-basic sssskill l-level 6...^000000";
			}
			return;
		}
		mes "I'm sorry, but you";
		if (Class == Job_Summoner) {
			mes "need the New Basic Skill to";
		} else {
			mes "need the Novice's";
			mes "Basic Skill Level 6 to";
		}
		mes "use the Storage Service.";
		return;
	}
	// Accessing Normal Storage (Skipped if accessing Storage from Guild castle)
	if (getarg(0) != 2) {
		// Consume "Free Ticket for Kafra Storage" if available.
		if (countitem(Cargo_Free_Ticket)) {
			delitem Cargo_Free_Ticket, 1;
		} else {
			if (Zeny < getarg(1)) {
				mes getarg(3);
				// Niflheim Specific Message
				if (getarg(2) == 1) {
					percentheal -50,-50;
					mes "^666666Zeeeeeny...";
					mes "M-more z-zeny...!";
					mes "N-neeed 150... zeny...";
					mes "Ergh! T-taking bl-blood~!^000000";
					return;
				}
				// Standard Message
				mes "I'm sorry, but you don't";
				mes "have enough zeny to use";
				mes "the Storage Service. Our";
				mes "Storage access fee is "+getarg(1)+" zeny.";
				return;
			}
			Zeny -= getarg(1);
			if (getarg(2) != 6)
				RESRVPTS += getarg(1) / 5;
		}
	}

	// Surpress the "End" message if in guild castle.
	if (getarg(0) != 2) {
		if (getarg(2) == 1) {
			// Niflheim specific Message
			percentheal 0,-10;
			mes getarg(3);
			for (.@i = 0; .@i < 5; ++.@i)
				mes "^666666Thank you.. for... using...^000000";
		} else if (getarg(2) == 6) {
			// Zonda
			mes getarg(3);
			mes "Let me open your personal";
			mes "storage for you right away.";
			mes "Thanks for supporting Cool";
			mes "Event Corp. by using our";
			mes "services. Have a good day~";
		} else {
			// Normal message
			mes getarg(3);
			mes "Here, let me open";
			mes "your Storage for you.";
			mes "Thank you for using";
			mes "the Kafra Service.";
		}
	}
	callfunc("F_CheckKafCode"); //check your storage password, if set
	close2;
	openstorage;
	cutin "", 255;
	end;
}

//== Teleport Function =====================================
// Arguments:
// - 1: NPC title to display.
// - 2: The type of NPC this is being called from. Notable values:
//      2 = Guild Castle Kafra (don't consume tickets)
//      6 = Zonda/Cool Event Staff (no RESRVPTS)
function	script	F_KafTele	{
	mes getarg(1);
	mes "Please choose";
	mes "your destination.";
	next;
	.@menu$ = "";
	for (.@i = 0; .@i <= getarraysize(@wrpD$); ++.@i)
		.@menu$ += @wrpC$[.@i] + ":";
	.@j = select(.@menu$) - 1;
	if (@wrpC$[.@j] == "Cancel")
		return;
	// Consume "Free Ticket for Kafra Transportation" if available.
	// Do not consume if in Guild castle
	if (countitem(Warp_Free_Ticket) > 0 && getarg(0) != 2) {
		delitem Warp_Free_Ticket, 1;
	} else {
		if (Zeny < @wrpP[.@j]) {
			mes getarg(1);
			mes "I'm sorry, but you don't have";
			mes "enough zeny for the Teleport";
			mes "Service. The fee to teleport";
			mes "to "+@wrpD$[.@j]+" is "+@wrpP[.@j]+" zeny.";
			close2;
			cutin "", 255;
			end;
		}
		Zeny -= @wrpP[.@j];
		if (getarg(0) != 6)
			RESRVPTS += @wrpP[.@j] / 16;
	}
	cutin "", 255;
	if (@wrpD$[.@j] == "Al De Baran") warp "aldebaran",168,112;
	else if (@wrpD$[.@j] == "Alberta") warp "alberta", 117, 56;
	else if (@wrpD$[.@j] == "Comodo") warp "comodo", 209, 143;
	else if (@wrpD$[.@j] == "Comodo Pharos Beacon") warp "cmd_fild07", 127, 134;
	else if (@wrpD$[.@j] == "Geffen") warp "geffen", 120, 39;
	else if (@wrpD$[.@j] == "Izlude") { if (RENEWAL) warp "izlude", 128, 98; else warp "izlude", 91, 105; }
	else if (@wrpD$[.@j] == "Juno") warp "yuno", 158, 125;
	else if (@wrpD$[.@j] == "Mjolnir Dead Pit") warp "mjolnir_02", 99, 351;
	else if (@wrpD$[.@j] == "Morroc") warp "morocc", 156, 46;
	else if (@wrpD$[.@j] == "Orc Dungeon") warp "gef_fild10", 52, 326;
	else if (@wrpD$[.@j] == "Payon") warp "payon", 161, 58;
	else if (@wrpD$[.@j] == "Prontera") warp "prontera", 116, 72;
	else if (@wrpD$[.@j] == "Umbala") warp "umbala", 100, 154;
	else if (@wrpD$[.@j] == "Veins") warp "veins",205,101;
	else if (@wrpD$[.@j] == "Rachel") warp "rachel",115,125;
	end;
}

//== Cart Function =========================================
// Arguments:
// - 0: The type of NPC this is being called from. Notable values:
//      0,1,3-5 = Regular Kafra
//      2 = Guild Castle Kafra (don't consume tickets)
//      6 = Zonda/Cool Event Staff (no RESRVPTS)
// - 1: Cost to rent a cart.
// - 2: NPC title to display.
function	script	F_KafCart	{
	// Ensure that the class wanting to rent a pushcart is a merchant
	if (BaseClass != Job_Merchant) {
		mes getarg(2);
		mes "I'm sorry, but the";
		mes "Pushcart rental service";
		mes "is only available to Merchants,";
		mes "Blacksmiths, Master Smiths,";
		mes "Alchemists and Biochemists.";
		return 1;
	}
	if (getskilllv(MC_PUSHCART) == 0) {
		mes getarg(2);
		mes "You can only rent a cart after";
		mes "learning the Pushcart Skill.";
		return 1;
	}
	// Make sure the invoking character does not have a cart already
	if (checkcart() == 1) {
		mes getarg(2);
		mes "You already have";
		mes "a Pushcart equipped.";
		mes "Unfortunately, we can't";
		mes "rent more than one to";
		mes "each customer at a time.";
		return 1;
	}
	// Consume "Free Ticket for the Cart Service" if available.
	// Do not consume if in Guild castle.
	if (countitem(Cart_Free_Ticket) > 0 && getarg(0) != 2) {
		delitem Cart_Free_Ticket, 1;
	} else {
		mes getarg(2);
		mes "The Pushcart rental";
		mes "fee is "+getarg(1)+" zeny. Would";
		mes "you like to rent a Pushcart?";
		next;
		if (select("Rent a Pushcart.", "Cancel") == 2)
			return 0;
		if (Zeny < getarg(1)) {
			mes getarg(2);
			mes "I'm sorry, but you";
			mes "don't have enough";
			mes "zeny to pay the Pushcart";
			mes "rental fee of "+getarg(1)+" zeny.";
			return 1;
		}
		Zeny -= getarg(1);
		if (getarg(0) != 6)
			RESRVPTS += 48;
	}
	setcart;
	return 1;
}

//== Special Reserve Points Function =======================
function	script	F_KafInfo	{
	// Uncomment next line to block Kafra Storage Protection
	//.@block = 1;
	setarray .@m$, "Check Special Reserve Points.","Storage Password Service","Kafra Employee Locations","Cancel";
	if (getarg(0) == 2) deletearray .@m$[1],2; // Port Malaya, Rune Knight: remove Storage Password and Kafra Employee Locations
	else if (.@block) deletearray .@m$[1],1; // Remove Storage Password
	while (true) {
		.@j = select(implode(.@m$,":")) - 1;
		if (.@m$[.@j] == "Check Special Reserve Points.") {
			mes "[Kafra Employee]";
			mes "Let's see...";
			mes strcharinfo(PC_NAME) + "...";
			mes "Ah, you have a total of";
			mes RESRVPTS+ " Special Reserve Points.";
			next;
			mes "[Kafra Employee]";
			mes "You can exchange your";
			mes "Special Reserve Points for";
			mes "rewards at the Kafra Main Office in Al De Baran. Please use our";
			mes "convenient services to see the benefits of our rewards program.";
			next;
			if(getarg(0) == 1)
				return;
		} else if (.@m$[.@j] == "Kafra Employee Locations") {
			for (.@i = 0; .@i <= 3; ++.@i)
				viewpoint 1,@viewpX[.@i],@viewpY[.@i],(.@i+1),0xFF00FF;
			next;
			for (.@i = 0; .@i <= 3; ++.@i)
				viewpoint 2,@viewpX[.@i],@viewpY[.@i],(.@i+1),0xFF00FF;
		} else if (.@m$[.@j] == "Storage Password Service") {
			callfunc("F_SetKafCode","[Kafra Employee]","Kafra Services");
		} else {
			return;
		}
	}
}

//== End Function ==========================================
// Arguments:
// - 0: used to determine what message to display.
// - 1: used to determine if save message is displayed.
// - 2: used to display the name of the area you're saving in.
function	script	F_KafEnd	{
	mes "[Kafra Employee]";
	if (getarg(1) == 1) {
		// Save
		mes "Your Respawn Point";
		mes "has been saved here";
		mes getarg(2)+".";
		mes "Thank you for using";
		mes "the Kafra Services.";
	} else if (getarg(0) == 0 || getarg(0) == 5) {
		// Generic End
		mes "We, here at Kafra Corporation,";
		mes "are always endeavoring to provide you with the best services. We hope that we meet your adventuring needs and standards of excellence.";
	} else if (getarg(0) == 1) {
		// Niflheim End
		percentheal 0,-25;
		mes "^666666Kaffffra n-never";
		mes "diiiiiiiiiiiiiies. On...";
		mes "On y-yooour siiiiide~^000000";
	}
	close2;
	cutin "", 255;
	end;
}

//== Check Storage Password Function =======================
function	script	F_CheckKafCode	{
	if (!#kafra_code)
		return;
	mes "Enter your storage password:";
	@code_ = 0;
	input(@code_, 0);
	if (@code_ != #kafra_code) {
		dispbottom "Wrong storage password.";
		close2;
		cutin "",255;
		end;
	}
	@kafcode_try = 0;
	@code_ = 0;
	return;
}

//== Set / Change / Clear Storage Password Function ========
// Arguments:
// - 0: NPC Name
// - 1: Company Name
function	script	F_SetKafCode	{
	mes getarg(0);
	if (#kafra_code) {
		mes "Your storage is protected with a password. What would you do now?";
		next;
		switch (select("Change old password -> 5000z", "Remove storage password -> 1000z", "Cancel")) {
			case 1:
				mes getarg(0);
				mes "At first, please enter your ^0000FFold password^000000.";
				@code = callfunc("F_EntKafCode");
				if (!@code || @code != #kafra_code) {
					mes "Wrong password. You can't set a new password.";
					emotion e_hmm;
					break;
				}
				next;
				callsub S_SET,getarg(0),getarg(1);
				break;
			case 2:
				mes getarg(0);
				mes "Please, enter your password before its removal.";
				@code = callfunc("F_EntKafCode");
				if (!@code) {
					mes "The password hasn't been removed.";
					emotion e_hmm;
					break;
				}
				next;
				mes getarg(0);
				if (Zeny < 1000) {
					mes "You don't have enough zeny.";
					emotion e_cash;
					break;
				}
				Zeny -= 1000;
				if (@code == #kafra_code) {
					#kafra_code = 0;
					mes "You've successfully cleared your storage password.";
					mes "Thank you for using "+getarg(1)+".";
					emotion e_thx;
				} else {
					mes "Wrong password. We won't return your 1000z.";
					mes "Please, next time enter correct password.";
					emotion e_sry;
				}
				break;
			case 3:
				break;
		}
	} else {
		mes getarg(1)+" proudly presents you a new service:";
		mes "Additional storage protection with a password.";
		next;
		switch (select("Set new password -> 5000z", "Cancel")) {
			case 1: callsub S_SET,getarg(0),getarg(1); break;
			case 2: break;
		}
	}
	close2;
	cutin "",255;
	end;

S_SET:
	mes getarg(0);
	mes "Now enter your ^FF0000new password^000000 to protect your storage from thieves.";
	@code = callfunc("F_EntKafCode");
	if (!@code) {
		mes "The password hasn't been changed.";
		emotion e_hmm;
		return;
	}
	next;
	mes getarg(0);
	if (Zeny < 5000) {
		mes "You don't have enough zeny.";
		emotion e_cash;
		return;
	}
	Zeny -= 5000;
	#kafra_code = @code;
	mes "You've protected your storage with a secret password.";
	mes "Thank you for using "+getarg(1)+".";
	emotion e_thx;
	return;
}

//== Basic Password Validation Function ====================
function	script	F_EntKafCode	{
	mes "Enter a number 1000~10000000:";
	@code_ = 0;
	++@kafcode_try;
	if (@kafcode_try > 10) {
		@kafcode_try = 0;
		logmes "Hack: Tried to fit storage password.";
	}
	if (input(@code_, 0) == 1) {
		mes "You can't use such big password.";
		return 0;
	}
	if (@code_ < 1000) {
		mes "You shouldn't use such short password.";
		return 0;
	}
	return @code_;
}

//== Warp Points / View Points Function ====================
function	script	F_KafSet	{
	deletearray @wrpC$;
	deletearray @wrpD$;
	deletearray @wrpP$;
	deletearray @viewpX;
	deletearray @viewpY;
	if (strnpcinfo(NPC_MAP) == "prontera") {
		setarray @wrpD$, "Izlude", "Geffen", "Payon", "Morroc", "Orc Dungeon", "Alberta";
		setarray @wrpP, 600, 1200, 1200, 1200, 1200, 1800;
		setarray @viewpX, 151, 29, 282, 152;
		setarray @viewpY, 29, 207, 200, 326;
	} else if (strnpcinfo(NPC_MAP) == "alberta") {
		setarray @wrpP, 1200, 1800, 1800;
		setarray @wrpD$, "Payon", "Morroc", "Prontera";
		setarray @viewpX, 28, 113, 0, 0;
		setarray @viewpY, 229, 60, 0, 0;
	} else if (strnpcinfo(NPC_MAP) == "aldebaran") {
		setarray @wrpP, 1200, 1200, 1800, 1700;
		setarray @wrpD$, "Geffen", "Juno" , "Izlude", "Mjolnir Dead Pit";
	} else if (strnpcinfo(NPC_MAP) == "comodo" ) {
		setarray @wrpD$, "Morroc", "Comodo Pharos Beacon", "Umbala";
		setarray @wrpP, 1800, 1200, 1800;
	} else if (strnpcinfo(NPC_MAP) == "cmd_fild07") {
		setarray @wrpD$, "Comodo", "Morroc";
		setarray @wrpP, 1200, 1200;
	} else if (strnpcinfo(NPC_MAP) == "geffen") {
		setarray @wrpD$, "Prontera", "Al De Baran", "Orc Dungeon", "Mjolnir Dead Pit";
		setarray @wrpP, 1200, 1200, 1200, 1700;
		setarray @viewpX, 120, 203;
		setarray @viewpY, 62, 123;
	} else if (strnpcinfo(NPC_MAP) == "izlude") {
		setarray @wrpD$, "Geffen", "Payon", "Morroc", "Al De Baran";
		setarray @wrpP, 1200, 1200, 1200, 1800;
	} else if (strnpcinfo(NPC_MAP) == "morocc") {
		setarray @wrpD$, "Prontera", "Payon", "Alberta", "Comodo", "Comodo Pharos Beacon";
		setarray @wrpP, 1200, 1200, 1800, 1800, 1200;
		setarray @viewpX, 156, 163, 28, 292;
		setarray @viewpY, 97, 260, 167, 211;
	} else if (strnpcinfo(NPC_MAP) == "umbala") {
		setarray @wrpD$, "Comodo";
		setarray @wrpP, 1800;
	} else if (strnpcinfo(NPC_MAP) == "payon") {
		setarray @wrpD$, "Prontera", "Alberta", "Morroc";
		setarray @wrpP, 1200, 1200, 1200;
	} else if (strnpcinfo(NPC_MAP) == "yuno") {
		setarray @wrpD$, "Al De Baran";
		setarray @wrpP, 1200;
		setarray @viewpX, 328, 278, 153, 0;
		setarray @viewpY, 108, 221, 187, 0;
	} else if (strnpcinfo(NPC_MAP) == "job3_rune01") {
		setarray @wrpD$, "Izlude", "Geffen", "Payon", "Morroc", "Alberta";
		setarray @wrpP, 600, 1200, 1200, 1200, 1800;
	} else if (strnpcinfo(NPC_MAP) == "rachel") {
		setarray @wrpD$, "Veins";
		setarray @wrpP, 2200;
	} else if (strnpcinfo(NPC_MAP) == "veins") {
		setarray @wrpD$, "Rachel";
		setarray @wrpP, 2200;
	}
	for (.@i = 0; .@i < getarraysize(@wrpD$); ++.@i)
		@wrpC$[.@i] = @wrpD$[.@i]+" -> "+@wrpP[.@i];
	@wrpC$[getarraysize(@wrpC$)] = "Cancel";
	return;
}