johnlol

Card Compounder v1.1

May 3rd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //===== rAthena Script =======================================
  2. //= Card Compounder
  3. //===== By ===================================================
  4. //= llchrisll
  5. //===== Version ==============================================
  6. //= 1.0 - Initial Version
  7. //= 1.1 - Script Optimization
  8. //      - Added config for custom Variable, see .requ_vard$ and .requ_varn$
  9. //===== Tested With =========================================
  10. //= rAthena SQL 07/16-2017 Revision
  11. //===== Description ==========================================
  12. //= This script allows you to insert any card you in your inventory
  13. //  in any equip you have in exchange for an high fee.
  14. //===== Comments =============================================
  15. //= None yet...
  16. //===========================================================
  17. prontera,147,167,0  script  Card Compounder 100,{
  18.  
  19. // GM Settings & Testing Help
  20. if(getgmlevel() > 0) {
  21.     if(.requ[0] == 1) {
  22.         mes "Zeny:";
  23.         input .@zeny,.requ[1],1000000; // 1m Zeny
  24.         if(.@zeny == 0) set @zeny,.requ[1];
  25.         set .Zeny,@zeny*4;
  26.     } else if(.requ[0] == 2) {
  27.         mes "Cash Points:";
  28.         input .@cash,.requ[1],10000; // 10k Cash Points
  29.         if(.@cash == 0) set .@cash,.requ[1];
  30.         set #CASHPOINTS,.@cash*4;
  31.     } else if(.requ[0] == 3) {
  32.         mes ""+.requ_vard$;
  33.         input @custom,.requ[1],2000;
  34.         if(.@custom == 0) set .@custom,.requ[1];
  35.         setd(""+.requ_varn$),.@custom*4;
  36.     } else if(.requ[0] > 500) {
  37.         mes getitemname(.requ[0])+":";
  38.         input .@item,.requ[1],10000;
  39.         if(.@item == 0) set .@item,.requ[1];
  40.         getitem .requ[0],.@item*4;
  41.     }
  42.     next;
  43.     mes "Balances:";
  44.     mes "Zeny: "+ Zeny;
  45.     mes "Cash Points: "+#CASHPOINTS;
  46.     mes .requ_vard$+": "+getd(""+.requ_varn$);
  47.     set @debug,1;  
  48.     next;
  49. }
  50.  
  51. mes .n$;
  52. mes "Hello, how can I help you?";
  53. next;
  54. switch(select("- Compound Cards:- Information:- Nothing")) {
  55.  
  56.     case 1:
  57.     mes .n$;
  58.     mes "Please choose the item you want to compound cards on from your inventory:";
  59.     next;
  60.     getinventorylist;
  61.     set .@e,0; // Reset Array Position
  62.     for ( set .@i,0; .@i < @inventorylist_count; set .@i,.@i + 1) { // Looping through the Items
  63.         // Available Equipment
  64.         if( (getiteminfo(@inventorylist_id[.@i],2) == 4 || getiteminfo(@inventorylist_id[.@i],2) == 5) && getitemslots(@inventorylist_id[.@i]) > 0 && @inventorylist_identify[.@i] == 1 && @inventorylist_equip[.@i] == 0) {
  65.             // Item ID
  66.             setarray .@eq_list[.@e],@inventorylist_id[.@i];
  67.             if(@debug) dispbottom "Equip Name: "+getitemname(@inventorylist_id[.@i])+" ["+@inventorylist_id[.@i]+"]";
  68.             // Does the items have an refine?
  69.             setarray .@eq_ref[.@e],@inventorylist_refine[.@i];
  70.             // Does the items already have cards compounded?
  71.             setarray .@eq_c1[.@e],@inventorylist_card1[.@i];
  72.             if(@debug) dispbottom "Card 1: "+ getitemname(@inventorylist_card1[.@i])+" ["+@inventorylist_card1[.@i]+"]";
  73.             setarray .@eq_c2[.@e],@inventorylist_card2[.@i];
  74.             if(@debug) dispbottom "Card 2: "+ getitemname(@inventorylist_card2[.@i])+" ["+@inventorylist_card2[.@i]+"]";
  75.             setarray .@eq_c3[.@e],@inventorylist_card3[.@i];
  76.             if(@debug) dispbottom "Card 3: "+ getitemname(@inventorylist_card3[.@i])+" ["+@inventorylist_card3[.@i]+"]";
  77.             setarray .@eq_c4[.@e],@inventorylist_card4[.@i];
  78.             if(@debug) dispbottom "Card 4: "+ getitemname(@inventorylist_card4[.@i])+" ["+@inventorylist_card4[.@i]+"]";
  79.             if(@debug) dispbottom "------------------------------------------------------";
  80.             if(@debug) dispbottom "Array Sizes: Card 1: "+getarraysize(.@eq_c1)+" - Card 2: "+getarraysize(.@eq_c2)+" - Card 3: "+getarraysize(.@eq_c3)+" - Card 4: "+getarraysize(.@eq_c4);
  81.             if(@debug) dispbottom "=============================================";
  82.             if(@debug) dispbottom " ";
  83.             // Menu Creation
  84.             set .@it_m$,.@it_m$ + "- (+"+@inventorylist_refine[.@i]+") " + getitemname(@inventorylist_id[.@i])+" ["+getitemslots(@inventorylist_id[.@i])+"]" + ( (@inventorylist_id[@i+1])?":":"");
  85.            
  86.             // New Array Position:
  87.             // getarraysize would be bugged if an entry would be 0
  88.             // since it won't be counted as a valid value
  89.             set .@e,.@e + 1;
  90.         }
  91.         // Available Cards
  92.         if(getiteminfo(@inventorylist_id[.@i],2) == 6) {
  93.             setarray .@ca_list[getarraysize(.@ca_list)],@inventorylist_id[.@i];
  94.             setarray .@ca_am[getarraysize(.@ca_am)],@inventorylist_amount[.@i];
  95.         }
  96.     }
  97.     // Menu Selection
  98.     set .@id,select(.@it_m$) - 1;
  99.    
  100.     set .@max_c,getitemslots(.@eq_list[.@id]);
  101.     if(getd(".@eq_c"+.@max_c+"["+.@id+"]") > 0) {
  102.         mes .n$;
  103.         mes "Each slot is in usage already, please uncompound the current cards and try again.";
  104.         close;
  105.     }
  106.     set .@cards,0;
  107.    
  108.     set .@slots,.@max_c;
  109.     set .@c,1;
  110.     while(.@c <= .@max_c) {
  111.         if(getd(".@eq_c"+.@c+"["+.@id+"]") == 0) {
  112.             set .@ca_m$,"";
  113.             for ( set .@l,0; .@l < getarraysize(.@ca_list); set .@l,.@l + 1)
  114.                 set .@ca_m$,.@ca_m$ + "- "+getitemname(.@ca_list[.@l]) + " ("+.@ca_am[.@l]+")" + ( (.@ca_list[.@l+1])?":":"");
  115.             mes .n$;
  116.             mes "Slots left: "+.@slots;
  117.             next;
  118.             if(prompt(.@ca_m$) != 255) {
  119.                 setd(".@card"+@c),.@ca_list[@menu-1];
  120.                 if(.@ca_am[@menu-1] == 1) {
  121.                     deletearray .@ca_list[@menu-1],1;
  122.                     deletearray .@ca_am[@menu-1],1;
  123.                 } else setarray .@ca_am[@menu-1],.@ca_am[@menu-1] - 1;
  124.                
  125.             } else setd(".@card"+.@c),0;
  126.             if(getd(".@card"+.@c) != 0) set .@cards,.@cards + 1;
  127.         }
  128.         set .@slots,.@slots - 1;
  129.     set .@c,.@c + 1;
  130.     }
  131.  
  132.     mes .n$;
  133.     mes "You will recieve the following Item:";
  134.     mes "Name: 1x +"+.@eq_ref[.@id]+" "+ getitemname(.@eq_list[.@id]) + " with these cards:";
  135.     if(!.@cards) { // No new Cards inserted!
  136.         mes "Error: No Cards inserted.";
  137.         close;
  138.     }
  139.     if(.@card1) mes "Card 1: "+ getitemname(.@card1)+" ["+.@card1+"]";
  140.     if(.@card2) mes "Card 2: "+ getitemname(.@card2)+" ["+.@card2+"]";
  141.     if(.@card3) mes "Card 3: "+ getitemname(.@card3)+" ["+.@card3+"]";
  142.     if(.@card4) mes "Card 4: "+ getitemname(.@card4)+" ["+.@card4+"]";
  143.     if(.requ[0] > 0) {
  144.         set .@cost,.requ[1]*.@cards;
  145.         mes " ";
  146.         mes "Therefore I require";
  147.         mes .@cost + ( (.requ[0] > 500)?"x ":" ") + ( (.requ[0] == 1)?"Zeny":( (.requ[0] == 2)?"Cash Points":( (.requ[0] > 3)?getitemname(.requ[0]):"Custom Points")));
  148.         mes "Proceed?";
  149.         if(select("- Yes:- No") - 1) close;
  150.        
  151.         if(.requ[0] == 1 && Zeny < .@cost ) {
  152.             mes "I'm sorry, but you don't have the required Zeny for inserting "+.@cards+" Cards.";
  153.             mes "You'll need "+.@cost+" Zeny.";
  154.             close;
  155.         } else if(.requ[0] == 2 && #CASHPOINTS < .@cost) {
  156.             mes "I'm sorry, but you don't have the required Cash Points for inserting "+.@cards+" Cards.";
  157.             mes "You'll need "+.@cost+" Cash Points.";
  158.             close;
  159.         } else if(.requ[0] == 3 && getd(""+.requ_varn$) < .@cost) {
  160.             mes "I'm sorry, but you don't have the required "+.requ_vard$+" for inserting "+.@cards+" Cards.";
  161.             mes "You'll need "+.@cost+" "+.requ_vard$+".";
  162.             close;
  163.         } else if(.requ[0] > 500 && countitem(.requ[0]) < .@cost) {
  164.             mes "I'm sorry, but you don't have the required "+getitemname(.requ[0])+" for inserting "+.@cards+" Cards.";
  165.             mes "You'll need "+.@cost+" "+getitemname(.requ[0])+".";
  166.             close;
  167.         }
  168.     }
  169.     // If there are cards inserted already,
  170.     // re-add them also else they will be deleted
  171.     // and only the new card will be added.
  172.     if(!.@card1 && .@eq_c1[.@id]) set .@card1,.@eq_c1[.@id];
  173.     if(!.@card2 && .@eq_c2[.@id]) set .@card2,.@eq_c2[.@id];
  174.     if(!.@card3 && .@eq_c3[.@id]) set .@card3,.@eq_c3[.@id];
  175.     if(!.@card4 && .@eq_c4[.@id]) set .@card4,.@eq_c4[.@id];
  176.    
  177.     delitem2 .@eq_list[.@id],1,1,.@eq_ref[.@id],0,.@eq_c1[.@id],.@eq_c2[.@id],.@eq_c3[.@id],.@eq_c4[.@id];
  178.     getitem2 .@eq_list[.@id],1,1,.@eq_ref[.@id],0,.@card1,.@card2,.@card3,.@card4;
  179.     for ( set .@c,1; .@c <= .@max_c; set .@c,.@c+1)
  180.         if(getd(".@card"+.@c)) delitem getd(".@card"+.@c),1;
  181.  
  182.     if(.requ[0] == 1) set Zeny,Zeny - .@cost;
  183.     else if(.requ[0] == 2) set #CASHPOINTS,#CASHPOINTS - .@cost;
  184.     else if(.requ[0] == 3) setd(""+.requ_varn$),getd(""+.requ_varn$) - .@cost;
  185.     else if(.requ[0] > 500) delitem .requ[0],.requ[1];
  186.     close;
  187.  
  188.     case 2:
  189.     mes .n$;
  190.     mes "I am able to insert cards in any equipment you want.";
  191.     if(.requ[0] == 0) close;
  192.     mes "The only thing I require is";
  193.     mes .requ[1] + ( (.requ[0] > 500)?"x ":" ") + ( (.requ[0] == 1)?"Zeny":( (.requ[0] == 2)?"Cash Points":( (.requ[0] > 3)?getitemname(.requ[0]):.requ_vard$)));
  194.     mes "for each card you inserted.";
  195.     close;
  196.    
  197.     case 3:
  198.     close;
  199. }
  200.  
  201. OnInit:
  202. set .n$,"["+strnpcinfo(1)+"]";
  203. // ======== Requirement Settings: ============
  204. // = Format:
  205. // - .requ[0],<ID>,<Amount>;
  206. // = ID:
  207. // - 0 = Nothing/Disabled
  208. // - 1 = Zeny
  209. // - 2 = #CASHPOINTS
  210. // - 3 = Custom Variable, see below
  211. // - 501 and higher means Item ID
  212. // Amount should be obvious :D.
  213. setarray .requ[0],2,100; // Default: 2,100 = 100x Cash Points
  214. // Custom Points:
  215. set .requ_vard$,"Custom Points"; // Display Name
  216. set .requ_varn$,"custom_points"; // Variable Name
  217. end;
  218. }
Add Comment
Please, Sign In to add comment