Advertisement
Guest User

Untitled

a guest
Jun 7th, 2019
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.98 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= 精煉師 艾達
  3. //===== By: ==================================================
  4. //= 天波工作組
  5. //===== Current Version: =====================================
  6. //= 2.1
  7. //===== Compatible With: =====================================
  8. //= rAthena SVN
  9. //===== Description: =========================================
  10. //= 集合多功能為一身的精煉人員
  11. //===== Additional Comments: =================================
  12. //= 1.0 第一個版本完成
  13. //= 2.0 增加各種防爆物品使用(祝福的礦石、鐵匠的祝福、鐵匠的神乎其技)
  14. //= 2.1 修復精煉等級掉出允許範圍後仍可精煉的錯誤
  15. //= 修復受祝福的礦石判斷武器/防具錯誤的問題
  16. //============================================================
  17.  
  18. pri_in.gat,63,60,4 script 精煉師 艾達 10078,{callfunc "refines";}
  19. // ----------------------------------Script Setting--------------------------------------
  20. function script refines {
  21. disable_items;
  22. setarray .@indices[1], 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;
  23. .@REFINE_MIN_LEVEL = 0;
  24. .@REFINE_MAX_LEVEL = 20;
  25.  
  26. .@menu$ = "";
  27. for(.@i = 1; .@i<getarraysize(.@indices); ++.@i) {
  28. if(getequipisequiped(.@indices[.@i])) {
  29. .@menu$ = .@menu$ + F_getpositionname(.@indices[.@i]) + " [" + getequipname(.@indices[.@i]) + "]";
  30. .@equipped = 1;
  31. }
  32. .@menu$ = .@menu$ + ":";
  33. }
  34.  
  35. if (.@equipped == 0) {
  36. mes "[精煉師 艾達]";
  37. mes "你身上沒有任何可以精鍊的裝備。";
  38. close;
  39. }
  40. mes "[精煉師 艾達]";
  41. mes "部分防爆物品有精煉等級的區間限制,詳情請自行查看物品說明。";
  42. mes " ";
  43. mes "^FF0000注意事項:選單內的選項,是依照選擇的裝備而顯示。^000000";
  44. next;
  45. .@part = .@indices[select(.@menu$)];
  46.  
  47. // -- Initialize refine setting --- //
  48. .@refinereycnt = getequiprefinerycnt(.@part);
  49. if(.@refinereycnt < 10) {
  50. setarray .@refineType[0], REFINE_COST_NORMAL, REFINE_COST_ENRICHED;
  51. setarray .@enriched[0], 0, 1; // * If enriched parameter is set to true, chance to successfully refine the
  52. // item withenriched material is returned instead.
  53. setarray .@refpenalty[0], -99, -99; // borken : -99 / borken and downrefitem n: -n / nothing : 0 / downrefitem n : n
  54.  
  55. .@arySize = getarraysize(.@refineType);
  56. for(.@i=0; .@i<.@arySize; .@i++)
  57. .@materialArray[.@i] = getequiprefinecost(.@part, .@refineType[.@i], REFINE_MATERIAL_ID);
  58.  
  59. .@mes$[1] = "使用"+getitemname(.@materialArray[1])+"精鍊時,成功率會比較高唷~";
  60. .@failmes$[0] = .@failmes$[1] = "失敗懲罰:^E38EFF裝備損毀消失^000000";
  61. }else{
  62. setarray .@refineType[0], REFINE_COST_OVER10, REFINE_COST_OVER10_HD;
  63. setarray .@enriched[0], 0, 1; // * If enriched parameter is set to true, chance to successfully refine the
  64. // item withenriched material is returned instead.
  65. setarray .@refpenalty[0], -3, 1; // borken : -99 / borken and downrefitem n: -n / nothing : 0 / downrefitem n : n
  66. .@arySize = getarraysize(.@refineType);
  67. for(.@i=0; .@i<.@arySize; .@i++)
  68. .@materialArray[.@i] = getequiprefinecost(.@part, .@refineType[.@i], REFINE_MATERIAL_ID);
  69.  
  70. .@mes$[1] = "使用^0000FF"+getitemname(.@materialArray[1])+"^000000精鍊時,失敗的精鍊處罰等級只有1等唷~";
  71. .@failmes$[0] = "失敗懲罰:^E38EFF下降3等或損毀消失^000000";
  72. .@failmes$[1] = "失敗懲罰:^E38EFF下降1等^000000";
  73. }
  74.  
  75. // 高濃縮神之金屬/鋁
  76. if(.@refinereycnt >= 7 && .@refinereycnt <=9) {
  77. .@index = getarraysize(.@refineType);
  78. .@limitLvMin[.@index] = 7;
  79. .@limitLvMax[.@index] = 9;
  80. .@refineType[.@index] = REFINE_COST_HD;
  81. .@enriched[.@index] = 1;
  82. .@refpenalty[.@index] = 1; // downrefitem 1
  83. .@materialArray[.@index] = getequiprefinecost(.@part, .@refineType[.@index], REFINE_MATERIAL_ID);
  84. .@mes$[.@index] = "使用"+getitemname(.@materialArray[.@index])+"精鍊時,失敗的精鍊處罰等級只有1等唷~";
  85. .@failmes$[.@index] = "失敗懲罰:^E38EFF下降1等^000000";
  86. }
  87.  
  88. // 受祝福的武器/防具礦石
  89. if(.@refinereycnt >= 6 && .@refinereycnt <=12) {
  90. .@index = getarraysize(.@refineType);
  91. if(.@refinereycnt < 10)
  92. .@refineType[.@index] = REFINE_COST_HD;
  93. else
  94. .@refineType[.@index] = REFINE_COST_OVER10_HD;
  95. .@limitLvMin[.@index] = 6;
  96. .@limitLvMax[.@index] = 12;
  97. .@enriched[.@index] = 1;
  98. .@refpenalty[.@index] = 0; // nothing
  99. if(getiteminfo(getequipid(.@part), 5) == 2) // Weapon
  100. .@materialArray[.@index] = 6438; // 受祝福的武器礦石
  101. else
  102. .@materialArray[.@index] = 6439; // 受祝福的防具礦石
  103.  
  104. .@mes$[.@index] = "使用^0000FF"+getitemname(.@materialArray[.@index])+"^000000精鍊時,失敗不會退階或損壞~";
  105. .@failmes$[.@index] = "失敗懲罰:^E38EFF不會退階或損壞^000000";
  106. }
  107.  
  108. // 鐵匠的祝福
  109. if(.@refinereycnt >= 7 && .@refinereycnt <=11) {
  110. setarray .@needNums_1[0],1,2,3,4,4;
  111. .@index = getarraysize(.@refineType);
  112. if(.@refinereycnt < 10)
  113. .@refineType[.@index] = REFINE_COST_HD;
  114. else
  115. .@refineType[.@index] = REFINE_COST_OVER10_HD;
  116. .@limitLvMin[.@index] = 7;
  117. .@limitLvMax[.@index] = 11;
  118. .@enriched[.@index] = 1;
  119. .@refpenalty[.@index] = 0; // nothing
  120. .@materialArray[.@index] = 6635;
  121. .@mes$[.@index] = "使用^0000FF"+getitemname(.@materialArray[.@index])+"^000000精鍊時,失敗不會退階或損壞~";
  122. .@failmes$[.@index] = "失敗懲罰:^E38EFF不會退階或損壞^000000";
  123. }
  124.  
  125. // 鐵匠的神乎其技
  126. if(.@refinereycnt >= 12 && .@refinereycnt <=13) {
  127. setarray .@needNums_2[0],1,2;
  128. .@index = getarraysize(.@refineType);
  129. .@refineType[.@index] = REFINE_COST_OVER10_HD;
  130. .@limitLvMin[.@index] = 12;
  131. .@limitLvMax[.@index] = 13;
  132. .@enriched[.@index] = 1;
  133. .@refpenalty[.@index] = 0; // nothing
  134. .@materialArray[.@index] = 7650;
  135. .@mes$[.@index] = "使用^0000FF"+getitemname(.@materialArray[.@index])+"^000000精鍊時,失敗不會退階或損壞~";
  136. .@failmes$[.@index] = "失敗懲罰:^E38EFF不會退階或損壞^000000";
  137. }
  138.  
  139. // -- Dynamic create menu --- //
  140. .@menu$ = "";
  141. .@arySize = getarraysize(.@materialArray);
  142. for(.@i=0; .@i<.@arySize; .@i++) {
  143. // 鐵匠的祝福
  144. if(.@materialArray[.@i] == 6635) {
  145. if(countitem(.@materialArray[.@i]) >= .@needNums_1[.@refinereycnt - 7] &&
  146. countitem(getequiprefinecost(.@part, .@refineType[.@i], REFINE_MATERIAL_ID)) > 0)
  147. .@menu$ += "^000000";
  148. else
  149. .@menu$ += "^888888";
  150. .@menu$ += getitemname(.@materialArray[.@i]) + "^000000"+(.@i!=.@arySize-1?":":"");
  151. // 鐵匠的神乎其技
  152. }else if(.@materialArray[.@i] == 7650) {
  153. if(countitem(.@materialArray[.@i]) >= .@needNums_2[.@refinereycnt - 12] &&
  154. countitem(getequiprefinecost(.@part, .@refineType[.@i], REFINE_MATERIAL_ID)) > 0)
  155. .@menu$ += "^000000";
  156. else
  157. .@menu$ += "^888888";
  158. .@menu$ += getitemname(.@materialArray[.@i]) + "^000000"+(.@i!=.@arySize-1?":":"");
  159. }else
  160. .@menu$ += (countitem(.@materialArray[.@i])?"^000000":"^888888") + getitemname(.@materialArray[.@i]) + "^000000"+(.@i!=.@arySize-1?":":"");
  161. }
  162.  
  163. mes "[精煉師 艾達]";
  164. mes "你想使用哪種物品進行精鍊?";
  165. next;
  166. .@select = select(.@menu$)-1;
  167. next;
  168. if(.@select) {
  169. mes "[精煉師 艾達]";
  170. mes ""+.@mes$[.@select]+"";
  171. next;
  172. }
  173.  
  174. .@refineLvMin = .@limitLvMin[.@select]?.@limitLvMin[.@select]:.@REFINE_MIN_LEVEL;
  175. .@refineLvMax = .@limitLvMax[.@select]?.@limitLvMax[.@select]:.@REFINE_MAX_LEVEL;
  176. do{
  177. //檢查物品可否精鍊
  178. if(!getequipisequiped(.@part)) { //custom check
  179. mes "[精煉師 艾達]";
  180. mes "你說的位置沒穿戴任何裝備,";
  181. mes "我無法進行精鍊…";
  182. emotion ET_FRET;
  183. close;
  184. }else if(!getequipisenableref(.@part)) {
  185. mes "[精煉師 艾達]";
  186. mes "我不認為這件裝備可以精鍊。";
  187. close;
  188. }else if (getequiprefinerycnt(.@part) >= .@REFINE_MAX_LEVEL) { //custom check
  189. mes "[精煉師 艾達]";
  190. mes "我不能精鍊這樣的東西,";
  191. mes "因為它超出我個人限定的等級。";
  192. close;
  193. }else if(getequiprefinerycnt(.@part) >= 10) {
  194. .@safe = 10;
  195. }else{
  196. switch (getequipweaponlv(.@part)) {
  197. case 1: .@safe = 7; break;
  198. case 2: .@safe = 6; break;
  199. case 3: .@safe = 5; break;
  200. case 4:
  201. default: .@safe = 4; break;
  202. }
  203. }
  204.  
  205. .@type = .@refineType[.@select];
  206. if(.@refinereycnt >= 10) {
  207. if(.@type == REFINE_COST_NORMAL)
  208. .@type = REFINE_COST_OVER10;
  209. else if(.@type == REFINE_COST_ENRICHED || .@type == REFINE_COST_HD)
  210. .@type = REFINE_COST_OVER10_HD;
  211. }else{
  212. if(.@type == REFINE_COST_OVER10)
  213. .@type = REFINE_COST_NORMAL;
  214. else if(.@type == REFINE_COST_OVER10_HD)
  215. .@type = REFINE_COST_HD;
  216. }
  217.  
  218. .@price = getequiprefinecost(.@part, .@type, REFINE_ZENY_COST);
  219. .@material[0] = getequiprefinecost(.@part, .@type, REFINE_MATERIAL_ID);
  220. .@materialNums[0] = 1;
  221. .@refineitemid = getequipid(.@part); // save id of the item
  222. .@refinerycnt = getequiprefinerycnt(.@part); // save refinery count
  223. .@refinePro = getequippercentrefinery(.@part, .@enriched[.@select]); // 精鍊機率
  224.  
  225. // 確認精煉物品的可精煉等級範圍
  226. if(.@refinereycnt > .@refineLvMax)
  227. callsub L_OverMax, .@materialArray[.@select], .@refineLvMax;
  228. else if(.@refinereycnt < .@refineLvMin)
  229. callsub L_BelowMin, .@materialArray[.@select], .@refineLvMin;
  230.  
  231. // 受祝福的武器/防具礦石
  232. if(.@materialArray[.@select] == 6438 || .@materialArray[.@select] == 6439) {
  233. .@material[0] = .@materialArray[.@select];
  234. }
  235.  
  236. // 鐵匠的祝福
  237. if(.@materialArray[.@select] == 6635) {
  238. .@material[1] = .@materialArray[.@select];
  239. .@materialNums[1] = .@needNums_1[.@refinereycnt - 7];
  240. }
  241.  
  242. // 鐵匠的神乎其技
  243. if(.@materialArray[.@select] == 7650) {
  244. .@material[1] = .@materialArray[.@select];
  245. .@materialNums[1] = .@needNums_2[.@refinereycnt - 12];
  246. }
  247.  
  248. if(.@refinePro==100) set @color$,"^0000FF";
  249. else set @color$,"^FF0000";
  250. mes "[精煉師 艾達]";
  251. mes "精鍊項目:^339900"+getequipname(.@part)+"^000000 ^2F4F4F+"+.@refinerycnt+"^000000 至 ^A0522D+"+(.@refinerycnt+1)+"^000000";
  252. mes "成功機率:"+.@color$+""+.@refinePro+" %^000000";
  253. for(.@i=0 ;.@i<getarraysize(.@material); .@i++)
  254. mes "消耗物品:^6CA6CD"+getitemname(.@material[.@i])+"^000000 x ^8968CD"+.@materialNums[.@i]+"^000000";
  255. mes "精鍊費用:^B8860B"+callfunc("F_InsertComma",.@price)+"^000000 Zeny";
  256. mes .@failmes$[.@select];
  257. next;
  258. if(select("繼續:取消")==2) close;
  259.  
  260. for(.@i=0 ;.@i<getarraysize(.@material); .@i++) {
  261. if(countitem(.@material[.@i]) < .@materialNums[.@i] || Zeny < .@price) {
  262. mes "[精煉師 艾達]";
  263. mes "您的精鍊所需材料或費用不足。";
  264. close;
  265. }
  266. }
  267.  
  268. Zeny = Zeny - .@price;
  269. for(.@i=0 ;.@i<getarraysize(.@material); .@i++)
  270. delitem .@material[.@i],.@materialNums[.@i];
  271.  
  272. // anti-hack
  273. if (callfunc("F_IsEquipIDHack", .@part, .@refineitemid) ||
  274. callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) {
  275. emotion ET_FRET;
  276. mes "[精煉師 艾達]";
  277. mes "等一下…";
  278. mes "你覺得我是傻瓜嘛?";
  279. mes "你要精鍊的東西我並沒有看見阿!";
  280. close;
  281. }
  282.  
  283. if(.@refinePro > rand(100)) {
  284. successrefitem .@part;
  285. if(.@safe < 10) emotion ET_SMILE;
  286. else emotion ET_BEST;
  287.  
  288. mes "[精煉師 艾達]";
  289. mes "恭喜你,精鍊成功了!";
  290. mes "我果然是最好的精鍊師。";
  291. } else {
  292. .@penalty = .@refpenalty[.@select];
  293. if(.@penalty == 0) {
  294. specialeffect2 EF_REPAIRWEAPON;
  295. mes "精鍊失敗了…";
  296. mes "但因為有^006400"+getitemname(.@materialArray[.@select])+"^000000,";
  297. mes "所以裝備沒有損壞。";
  298. }else{
  299. if((rand(100) < 80 && .@penalty != -99 && .@penalty < 0) || .@penalty > 0) {
  300. // downrefitem n
  301. .@downLevel = .@penalty*(.@penalty<0?-1:1);
  302. downrefitem .@part, .@downLevel; // Failed refine attempts decrease the item's refine level by 3
  303. emotion (!rand(5))?ET_MONEY:ET_HUK;
  304. mes "[精煉師 艾達]";
  305. mes "我的天阿!";
  306. mes "精鍊的等級已經下降了"+.@downLevel+"等…";
  307. }else{
  308. // borken
  309. failedrefitem .@part;
  310. mes "[精煉師 艾達]";
  311. mes "天啊!我沒有精鍊成功…";
  312. mes "我不是故意的!";
  313. close;
  314. }
  315. }
  316. }
  317. next;
  318. .@refinereycnt = getequiprefinerycnt(.@part);
  319. }while(.@refinereycnt < .@REFINE_MAX_LEVEL);
  320. end;
  321.  
  322. L_OverMax:
  323. mes "[精煉師 艾達]";
  324. mes "我已經沒辦法替你精煉了!";
  325. mes "因為^0000FF"+getitemname(getarg(0))+"^000000…";
  326. mes "只能使用到^0000FF精煉值"+getarg(1)+"等^000000。";
  327. close;
  328.  
  329. L_BelowMin:
  330. mes "[精煉師 艾達]";
  331. mes "你的裝備沒辦法繼續精煉!";
  332. mes "因為^0000FF"+getitemname(getarg(0))+"^000000…";
  333. mes "只能用於^0000FF精煉值"+getarg(1)+"等以上^000000。";
  334. close;
  335. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement