Advertisement
johnlol

RandomOptionDealer

May 27th, 2019
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ________________     ______            ________      
  3. ___    |_____  /________  /______      ___  __ \_____
  4. __  /| |  __  /_  __ \_  __ \  _ \     __  /_/ /  __ \
  5. _  ___ / /_/ / / /_/ /  /_/ /  __/     _  _, _// /_/ /
  6. /_/  |_\__,_/  \____//_.___/\___/      /_/ |_| \____/
  7.  
  8. */
  9.  
  10. //===== rAthena Script =======================================
  11. //= Random Option NPC dealer
  12. //===== By: ==================================================
  13. //= Johnlol
  14. //===== Current Version: =====================================
  15. //= 1.0
  16. //===== Compatible With: =====================================
  17. //= rAthena Project
  18. //===== Description: =========================================
  19. //= Deals with a player to apply random item option
  20. //= for the price of zeny/cashpoint
  21. //============================================================
  22.  
  23. sec_in02,157,153,2  script  Keitenai    700,{
  24.     goto NPC;
  25. end;
  26.  
  27. OnInit:
  28. //==============================
  29. //  CURRENCY SETTING
  30. //  1 = Zeny
  31. //  0 = Cashpoints
  32. //==============================
  33. set .Currency,1;        // Moeda para comprar opção aleatória
  34. set .Price,1000000; // Prize of random option
  35.  
  36. //==============================
  37. //  RANDOM OPTION SETTING
  38. //==============================
  39.     set .OverWrite,1;   // Permite sobrescrever o encantamento da opção já existente ( 0 to disable )
  40.     set .FailRate,10;   // Define chance de falha
  41.     set .MaxOpt,192;    // Maximum item option a player can enchant ( reference: https://github.com/rathena/rathena/blob/master/db/const.txt#L1645-L1836 )
  42.     set .MinOpt,1;      // Minimum item option a player can enchant
  43.     set .MinValue,1;    // Minimum option effect value
  44.     set .MaxValue,10;   // Maximum option effect value
  45.     set .MaxIndex,4;    // Maximum option slots ( default is 0 to 4 )
  46.     set .Wait,10;       // Progress bar delay in seconds
  47.  
  48.     // Opção aleatória que não será aplicada
  49.     setarray .ignore[0],
  50.         86,     // RDMOPT_BODY_ATTR_ALL
  51.         173,    // RDMOPT_HP_DRAIN
  52.         174,    // RDMOPT_SP_DRAIN
  53.         190,    // RDMOPT_MDAMAGE_SIZE_SMALL_USER
  54.         191,    // RDMOPT_MDAMAGE_SIZE_MIDIUM_USER
  55.         192,    // RDMOPT_MDAMAGE_SIZE_LARGE_USER
  56.         193;    // RDMOPT_ATTR_TOLERACE_ALL
  57. end;
  58.  
  59. NPC:
  60. disable_items;
  61.     mes "[ Keitenai ]";
  62.     mes "Good day young fella!";
  63.     mes "I came from the land of";
  64.     mes "far far away to introduce the";
  65.     mes "amazing equipment ^FF0000random^000000";
  66.     mes "option enchantment.";
  67.     next;
  68.     mes "[ Keitenai ]";
  69.     mes "I can make any of your equipment";
  70.     mes "become more powerful";
  71.     mes "than its current condition...";
  72.     if(.Currency){
  73.         mes "For a prize of ^0000FF"+.Price+" Zeny^000000,";
  74.     } else {
  75.         mes "For a prize of ^0000FF"+.Price+" Cashpoints^000000,";
  76.     }
  77.     mes "I will apply a ^FF0000RANDOM^000000";
  78.     mes "option enchantment on your";
  79.     mes "equipment. (^_^)";
  80.     next;
  81.     mes "[ Keitenai ]";
  82.     mes "I forgot to tell you that";
  83.     mes "there is ^FF0000"+.FailRate+"%^000000 chance";
  84.     mes "that this process may ^FF0000FAIL^000000";
  85.     mes "and lose your equip along";
  86.     mes "with its card..."," ";
  87.     next;
  88.     mes "[ Keitenai ]";
  89.     mes "Do you still want to take";
  90.     mes "the risk of enchanting with";
  91.     mes "^FF0000"+.FailRate+"%^000000 chance to ^FF0000Fail^000000";
  92.     mes "and lose your equip along";
  93.     mes "with its card?";
  94.     next;
  95.     if(select("Nah! I don't want to...:^0000FFI'll Take the risk!  Enchant my equip!^000000")==1) goto OnCancel;
  96.     mes "[ Keitenai ]";
  97.     mes "Wonderful!";
  98.     mes "This process will take";
  99.     mes "about ^0000FF"+.Wait+"^000000 seconds...";
  100.     mes "Don't move a muscle while";
  101.     mes "i'm enchanting your equipment!";
  102.     close2;
  103.  
  104.     setarray .@eq[1], EQI_HEAD_TOP,EQI_HEAD_MID,EQI_HEAD_LOW,EQI_ARMOR,EQI_HAND_R,EQI_HAND_L,EQI_GARMENT,EQI_SHOES,EQI_ACC_R,EQI_ACC_L,EQI_COSTUME_HEAD_TOP,EQI_COSTUME_HEAD_MID,EQI_COSTUME_HEAD_LOW,EQI_SHADOW_ARMOR,EQI_SHADOW_WEAPON,EQI_SHADOW_SHIELD,EQI_COSTUME_GARMENT,EQI_SHADOW_SHOES,EQI_SHADOW_ACC_R,EQI_SHADOW_ACC_L,EQI_AMMO;
  105.     for(set .@i,1; .@i<getarraysize(.@eq); set .@i,.@i+1){
  106.         if(getequipisequiped(.@eq[.@i])){
  107.             set .@menu$,.@menu$+F_getpositionname(.@eq[.@i])+" ~ [ " + getequipname(.@eq[.@i]) + " ]";
  108.             set .@equipped,1;
  109.         } set .@menu$,.@menu$+":";
  110.     } set .@part,.@eq[select(.@menu$)];
  111.  
  112.     set .@val,rand(.MinValue,.MaxValue);
  113.  
  114. IgnoreCheck:
  115.     set .@opt,rand(.MinOpt,.MaxOpt);
  116.     for(set .@f,1; .@f<getarraysize(.ignore); set .@f,.@f+1)
  117.         if(.@opt==.ignore[.@f])
  118.             goto IgnoreCheck;
  119.  
  120.     set .@indx,rand(.MaxIndex);
  121.     if(!.OverWrite){
  122.         if(getequiprandomoption(.@part,4,ROA_ID,getcharid(0))) set .@x4,4;
  123.         if(getequiprandomoption(.@part,3,ROA_ID,getcharid(0))) set .@x3,3;
  124.         if(getequiprandomoption(.@part,2,ROA_ID,getcharid(0))) set .@x2,2;
  125.         if(getequiprandomoption(.@part,1,ROA_ID,getcharid(0))) set .@x1,1;
  126.         if(getequiprandomoption(.@part,0,ROA_ID,getcharid(0))) set .@x0,0;
  127.  
  128.         if(.@indx == 0 && .@x0)
  129.             if(.@indx==.MaxIndex) goto OnMax;
  130.             else set .@indx,1;
  131.         if(.@indx == 1 && .@x1)
  132.             if(.@indx==.MaxIndex) goto OnMax;
  133.             else set .@indx,2;
  134.         if(.@indx == 2 && .@x2)
  135.             if(.@indx==.MaxIndex) goto OnMax;
  136.             else set .@indx,3;
  137.         if(.@indx == 3 && .@x3)
  138.             if(.@indx==.MaxIndex) goto OnMax;
  139.             else set .@indx,4;
  140.         if(.@indx == 4 && .@x4)
  141.             if(.@indx==.MaxIndex) goto OnMax;
  142.     }
  143.     if(.@indx == 4 && (!getequiprandomoption(.@part,3,ROA_ID,getcharid(0)))) set .@indx,3;
  144.     if(.@indx == 3 && (!getequiprandomoption(.@part,2,ROA_ID,getcharid(0)))) set .@indx,2;
  145.     if(.@indx == 2 && (!getequiprandomoption(.@part,1,ROA_ID,getcharid(0)))) set .@indx,1;
  146.     if(.@indx == 1 && (!getequiprandomoption(.@part,0,ROA_ID,getcharid(0)))) set .@indx,0;
  147.  
  148.     progressbar "ffff00",.Wait;
  149.  
  150.     if(.Currency){
  151.         if(Zeny < .Price)
  152.             goto PriceFail;
  153.         else
  154.             set Zeny,Zeny-.Price;
  155.     } else {
  156.         if(#CASHPOINTS < .Price)
  157.             goto PriceFail;
  158.         else
  159.             set #CASHPOINTS,#CASHPOINTS-.Price;
  160.     }
  161.  
  162.     // Failed...
  163.     if(.FailRate > 100) set .FailRate,100;
  164.     if(rand(100) <= .FailRate) goto OnFailure;
  165.  
  166.     // Success!!
  167.     setrandomoption(.@part,.@indx,.@opt,.@val,.@indx,getcharid(0));
  168. end;
  169.  
  170. OnMax:
  171.     mes "[ Keitenai ]";
  172.     mes "Wow! your equip already";
  173.     mes "Maxed out its option";
  174.     mes "enchant slots!";
  175.     mes "Sorry but I can't add";
  176.     mes "any more enchantment with";
  177.     mes "your equipment.";
  178. close;
  179.  
  180. OnFailure:
  181. specialeffect2 EF_PHARMACY_FAIL;
  182.     mes "[ Keitenai ]"," ";
  183.     mes "I'm really sorry..."," ";
  184.     mes "^FF0000The process have failed...";
  185.     mes "Your item has been destroyed.^000000";
  186.     delequip .@part;
  187. close;
  188.  
  189. PriceFail:
  190.     mes "[ Keitenai ]";
  191.     mes "What's this?";
  192.     mes "Are you kidding me?";
  193.     mes "Sorry but I don't work";
  194.     mes "for free!";
  195.     mes "You can come back if you";
  196.     mes "Have enough to pay for";
  197.     mes "my service.";
  198. close;
  199.  
  200. OnCancel:
  201.     mes "[ Keitenai ]";
  202.     mes "Suit yourself.";
  203.     mes "Let me know if you";
  204.     mes "ever changed you mind";
  205. close;
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement