소스 검색

* Part one of fixing bugreport:6527. This does not yet change functionality.
-- Added 'disable_items' to all applicable scripts.
-- Added preliminary source modifications. (Hercules 137cc43)
* Raised max stat for third jobs to 125 (follow-up r17133, bugreport:7295).
* Fixed logical issue with r17151. (Hercules 5c667cc)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17160 54d463be-8e91-2dee-dedb-b68131a5f0ec

euphyy 12 년 전
부모
커밋
3a330a455a

+ 1 - 1
conf/battle/player.conf

@@ -80,7 +80,7 @@ max_sp: 1000000
 max_parameter: 99
 
 // Same as max_parameter, but for 3rd classes.
-max_third_parameter: 120
+max_third_parameter: 125
 
 // Same as max_parameter, but for baby classes.
 max_baby_parameter: 80

+ 2 - 2
db/re/item_db.txt

@@ -5082,9 +5082,9 @@
 11529,MAAMOUL_,Maamoul,0,500,,100,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal 120,60; },{},{}
 11530,Jujube,Jujube,0,10,,100,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal 30,0; },{},{}
 11531,Coffee,Coffee,0,10,,100,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal 0,10; },{},{}
-11532,Nasi_Goreng,Nasi_Goreng,0,15,,20,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal rand(17,23),0; },{},{}
+11532,Nasi_Goreng,Nasi Goreng,0,15,,20,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal rand(17,23),0; },{},{}
 11533,Satay,Satay,0,15,,20,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal rand(17,23),0; },{},{}
-11534,Coconut_Juice,Coconut Juice,0,20,,20,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal rand(17,23),0; },{},{}
+11534,Coco_Juice,Coconut Juice,0,20,,50,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal rand(17,23),0; },{},{}
 //
 11536,Cat_Hard_Biscuit,Cat Biscuit,0,20,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ itemheal rand(70,110),0; },{},{}
 //

+ 5 - 1
npc/custom/card_remover.txt

@@ -3,7 +3,7 @@
 //===== By: ==================================================
 //= TyrNemesis^
 //===== Current Version: =====================================
-//= 1.2
+//= 1.2a
 //===== Compatible With: =====================================
 //= rAthena SVN
 //===== Description: =========================================
@@ -11,12 +11,16 @@
 //===== Additional Comments: =================================
 //= 1.0 First version. [TyrNemesis^]
 //= 1.2 Optimized and fixed getequipname menu. [Kisuka]
+//= 1.2a Added 'disable_items' command. [Euphy]
 //============================================================
 
 prt_in,28,73,4	script	Wise Old Woman#eAcustom	78,{
+
 	set .zenycost,200000; // Set base cost in zeny of the card remover services
 	set .percardcost,25000; // set cost per card of the card remover services
 	set .faildestroy,1; // Should the card remover have a chance of failure that destroys items? 1 = Yes, 0 = No.
+
+	disable_items;
 	mes "[Wise Old Woman]";
 	mes "Good day, young one. I have the power to remove cards that you have compounded onto your equipment. Does this idea please you?";
 	next;

+ 4 - 2
npc/custom/item_signer.txt

@@ -3,20 +3,22 @@
 //===== By: ==================================================
 //= Lupus
 //===== Current Version: =====================================
-//= 1.1
+//= 1.1a
 //===== Compatible With: =====================================
 //= rAthena SVN
 //===== Description: =========================================
 //= Write you name on your rare equipment or weapon ^_-
 //===== Additional Comments: =================================
 //= 1.1 Cleaned and edited for general use. [Euphy]
+//= 1.1a Added 'disable_items' command. [Euphy]
 //============================================================
 
 prt_in,24,61,7	script	Perchik	47,{
 	
 	setarray .@Item[0],644,3;	// Item requirements: <ID>,<Count>{,...} (0 to disable)
 	setarray .@Cost[0],0,5000;	// Zeny requirements: <base price>,<price per refine>
-	
+
+	disable_items;
 	mes "[Perchik]";
 	mes "I can ^0055FFsign your name^000000 on almost any rare item you hold.";
 	next;

+ 2 - 1
npc/custom/quests/quest_shop.txt

@@ -3,7 +3,7 @@
 //===== By: ==================================================
 //= Euphy
 //===== Current Version: =====================================
-//= 1.6
+//= 1.6a
 //===== Compatible With: =====================================
 //= rAthena SVN r16862+
 //===== Description: =========================================
@@ -107,6 +107,7 @@ OnBuyItem:
 		message strcharinfo(0),"You can't purchase that many "+getitemname(.@q[0])+".";
 		end;
 	}
+	disable_items;
 	mes "[Quest Shop]";
 	mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
 	mes "Requirements:";

+ 3 - 1
npc/merchants/advanced_refiner.txt

@@ -3,7 +3,7 @@
 //===== By: ==================================================
 //= L0ne_W0lf
 //===== Current Version: =====================================
-//= 1.4
+//= 1.4a
 //===== Compatible With: =====================================
 //= rAthena SVN
 //===== Description: =========================================
@@ -22,9 +22,11 @@
 //= 1.2 Optimizing refine method [Zephyrus]
 //= 1.3 Typo fixes [Yommy]
 //= 1.4 Removed unnecessary dialogs [Zephyrus]
+//= 1.4a Added 'disable_items' command. [Euphy]
 //============================================================
 
 payon,174,138,0	script	Suhnbi#cash	85,{
+	disable_items;
 	mes "[Suhnbi]";
 	mes "I am the Armsmith";
 	mes "I can refine all kinds of weapons,";

+ 3 - 1
npc/merchants/enchan_arm.txt

@@ -3,7 +3,7 @@
 //===== By: ================================================== 
 //= L0ne_W0lf
 //===== Current Version: ===================================== 
-//= 1.3
+//= 1.3a
 //===== Compatible With: ===================================== 
 //= rAthena SVN
 //===== Description: ========================================= 
@@ -14,9 +14,11 @@
 //= 1.1 Corrected typo (Sit -> Suit) (bugreport:4586)
 //= 1.2 Optimized. [Euphy]
 //= 1.3 Fixed some typos and optimized a little more. [Daegaladh]
