// Item trader
// https://rathena.org/board/topic/121585-item-trader/
// by Mabuhay
// v2 by Racaae - bulk option added
payon,139,226,5 script Potion Converter 4_M_ALCHE_B,{
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes("I can convert some items for you.");
next;
// < ITEM FOR TRADE >, < AMOUNT >, < ITEM TRADED >, < AMOUNT >, < SUCCESS RATE >..
setarray .@trade,
11503, 2, 32018, 1, 100, // 2 Siege White Potion = 1 Battle Blue Potion @ 100 %
32042, 2, 32018, 1, 100, // 2 War White Potion = 1 Battle Blue Potion @ 100 %
32017, 2, 32018, 1, 100, // 2 Battle White Potion = 1 Battle Blue Potion @ 100 %
11504, 1, 32017, 2, 100, // 2 Siege White Potion = 1 Battle Blue Potion @ 100 %
32043, 1, 32017, 2, 100, // 2 War White Potion = 1 Battle Blue Potion @ 100 %
32018, 1, 32017, 2, 100; // 2 Battle White Potion = 1 Battle Blue Potion @ 100 %
.@size = getarraysize(.@trade);
for ( .@i = 0; .@i < .@size; .@i += 5 ) {
.@menu$ += .@trade[.@i+1] +"x "+getitemname(.@trade[.@i])+" for "+.@trade[.@i+3]+"x "+ getitemname(.@trade[.@i+2]) +":";
}
.@sel = select(.@menu$)-1;
.@s = .@sel * 5;
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "Your "+.@trade[.@s+1] +"x "+getitemname(.@trade[.@s])+" for "+.@trade[.@s+3]+"x "+ getitemname(.@trade[.@s+2]) +"?";
mes "This has "+ .@trade[.@s+4]+"% success rate.";
mes "Note: everything you trade will be character bound.";
next;
switch(select("Trade one time", "Choose how much to trade", "Finish conversation")) {
case 1:
if ( countitem(.@trade[.@s]) < .@trade[.@s+1] ) {
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "You dont have enough item required.";
close;
}
delitem .@trade[.@s], .@trade[.@s+1];
if ( .@trade[.@s+4] <= rand(100) ) {
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "Opps! It failed!";
mes "Try again next time.";
close;
}
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "Congrats! You got it!";
getitem .@trade[.@s+2], .@trade[.@s+3];
close2;
end;
case 2:
input .@q;
if (.@q < 1) {
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes("Trade cancelled.");
close;
}
.@cost = .@trade[.@s+1]*.@q;
if ( countitem(.@trade[.@s]) < .@cost ) {
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "You dont have enough item required.";
close;
}
if ( .@trade[.@s+4] < 100)
for ( .@i = 0; .@i < .@q; .@i++ )
if ( .@trade[.@s+4] <= rand(100) )
.@fail++;
delitem .@trade[.@s], .@cost;
getitem .@trade[.@s+2], .@trade[.@s+3]*.@q-.@fail;
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
if (.@fail == .@q)
mes "I'm sorry. All failed.";
else if (.@fail)
mes("Congrats! You got some of it, and failed " + .@fail + " times.");
else
mes "Congrats! You got it all!";
close;
case 3:
close;
}
}
// Item trader
// https://rathena.org/board/topic/121585-item-trader/
// by Mabuhay
// v2 by Racaae - bulk option added
payon,139,226,5 script Potion Converter 4_M_ALCHE_B,{
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes("I can convert some items for you.");
next;
// < ITEM FOR TRADE >, < AMOUNT >, < ITEM TRADED >, < AMOUNT >, < SUCCESS RATE >..
setarray .@trade,
11503, 2, 32018, 1, 100, // 2 Siege White Potion = 1 Battle Blue Potion @ 100 %
32042, 2, 32018, 1, 100, // 2 War White Potion = 1 Battle Blue Potion @ 100 %
32017, 2, 32018, 1, 100, // 2 Battle White Potion = 1 Battle Blue Potion @ 100 %
11504, 1, 32017, 2, 100, // 2 Siege White Potion = 1 Battle Blue Potion @ 100 %
32043, 1, 32017, 2, 100, // 2 War White Potion = 1 Battle Blue Potion @ 100 %
32018, 1, 32017, 2, 100; // 2 Battle White Potion = 1 Battle Blue Potion @ 100 %
.@size = getarraysize(.@trade);
for ( .@i = 0; .@i < .@size; .@i += 5 ) {
.@menu$ += .@trade[.@i+1] +"x "+getitemname(.@trade[.@i])+" for "+.@trade[.@i+3]+"x "+ getitemname(.@trade[.@i+2]) +":";
}
.@sel = select(.@menu$)-1;
.@s = .@sel * 5;
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "Your "+.@trade[.@s+1] +"x "+getitemname(.@trade[.@s])+" for "+.@trade[.@s+3]+"x "+ getitemname(.@trade[.@s+2]) +"?";
mes "This has "+ .@trade[.@s+4]+"% success rate.";
mes "Note: everything you trade will be character bound.";
next;
switch(select("Trade one time", "Choose how much to trade", "Finish conversation")) {
case 1:
if ( countitem(.@trade[.@s]) < .@trade[.@s+1] ) {
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "You dont have enough item required.";
close;
}
delitem .@trade[.@s], .@trade[.@s+1];
if ( .@trade[.@s+4] <= rand(100) ) {
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "Opps! It failed!";
mes "Try again next time.";
close;
}
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "Congrats! You got it!";
getitem .@trade[.@s+2], .@trade[.@s+3];
close2;
end;
case 2:
input .@q;
if (.@q < 1) {
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes("Trade cancelled.");
close;
}
.@cost = .@trade[.@s+1]*.@q;
if ( countitem(.@trade[.@s]) < .@cost ) {
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
mes "You dont have enough item required.";
close;
}
if ( .@trade[.@s+4] < 100)
for ( .@i = 0; .@i < .@q; .@i++ )
if ( .@trade[.@s+4] <= rand(100) )
.@fail++;
delitem .@trade[.@s], .@cost;
getitem .@trade[.@s+2], .@trade[.@s+3]*.@q-.@fail;
mesf("[%s]", strnpcinfo(NPC_NAME_VISIBLE));
if (.@fail == .@q)
mes "I'm sorry. All failed.";
else if (.@fail)
mes("Congrats! You got some of it, and failed " + .@fail + " times.");
else
mes "Congrats! You got it all!";
close;
case 3:
close;
}
}