prontera,100,100,5 script ticket_refine 100,{
mes .npc$;
mes "Which item would you like to refine?";
next;
while( .@a++ <= .e_len ) {
.@b = .@a -1;
if( .eqpl[ .@b ] ) {
if( getequipid( .@a ) > -1 )
.@menu$ = .@menu$ + .eqp$[ .@b ]+" - [^0000FF"+getitemname( getequipid( .@a ) )+"^000000]:";
else .@menu$ = .@menu$ + "^adb4be"+.eqp$[ .@b ]+" - [Empty]^000000:";
} else .@menu$ = .@menu$ + ":";
}
.@menu = select( .@menu$ );
.@eq_loc = .eqpl[ .@menu -1 ];
.@eq_itm = getequipid( .@eq_loc );
.@eq_ref = getequiprefinerycnt( .@eq_loc );
if( .@eq_itm <= 0 ) {
mes .npc$;
mes "Hmm, I don't think you have anything equipped there.";
close;
}
if( !getequipisenableref( .@eq_loc ) && .chk_rf_able ) {
mes .npc$;
mes "Hmm, this item doesn't seem to be refine-able.";
close;
}
if( .@eq_ref < .ref_cap ) {
mes .npc$;
mes "Sorry but I don't refine items that so weak. Come back when it's at least +"+.ref_cap+".";
close;
}
mes .npc$;
mes "Input desired refine.";
next;
switch( input( .@ds_ref, (( .@eq_ref < .min_ref )? .min_ref : .@eq_ref+1 ), .max_ref ) ) {
case -1:
mes .npc$;
if( .@eq_ref < .min_ref )
mes "I do not refine items lower than "+.min_ref+".";
else
mes "This item can not be refined lower than "+(.@eq_ref+1)+".";
close;
case 1:
mes .npc$;
mes "Items can not be refined above "+.max_ref+"!";
close;
default:
}
.@nw_ref = .@ds_ref - .@eq_ref;
for( .@c = .@eq_ref; .@c < .c_len && .@c < .@ds_ref; .@c++ )
.@tk_cost = .@tk_cost + .cost[.@c];
mes .npc$;
mes "This new refine will cost you "+.@tk_cost+" "+getitemname(.tk_id)+"(s). Do you accept?";
next;
if( select("Yes:No") == 2 ) {
mes .npc$; mes "Alright, thanks anyways, goodbye!";
close;
}
if( .chk_rf_prct ) {
mes .npc$;
mes "There is a chance that this item will break! Do you still accept?";
next;
if( select("Yes:No") == 2 ) {
mes .npc$; mes "Alright, that's probably for the best!";
close;
}
}
if( countitem(.tk_id) < .@tk_cost ) {
mes .npc$;
mes "I'm sorry but you don't have enough tickets for that.";
close;
}
if( .@eq_itm != getequipid( .@eq_loc ) || .@eq_ref != getequiprefinerycnt( .@eq_loc ) ) {
mes .npc$;
mes "Something went wrong! Aborting!";
close;
}
if( .chk_rf_gtim ) {
.@card1 = getequipcardid( .@eq_loc, 0 );
.@card2 = getequipcardid( .@eq_loc, 1 );
.@card3 = getequipcardid( .@eq_loc, 2 );
.@card4 = getequipcardid( .@eq_loc, 3 );
}
while( (.@tmp_ref = getequiprefinerycnt( .@eq_loc )) < .@ds_ref && .@tmp_ref < .c_len ) {
if( .chk_rf_prct && getequippercentrefinery(.@eq_loc) <= rand(101) ) {
failedrefitem( .@eq_loc );
mes "Ahh! I'm soooo sorry but your item broke!";
close;
}
if( !.@h ) {
successrefitem( .@eq_loc );
if( .chk_rf_gtim ) {
delequip(.@eq_loc);
getitem2 .@eq_itm, 1, 1, .@ds_ref, 0, .@card1, .@card2, .@card3, .@card4;
equip(.@eq_itm);
.@h = 1;
}
}
.@tmp_ref2 = getequiprefinerycnt( .@eq_loc );
if( .@tmp_ref == .@tmp_ref2 ) break;
delitem .tk_id, .cost[ .@tmp_ref ];
}
mes .npc$;
mes "All done thanks for stopping bye!.";
close;
OnInit:
.npc$ = "[ Ticket Refiner ]";
.tk_id = 674;
setarray .cost, // Ticket cost per level.
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1~10
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 11~20
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5; // 21~31
.ref_cap = 10; // An item must be at least this refine before it can be refined by this npc. 0 disabled.
.max_ref = 31; // This is the max refine. 0 disabled.
.min_ref = 10; // This is the min refine. 0 disabled.
.chk_rf_able = 1; // Check if the item is refine-able? 0 disabled.
.chk_rf_prct = 0; // Check refine-able percentages? 0 disabled.
.chk_rf_gtim = 0; // The npc will switch to getitem if the refine cap is too high. 0 disabled.
setarray .eqp$,
"Upper Headgear", "Armor", "Left Hand", "Right Hand", "Garment",
"Shoes", "Accessory1", "Accessory2", "Mid Headgear", "Low Headgear";
setarray .eqpl, //Set EQI 0 to disable slot.
EQI_HEAD_TOP, EQI_ARMOR, EQI_HAND_L, EQI_HAND_R, EQI_GARMENT,
EQI_SHOES, EQI_ACC_L, EQI_ACC_R, EQI_HEAD_MID, EQI_HEAD_LOW;
.e_len = getarraysize( .eqp$ );
.c_len = getarraysize( .cost );
}
About the other thing in the item script just do...
doevent "ticket_refine::OnGoNPCEvent"; getitem 674, 1;