+//= 1.3a Added 'disable_items' command. [Euphy]
 //============================================================ 
 
 prontera,165,60,2	script	Apprentice Craftsman	73,{
+	disable_items;
 	mes "[Apprentice Craftsman]";
 	if (Zeny > 399999) {
 		mes "I've been studying ways to enhance an armor to maximize its capability.";

+ 1 - 4
npc/merchants/old_pharmacist.txt

@@ -223,25 +223,22 @@ L_making:
 			mes "[Old Pharmacist]";
 			mes "Then pick a number below 100. If you don't want any, just enter '0'. With the materials you have, you can make about "+.@max+" potions.";
 			input .@amount;
+			next;
 			if (.@amount == 0) {
-				next;
 				mes "[Old Pharmacist]";
 				mes "Make up your mind, will you?!";
 				close;
 			}
 			if (.@amount > 100) {
-				next;
 				mes "[Old Pharmacist]";
 				mes "Are you deaf? I said less than 100!";
 				close;
 			}
 			if ((countitem(getarg(0)) < .@amount*2) || (countitem(713) < .@amount) || (Zeny < .@amount*getarg(1))) {
-				next;
 				mes "[Old Pharmacist]";
 				mes "You rascal! You don't even have all the materials and you want me to make you potions?!";
 				close;
 			}
-			next;
 			set Zeny,Zeny-(.@amount*getarg(1));
 			delitem getarg(0),.@amount*2;
 			delitem 713,.@amount;	// Empty_Bottle

+ 3 - 1
npc/merchants/refine.txt

@@ -3,7 +3,7 @@
 //===== By: ==================================================
 //= Syrus22 (1.1) dafide18 (1.4) Skotlex (1.5)
 //===== Current Version: =====================================
-//= 3.2
+//= 3.2a
 //===== Compatible With: =====================================
 //= Any Athena Version
 //===== Description: =========================================
@@ -59,6 +59,7 @@
 //		Added WoE map Refiners.
 //= 3.1 Added the new refinement & Ore creation NPC's for +11 and above Refinement. [Masao]
 //= 3.2 Moved some scripts to Renewal file, other minor changes. [Euphy]
+//= 3.2a Added 'disable_items' command. [Euphy]
 //============================================================
 
 // Christopher: Geffen Blacksmith
@@ -603,6 +604,7 @@ lhz_in02,282,20,7	script	Fulerr	869,{
 //= .@safe to the max safe refine in refine_db.txt as well.
 //============================================================
 function	script	refinemain	{
+	disable_items;
 	set .@features,getarg(1);
 	mes "[" + getarg(0) + "]";
 	mes "I'm the Armsmith.";

+ 3 - 1
npc/merchants/socket_enchant.txt

@@ -3,7 +3,7 @@
 //===== By: ==================================================
 //= rAthena Dev Team
 //===== Current Version: =====================================
-//= 2.0
+//= 2.0a
 //===== Compatible With: =====================================
 //= rAthena SVN
 //===== Description: =========================================
@@ -27,6 +27,7 @@
 //= 1.9 Moved Episode 12 items to separate NPC.
 //=     Some cleanup & optimization. [Gepard]
 //= 2.0 Duplicates now spawn from floating NPCs. [L0ne_W0lf]
+//= 2.0a Added 'disable_items' command. [Euphy]
 //============================================================
 
 -	script	Seiyablem#dummy::SocketEnchant	-1,{
@@ -247,6 +248,7 @@
 
 function	script	Func_Socket	{
 
+	disable_items;
 	mes "[Seiyablem]";
 	mes "You want to add a Slot to a " + getitemname(getarg(0)) + "?";
 	mes "Alright, please bring me ^FF0000" + getarg(6) + " " + getitemname(getarg(5)) + (getarg(6) > 1 && getarg(5) != 999 ? "s":"") + "^000000, " + (getarg(7,0) != 0 && getarg(8,0) != 0 ? ("^FF0000" + getarg(8,0) + " " + getitemname(getarg(7,0)) + (getarg(8,0) > 1 && getarg(7,0) != 999 ? "s":"") + "^000000 ") : "") + "and my ^FF0000" + (getarg(4) >= 1000 ? (getarg(4)/1000 + ",000") : getarg(4)) + ",000 zeny^000000 service fee.";

+ 3 - 1
npc/merchants/socket_enchant2.txt

@@ -3,7 +3,7 @@
 //===== By: ================================================== 
 //= Gepard
 //===== Current Version: ===================================== 
-//= 1.1
+//= 1.1a
 //===== Compatible With: ===================================== 
 //= rAthena SVN
 //===== Description: ========================================= 
@@ -12,6 +12,7 @@
 //===== Additional Comments: ================================= 
 //= 1.0 First version.
 //= 1.1 Duplicates now spawn from floating NPCs. [L0ne_W0lf]
+//= 1.1a Added 'disable_items' command. [Euphy]
 //============================================================ 
 
 -	script	Leablem#dummy::SocketEnchant2	-1,{
@@ -385,6 +386,7 @@ moc_ruins,154,86,3	duplicate(SocketEnchant2)	Leablem#moc	86
 
 function	script	Func_Socket2	{
 
+	disable_items;
 	mes "[Leablem]";
 	if(getarg(7,0) != 0 && getarg(8,0) != 0)
 	{

+ 3 - 6
npc/quests/newgears/2004_headgears.txt

@@ -3,7 +3,7 @@
 //===== By: ================================================== 
 //= Dj-Yhn
 //===== Current Version: ===================================== 
-//= 1.6
+//= 1.6a
 //===== Compatible With: ===================================== 
 //= rAthena SVN
 //===== Description: ========================================= 
@@ -33,6 +33,7 @@
 //= 1.4 Rescripted to Aegis 10.3 standards. [L0ne_W0lf]
 //= 1.5 Vito'd function call for checkweight. [L0ne_W0lf]
 //= 1.6 Replaced effect numerics with constants. [L0ne_W0lf]
+//= 1.6a Added 'disable_items' command. [Euphy]
 //============================================================
 
 // Black Cat Ears
@@ -637,7 +638,7 @@ geffen,67,87,3	script	Ipore#1	700,{
 // Angel Wing Ears, Devil Wing Ears
 //============================================================
 yuno,241,52,3	script	Old Blacksmith#hgear	813,{
-	//DisableItemMove
+	disable_items;
 	if (checkweight(1201,1) == 0) {
 		mes "- Wait a minute! -";
 		mes "- Currently you're carrying -";
@@ -645,9 +646,6 @@ yuno,241,52,3	script	Old Blacksmith#hgear	813,{
 		mes "- Please try again after -";
 		mes "- you put some items into Kafra Storage. -";
 		close;
-	//	close2;
-	//	EnableItemMove
-	//	end;
 	}
 	mes "[Skillful Looking Artisan]";
 	mes "Aha~";
@@ -960,7 +958,6 @@ yuno,241,52,3	script	Old Blacksmith#hgear	813,{
 		mes "I'm always here at this scenic spot so I can enjoy the view. Just come back whenever you feel like it.";
 		close;
 	}
-	//EnableItemMove
 }
 
 // Sea-Otter Hat

+ 5 - 2
npc/quests/newgears/2005_headgears.txt

@@ -3,9 +3,9 @@
 //===== By: ================================================== 
 //= MasterOfMuppets
 //===== Current Version: ===================================== 
-//= 1.3
+//= 1.3a
 //===== Compatible With: ===================================== 
-//= rAthena
+//= rAthena SVN
 //===== Description: ========================================= 
 //= [Aegis Conversion]
 //= 2005 Headgears Official Quest.
@@ -15,6 +15,7 @@
 //= 1.2 Replaced effect numerics with constants. [L0ne_W0lf]
 //= 1.3 Fixed item check bugs, added missing airport NPC,
 //      and took out unneeded breaks [Xantara] [Muad_Dib]
+//= 1.3a Added 'disable_items' command. [Euphy]
 //============================================================ 
 
 yuno,222,116,3	script	Kasis#LhzHat	851,{
@@ -227,6 +228,7 @@ yuno,222,116,3	script	Kasis#LhzHat	851,{
 }
 
 lighthalzen,143,68,0	script	Strange Guy#LhzHat	47,{
+	disable_items;
 	if(DTHATQ == 0)
 	{
 		mes "[Strange Guy]";
@@ -1085,6 +1087,7 @@ lhz_in02,91,38,5	script	Margaret Mary#LhzHat	90,{
 }
 
 lighthalzen,182,89,0	script	Relaxed-Looking Lady	91,{
+	disable_items;
 	if(LHZBTQ == 0)
 	{
 		mes "[Relaxed-Looking Lady]";

+ 3 - 1
npc/quests/seals/mjolnir_seal.txt

@@ -3,7 +3,7 @@
 //===== By: ================================================== 
 //= SinSloth
 //===== Current Version: ===================================== 
-//= 1.8
+//= 1.8a
 //===== Compatible With: ===================================== 
 //= rAthena
 //===== Description: ========================================= 
@@ -20,6 +20,7 @@
 //=     Corrected Sudi's and player's HP settings.
 //= 1.7 Fixed a copy/paste error in Nordri. [L0ne_W0lf]
 //= 1.8 Fixed item check for Oridecon. [L0ne_W0lf]
+//= 1.8a Added 'disable_items' command. [Euphy]
 //============================================================
 
 prontera,124,297,3	script	Tialfi	706,{
@@ -1934,6 +1935,7 @@ mjolnir_01,35,136,7	script	Dwarf Blacksmith#west	826,{
 				}
 			}
 			else if(god_mjo_3 == 1) {
+				disable_items;
 				mes "[Vestri]";
 				mes "Great...!";
 				mes "Which one should I upgrade first, huh? My heart is pounding with anticipation...";

+ 3 - 1
npc/re/merchants/refine.txt

@@ -3,13 +3,14 @@
 //===== By: ==================================================
 //= rAthena Dev Team
 //===== Current Version: =====================================
-//= 1.0
+//= 1.0a
 //===== Compatible With: =====================================
 //= rAthena SVN
 //===== Description: =========================================
 //= Renewal-specific refining NPCs and material merchants.
 //===== Additional Comments: =================================
 //= 1.0 Moved some scripts to Renewal file, optimized "Austry" NPC. [Euphy]
+//= 1.0a Added 'disable_items' command. [Euphy]
 //============================================================
 
 // +11 and above Refiners
@@ -41,6 +42,7 @@ payon_in01,18,132,3	script	Bestry#pay	826,{
 //= function call.  Otherwise, the chance in refine_db.txt is used.
 //============================================================
 function	script	refinenew	{
+	disable_items;
 	mes "["+ getarg(0) +"]";
 	mes "I am the best Blacksmith ever!";
 	mes "I don't work with normal, boring items.";

+ 3 - 1
npc/re/quests/eden/eden_quests.txt

@@ -3,7 +3,7 @@
 //===== By: ==================================================
 //= L0ne_W0lf
 //===== Current Version: =====================================
-//= 1.4a
+//= 1.4b
 //===== Compatible With: =====================================
 //= rAthena SVN
 //===== Description: =========================================
@@ -17,6 +17,7 @@
 //= alongside him. Special thanks to Chilly for the base. [Masao]
 //= 1.4 Partial cleaning and bug fixing. [Euphy]
 //= 1.4a Added 'npcskill' command. [Euphy]
+//= 1.4b Added 'disable_items' command. [Euphy]
 //============================================================
 
 moc_para01,25,35,4	script	Instructor Boya#para01	469,{
@@ -3364,6 +3365,7 @@ moc_para01,112,96,5	script	Administrator Michael	967,{
 		mes "We can only upgrade the Eden Group Hat.";
 		if (para_suv02 == 3) {
 			if (countitem(5583) > 0) {
+				disable_items;
 				mes "[Michael]";
 				mes "What status bonus do you want to upgrade?";
 				next;

+ 2 - 2
sql-files/item_db_re.sql

@@ -5113,9 +5113,9 @@ REPLACE INTO `item_db_re` VALUES (11528,'Kanafeh','Kanafeh',0,1500,NULL,200,NULL
 REPLACE INTO `item_db_re` VALUES (11529,'MAAMOUL_','Maamoul',0,500,NULL,100,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal 120,60;',NULL,NULL);
 REPLACE INTO `item_db_re` VALUES (11530,'Jujube','Jujube',0,10,NULL,100,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal 30,0;',NULL,NULL);
 REPLACE INTO `item_db_re` VALUES (11531,'Coffee','Coffee',0,10,NULL,100,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal 0,10;',NULL,NULL);
-REPLACE INTO `item_db_re` VALUES (11532,'Nasi_Goreng','Nasi_Goreng',0,15,NULL,20,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal rand(17,23),0;',NULL,NULL);
+REPLACE INTO `item_db_re` VALUES (11532,'Nasi_Goreng','Nasi Goreng',0,15,NULL,20,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal rand(17,23),0;',NULL,NULL);
 REPLACE INTO `item_db_re` VALUES (11533,'Satay','Satay',0,15,NULL,20,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal rand(17,23),0;',NULL,NULL);
-REPLACE INTO `item_db_re` VALUES (11534,'Coconut_Juice','Coconut Juice',0,20,NULL,20,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal rand(17,23),0;',NULL,NULL);
+REPLACE INTO `item_db_re` VALUES (11534,'Coco_Juice','Coconut Juice',0,20,NULL,50,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal rand(17,23),0;',NULL,NULL);
 #
 REPLACE INTO `item_db_re` VALUES (11536,'Cat_Hard_Biscuit','Cat Biscuit',0,20,NULL,10,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal rand(70,110),0;',NULL,NULL);
 #

+ 1 - 1
src/map/battle.c

@@ -5209,7 +5209,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
 		case BL_MOB:
 			if(((((TBL_MOB*)target)->special_state.ai == 2 || //Marine Spheres
 				(((TBL_MOB*)target)->special_state.ai == 3 && battle_config.summon_flora&1)) && //Floras
-				s_bl->type == BL_PC && src->type != BL_MOB) || ((TBL_MOB*)target)->special_state.ai == 4 && t_bl->id != s_bl->id) //Zanzoe
+				s_bl->type == BL_PC && src->type != BL_MOB) || (((TBL_MOB*)target)->special_state.ai == 4 && t_bl->id != s_bl->id)) //Zanzoe
 			{	//Targettable by players
 				state |= BCT_ENEMY;
 				strip_enemy = 0;

+ 14 - 12
src/map/clif.c

@@ -9518,7 +9518,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd)
 		sd->st->state = END;
 
 	sd->progressbar.npc_id = sd->progressbar.timeout = 0;
-	npc_scriptcont(sd, npc_id);
+	npc_scriptcont(sd, npc_id, false);
 }
 
 
@@ -10186,12 +10186,7 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd)
 		return;
 	}
 
-	//This flag enables you to use items while in an NPC. [Skotlex]
-	if (sd->npc_id) {
-		if (sd->npc_id != sd->npc_item_flag)
-			return;
-	}
-	else if (pc_istrading(sd) || sd->chatID)
+	if ( (!sd->npc_id && pc_istrading(sd)) || sd->chatID )
 		return;
 
 	//Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex]
@@ -10802,6 +10797,13 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
 	// Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
 	sd->idletime = last_tick;
 
+	if( sd->npc_id ){
+#ifdef RENEWAL
+		clif_msg(sd, 0x783); // TODO look for the client date that has this message.
+#endif
+		return;
+	}
+
 	if( pc_cant_act(sd) && skill_id != RK_REFRESH && !(skill_id == SR_GENTLETOUCH_CURE && (sd->sc.opt1 == OPT1_STONE || sd->sc.opt1 == OPT1_FREEZE || sd->sc.opt1 == OPT1_STUN)) )
 		return;
 	if( pc_issit(sd) )
@@ -11136,7 +11138,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
 	}
 
 	sd->npc_menu = select;
-	npc_scriptcont(sd,npc_id);
+	npc_scriptcont(sd,npc_id, false);
 }
 
 
@@ -11144,7 +11146,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
 /// 00b9 <npc id>.L
 void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
 {
-	npc_scriptcont(sd,RFIFOL(fd,2));
+	npc_scriptcont(sd,RFIFOL(fd,2), false);
 }
 
 
@@ -11156,7 +11158,7 @@ void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
 	int amount = (int)RFIFOL(fd,6);
 
 	sd->npc_amount = amount;
-	npc_scriptcont(sd, npcid);
+	npc_scriptcont(sd, npcid, false);
 }
 
 
@@ -11172,7 +11174,7 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd)
 		return; // invalid input
 
 	safestrncpy(sd->npc_str, message, min(message_len,CHATBOX_SIZE));
-	npc_scriptcont(sd, npcid);
+	npc_scriptcont(sd, npcid, false);
 }
 
 
@@ -11182,7 +11184,7 @@ void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
 {
 	if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
 		return;
-	npc_scriptcont(sd,RFIFOL(fd,2));
+	npc_scriptcont(sd, RFIFOL(fd,2), true);
 }
 
 

+ 4 - 1
src/map/npc.c

@@ -1193,7 +1193,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd)
 /*==========================================
  *
  *------------------------------------------*/
-int npc_scriptcont(struct map_session_data* sd, int id)
+int npc_scriptcont(struct map_session_data* sd, int id, bool closing)
 {
 	nullpo_retr(1, sd);
 
@@ -1228,6 +1228,9 @@ int npc_scriptcont(struct map_session_data* sd, int id)
 	if( sd->progressbar.npc_id && DIFF_TICK(sd->progressbar.timeout,gettick()) > 0 )
 		return 1;
 
+	if( closing && sd->st->state == CLOSE )
+		sd->st->state = END;
+
 	run_script_main(sd->st);
 
 	return 0;

+ 1 - 1
src/map/npc.h

@@ -118,7 +118,7 @@ int npc_touch_areanpc2(struct mob_data *md); // [Skotlex]
 int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range);
 int npc_touchnext_areanpc(struct map_session_data* sd,bool leavemap);
 int npc_click(struct map_session_data* sd, struct npc_data* nd);
-int npc_scriptcont(struct map_session_data* sd, int id);
+int npc_scriptcont(struct map_session_data* sd, int id, bool closing);
 struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl);
 int npc_buysellsel(struct map_session_data* sd, int id, int type);
 int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list);

+ 8 - 0
src/map/pc.c

@@ -4215,6 +4215,14 @@ int pc_useitem(struct map_session_data *sd,int n)
 
 	nullpo_ret(sd);
 
+	//This flag enables you to use items while in an NPC. [Skotlex]
+	if( sd->npc_id && sd->npc_id != sd->npc_item_flag ){
+#ifdef RENEWAL
+		clif_msg(sd, 0x783); // TODO look for the client date that has this message.
+#endif
+		return 0;
+	}
+
 	if( sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0 )
 		return 0;
 

+ 1 - 1
src/map/script.c

@@ -4391,7 +4391,7 @@ BUILDIN_FUNC(close)
 	if( sd == NULL )
 		return 0;
 
-	st->state = END;
+	st->state = CLOSE;
 	clif_scriptclose(sd, st->oid);
 	return 0;
 }

+ 1 - 1
src/map/script.h

@@ -114,7 +114,7 @@ struct script_stack {
 //
 // Script state
 //
-enum e_script_state { RUN,STOP,END,RERUNLINE,GOTO,RETFUNC };
+enum e_script_state { RUN,STOP,END,RERUNLINE,GOTO,RETFUNC,CLOSE };
 
 struct script_state {
 	struct script_stack* stack;