Jump to content
  • 0

Question

Posted

I have Different kinds of orbs(enchant stone in my server)
i want to make a simple Enchant NPC that you can put an enchant stone by 100% chance Selected gears and armors
here are my orbs

//Classes
35934,Swordsman,Swordsman,3,20,,10,,,,,,,,,,,,,{ bonus bStr,1; },{},{}
35935,Mage,Mage,3,20,,10,,,,,,,,,,,,,{ bonus bInt,1; },{},{}
35936,Acolyte,Acolyte,3,20,,10,,,,,,,,,,,,,{ bonus bVit,1; },{},{}
35937,Archer,Archer,3,20,,10,,,,,,,,,,,,,{ bonus bDex,1; },{},{}
35938,Thief,Thief,3,20,,10,,,,,,,,,,,,,{ bonus bAgi,1; },{},{}
35939,Merchant,Merchant,3,20,,10,,,,,,,,,,,,,{ bonus bLuk,1; },{},{}
//Elementals
35940,Fire,Fire,3,20,,10,,,,,,,,,,,,,{ bonus2 bSubEle,Ele_Fire,3; },{},{}
35941,Water,Water,3,20,,10,,,,,,,,,,,,,{ bonus2 bSubEle,Ele_Water,3; },{},{}
35942,Earth,Earth,3,20,,10,,,,,,,,,,,,,{ bonus2 bSubEle,Ele_Earth,3; },{},{}
35943,Wind,Wind,3,20,,10,,,,,,,,,,,,,{ bonus2 bSubEle,Ele_Wind,3; },{},{}
35944,Dark,Dark,3,20,,10,,,,,,,,,,,,,{ bonus2 bSubEle,Ele_Dark,3; },{},{}
35945,Holy,Holy,3,20,,10,,,,,,,,,,,,,{ bonus2 bSubEle,Ele_Holy,3; },{},{}
35946,Ghost,Ghost,3,20,,10,,,,,,,,,,,,,{ bonus2 bSubEle,Ele_Ghost,3; },{},{}
35947,Poison,Poison,3,20,,10,,,,,,,,,,,,,{ bonus2 bSubEle,Ele_Poison,3; },{},{}

7 answers to this question

Recommended Posts

  • 2
Posted

You can try this script by Sehrentos, it's one of the most configurable enchanters I've seen:

//===== rAthena Script =======================================
//= Enchant NPC
//===== By: ==================================================
//= Sehrentos
//===== Current Version: =====================================
//= 1.2
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Enchant player's equipment. Support multiple enchants.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.1 Remove enchant option.
//= 1.2 Added .max_enchant option.
//============================================================
// shop/cashshop/itemshop/pointshop
-	shop	enc_atk	-1,501:300;
-	shop	enc_def	-1,501:300;
-	shop	enc_stats	-1,501:300;

prt_in,65,68,4	script	Enchant#prt1	4_M_MERCAT1,{
	disable_items;
	switch(select("Attack:Defence:Stats:Remove")) {
		case 1: @shop_name$ = "enc_atk"; break;
		case 2: @shop_name$ = "enc_def"; break;
		case 3: @shop_name$ = "enc_stats"; break;
		case 4: callsub S_Remove; break;
		default: end;
	}
	callshop @shop_name$, 1;
	npcshopattach @shop_name$;
	end;

OnInit:
	// Settings: shop names, currencies, items, prices
	.max_enchant = 2; // Max amount of enchants 0-4
	setarray .shop_name$[0],   "enc_atk", "enc_def", "enc_stats";
	setarray .shop_currency$[0],"Zeny",    "Zeny",    "Zeny";
	setarray .enc_atk_id[0],    4760, 4761, 4806, 4815, 4814, 4813, 4812, 4826, 4827, 4828, 4829, 4830,  4831, 4819, 4766, 4767,4764,4765, 4807, 4842, 4818, 4817, 4816, 4843, 4844, 4811, 4810, 4809, 4808, 4820, 4821, 4822, 4823, 4824,  4825, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840,  4841;
	setarray .enc_atk_price[0],10000,20000,30000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,5000,7000,10000,20000,10000,20000,30000,40000,50000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000;
	setarray .enc_def_id[0],    4805, 4850, 4851, 4852,4762, 4763,4786,4787,4788,4789, 4790,4791,4792,4793, 4794,4795,4796,4797,4798,4799,4800,4801, 4802;
	setarray .enc_def_price[0],10000,20000,40000,60000,5000,12000,2000,4000,6000,8000,10000,3000,5000,9000,12000,1000,2000,3000,4000,5000,2500,5000,10000;
	setarray .enc_stats_id[0],   4700,4710,4720,4730,4740,4750, 4701,4711,4721,4731,4741,4751, 4702,4712,4722,4732,4742,4752, 4703,4713,4723,4733,4743,4753, 4704,4714,4724,4734,4744,4754, 4705,4715,4725,4735,4745,4755, 4706,4716,4726,4736,4746,4756, 4707,4717,4727,4737,4747,4757, 4708,4718,4728,4738,4748,4758, 4709, 4719, 4729, 4739, 4749, 4759;
	setarray .enc_stats_price[0],1500,1500,1500,1500,1500,1500, 2500,2500,2500,2500,2500,2500, 3500,3500,3500,3500,3500,3500, 4500,4500,4500,4500,4500,4500, 5500,5500,5500,5500,5500,5500, 6500,6500,6500,6500,6500,6500, 7500,7500,7500,7500,7500,7500, 8500,8500,8500,8500,8500,8500, 9500,9500,9500,9500,9500,9500, 10500,10500,10500,10500,10500,10500;

	// Load shop items
	for(.@i = 0; .@i < getarraysize(.shop_name$); .@i++) {
		.@npc$ = .shop_name$[.@i];
		deletearray .@id[0],getarraysize(.@id);
		deletearray .@price[0],getarraysize(.@price);
		copyarray .@id[0], getd("."+.@npc$+"_id[0]"), getarraysize(getd("."+.@npc$+"_id"));
		copyarray .@price[0], getd("."+.@npc$+"_price[0]"), getarraysize(getd("."+.@npc$+"_price"));
		npcshopdelitem .@npc$,501;// Remove apple
		for(.@j = 0; .@j < getarraysize(.@id); .@j++) {
			npcshopadditem .@npc$, .@id[.@j], .@price[.@j];
		}
	}
	end;

OnSellItem:
	end;

OnBuyItem:
	.@bought_count = getarraysize(@bought_nameid);
	if(.@bought_count < 1) end;
	// Get shop data by @shop_name$
	.@shop_index = inarray(.shop_name$[0], @shop_name$);
	if(.@shop_index == -1 || getarraysize(.shop_name$) < 1) {
		message strcharinfo(0), "Shop was not found!";
		debugmes "Incorrect shop array detected in '"+@shop_name$+"'! FIXME!";
		end;
	}
	copyarray .@shop_id[0], getd("."+@shop_name$+"_id"), getarraysize(getd("."+@shop_name$+"_id"));
	copyarray .@shop_price[0], getd("."+@shop_name$+"_price"), getarraysize(getd("."+@shop_name$+"_price"));

	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@index = inarray(.@shop_id[0], @bought_nameid[.@i]);
		if(.@index == -1) {
			message strcharinfo(0), "Price was not found!";
			debugmes "Incorrect price array detected in '"+@shop_name$+"'! FIXME!";
			end;
		}
		setarray .@bought_cost[getarraysize(.@bought_cost)],.@shop_price[.@index]*@bought_quantity[.@i];
		for (.@j = 0; .@j < @bought_quantity[.@i]; .@j++) {
			setarray .@enchant[getarraysize(.@enchant)],@bought_nameid[.@i];
		}
	}

	// Count total cost
	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@total_cost = .@total_cost + .@bought_cost[.@i];
	}

	// Currency check
	if(.shop_currency$[.@shop_index] == "Zeny" && Zeny < .@total_cost) {
		message strcharinfo(0), "("+.@total_cost+") Not enough "+.shop_currency$[.@shop_index]+"!";
		end;
	}
	// Other currency checks...

	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to enchant.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

	/*if(.@enchant_count > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}*/
	// Check for enabled refinement
	/*if(!getequipisenableref(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "I don't think I can enchant this item at all.";
		mes "Sorry...";
		close;
	}*/

	// Add all card slots
	for(.@i = 0; .@i < .@slots; .@i++) {
		setarray .@item[getarraysize(.@item)], (.@cards[.@i] > 0 ? .@cards[.@i] : -1);
	}
	// Add previous enchants
	for(.@i = .@slots; .@i < .@cards_count; .@i++) {
		if(.@cards[.@i] > 0) {
			setarray .@item[getarraysize(.@item)], .@cards[.@i];
		}
	}
	// Add new enchants
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		setarray .@item[getarraysize(.@item)], .@enchant[.@i];
	}

	// Check for produced/crafted items 254,255
	if(.@cards[0] == CARD0_FORGE || .@cards[0] == CARD0_CREATE) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}

	// Has card sockets 4 - slots
	if(.@enchant_count > (.max_enchant - .@slots)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This equipment can hold "+(.max_enchant - .@slots)+" enchant.";
		close;
	}

	// Has free sockets
	if((.@slots + .@enchant_count) > .max_enchant || getarraysize(.@item) > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item does not have enough free sockets to enchant.";
		close;
	}

	// Confirm the setup
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Setup^000000";
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		mes "Enchant: "+ getitemname(.@enchant[.@i]);
	}
	mes "Equipment: "+ getitemname(getequipid(.@position));
	mes "Cost: "+.@total_cost+" "+.shop_currency$[.@shop_index]+".";
	if (select("Create enchant:Cancel") != 1) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "Farewell.";
		close;
	}

	// Create selected enchant
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your enchanted equipment!";
	delequip(.@position);
	specialeffect2 154;

	if(.shop_currency$[.@shop_index] == "Zeny") {
		Zeny = Zeny - .@total_cost;
	}

	getitem2 .@item_id, 1, 1, .@refine, 0,
		(.@item[0] > 0 ? .@item[0] : 0),
		(.@item[1] > 0 ? .@item[1] : 0),
		(.@item[2] > 0 ? .@item[2] : 0),
		(.@item[3] > 0 ? .@item[3] : 0);
	close;

S_Remove:
	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to work on.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

	// Create selected item
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your equipment back!";
	delequip(.@position);
	specialeffect2 169;

	getitem2 .@item_id, 1, 1, .@refine, 0,0,0,0,0;
	for(.@i=0; .@i<.@slots; .@i++) {
		if(.@cards[.@i] > 0)
			getitem .@cards[.@i], 1;
	}
	close;

S_SelectPosition:
	setarray .@indices[1], EQI_HEAD_TOP, EQI_HEAD_MID, EQI_HEAD_LOW, EQI_ARMOR, EQI_HAND_L, EQI_HAND_R, EQI_GARMENT, EQI_SHOES, EQI_ACC_L, EQI_ACC_R;
	setarray .@position$[1], "Top", "Mid", "Low", "Armor", "Left Hand", "Right Hand", "Garment", "Shoes", "Accessory L", "Accessory R";
	setarray .@option[1], 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; // 1=allow, 0=deny
	for(.@i=1; .@i<getarraysize(.@indices); .@i++) {
		if(.@option[.@i] && getequipisequiped(.@indices[.@i])) {
			.@menu$ = .@menu$ + .@position$[.@i] + "-[" + getequipname(.@indices[.@i]) + "]";
		}
		.@menu$ = .@menu$ + ":";
	}
	.@part = .@indices[select(.@menu$)];
	return .@part;
}

 

  • Upvote 2
  • Love 1
  • MVP 2
  • 0
Posted (edited)

@n0tttt how to make it use proof of donation instead of zeny?

Nevermind i figured out how to change it. Thanks for this script @n0tttt

Update: I figured out how to change it to itemshop but it didn't work like the way it was. 

Edited by walter307
  • 0
Posted
On 1/13/2019 at 2:17 AM, n0tttt said:

You can try this script by Sehrentos, it's one of the most configurable enchanters I've seen:


//===== rAthena Script =======================================
//= Enchant NPC
//===== By: ==================================================
//= Sehrentos
//===== Current Version: =====================================
//= 1.2
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Enchant player's equipment. Support multiple enchants.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.1 Remove enchant option.
//= 1.2 Added .max_enchant option.
//============================================================
// shop/cashshop/itemshop/pointshop
-	shop	enc_atk	-1,501:300;
-	shop	enc_def	-1,501:300;
-	shop	enc_stats	-1,501:300;

prt_in,65,68,4	script	Enchant#prt1	4_M_MERCAT1,{
	disable_items;
	switch(select("Attack:Defence:Stats:Remove")) {
		case 1: @shop_name$ = "enc_atk"; break;
		case 2: @shop_name$ = "enc_def"; break;
		case 3: @shop_name$ = "enc_stats"; break;
		case 4: callsub S_Remove; break;
		default: end;
	}
	callshop @shop_name$, 1;
	npcshopattach @shop_name$;
	end;

OnInit:
	// Settings: shop names, currencies, items, prices
	.max_enchant = 2; // Max amount of enchants 0-4
	setarray .shop_name$[0],   "enc_atk", "enc_def", "enc_stats";
	setarray .shop_currency$[0],"Zeny",    "Zeny",    "Zeny";
	setarray .enc_atk_id[0],    4760, 4761, 4806, 4815, 4814, 4813, 4812, 4826, 4827, 4828, 4829, 4830,  4831, 4819, 4766, 4767,4764,4765, 4807, 4842, 4818, 4817, 4816, 4843, 4844, 4811, 4810, 4809, 4808, 4820, 4821, 4822, 4823, 4824,  4825, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840,  4841;
	setarray .enc_atk_price[0],10000,20000,30000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,5000,7000,10000,20000,10000,20000,30000,40000,50000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000;
	setarray .enc_def_id[0],    4805, 4850, 4851, 4852,4762, 4763,4786,4787,4788,4789, 4790,4791,4792,4793, 4794,4795,4796,4797,4798,4799,4800,4801, 4802;
	setarray .enc_def_price[0],10000,20000,40000,60000,5000,12000,2000,4000,6000,8000,10000,3000,5000,9000,12000,1000,2000,3000,4000,5000,2500,5000,10000;
	setarray .enc_stats_id[0],   4700,4710,4720,4730,4740,4750, 4701,4711,4721,4731,4741,4751, 4702,4712,4722,4732,4742,4752, 4703,4713,4723,4733,4743,4753, 4704,4714,4724,4734,4744,4754, 4705,4715,4725,4735,4745,4755, 4706,4716,4726,4736,4746,4756, 4707,4717,4727,4737,4747,4757, 4708,4718,4728,4738,4748,4758, 4709, 4719, 4729, 4739, 4749, 4759;
	setarray .enc_stats_price[0],1500,1500,1500,1500,1500,1500, 2500,2500,2500,2500,2500,2500, 3500,3500,3500,3500,3500,3500, 4500,4500,4500,4500,4500,4500, 5500,5500,5500,5500,5500,5500, 6500,6500,6500,6500,6500,6500, 7500,7500,7500,7500,7500,7500, 8500,8500,8500,8500,8500,8500, 9500,9500,9500,9500,9500,9500, 10500,10500,10500,10500,10500,10500;

	// Load shop items
	for(.@i = 0; .@i < getarraysize(.shop_name$); .@i++) {
		.@npc$ = .shop_name$[.@i];
		deletearray .@id[0],getarraysize(.@id);
		deletearray .@price[0],getarraysize(.@price);
		copyarray .@id[0], getd("."+.@npc$+"_id[0]"), getarraysize(getd("."+.@npc$+"_id"));
		copyarray .@price[0], getd("."+.@npc$+"_price[0]"), getarraysize(getd("."+.@npc$+"_price"));
		npcshopdelitem .@npc$,501;// Remove apple
		for(.@j = 0; .@j < getarraysize(.@id); .@j++) {
			npcshopadditem .@npc$, .@id[.@j], .@price[.@j];
		}
	}
	end;

OnSellItem:
	end;

OnBuyItem:
	.@bought_count = getarraysize(@bought_nameid);
	if(.@bought_count < 1) end;
	// Get shop data by @shop_name$
	.@shop_index = inarray(.shop_name$[0], @shop_name$);
	if(.@shop_index == -1 || getarraysize(.shop_name$) < 1) {
		message strcharinfo(0), "Shop was not found!";
		debugmes "Incorrect shop array detected in '"+@shop_name$+"'! FIXME!";
		end;
	}
	copyarray .@shop_id[0], getd("."+@shop_name$+"_id"), getarraysize(getd("."+@shop_name$+"_id"));
	copyarray .@shop_price[0], getd("."+@shop_name$+"_price"), getarraysize(getd("."+@shop_name$+"_price"));

	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@index = inarray(.@shop_id[0], @bought_nameid[.@i]);
		if(.@index == -1) {
			message strcharinfo(0), "Price was not found!";
			debugmes "Incorrect price array detected in '"+@shop_name$+"'! FIXME!";
			end;
		}
		setarray .@bought_cost[getarraysize(.@bought_cost)],.@shop_price[.@index]*@bought_quantity[.@i];
		for (.@j = 0; .@j < @bought_quantity[.@i]; .@j++) {
			setarray .@enchant[getarraysize(.@enchant)],@bought_nameid[.@i];
		}
	}

	// Count total cost
	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@total_cost = .@total_cost + .@bought_cost[.@i];
	}

	// Currency check
	if(.shop_currency$[.@shop_index] == "Zeny" && Zeny < .@total_cost) {
		message strcharinfo(0), "("+.@total_cost+") Not enough "+.shop_currency$[.@shop_index]+"!";
		end;
	}
	// Other currency checks...

	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to enchant.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

	/*if(.@enchant_count > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}*/
	// Check for enabled refinement
	/*if(!getequipisenableref(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "I don't think I can enchant this item at all.";
		mes "Sorry...";
		close;
	}*/

	// Add all card slots
	for(.@i = 0; .@i < .@slots; .@i++) {
		setarray .@item[getarraysize(.@item)], (.@cards[.@i] > 0 ? .@cards[.@i] : -1);
	}
	// Add previous enchants
	for(.@i = .@slots; .@i < .@cards_count; .@i++) {
		if(.@cards[.@i] > 0) {
			setarray .@item[getarraysize(.@item)], .@cards[.@i];
		}
	}
	// Add new enchants
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		setarray .@item[getarraysize(.@item)], .@enchant[.@i];
	}

	// Check for produced/crafted items 254,255
	if(.@cards[0] == CARD0_FORGE || .@cards[0] == CARD0_CREATE) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}

	// Has card sockets 4 - slots
	if(.@enchant_count > (.max_enchant - .@slots)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This equipment can hold "+(.max_enchant - .@slots)+" enchant.";
		close;
	}

	// Has free sockets
	if((.@slots + .@enchant_count) > .max_enchant || getarraysize(.@item) > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item does not have enough free sockets to enchant.";
		close;
	}

	// Confirm the setup
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Setup^000000";
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		mes "Enchant: "+ getitemname(.@enchant[.@i]);
	}
	mes "Equipment: "+ getitemname(getequipid(.@position));
	mes "Cost: "+.@total_cost+" "+.shop_currency$[.@shop_index]+".";
	if (select("Create enchant:Cancel") != 1) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "Farewell.";
		close;
	}

	// Create selected enchant
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your enchanted equipment!";
	delequip(.@position);
	specialeffect2 154;

	if(.shop_currency$[.@shop_index] == "Zeny") {
		Zeny = Zeny - .@total_cost;
	}

	getitem2 .@item_id, 1, 1, .@refine, 0,
		(.@item[0] > 0 ? .@item[0] : 0),
		(.@item[1] > 0 ? .@item[1] : 0),
		(.@item[2] > 0 ? .@item[2] : 0),
		(.@item[3] > 0 ? .@item[3] : 0);
	close;

S_Remove:
	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to work on.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

	// Create selected item
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your equipment back!";
	delequip(.@position);
	specialeffect2 169;

	getitem2 .@item_id, 1, 1, .@refine, 0,0,0,0,0;
	for(.@i=0; .@i<.@slots; .@i++) {
		if(.@cards[.@i] > 0)
			getitem .@cards[.@i], 1;
	}
	close;

S_SelectPosition:
	setarray .@indices[1], EQI_HEAD_TOP, EQI_HEAD_MID, EQI_HEAD_LOW, EQI_ARMOR, EQI_HAND_L, EQI_HAND_R, EQI_GARMENT, EQI_SHOES, EQI_ACC_L, EQI_ACC_R;
	setarray .@position$[1], "Top", "Mid", "Low", "Armor", "Left Hand", "Right Hand", "Garment", "Shoes", "Accessory L", "Accessory R";
	setarray .@option[1], 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; // 1=allow, 0=deny
	for(.@i=1; .@i<getarraysize(.@indices); .@i++) {
		if(.@option[.@i] && getequipisequiped(.@indices[.@i])) {
			.@menu$ = .@menu$ + .@position$[.@i] + "-[" + getequipname(.@indices[.@i]) + "]";
		}
		.@menu$ = .@menu$ + ":";
	}
	.@part = .@indices[select(.@menu$)];
	return .@part;
}

 

how to use thiese items ??

  • 0
Posted
On 1/13/2019 at 2:17 AM, n0tttt said:

You can try this script by Sehrentos, it's one of the most configurable enchanters I've seen:


//===== rAthena Script =======================================
//= Enchant NPC
//===== By: ==================================================
//= Sehrentos
//===== Current Version: =====================================
//= 1.2
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Enchant player's equipment. Support multiple enchants.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.1 Remove enchant option.
//= 1.2 Added .max_enchant option.
//============================================================
// shop/cashshop/itemshop/pointshop
-	shop	enc_atk	-1,501:300;
-	shop	enc_def	-1,501:300;
-	shop	enc_stats	-1,501:300;

prt_in,65,68,4	script	Enchant#prt1	4_M_MERCAT1,{
	disable_items;
	switch(select("Attack:Defence:Stats:Remove")) {
		case 1: @shop_name$ = "enc_atk"; break;
		case 2: @shop_name$ = "enc_def"; break;
		case 3: @shop_name$ = "enc_stats"; break;
		case 4: callsub S_Remove; break;
		default: end;
	}
	callshop @shop_name$, 1;
	npcshopattach @shop_name$;
	end;

OnInit:
	// Settings: shop names, currencies, items, prices
	.max_enchant = 2; // Max amount of enchants 0-4
	setarray .shop_name$[0],   "enc_atk", "enc_def", "enc_stats";
	setarray .shop_currency$[0],"Zeny",    "Zeny",    "Zeny";
	setarray .enc_atk_id[0],    4760, 4761, 4806, 4815, 4814, 4813, 4812, 4826, 4827, 4828, 4829, 4830,  4831, 4819, 4766, 4767,4764,4765, 4807, 4842, 4818, 4817, 4816, 4843, 4844, 4811, 4810, 4809, 4808, 4820, 4821, 4822, 4823, 4824,  4825, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840,  4841;
	setarray .enc_atk_price[0],10000,20000,30000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,5000,7000,10000,20000,10000,20000,30000,40000,50000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000;
	setarray .enc_def_id[0],    4805, 4850, 4851, 4852,4762, 4763,4786,4787,4788,4789, 4790,4791,4792,4793, 4794,4795,4796,4797,4798,4799,4800,4801, 4802;
	setarray .enc_def_price[0],10000,20000,40000,60000,5000,12000,2000,4000,6000,8000,10000,3000,5000,9000,12000,1000,2000,3000,4000,5000,2500,5000,10000;
	setarray .enc_stats_id[0],   4700,4710,4720,4730,4740,4750, 4701,4711,4721,4731,4741,4751, 4702,4712,4722,4732,4742,4752, 4703,4713,4723,4733,4743,4753, 4704,4714,4724,4734,4744,4754, 4705,4715,4725,4735,4745,4755, 4706,4716,4726,4736,4746,4756, 4707,4717,4727,4737,4747,4757, 4708,4718,4728,4738,4748,4758, 4709, 4719, 4729, 4739, 4749, 4759;
	setarray .enc_stats_price[0],1500,1500,1500,1500,1500,1500, 2500,2500,2500,2500,2500,2500, 3500,3500,3500,3500,3500,3500, 4500,4500,4500,4500,4500,4500, 5500,5500,5500,5500,5500,5500, 6500,6500,6500,6500,6500,6500, 7500,7500,7500,7500,7500,7500, 8500,8500,8500,8500,8500,8500, 9500,9500,9500,9500,9500,9500, 10500,10500,10500,10500,10500,10500;

	// Load shop items
	for(.@i = 0; .@i < getarraysize(.shop_name$); .@i++) {
		.@npc$ = .shop_name$[.@i];
		deletearray .@id[0],getarraysize(.@id);
		deletearray .@price[0],getarraysize(.@price);
		copyarray .@id[0], getd("."+.@npc$+"_id[0]"), getarraysize(getd("."+.@npc$+"_id"));
		copyarray .@price[0], getd("."+.@npc$+"_price[0]"), getarraysize(getd("."+.@npc$+"_price"));
		npcshopdelitem .@npc$,501;// Remove apple
		for(.@j = 0; .@j < getarraysize(.@id); .@j++) {
			npcshopadditem .@npc$, .@id[.@j], .@price[.@j];
		}
	}
	end;

OnSellItem:
	end;

OnBuyItem:
	.@bought_count = getarraysize(@bought_nameid);
	if(.@bought_count < 1) end;
	// Get shop data by @shop_name$
	.@shop_index = inarray(.shop_name$[0], @shop_name$);
	if(.@shop_index == -1 || getarraysize(.shop_name$) < 1) {
		message strcharinfo(0), "Shop was not found!";
		debugmes "Incorrect shop array detected in '"+@shop_name$+"'! FIXME!";
		end;
	}
	copyarray .@shop_id[0], getd("."+@shop_name$+"_id"), getarraysize(getd("."+@shop_name$+"_id"));
	copyarray .@shop_price[0], getd("."+@shop_name$+"_price"), getarraysize(getd("."+@shop_name$+"_price"));

	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@index = inarray(.@shop_id[0], @bought_nameid[.@i]);
		if(.@index == -1) {
			message strcharinfo(0), "Price was not found!";
			debugmes "Incorrect price array detected in '"+@shop_name$+"'! FIXME!";
			end;
		}
		setarray .@bought_cost[getarraysize(.@bought_cost)],.@shop_price[.@index]*@bought_quantity[.@i];
		for (.@j = 0; .@j < @bought_quantity[.@i]; .@j++) {
			setarray .@enchant[getarraysize(.@enchant)],@bought_nameid[.@i];
		}
	}

	// Count total cost
	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@total_cost = .@total_cost + .@bought_cost[.@i];
	}

	// Currency check
	if(.shop_currency$[.@shop_index] == "Zeny" && Zeny < .@total_cost) {
		message strcharinfo(0), "("+.@total_cost+") Not enough "+.shop_currency$[.@shop_index]+"!";
		end;
	}
	// Other currency checks...

	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to enchant.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

	/*if(.@enchant_count > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}*/
	// Check for enabled refinement
	/*if(!getequipisenableref(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "I don't think I can enchant this item at all.";
		mes "Sorry...";
		close;
	}*/

	// Add all card slots
	for(.@i = 0; .@i < .@slots; .@i++) {
		setarray .@item[getarraysize(.@item)], (.@cards[.@i] > 0 ? .@cards[.@i] : -1);
	}
	// Add previous enchants
	for(.@i = .@slots; .@i < .@cards_count; .@i++) {
		if(.@cards[.@i] > 0) {
			setarray .@item[getarraysize(.@item)], .@cards[.@i];
		}
	}
	// Add new enchants
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		setarray .@item[getarraysize(.@item)], .@enchant[.@i];
	}

	// Check for produced/crafted items 254,255
	if(.@cards[0] == CARD0_FORGE || .@cards[0] == CARD0_CREATE) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}

	// Has card sockets 4 - slots
	if(.@enchant_count > (.max_enchant - .@slots)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This equipment can hold "+(.max_enchant - .@slots)+" enchant.";
		close;
	}

	// Has free sockets
	if((.@slots + .@enchant_count) > .max_enchant || getarraysize(.@item) > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item does not have enough free sockets to enchant.";
		close;
	}

	// Confirm the setup
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Setup^000000";
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		mes "Enchant: "+ getitemname(.@enchant[.@i]);
	}
	mes "Equipment: "+ getitemname(getequipid(.@position));
	mes "Cost: "+.@total_cost+" "+.shop_currency$[.@shop_index]+".";
	if (select("Create enchant:Cancel") != 1) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "Farewell.";
		close;
	}

	// Create selected enchant
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your enchanted equipment!";
	delequip(.@position);
	specialeffect2 154;

	if(.shop_currency$[.@shop_index] == "Zeny") {
		Zeny = Zeny - .@total_cost;
	}

	getitem2 .@item_id, 1, 1, .@refine, 0,
		(.@item[0] > 0 ? .@item[0] : 0),
		(.@item[1] > 0 ? .@item[1] : 0),
		(.@item[2] > 0 ? .@item[2] : 0),
		(.@item[3] > 0 ? .@item[3] : 0);
	close;

S_Remove:
	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to work on.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

	// Create selected item
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your equipment back!";
	delequip(.@position);
	specialeffect2 169;

	getitem2 .@item_id, 1, 1, .@refine, 0,0,0,0,0;
	for(.@i=0; .@i<.@slots; .@i++) {
		if(.@cards[.@i] > 0)
			getitem .@cards[.@i], 1;
	}
	close;

S_SelectPosition:
	setarray .@indices[1], EQI_HEAD_TOP, EQI_HEAD_MID, EQI_HEAD_LOW, EQI_ARMOR, EQI_HAND_L, EQI_HAND_R, EQI_GARMENT, EQI_SHOES, EQI_ACC_L, EQI_ACC_R;
	setarray .@position$[1], "Top", "Mid", "Low", "Armor", "Left Hand", "Right Hand", "Garment", "Shoes", "Accessory L", "Accessory R";
	setarray .@option[1], 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; // 1=allow, 0=deny
	for(.@i=1; .@i<getarraysize(.@indices); .@i++) {
		if(.@option[.@i] && getequipisequiped(.@indices[.@i])) {
			.@menu$ = .@menu$ + .@position$[.@i] + "-[" + getequipname(.@indices[.@i]) + "]";
		}
		.@menu$ = .@menu$ + ":";
	}
	.@part = .@indices[select(.@menu$)];
	return .@part;
}

How to fix do not remove option on armor 

when i use this script my random option is remove out.

 

Thank you

  • 0
Posted (edited)
On 10/1/2020 at 6:49 PM, ittiphol said:

How to fix do not remove option on armor 

when i use this script my random option is remove out.

 

Thank you

I've added a loop to save the gear`s random options in variables

for(.@i=0;.@i<(MAX_ITEM_RDM_OPT);.@i++){
  .@randOptId[.@i] = getequiprandomoption(.@position,.@i,ROA_ID);
  .@randOptValue[.@i] = getequiprandomoption(.@position,.@i,ROA_VALUE);
  .@randOptParam[.@i] = getequiprandomoption(.@position,.@i,ROA_PARAM);
}

And changed getitem2 to getitem3 to create the stored random options values.

Here it is:

//===== rAthena Script =======================================
//= Enchant NPC
//===== By: ==================================================
//= Sehrentos
//===== Current Version: =====================================
//= 1.2
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Enchant player's equipment. Support multiple enchants.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.1 Remove enchant option.
//= 1.2 Added .max_enchant option.
//============================================================
// shop/cashshop/itemshop/pointshop
-	shop	enc_atk	-1,501:300;
-	shop	enc_def	-1,501:300;
-	shop	enc_stats	-1,501:300;

prontera,159,177,6	script	Enchant#prt1	4_M_MERCAT1,{
	disable_items;
	switch(select("Attack:Defence:Stats:Remove")) {
		case 1: @shop_name$ = "enc_atk"; break;
		case 2: @shop_name$ = "enc_def"; break;
		case 3: @shop_name$ = "enc_stats"; break;
		case 4: callsub S_Remove; break;
		default: end;
	}
	callshop @shop_name$, 1;
	npcshopattach @shop_name$;
	end;

OnInit:
	// Settings: shop names, currencies, items, prices
	.max_enchant = 2; // Max amount of enchants 0-4
	setarray .shop_name$[0],   "enc_atk", "enc_def", "enc_stats";
	setarray .shop_currency$[0],"Zeny",    "Zeny",    "Zeny";
	setarray .enc_atk_id[0],    4760, 4761, 4806, 4815, 4814, 4813, 4812, 4826, 4827, 4828, 4829, 4830,  4831, 4819, 4766, 4767,4764,4765, 4807, 4842, 4818, 4817, 4816, 4843, 4844, 4811, 4810, 4809, 4808, 4820, 4821, 4822, 4823, 4824,  4825, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840,  4841;
	setarray .enc_atk_price[0],10000,20000,30000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,5000,7000,10000,20000,10000,20000,30000,40000,50000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000;
	setarray .enc_def_id[0],    4805, 4850, 4851, 4852,4762, 4763,4786,4787,4788,4789, 4790,4791,4792,4793, 4794,4795,4796,4797,4798,4799,4800,4801, 4802;
	setarray .enc_def_price[0],10000,20000,40000,60000,5000,12000,2000,4000,6000,8000,10000,3000,5000,9000,12000,1000,2000,3000,4000,5000,2500,5000,10000;
	setarray .enc_stats_id[0],   4700,4710,4720,4730,4740,4750, 4701,4711,4721,4731,4741,4751, 4702,4712,4722,4732,4742,4752, 4703,4713,4723,4733,4743,4753, 4704,4714,4724,4734,4744,4754, 4705,4715,4725,4735,4745,4755, 4706,4716,4726,4736,4746,4756, 4707,4717,4727,4737,4747,4757, 4708,4718,4728,4738,4748,4758, 4709, 4719, 4729, 4739, 4749, 4759;
	setarray .enc_stats_price[0],1500,1500,1500,1500,1500,1500, 2500,2500,2500,2500,2500,2500, 3500,3500,3500,3500,3500,3500, 4500,4500,4500,4500,4500,4500, 5500,5500,5500,5500,5500,5500, 6500,6500,6500,6500,6500,6500, 7500,7500,7500,7500,7500,7500, 8500,8500,8500,8500,8500,8500, 9500,9500,9500,9500,9500,9500, 10500,10500,10500,10500,10500,10500;

	// Load shop items
	for(.@i = 0; .@i < getarraysize(.shop_name$); .@i++) {
		.@npc$ = .shop_name$[.@i];
		deletearray .@id[0],getarraysize(.@id);
		deletearray .@price[0],getarraysize(.@price);
		copyarray .@id[0], getd("."+.@npc$+"_id[0]"), getarraysize(getd("."+.@npc$+"_id"));
		copyarray .@price[0], getd("."+.@npc$+"_price[0]"), getarraysize(getd("."+.@npc$+"_price"));
		npcshopdelitem .@npc$,501;// Remove apple
		for(.@j = 0; .@j < getarraysize(.@id); .@j++) {
			npcshopadditem .@npc$, .@id[.@j], .@price[.@j];
		}
	}
	end;

OnSellItem:
	end;

OnBuyItem:
	.@bought_count = getarraysize(@bought_nameid);
	if(.@bought_count < 1) end;
	// Get shop data by @shop_name$
	.@shop_index = inarray(.shop_name$[0], @shop_name$);
	if(.@shop_index == -1 || getarraysize(.shop_name$) < 1) {
		message strcharinfo(0), "Shop was not found!";
		debugmes "Incorrect shop array detected in '"+@shop_name$+"'! FIXME!";
		end;
	}
	copyarray .@shop_id[0], getd("."+@shop_name$+"_id"), getarraysize(getd("."+@shop_name$+"_id"));
	copyarray .@shop_price[0], getd("."+@shop_name$+"_price"), getarraysize(getd("."+@shop_name$+"_price"));

	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@index = inarray(.@shop_id[0], @bought_nameid[.@i]);
		if(.@index == -1) {
			message strcharinfo(0), "Price was not found!";
			debugmes "Incorrect price array detected in '"+@shop_name$+"'! FIXME!";
			end;
		}
		setarray .@bought_cost[getarraysize(.@bought_cost)],.@shop_price[.@index]*@bought_quantity[.@i];
		for (.@j = 0; .@j < @bought_quantity[.@i]; .@j++) {
			setarray .@enchant[getarraysize(.@enchant)],@bought_nameid[.@i];
		}
	}

	// Count total cost
	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@total_cost = .@total_cost + .@bought_cost[.@i];
	}

	// Currency check
	if(.shop_currency$[.@shop_index] == "Zeny" && Zeny < .@total_cost) {
		message strcharinfo(0), "("+.@total_cost+") Not enough "+.shop_currency$[.@shop_index]+"!";
		end;
	}
	// Other currency checks...

	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to enchant.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

    for(.@i=0;.@i<(MAX_ITEM_RDM_OPT);.@i++){
		.@randOptId[.@i] = getequiprandomoption(.@position,.@i,ROA_ID);
		.@randOptValue[.@i] = getequiprandomoption(.@position,.@i,ROA_VALUE);
		.@randOptParam[.@i] = getequiprandomoption(.@position,.@i,ROA_PARAM);
	}

	/*if(.@enchant_count > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}*/
	// Check for enabled refinement
	/*if(!getequipisenableref(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "I don't think I can enchant this item at all.";
		mes "Sorry...";
		close;
	}*/

	// Add all card slots
	for(.@i = 0; .@i < .@slots; .@i++) {
		setarray .@item[getarraysize(.@item)], (.@cards[.@i] > 0 ? .@cards[.@i] : -1);
	}
	// Add previous enchants
	for(.@i = .@slots; .@i < .@cards_count; .@i++) {
		if(.@cards[.@i] > 0) {
			setarray .@item[getarraysize(.@item)], .@cards[.@i];
		}
	}
	// Add new enchants
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		setarray .@item[getarraysize(.@item)], .@enchant[.@i];
	}

	// Check for produced/crafted items 254,255
	if(.@cards[0] == CARD0_FORGE || .@cards[0] == CARD0_CREATE) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}

	// Has card sockets 4 - slots
	if(.@enchant_count > (.max_enchant - .@slots)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This equipment can hold "+(.max_enchant - .@slots)+" enchant.";
		close;
	}

	// Has free sockets
	if((.@slots + .@enchant_count) > .max_enchant || getarraysize(.@item) > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item does not have enough free sockets to enchant.";
		close;
	}

	// Confirm the setup
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Setup^000000";
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		mes "Enchant: "+ getitemname(.@enchant[.@i]);
	}
	mes "Equipment: "+ getitemname(getequipid(.@position));
	mes "Cost: "+.@total_cost+" "+.shop_currency$[.@shop_index]+".";
	if (select("Create enchant:Cancel") != 1) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "Farewell.";
		close;
	}

	// Create selected enchant
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your enchanted equipment!";
	delequip(.@position);
	specialeffect2 154;

	if(.shop_currency$[.@shop_index] == "Zeny") {
		Zeny = Zeny - .@total_cost;
	}

	//getitem2 .@item_id, 1, 1, .@refine, 0,
    getitem3 .@item_id, 1, 1, .@refine, 0,
		(.@item[0] > 0 ? .@item[0] : 0),
		(.@item[1] > 0 ? .@item[1] : 0),
		(.@item[2] > 0 ? .@item[2] : 0),
		(.@item[3] > 0 ? .@item[3] : 0),.@randOptId,.@randOptValue,@randOptParam;
	close;

S_Remove:
	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to work on.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

    for(.@i=0;.@i<(MAX_ITEM_RDM_OPT);.@i++){
		.@randOptId[.@i] = getequiprandomoption(.@position,.@i,ROA_ID);
		.@randOptValue[.@i] = getequiprandomoption(.@position,.@i,ROA_VALUE);
		.@randOptParam[.@i] = getequiprandomoption(.@position,.@i,ROA_PARAM);
	}

	// Create selected item
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your equipment back!";
	delequip(.@position);
	specialeffect2 169;

	//getitem2 .@item_id, 1, 1, .@refine, 0,0,0,0,0;
	getitem3 .@item_id, 1, 1, .@refine, 0,0,0,0,0,.@randOptId,.@randOptValue,@randOptParam;
	for(.@i=0; .@i<.@slots; .@i++) {
		if(.@cards[.@i] > 0)
			getitem .@cards[.@i], 1;
	}
	close;

S_SelectPosition:
	setarray .@indices[1], EQI_HEAD_TOP, EQI_HEAD_MID, EQI_HEAD_LOW, EQI_ARMOR, EQI_HAND_L, EQI_HAND_R, EQI_GARMENT, EQI_SHOES, EQI_ACC_L, EQI_ACC_R;
	setarray .@position$[1], "Top", "Mid", "Low", "Armor", "Left Hand", "Right Hand", "Garment", "Shoes", "Accessory L", "Accessory R";
	setarray .@option[1], 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; // 1=allow, 0=deny
	for(.@i=1; .@i<getarraysize(.@indices); .@i++) {
		if(.@option[.@i] && getequipisequiped(.@indices[.@i])) {
			.@menu$ = .@menu$ + .@position$[.@i] + "-[" + getequipname(.@indices[.@i]) + "]";
		}
		.@menu$ = .@menu$ + ":";
	}
	.@part = .@indices[select(.@menu$)];
	return .@part;
}

 

Edited by -to-
wrong script lul
  • 0
Posted
18 hours ago, -to- said:

I've added a loop to save the gear`s random options in variables


for(.@i=0;.@i<(MAX_ITEM_RDM_OPT);.@i++){
  .@randOptId[.@i] = getequiprandomoption(.@position,.@i,ROA_ID);
  .@randOptValue[.@i] = getequiprandomoption(.@position,.@i,ROA_VALUE);
  .@randOptParam[.@i] = getequiprandomoption(.@position,.@i,ROA_PARAM);
}

And changed getitem2 to getitem3 to create the stored random options values.

Here it is:


//===== rAthena Script =======================================
//= Enchant NPC
//===== By: ==================================================
//= Sehrentos
//===== Current Version: =====================================
//= 1.2
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Enchant player's equipment. Support multiple enchants.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.1 Remove enchant option.
//= 1.2 Added .max_enchant option.
//============================================================
// shop/cashshop/itemshop/pointshop
-	shop	enc_atk	-1,501:300;
-	shop	enc_def	-1,501:300;
-	shop	enc_stats	-1,501:300;

prontera,159,177,6	script	Enchant#prt1	4_M_MERCAT1,{
	disable_items;
	switch(select("Attack:Defence:Stats:Remove")) {
		case 1: @shop_name$ = "enc_atk"; break;
		case 2: @shop_name$ = "enc_def"; break;
		case 3: @shop_name$ = "enc_stats"; break;
		case 4: callsub S_Remove; break;
		default: end;
	}
	callshop @shop_name$, 1;
	npcshopattach @shop_name$;
	end;

OnInit:
	// Settings: shop names, currencies, items, prices
	.max_enchant = 2; // Max amount of enchants 0-4
	setarray .shop_name$[0],   "enc_atk", "enc_def", "enc_stats";
	setarray .shop_currency$[0],"Zeny",    "Zeny",    "Zeny";
	setarray .enc_atk_id[0],    4760, 4761, 4806, 4815, 4814, 4813, 4812, 4826, 4827, 4828, 4829, 4830,  4831, 4819, 4766, 4767,4764,4765, 4807, 4842, 4818, 4817, 4816, 4843, 4844, 4811, 4810, 4809, 4808, 4820, 4821, 4822, 4823, 4824,  4825, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840,  4841;
	setarray .enc_atk_price[0],10000,20000,30000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,5000,7000,10000,20000,10000,20000,30000,40000,50000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000;
	setarray .enc_def_id[0],    4805, 4850, 4851, 4852,4762, 4763,4786,4787,4788,4789, 4790,4791,4792,4793, 4794,4795,4796,4797,4798,4799,4800,4801, 4802;
	setarray .enc_def_price[0],10000,20000,40000,60000,5000,12000,2000,4000,6000,8000,10000,3000,5000,9000,12000,1000,2000,3000,4000,5000,2500,5000,10000;
	setarray .enc_stats_id[0],   4700,4710,4720,4730,4740,4750, 4701,4711,4721,4731,4741,4751, 4702,4712,4722,4732,4742,4752, 4703,4713,4723,4733,4743,4753, 4704,4714,4724,4734,4744,4754, 4705,4715,4725,4735,4745,4755, 4706,4716,4726,4736,4746,4756, 4707,4717,4727,4737,4747,4757, 4708,4718,4728,4738,4748,4758, 4709, 4719, 4729, 4739, 4749, 4759;
	setarray .enc_stats_price[0],1500,1500,1500,1500,1500,1500, 2500,2500,2500,2500,2500,2500, 3500,3500,3500,3500,3500,3500, 4500,4500,4500,4500,4500,4500, 5500,5500,5500,5500,5500,5500, 6500,6500,6500,6500,6500,6500, 7500,7500,7500,7500,7500,7500, 8500,8500,8500,8500,8500,8500, 9500,9500,9500,9500,9500,9500, 10500,10500,10500,10500,10500,10500;

	// Load shop items
	for(.@i = 0; .@i < getarraysize(.shop_name$); .@i++) {
		.@npc$ = .shop_name$[.@i];
		deletearray .@id[0],getarraysize(.@id);
		deletearray .@price[0],getarraysize(.@price);
		copyarray .@id[0], getd("."+.@npc$+"_id[0]"), getarraysize(getd("."+.@npc$+"_id"));
		copyarray .@price[0], getd("."+.@npc$+"_price[0]"), getarraysize(getd("."+.@npc$+"_price"));
		npcshopdelitem .@npc$,501;// Remove apple
		for(.@j = 0; .@j < getarraysize(.@id); .@j++) {
			npcshopadditem .@npc$, .@id[.@j], .@price[.@j];
		}
	}
	end;

OnSellItem:
	end;

OnBuyItem:
	.@bought_count = getarraysize(@bought_nameid);
	if(.@bought_count < 1) end;
	// Get shop data by @shop_name$
	.@shop_index = inarray(.shop_name$[0], @shop_name$);
	if(.@shop_index == -1 || getarraysize(.shop_name$) < 1) {
		message strcharinfo(0), "Shop was not found!";
		debugmes "Incorrect shop array detected in '"+@shop_name$+"'! FIXME!";
		end;
	}
	copyarray .@shop_id[0], getd("."+@shop_name$+"_id"), getarraysize(getd("."+@shop_name$+"_id"));
	copyarray .@shop_price[0], getd("."+@shop_name$+"_price"), getarraysize(getd("."+@shop_name$+"_price"));

	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@index = inarray(.@shop_id[0], @bought_nameid[.@i]);
		if(.@index == -1) {
			message strcharinfo(0), "Price was not found!";
			debugmes "Incorrect price array detected in '"+@shop_name$+"'! FIXME!";
			end;
		}
		setarray .@bought_cost[getarraysize(.@bought_cost)],.@shop_price[.@index]*@bought_quantity[.@i];
		for (.@j = 0; .@j < @bought_quantity[.@i]; .@j++) {
			setarray .@enchant[getarraysize(.@enchant)],@bought_nameid[.@i];
		}
	}

	// Count total cost
	for(.@i = 0; .@i < .@bought_count; .@i++) {
		.@total_cost = .@total_cost + .@bought_cost[.@i];
	}

	// Currency check
	if(.shop_currency$[.@shop_index] == "Zeny" && Zeny < .@total_cost) {
		message strcharinfo(0), "("+.@total_cost+") Not enough "+.shop_currency$[.@shop_index]+"!";
		end;
	}
	// Other currency checks...

	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to enchant.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

    for(.@i=0;.@i<(MAX_ITEM_RDM_OPT);.@i++){
		.@randOptId[.@i] = getequiprandomoption(.@position,.@i,ROA_ID);
		.@randOptValue[.@i] = getequiprandomoption(.@position,.@i,ROA_VALUE);
		.@randOptParam[.@i] = getequiprandomoption(.@position,.@i,ROA_PARAM);
	}

	/*if(.@enchant_count > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}*/
	// Check for enabled refinement
	/*if(!getequipisenableref(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "I don't think I can enchant this item at all.";
		mes "Sorry...";
		close;
	}*/

	// Add all card slots
	for(.@i = 0; .@i < .@slots; .@i++) {
		setarray .@item[getarraysize(.@item)], (.@cards[.@i] > 0 ? .@cards[.@i] : -1);
	}
	// Add previous enchants
	for(.@i = .@slots; .@i < .@cards_count; .@i++) {
		if(.@cards[.@i] > 0) {
			setarray .@item[getarraysize(.@item)], .@cards[.@i];
		}
	}
	// Add new enchants
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		setarray .@item[getarraysize(.@item)], .@enchant[.@i];
	}

	// Check for produced/crafted items 254,255
	if(.@cards[0] == CARD0_FORGE || .@cards[0] == CARD0_CREATE) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item has been crafted or produced and cannot be enchanted.";
		close;
	}

	// Has card sockets 4 - slots
	if(.@enchant_count > (.max_enchant - .@slots)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This equipment can hold "+(.max_enchant - .@slots)+" enchant.";
		close;
	}

	// Has free sockets
	if((.@slots + .@enchant_count) > .max_enchant || getarraysize(.@item) > .max_enchant) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "This item does not have enough free sockets to enchant.";
		close;
	}

	// Confirm the setup
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Setup^000000";
	for(.@i = 0; .@i < .@enchant_count; .@i++) {
		mes "Enchant: "+ getitemname(.@enchant[.@i]);
	}
	mes "Equipment: "+ getitemname(getequipid(.@position));
	mes "Cost: "+.@total_cost+" "+.shop_currency$[.@shop_index]+".";
	if (select("Create enchant:Cancel") != 1) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "Farewell.";
		close;
	}

	// Create selected enchant
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your enchanted equipment!";
	delequip(.@position);
	specialeffect2 154;

	if(.shop_currency$[.@shop_index] == "Zeny") {
		Zeny = Zeny - .@total_cost;
	}

	//getitem2 .@item_id, 1, 1, .@refine, 0,
    getitem3 .@item_id, 1, 1, .@refine, 0,
		(.@item[0] > 0 ? .@item[0] : 0),
		(.@item[1] > 0 ? .@item[1] : 0),
		(.@item[2] > 0 ? .@item[2] : 0),
		(.@item[3] > 0 ? .@item[3] : 0),.@randOptId,.@randOptValue,@randOptParam;
	close;

S_Remove:
	// Select equipment (EQI)
	mes "[ " + strnpcinfo(1) + " ]";
	mes "Please select which equipment you want me to work on.";
	.@position = callsub(S_SelectPosition);

	// Check if position has equipment
	if(!getequipisequiped(.@position)) {
		clear;
		mes "[ " + strnpcinfo(1) + " ]";
		mes "You don't have anything equipped there!";
		close;
	}

	.@item_id = getequipid(.@position); //Equipped item id
	.@refine = getequiprefinerycnt(.@position); //Equipped refine value
	.@slots = getitemslots(.@item_id);
	setarray .@cards[0],
		getequipcardid(.@position,0),
		getequipcardid(.@position,1),
		getequipcardid(.@position,2),
		getequipcardid(.@position,3);
	.@cards_count = getarraysize(.@cards);
	.@enchant_count = getarraysize(.@enchant);

    for(.@i=0;.@i<(MAX_ITEM_RDM_OPT);.@i++){
		.@randOptId[.@i] = getequiprandomoption(.@position,.@i,ROA_ID);
		.@randOptValue[.@i] = getequiprandomoption(.@position,.@i,ROA_VALUE);
		.@randOptParam[.@i] = getequiprandomoption(.@position,.@i,ROA_PARAM);
	}

	// Create selected item
	clear;
	mes "[ " + strnpcinfo(1) + " ]^6E6E6E Done^000000";
	mes "Here is your equipment back!";
	delequip(.@position);
	specialeffect2 169;

	//getitem2 .@item_id, 1, 1, .@refine, 0,0,0,0,0;
	getitem3 .@item_id, 1, 1, .@refine, 0,0,0,0,0,.@randOptId,.@randOptValue,@randOptParam;
	for(.@i=0; .@i<.@slots; .@i++) {
		if(.@cards[.@i] > 0)
			getitem .@cards[.@i], 1;
	}
	close;

S_SelectPosition:
	setarray .@indices[1], EQI_HEAD_TOP, EQI_HEAD_MID, EQI_HEAD_LOW, EQI_ARMOR, EQI_HAND_L, EQI_HAND_R, EQI_GARMENT, EQI_SHOES, EQI_ACC_L, EQI_ACC_R;
	setarray .@position$[1], "Top", "Mid", "Low", "Armor", "Left Hand", "Right Hand", "Garment", "Shoes", "Accessory L", "Accessory R";
	setarray .@option[1], 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; // 1=allow, 0=deny
	for(.@i=1; .@i<getarraysize(.@indices); .@i++) {
		if(.@option[.@i] && getequipisequiped(.@indices[.@i])) {
			.@menu$ = .@menu$ + .@position$[.@i] + "-[" + getequipname(.@indices[.@i]) + "]";
		}
		.@menu$ = .@menu$ + ":";
	}
	.@part = .@indices[select(.@menu$)];
	return .@part;
}

 

Wowwww your script is so cool!!
Thank youuuuuuu ^^

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...