浏览代码

Hotfix for issue #2879 (#2888)

* Fixed issue #2879
Little clean-up of kafra functions
Atemo 7 年之前
父节点
当前提交
139f6f2538
共有 2 个文件被更改,包括 271 次插入271 次删除
  1. 267 267
      npc/kafras/functions_kafras.txt
  2. 4 4
      npc/kafras/kafras.txt

+ 267 - 267
npc/kafras/functions_kafras.txt

@@ -1,12 +1,12 @@
-//===== rAthena Script ======================================= 
+//===== rAthena Script =======================================
 //= Kafra Functions
-//===== By: ================================================== 
+//===== By: ==================================================
 //= rAthena Dev Team
 //= Darlskies, Darkchild, Syrus22, Lupus, kobra_k88 (2.0)
 //= L0ne_W0lf
-//===== Current Version: ===================================== 
+//===== Current Version: =====================================
 //= 6.8
-//===== Compatible With: ===================================== 
+//===== Compatible With: =====================================
 //= rAthena Project
 //===== Description: =========================================
 //= These functions handle save, storage, cart rental, teleport,
@@ -15,7 +15,7 @@
 //= Kafra's will need a lot of work. The Welcome Message argument
 //= may become obsolete, as most kafras have a slightly differing
 //= Welcome message.
-//===== Additional Comments: ================================= 
+//===== Additional Comments: =================================
 //= 1.1 Now using functions v2.1 Added Cart Rent for Classes: Whitesmith, Professor.
 //=     Replaced checkoption(x) into checkcart(0) [Lupus] v2.1b Added Fix Kafra Pass Func [Kobra_k88]
 //= 2.2 Final fix of the Kafra Pass Exploit! [Lupus] a -Izlude[4] fix
@@ -39,7 +39,7 @@
 //= 5.1a Temporary? Added F_ClearGarbage to clear unused/outdated variables [Lupus]
 //= 5.2 By default commented out custom Guilds Kafra's "Guild Storage". [Lupus]
 //= 5.3 uncommented Guild Storage. Confirmed kRO feature. [Lupus]
-//= 5.4 added -Guide option (Kafra shows you nearest Guide) Work in progress. 
+//= 5.4 added -Guide option (Kafra shows you nearest Guide) Work in progress.
 //=     Need all coords for all guides.. and somehow pass their coords to kafra.
 //=     Removed universal Kafra Pass, added 3 new Kafra Tickets [Lupus]
 //= 5.4b temporary moved "-Guide" from the 1st menu punct [Lupus]
@@ -47,7 +47,7 @@
 //=     Cleaned up the menus a bit. Got rid of the proceeding "-" prefix.
 //= 5.5b Missed a preceeding hyphen, which was screwing up teleporting. [L0ne_W0lf]
 //= 5.6 Further dialog updates, added  dynamic costs for cart and storage use. [L0ne_W0lf]
-//=     Updated some functions to handle Guild Kafras the way they should. 
+//=     Updated some functions to handle Guild Kafras the way they should.
 //= 5.6a Corrected a few wrong names in the teleport function. [L0ne_W0lf]
 //= 5.7 Correced end message no longer displaying, and the duplicate names [L0ne_W0lf]
 //=     Thanks to Barron-Monster for pointing out the issues.
@@ -63,7 +63,7 @@
 //= 6.6 Added Warp Points / View Points Function. [Joseph]
 //= 6.7 Added Rune Knight Kafra. [Euphy]
 //= 6.8 Updated some functions and added VIP features. [Euphy]
-//============================================================ 
+//============================================================
 
 //=== Main Function ========================================================
 //=   arg(0): Used to determine which welcome message to show.
@@ -78,97 +78,85 @@ function	script	F_Kafra	{
 	.@menu_num = getarg(1);
 
 	// Display Kafra Welcome Message
-	switch(.@welcome){
-		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
-			set @GID,getcharid(2);
-			mes "[Kafra Employee]";
-	 		mes "Welcome. ^ff0000" + GetGuildName(@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;
+	switch(.@welcome) {
+	default:// 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
+		mes "[Kafra Employee]";
+		mes "Welcome. ^ff0000" + getguildname( getcharid(2) ) + "^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 (1) {
-		deletearray @K_Menu0$[0],getarraysize(@K_Menu0$);
-		if (.@welcome == 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(.@menu_num){
-				// 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;
-			}
+	if (.@welcome == 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(.@menu_num) {
+			// 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;
 		}
-		set .@menu$,"";
-		for (set .@i, 0; .@i < getarraysize(@K_Menu0$); set .@i, .@i + 1)
-			set .@menu$, .@menu$ + @K_Menu0$[.@i] + ":";	
-		set .@j, select (.@menu$) - 1;
-		if (@K_Menu0$[.@j] == "Save") {
+	}
+	.@menu$ = implode(.@K_Menu0$,":");
+	while (true) {
+		.@j = select(.@menu$) - 1;
+		if (.@K_Menu0$[.@j] == "Save")
 			return;
-		} else if (@K_Menu0$[.@j] == "Use Storage") {
-			// Do not charge for Guild Storage
-			if(.@welcome == 2) 
+		else if (.@K_Menu0$[.@j] == "Use Storage") {
+			if (.@welcome == 2)// Do not charge for Guild Storage
 				callfunc "F_KafStor",2,0,0;
-			else 
+			else
 				callfunc "F_KafStor",0,getarg(3),.@welcome;
 			next;
-		} else if (@K_Menu0$[.@j] == "Use Teleport Service") {
-			// Display Einbroch "No Teleport Service" notice.
-			if(.@menu_num != 4) callfunc "F_KafTele",.@welcome;
+		}
+		else if (.@K_Menu0$[.@j] == "Use Teleport Service") {
+			if (.@menu_num != 4)// Display Einbroch "No Teleport Service" notice.
+				callfunc "F_KafTele",.@welcome;
 			else {
 				mes "[Kafra Employee]";
 				mes "Because of the ^FF0000Limited";
@@ -184,16 +172,20 @@ function	script	F_Kafra	{
 				mes "understanding and cooperation.";
 			}
 			next;
-		} else if (@K_Menu0$[.@j] == "Rent a Pushcart") {
-			if(callfunc("F_KafCart",.@welcome,getarg(4)) == 1) 
+		}
+		else if (.@K_Menu0$[.@j] == "Rent a Pushcart") {
+			if (callfunc("F_KafCart",.@welcome,getarg(4)) == 1)
 				next;
-		} else if (@K_Menu0$[.@j] == "Check Other Information") {
+		}
+		else if (.@K_Menu0$[.@j] == "Check Other Information") {
 			callfunc "F_KafInfo",getarg(2);
 			next;
-		} else if (@K_Menu0$[.@j] == "Cancel"){
+		}
+		else if (.@K_Menu0$[.@j] == "Cancel") {
 			callfunc "F_KafEnd",.@welcome,0;
 			end;
-		} else if (@K_Menu0$[.@j] == "Use Guild Storage") {
+		}
+		else if (.@K_Menu0$[.@j] == "Use Guild Storage") {
 			callfunc "F_KafStor",1,0;
 			next;
 		}
@@ -208,20 +200,18 @@ function	script	F_KafStor	{
 	.@fee = getarg(1);
 
 	// Unable to access Guild Storage (Busy)
-	if(.@type == 1){
-		if(guildopenstorage()){
+	if (.@type == 1) {
+		if (guildopenstorage()) {
 			mes "[Kafra Employee]";
 			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;
+			close3;
 		}
 		cutin "", 255;
 		close;
 	}
 	// Unable to access Normal Storage (Insufficient Basic Skills)
-	if(!callfunc("F_CanOpenStorage")){
+	if (!callfunc("F_CanOpenStorage")) {
 		mes "[Kafra Employee]";
 		// Niflheim Specific Message
 		if (getarg(2) == 1) {
@@ -238,11 +228,12 @@ function	script	F_KafStor	{
 		return;
 	}
 	// Accessing Normal Storage (Skipped if accessing Storage from Guild castle)
-	if(.@type != 2){
+	if (.@type != 2) {
 		// Consume "Free Ticket for Kafra Storage" if available.
-		if(countitem(7059)) delitem 7059,1;
+		if (countitem(7059))
+			delitem 7059,1;
 		else {
-			if(Zeny<.@fee){
+			if (Zeny < .@fee) {
 				mes "[Kafra Employee]";
 				// Niflheim Specific Message
 				if (getarg(2) == 1) {
@@ -257,11 +248,11 @@ function	script	F_KafStor	{
 				mes "I'm sorry, but you don't";
 				mes "have enough zeny to use";
 				mes "the Storage Service. Our";
-				mes "Storage access fee is "+.@fee+" zeny.";
+				mes "Storage access fee is " + .@fee + " zeny.";
 				return;
 			}
-			set Zeny, Zeny-.@fee;
-			set RESRVPTS, RESRVPTS + (.@fee/5);
+			Zeny -= .@fee;
+			RESRVPTS += (.@fee/5);
 		}
 	}
 
@@ -271,7 +262,7 @@ function	script	F_KafStor	{
 		if (getarg(2) == 1) {
 			percentheal 0,-10;
 			mes "[Kafra Employee]";
-			for (set .@i, 0; .@i < 5; set .@i, .@i + 1)
+			for ( .@i = 0; .@i < 5; .@i++ )
 				mes "^666666Thank you.. for... using...^000000";
 		}
 		// Normal message
@@ -298,27 +289,24 @@ function	script	F_KafTele	{
 	mes "Please choose";
 	mes "your destination.";
 	next;
-	set .@menu$, "";
-	for (set .@i, 0; .@i <= 6; set .@i, .@i + 1)
-		set .@menu$, .@menu$ + @wrpC$[.@i] + ":";
-	set .@j, select (.@menu$) - 1;
-	if (@wrpC$[.@j] == "Cancel") return;
+	.@j = select( implode(@wrpC$,":") ) - 1;
+	if (@wrpC$[.@j] == "Cancel")
+		return;
 	// Consume "Free Ticket for Kafra Transportation" if available.
 	// Do not consume if in Guild castle
-	if(countitem(7060) > 0 && getarg(0) != 2) delitem 7060,1;
+	if (countitem(7060) > 0 && getarg(0) != 2)
+		delitem 7060,1;
 	else {
-		if (Zeny<@wrpP[.@j]){
+		if (Zeny < @wrpP[.@j]) {
 			mes "[Kafra Employee]";
 			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;
+			mes "to " + @wrpD$[.@j] + " is " + @wrpP[.@j] + " zeny.";
+			close3;
 		}
-		set Zeny, Zeny - @wrpP[.@j];
-		set RESRVPTS, RESRVPTS + (@wrpP[.@j]/16);
+		Zeny -= @wrpP[.@j];
+		RESRVPTS += (@wrpP[.@j]/16);
 	}
 	cutin "", 255;
 	if (@wrpD$[.@j] == "Al De Baran") warp "aldebaran",168,112;
@@ -326,7 +314,12 @@ function	script	F_KafTele	{
 	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 (checkre(0)) warp "izlude", 128, 98; else warp "izlude", 91, 105; }
+	else if (@wrpD$[.@j] == "Izlude") {
+		if (checkre(RENEWAL) == true)
+			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;
@@ -343,11 +336,11 @@ function	script	F_KafTele	{
 //===================================================
 function	script	F_KafCart	{
 	// Ensure that the class wanting to rent a pushcart is a merchant
-	if(BaseClass != Job_Merchant){
+	if (BaseClass != Job_Merchant) {
 		mes "[Kafra Employee]";
 		mes "I'm sorry, but the";
 		mes "Pushcart rental service";
-		if (checkre(0))
+		if (checkre(RENEWAL) == true)
 			mes "is only available to Merchant classes.";
 		else {
 			mes "is only available to Merchants,";
@@ -357,7 +350,7 @@ function	script	F_KafCart	{
 		return 1;
 	}
 	// Make sure the invoking character does not have a cart already
-	else if(checkcart() == 1){
+	else if (checkcart() == true) {
 		mes "[Kafra Employee]";
 		mes "You already have";
 		mes "a Pushcart equipped.";
@@ -367,31 +360,34 @@ function	script	F_KafCart	{
 		return 1;
 	}
 	// Check if the player has the Pushcart skill
-	else if(getskilllv("MC_PUSHCART") == 0) {
+	else if (getskilllv("MC_PUSHCART") == 0) {
 		mes "[Kafra Employee]";
 		mes "You can only rent a cart after learning the \"Push Cart\" skill.";
 		return 1;
 	}
 	// Consume "Free Ticket for the Cart Service" if available.
 	// Do not consume if in Guild castle.
-	if(countitem(7061) > 0 && getarg(0) != 2) delitem 7061,1;
+	if (countitem(7061) > 0 && getarg(0) != 2)
+		delitem 7061,1;
 	else {
+		.@rental_fee = getarg(1);
 		mes "[Kafra Employee]";
 		mes "The Pushcart rental";
-		mes "fee is "+getarg(1)+" zeny. Would";
+		mes "fee is " + .@rental_fee + " zeny. Would";
 		mes "you like to rent a Pushcart?";
 		next;
-		if (select("Rent a Pushcart.:Cancel") == 2) return 0;
-			if(Zeny<getarg(1)){
-				mes "[Kafra Employee]";
-				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;
-			}
-			set Zeny,Zeny-getarg(1);
-			set RESRVPTS, RESRVPTS + 48;
+		if (select("Rent a Pushcart.:Cancel") == 2)
+			return 0;
+		if (Zeny < .@rental_fee) {
+			mes "[Kafra Employee]";
+			mes "I'm sorry, but you";
+			mes "don't have enough";
+			mes "zeny to pay the Pushcart";
+			mes "rental fee of " + .@rental_fee + " zeny.";
+			return 1;
+		}
+		Zeny -= .@rental_fee;
+		RESRVPTS += 48;
 	}
 	setcart;
 	return 1;
@@ -401,36 +397,44 @@ function	script	F_KafCart	{
 // Special Reserve Points Function
 //===================================================
 function	script	F_KafInfo	{
-	// Uncomment next line to block Kafra Storage Protection
-	//	set .@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
-		else if (.@block) deletearray .@m$[1],1;
-	while (1) {
-		set .@j, select(implode(.@m$,":")) - 1;
-		if (.@m$[.@j] == "Check Special Reserve Points.") {
+// Uncomment next line to block Kafra Storage Protection
+//	.@block = 1;
+	if (getarg(0) == 2)// Port Malaya, Rune Knight
+		setarray .@menu$[0], "Check Special Reserve Points.", "", "", "Cancel";
+	else if (.@block)
+		setarray .@menu$[0], "Check Special Reserve Points.", "", "Kafra Employee Locations", "Cancel";
+	else
+		setarray .@menu$[0], "Check Special Reserve Points.", "Storage Password Service", "Kafra Employee Locations", "Cancel";
+	.@menu_list$ = implode(.@menu$,":");
+	while (true) {
+		.@j = select(.@menu_list$) - 1;
+		switch(.@j) {
+		case 0:// Check Special Reserve Points.
 			mes "[Kafra Employee]";
 			mes "Let's see...";
-			mes strcharinfo(0) + "...";
+			mes "" + strcharinfo(0) + "...";
 			mes "Ah, you have a total of";
-			mes RESRVPTS+ " Special Reserve Points.";
+			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.";
+			if (getarg(0) == 1)
+				return;
 			next;
-			if(getarg(0) == 1) return;
-		} else if (.@m$[.@j] == "Kafra Employee Locations") {
-			for (set .@i, 0; .@i <= 3; set .@i, .@i + 1)
+			break;
+		case 1:// Storage Password Service
+			callfunc("F_SetKafCode","[Kafra Employee]","Kafra Services");
+		case 2:// Kafra Employee Locations
+			for ( .@i = 0; .@i <= 3; .@i++ )
 				viewpoint 1,@viewpX[.@i],@viewpY[.@i],(.@i+1),0xFF00FF;
 			next;
-			for (set .@i, 0; .@i <= 3; set .@i, .@i + 1)
+			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 {
+			break;
+		default:
 			return;
 		}
 	}
@@ -442,46 +446,39 @@ function	script	F_KafInfo	{
 //  arg(2): used to display the name of the area you're saving in.
 //===================================================================
 function	script	F_KafEnd	{
+	.@type = getarg(0);
 	mes "[Kafra Employee]";
-	if(getarg(1)==1) {	
-		// Save
+	if (getarg(1) == true) {// Save
 		mes "Your Respawn Point";
 		mes "has been saved here";
-		mes getarg(2)+".";
+		mes "" + getarg(2) + ".";
 		mes "Thank you for using";
 		mes "the Kafra Services.";
-	} else if(getarg(0)==0 || getarg(0)==5) {	
-		// Generic End
+	} else if (.@type == 0 || .@type == 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;
+	} else if (.@type == 1) {// Niflheim End
+		percentheal 0,-25;
 		mes "^666666Kaffffra n-never";
 		mes "diiiiiiiiiiiiiies. On...";
 		mes "On y-yooour siiiiide~^000000";
 	}
-	close2;
-	cutin "", 255;
-	end;
+	close3;
 }
 
 //===================================================
 // Check Storage Password Function
 //===================================================
 function	script	F_CheckKafCode	{
-	if(!#kafra_code) return;
+	if (!#kafra_code)
+		return;
 	mes "Enter your storage password:";
-	set @code_,0;
-	input @code_;
-	if(@code_ != #kafra_code) {
+	input .@code_;
+	if (.@code_ != #kafra_code) {
 		dispbottom "Wrong storage password.";
-		close2;
-		cutin "",255;
-		end;
+		close3;
 	}
-	set @kafcode_try,0;
-	set @code_,0;
+	@kafcode_try = 0;
 	return;
 }
 
@@ -494,86 +491,85 @@ function	script	F_SetKafCode	{
 	.@comp_name$ = getarg(1);
 
 	mes .@npc_name$;
-	if(#kafra_code) {
-		mes "Your storage is protected with a password. What would you do now?";
+	if (#kafra_code == 0) {
+		mes "" + .@comp_name$ + " proudly presents you a new service:";
+		mes "Additional storage protection with a password.";
 		next;
-		switch (select("Change old password -> 5000z:Remove storage password -> 1000z:Cancel")) {
-			case 1:
-				mes .@npc_name$;
-				mes "At first, please enter your ^0000FFold password^000000.";
-				set @code,callfunc("F_EntKafCode");
-				if(!@code || @code != #kafra_code) {
-					mes "Wrong password. You can't set a new password.";
-					emotion ET_SCRATCH;
-					break;
-				}
-				next;
-				callsub S_SET,.@npc_name$,.@comp_name$;
-				break;
-			case 2:
-				mes .@npc_name$;
-				mes "Please, enter your password before its removal.";
-				set @code,callfunc("F_EntKafCode");
-				if(!@code) {
-					mes "The password hasn't been removed.";
-					emotion ET_SCRATCH;
-					break;
-				}
-				next;
-				mes .@npc_name$;
-				if(Zeny < 1000) {
-					mes "You don't have enough zeny.";
-					emotion ET_MONEY;
-					break;
-				}
-				set Zeny,Zeny-1000;
-				if(@code == #kafra_code) {
-					set #kafra_code,0;
-					mes "You've successfully cleared your storage password.";
-					mes "Thank you for using "+.@comp_name$+".";
-					emotion ET_THANKS;
-				} else {
-					mes "Wrong password. We won't return your 1000z.";
-					mes "Please, next time enter correct password.";
-					emotion ET_SORRY;
-				}
-				break;
-			case 3:
-				break;
+		if (select( "Set new password -> 5000z", "Cancel" ) == 1)
+			callsub( S_SET, .@npc_name$, .@comp_name$ );
+		close3;
+	}
+	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 .@npc_name$;
+		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 ET_SCRATCH;
+			break;
 		}
-	} else {
-		mes .@comp_name$+" 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,.@npc_name$,.@comp_name$; break;
-			case 2: break;		
+		callsub( S_SET, .@npc_name$, .@comp_name$ );
+		break;
+	case 2:
+		mes .@npc_name$;
+		mes "Please, enter your password before its removal.";
+		.@code = callfunc("F_EntKafCode");
+		if (!.@code) {
+			mes "The password hasn't been removed.";
+			emotion ET_SCRATCH;
+			break;
+		}
+		next;
+		mes .@npc_name$;
+		if (Zeny < 1000) {
+			mes "You don't have enough zeny.";
+			emotion ET_MONEY;
+			break;
+		}
+		Zeny -= 1000;
+		if (.@code == #kafra_code) {
+			#kafra_code = 0;
+			mes "You've successfully cleared your storage password.";
+			mes "Thank you for using " + .@comp_name$ + ".";
+			emotion ET_THANKS;
+		} else {
+			mes "Wrong password. We won't return your 1000z.";
+			mes "Please, next time enter correct password.";
+			emotion ET_SORRY;
 		}
+		break;
+	case 3:
+		break;
 	}
-	close2;
-	cutin "",255;
-	end;
+	close3;
 
 S_SET:
+	.@npc_name$ = getarg(0);
+	.@comp_name$ = getarg(1);
+
 	mes .@npc_name$;
 	mes "Now enter your ^FF0000new password^000000 to protect your storage from thieves.";
-	set @code,callfunc("F_EntKafCode");
-	if(!@code) {
+	.@code = callfunc("F_EntKafCode");
+	if (!.@code) {
 		mes "The password hasn't been changed.";
 		emotion ET_SCRATCH;
 		return;
 	}
 	next;
 	mes .@npc_name$;
-	if(Zeny < 5000) {
+	if (Zeny < 5000) {
 		mes "You don't have enough zeny.";
 		emotion ET_MONEY;
 		return;
 	}
-	set Zeny,Zeny-5000;
-	set #kafra_code,@code;
+	Zeny -= 5000;
+	#kafra_code = .@code;
 	mes "You've protected your storage with a secret password.";
-	mes "Thank you for using "+.@comp_name$+".";
+	mes "Thank you for using " + .@comp_name$ + ".";
 	emotion ET_THANKS;
 	return;
 }
@@ -583,88 +579,92 @@ S_SET:
 //===================================================
 function	script	F_EntKafCode	{
 	mes "Enter a number 1000~10000000:";
-	set @code_,0;
-	set @kafcode_try,@kafcode_try+1;
-	if(@kafcode_try>10) {
-		set @kafcode_try,0;
+	@kafcode_try += 1;
+	if (@kafcode_try > 10) {
+		@kafcode_try = 0;
 		logmes "Tried to fit storage password.";
+		return 0;
 	}
-	if(input(@code_) == 1) {
+	if (input(.@code_) == 1) {
 		mes "You can't use such big password.";
 		return 0;
 	}
-	if(@code_<1000) {
+	if (.@code_ < 1000) {
 		mes "You shouldn't use such short password.";
 		return 0;
 	}
-	return @code_;
+	return .@code_;
 }
 
 //===================================================
 // Warp Points / View Points Function
 //===================================================
 function	script	F_KafSet	{
-	cleararray @wrpC$[0],"",getarraysize(@wrpC$);
-	cleararray @wrpD$[0],"",getarraysize(@wrpD$);
-	cleararray @wrpP$[0],"",getarraysize(@wrpP$);
-	cleararray @viewpX[0],"",getarraysize(@viewpX);
-	cleararray @viewpY[0],"",getarraysize(@viewpY);
-	if (strnpcinfo(4) == "prontera") {
+	deletearray @wrpC$[0], getarraysize(@wrpC$);
+	deletearray @wrpD$[0], getarraysize(@wrpD$);
+	deletearray @wrpP$[0], getarraysize(@wrpP$);
+	deletearray @viewpX[0], getarraysize(@viewpX);
+	deletearray @viewpY[0], getarraysize(@viewpY);
+
+	.@map$ = strnpcinfo(4);
+	if (.@map$ == "prontera") {
 		setarray @wrpD$[0], "Izlude", "Geffen", "Payon", "Morroc", "Orc Dungeon", "Alberta";
 		setarray @wrpP[0], 600, 1200, 1200, 1200, 1700, 1800;
 		setarray @viewpX[0], 151, 29, 282, 152;
 		setarray @viewpY[0], 29, 207, 200, 326;
-	} else if (strnpcinfo(4) == "alberta") {
+	} else if (.@map$ == "alberta") {
 		setarray @wrpP[0], 1200, 1800, 1800;
 		setarray @wrpD$[0], "Payon", "Morroc", "Prontera";
 		setarray @viewpX[0], 28, 113, 0, 0;
 		setarray @viewpY[0], 229, 60, 0, 0;
-	} else if (strnpcinfo(4) == "aldebaran") {
+	} else if (.@map$ == "aldebaran") {
 		setarray @wrpP[0], 1200, 1200, 1800, 1700;
 		setarray @wrpD$[0], "Geffen", "Juno" , "Izlude", "Mjolnir Dead Pit";
-	} else if (strnpcinfo(4) == "comodo" ) {
+	} else if (.@map$ == "comodo" ) {
 		setarray @wrpD$[0], "Morroc", "Comodo Pharos Beacon", "Umbala";
 		setarray @wrpP[0], 1800, 1200, 1800;
-	} else if (strnpcinfo(4) == "cmd_fild07") {
+	} else if (.@map$ == "cmd_fild07") {
 		setarray @wrpD$[0], "Comodo", "Morroc";
 		setarray @wrpP[0], 1200, 1200;
-	} else if (strnpcinfo(4) == "geffen") {
+	} else if (.@map$ == "geffen") {
 		setarray @wrpD$[0], "Prontera", "Al De Baran", "Orc Dungeon", "Mjolnir Dead Pit";
 		setarray @wrpP[0], 1200, 1200, 1700, 1700;
 		setarray @viewpX[0], 120, 203;
 		setarray @viewpY[0], 62, 123;
-	} else if (strnpcinfo(4) == "izlude") {
+	} else if (.@map$ == "izlude") {
 		setarray @wrpD$[0], "Geffen", "Payon", "Morroc", "Al De Baran";
 		setarray @wrpP[0], 1200, 1200, 1200, 1800;
-	} else if (strnpcinfo(4) == "morocc") {
+	} else if (.@map$ == "morocc") {
 		setarray @wrpD$[0], "Prontera", "Payon", "Alberta", "Comodo", "Comodo Pharos Beacon";
 		setarray @wrpP[0], 1200, 1200, 1800, 1800, 1200;
 		setarray @viewpX[0], 156, 163, 28, 292;
 		setarray @viewpY[0], 97, 260, 167, 211;
-	} else if (strnpcinfo(4) == "umbala") {
+	} else if (.@map$ == "umbala") {
 		setarray @wrpD$[0], "Comodo";
 		setarray @wrpP[0], 1800;
-	} else if (strnpcinfo(4) == "payon") {
+	} else if (.@map$ == "payon") {
 		setarray @wrpD$[0], "Prontera", "Alberta", "Morroc";
 		setarray @wrpP[0], 1200, 1200, 1200;
-	} else if (strnpcinfo(4) == "yuno") {
+	} else if (.@map$ == "yuno") {
 		setarray @wrpD$[0], "Al De Baran";
 		setarray @wrpP[0], 1200;
 		setarray @viewpX[0], 328, 278, 153, 0;
 		setarray @viewpY[0], 108, 221, 187, 0;
-	} else if (strnpcinfo(4) == "job3_rune01") {
+	} else if (.@map$ == "job3_rune01") {
 		setarray @wrpD$[0], "Izlude", "Geffen", "Payon", "Morroc", "Alberta";
 		setarray @wrpP[0], 600, 1200, 1200, 1200, 1800;
 	}
 
+	.@warp_size = getarraysize(@wrpD$);
+
 	// VIP pricing varies across the regional servers; this is most practical.
 	if (VIP_SCRIPT && !vip_status(VIP_STATUS_ACTIVE)) {
-		for (set .@i, 0; .@i < getarraysize(@wrpD$); set .@i, .@i + 1)
-			setd "@wrpP["+.@i+"]",getd("@wrpP["+.@i+"]") * 2;
+		for ( .@i = 0; .@i < .@warp_size; .@i++ )
+			@wrpP[.@i] *= 2;
 	}
 
-	for (set .@i, 0; .@i < getarraysize(@wrpD$); set .@i, .@i + 1)
-		setd "@wrpC$["+.@i+"]",getd("@wrpD$["+.@i+"]")+" -> "+getd("@wrpP["+.@i+"]")+" z";
-	setd "@wrpC$["+getarraysize(@wrpC$)+"]","Cancel";
+	for ( .@i = 0; .@i < .@warp_size; .@i++ )
+		@wrpC$[.@i] = @wrpD$[.@i] + " -> " + @wrpP[.@i] + " z";
+	@wrpC$[ .@warp_size ] = "Cancel";
 	return;
 }

+ 4 - 4
npc/kafras/kafras.txt

@@ -427,7 +427,7 @@ moscovia,223,191,3	script	Kafra Employee::kaf_mosk	114,{
 	cutin "kafra_04",2;
 	callfunc "F_Kafra",0,3,0,80,700;
 	savepoint "moscovia",221,194,1,1;
-	callfunc "F_KafEnd",0,3,"in the city of Moscovia";
+	callfunc "F_KafEnd",0,1,"in the city of Moscovia";
 }
 
 // Amatsu
@@ -628,7 +628,7 @@ prt_fild05,290,224,3	script	Kafra Employee::prt_fild05	114,{
 	mes "what can I do for you today?";
 	callfunc "F_Kafra",5,1,1,40,0;
 	savepoint "prt_fild05",274,243,1,1;
-	callfunc "F_KafEnd",0,1, "at the Prontera Culverts";
+	callfunc "F_KafEnd",0,1,"at the Prontera Culverts";
 }
 
 // - Coal Mine (Dead Pitt)
@@ -657,7 +657,7 @@ moc_ruins,59,157,5	script	Kafra Employee::moc_ruins	114,{
 	mes "what can I do for you today?";
 	callfunc "F_Kafra",5,2,1,90,1200;
 	savepoint "moc_ruins",41,141,1,1;
-	callfunc "F_KafEnd",0,1," at the Pyramids";
+	callfunc "F_KafEnd",0,1,"at the Pyramids";
 }
 
 // - Orc Dungeon
@@ -685,5 +685,5 @@ alb2trea,59,69,5	script	Kafra Employee::kaf_alb2trea	117,{
 	mes "How may I assist you?";
 	callfunc "F_Kafra",5,2,1,50,0;
 	savepoint "alb2trea",92,64,1,1;
-	callfunc "F_KafEnd",0,1,0,"at Sunken Ship";
+	callfunc "F_KafEnd",0,1,"at Sunken Ship";
 }