Advertisement
Sehrentos

rAthena NPC script card lv up

Oct 15th, 2018
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Card Level Up System
  3. //===== By: ==================================================
  4. //= Sehrentos
  5. //===== Requested By: ========================================
  6. //= Elysium
  7. //===== Current Version: =====================================
  8. //= 1.0
  9. //===== Compatible With: =====================================
  10. //= rAthena Project
  11. //===== Description: =========================================
  12. //= Card Level Up System.
  13. //= Give a card to NPC and you will receive x number of exp
  14. //= to that specific card.
  15. //===== Additional Comments: =================================
  16. //= 1.0 Initial script.
  17. //============================================================
  18. prontera,158,159,4 script Card Level Up#cluc 4_M_HIGH_WIZARD,{
  19. disable_items;
  20. mes "["+ .npc_name$ +"]";
  21. mes "Lorem card ipsum levelum...";
  22. menu "Show Exp",L_ShowExp,"Show Cards",L_ShowCards,"Level UP Card",L_LevelUpCard,"Leave",L_Leave;
  23. close;
  24.  
  25. L_Leave:
  26. clear;
  27. mes "["+ .npc_name$ +"]";
  28. mes "Farewell.";
  29. close;
  30.  
  31. L_ShowExp:
  32. clear;
  33. mes "["+ .npc_name$ +"]";
  34. mes "Current card level and experience.";
  35. .@count = 0;
  36. // Normal cards
  37. for(.@i=0; .@i<getarraysize(.normal_card); .@i++) {
  38. .@level = getd("nclv_"+ .normal_card[.@i]); // nclv_4xxx
  39. .@exp = getd("ncexp_"+ .normal_card[.@i]); // ncexp_4xxx
  40. if(.@level > 0) {
  41. .@count++;
  42. .@rexp = .normal_exp[.@level]; // Required exp to the next level
  43. .@percent = 100 * .@exp / .@rexp;
  44. mes "Card: "+ getitemname(.normal_card[.@i]);
  45. mes "Level: "+ .@level;
  46. if(.@level < 3)
  47. mes "Exp: ["+ .@exp +"/"+ .@rexp +"] "+ .@percent +"%";
  48. mes " --- ";
  49. //dispbottom "Card Exp: ["+ .@exp +"/"+ .@rexp +"] "+.@percent+"%";
  50. }
  51. }
  52. // MVP cards
  53. for(.@i=0; .@i<getarraysize(.mvp_card); .@i++) {
  54. .@level = getd("nclv_"+ .mvp_card[.@i]); // nclv_4xxx
  55. .@exp = getd("ncexp_"+ .mvp_card[.@i]); // ncexp_4xxx
  56. if(.@level > 0) {
  57. .@count++;
  58. .@rexp = .mvp_exp[.@level]; // Required exp to the next level
  59. .@percent = 100 * .@exp / .@rexp;
  60. mes "Card: "+ getitemname(.mvp_card[.@i]);
  61. mes "Level: "+ .@level;
  62. if(.@level < 3)
  63. mes "Exp: ["+ .@exp +"/"+ .@rexp +"] "+ .@percent +"%";
  64. mes " --- ";
  65. //dispbottom "Card Exp: ["+ .@exp +"/"+ .@rexp +"] "+.@percent+"%";
  66. }
  67. }
  68. if(.@count < 1) {
  69. mes "You don't have any card progress.";
  70. }
  71. close;
  72.  
  73. L_ShowCards:
  74. clear;
  75. mes "["+ .npc_name$ +"]";
  76. mes "List of available cards.";
  77. // Normal cards
  78. for(.@i=0; .@i<getarraysize(.normal_card); .@i++) {
  79. mes (.@i+1) +". "+ getitemname(.normal_card[.@i]);
  80. }
  81. mes " -- MVP -- ";
  82. // MVP cards
  83. for(.@i=0; .@i<getarraysize(.mvp_card); .@i++) {
  84. mes (.@i+1) +". "+ getitemname(.mvp_card[.@i]);
  85. }
  86. close;
  87.  
  88. L_LevelUpCard:
  89. clear;
  90. mes "["+ .npc_name$ +"]";
  91. mes "Level up a card.";
  92. .@type = select("Normal:MVP"); // Select type 1=normal
  93.  
  94. // Create menu id and name array
  95. for(.@i=0; .@i<getarraysize(getd((.@type==1?".normal":".mvp")+"_card")); .@i++) {
  96. if(countitem(getd((.@type==1?".normal":".mvp")+"_card["+ .@i +"]"))) {
  97. .@menu_id[getarraysize(.@menu_id)] = getd((.@type==1?".normal":".mvp")+"_card["+ .@i +"]");
  98. .@menu_name$[getarraysize(.@menu_name$)] = getitemname(getd((.@type==1?".normal":".mvp")+"_card["+ .@i +"]"));
  99. }
  100. }
  101.  
  102. // If no card
  103. if(getarraysize(.@menu_id) < 1) {
  104. clear;
  105. mes "["+ .npc_name$ +"]";
  106. mes "You don't have any of this type of card.";
  107. close;
  108. }
  109.  
  110. // Build menu
  111. .@menu$ = implode(.@menu_name$, ":");
  112. .@select = select(.@menu$) - 1; // .@menu_name$ start from 0 not from 1
  113. if (.@select < 0) {
  114. goto L_Leave;
  115. }
  116.  
  117. .@item_id = .@menu_id[.@select]; // Should be same as .@card_id below
  118. .@char_card_lv = getd("nclv_" + .@item_id); // nclv_4001
  119. .@char_card_exp = getd("ncexp_" + .@item_id); // ncexp_4001
  120. .@index = inarray(getd((.@type==1?".normal":".mvp")+"_card[0]"), .@item_id);
  121.  
  122. // If not found
  123. if (.@index < 0) {
  124. clear;
  125. mes "["+ .npc_name$ +"]";
  126. mes "This card can't be upgraded.";
  127. close;
  128. }
  129. // at max level
  130. if (.@char_card_lv >= 3) {
  131. clear;
  132. mes "["+ .npc_name$ +"]";
  133. mes "This card is at max level.";
  134. // Update
  135. //setd "nclv_"+ .@item_id, 3;
  136. //setd "ncexp_"+ .@item_id, 0;
  137. close;
  138. }
  139.  
  140. .@card_id = getd((.@type==1?".normal":".mvp")+"_card["+ .@index +"]");
  141. .@card_exp = getd((.@type==1?".normal":".mvp")+"_exp["+ .@char_card_lv +"]");
  142.  
  143. // If level 0 (First activation)
  144. if (.@char_card_lv < 1) {
  145. .@char_card_lv++;
  146. .@card_exp = getd((.@type==1?".normal":".mvp")+"_exp["+ .@char_card_lv +"]");
  147. }
  148.  
  149. // Gain experience points (100000000 / 10)
  150. .@char_card_exp = .@char_card_exp + (.@card_exp / 10); // 10% increase
  151.  
  152. // Gain level up
  153. if(.@char_card_exp >= .@card_exp) {
  154. .@char_card_lv++;
  155. .@char_card_exp = 0;
  156. .@card_exp = getd((.@type==1?".normal":".mvp")+"_exp["+ .@char_card_lv +"]");
  157. }
  158.  
  159. // Check if card exist
  160. if(countitem(.@card_id)) {
  161. clear;
  162. mes "["+ .npc_name$ +"]";
  163. mes "Upgrade: "+ getitemname(.@card_id);
  164. mes "LV: "+ .@char_card_lv;
  165. mes "EXP: "+ .@char_card_exp + "/" + .@card_exp;
  166. delitem .@card_id, 1;
  167. // Update character variables
  168. setd "nclv_"+ .@card_id, .@char_card_lv;
  169. setd "ncexp_"+ .@card_id, .@char_card_exp;
  170. } else {
  171. // Card was moved after menu select
  172. clear;
  173. mes "["+ .npc_name$ +"]";
  174. mes "Please try again...";
  175. }
  176. close;
  177.  
  178. OnInit:
  179. .npc_name$ = strnpcinfo(1);
  180. setarray .normal_card[0],4001,4002,4003,4004,4005,4006,4007,4008,4009,4010; // Card item id's
  181. setarray .mvp_card[0],4121,4123,4128; // Card item id's
  182. setarray .normal_exp[1],1000000,2000000,3000000; // Exp required per level
  183. setarray .mvp_exp[1],1000,2000,3000; // Exp required per level
  184. end;
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement