Advertisement
Guest User

Untitled

a guest
Oct 21st, 2012
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.24 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Hunting Missions
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.1a
  7. //===== Compatible With: =====================================
  8. //= rAthena SVN
  9. //===== Description: =========================================
  10. //= Random hunting missions.
  11. //= Rewards are based on quest difficulty.
  12. //============================================================
  13.  
  14. prontera,147,176,6 script Hunting Missions 951,{
  15. function Chk; function Cm;
  16. mes "[Hunting Missions]";
  17. mes "Hello, "+strcharinfo(0)+"!";
  18. if (!#Mission_Delay) {
  19. next;
  20. mes "[Hunting Missions]";
  21. mes "I can't find any records...";
  22. mes "You must be new here!";
  23. emotion e_omg;
  24. next;
  25. callsub Mission_Info;
  26. emotion e_go;
  27. set #Mission_Delay,1;
  28. close;
  29. }
  30. mes rand(2)?"Working hard, as always...":"Not slacking, I hope...";
  31. mes "Is there anything I can help";
  32. mes "you with?";
  33. mes " ";
  34. mes "^777777~ You've completed ^0055FF"+Mission_Total+"^777777 mission"+((Mission_Total == 1)?"":"s")+". ~^000000";
  35. next;
  36. switch(select(((!Mission1)?" ~ New Mission::":": ~ Mission Status: ~ Abandon Mission")+": ~ Information: ~ Mission Shop: ~ View Top Hunters: ~ ^777777Cancel^000000")) {
  37. case 1:
  38. mes "[Hunting Missions]";
  39. if (#Mission_Count) {
  40. mes "You've started a mission";
  41. mes "on another character.";
  42. close;
  43. }
  44. if (#Mission_Delay > gettimetick(2) && .Delay) {
  45. set .@i, #Mission_Delay-gettimetick(2);
  46. if (.@i > 3600) set .@j$, (.@i/3600)+" hour"+(((.@i/3600) == 1)?"":"s");
  47. else if (.@i > 60) set .@j$, (.@i/60)+" minute"+(((.@i/60) == 1)?"":"s");
  48. else set .@j$, (.@i)+" second"+((.@i == 1)?"":"s");
  49. mes "I'm afraid you'll have to wait "+.@j$+" before taking another mission.";
  50. close;
  51. }
  52. mes "You must hunt:";
  53. freeloop(1);
  54. set .@size, getarraysize(.NoRange);
  55. for (set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  56. set .@valid,0;
  57. while (!.@valid) {
  58. set .@valid,1;
  59. set .@mob, rand(1001,1999);
  60. // Is mob ID blacklisted?
  61. if (compare(.Restrict$[0],""+.@mob) || compare(.Restrict$[1],""+.@mob)) set .@valid,0;
  62. // Is mob ID interval blacklisted?
  63. if (.@valid) for(set .@j,0; .@j<.@size; set .@j,.@j+2)
  64. if (.@mob > .NoRange[.@j] && .@mob < .NoRange[.@j+1]) {
  65. set .@valid,0;
  66. break;
  67. }
  68. // Is mob a duplicate?
  69. if (.@valid) for(set .@j,0; .@j<.@i; set .@j,.@j+1)
  70. if (strmobinfo(1,.@mob) == strmobinfo(1,getd("Mission"+.@j))) {
  71. set .@valid,0;
  72. break;
  73. }
  74. // Is mob an MVP?
  75. if (.@valid) if (getmonsterinfo(.@mob,22)) set .@valid,0;
  76. }
  77. setd "Mission"+.@i, .@mob;
  78. setd "Mission"+.@i+"_",0;
  79. }
  80. set #Mission_Count, rand(.Count[0],.Count[1]);
  81. freeloop(0);
  82. callsub Mission_Status;
  83. set @f,0;
  84. next;
  85. mes "[Hunting Missions]";
  86. mes "Report back when";
  87. mes "you've finished.";
  88. mes "Good luck!";
  89. close;
  90. case 2:
  91. mes "[Hunting Missions]";
  92. mes "Mission status:";
  93. callsub Mission_Status;
  94. if (@f) { set @f,0; close; }
  95. next;
  96. mes "[Hunting Missions]";
  97. mes "Oh, you're done!";
  98. mes "Good work.";
  99. mes "Here's your reward.";
  100. emotion e_no1;
  101. specialeffect2 377;
  102. deletearray .@j[0], getarraysize(.@j);
  103. for(set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  104. set .@j[.@i], getd("Mission"+.@i);
  105. set .@j[.Quests], .@j[.Quests]+strmobinfo(3,.@j[.@i]);
  106. set .@j[.Quests+1], .@j[.Quests+1]+strmobinfo(6,.@j[.@i]);
  107. set .@j[.Quests+2], .@j[.Quests+2]+strmobinfo(7,.@j[.@i]);
  108. setd "Mission"+.@i,0;
  109. setd "Mission"+.@i+"_",0;
  110. }
  111. set #Mission_Points, #Mission_Points+(3+(.@j[.Quests]/.Quests/6));
  112. getexp (#Mission_Count*.@j[.Quests+1]/5),(#Mission_Count*.@j[.Quests+2]/5);
  113. set Zeny, Zeny+(#Mission_Count*.Quests*.@j[.@i]*.Multiplier);
  114. set #Mission_Count,0;
  115. if (.Delay) set #Mission_Delay, gettimetick(2)+(.Delay*3600);
  116. set Mission_Total, Mission_Total+1;
  117. if (Mission_Total == 1) query_sql("INSERT INTO `global_reg_value` (`char_id`,`str`,`value`,`type`,`account_id`) VALUES ("+getcharid(0)+",'Mission_Total','1',3,0)");
  118. else query_sql("UPDATE `global_reg_value` SET `value` = "+Mission_Total+" WHERE char_id = "+getcharid(0)+" AND `str` = 'Mission_Total'");
  119. close;
  120. case 3:
  121. mes "[Hunting Missions]";
  122. mes "Do you really want to";
  123. mes "abandon your mission?";
  124. if (.Delay) mes "Your delay time will not be reset.";
  125. next;
  126. switch(select(" ~ Abandon...: ~ ^777777Cancel^000000")) {
  127. case 1:
  128. mes "[Hunting Missions]";
  129. mes "Alright, I've dropped";
  130. mes "your current mission.";
  131. specialeffect2 462;
  132. for(set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  133. setd "Mission"+.@i,0;
  134. setd "Mission"+.@i+"_",0;
  135. }
  136. set #Mission_Count,0;
  137. if (.Delay) set #Mission_Delay, gettimetick(2)+(.Delay*3600);
  138. close;
  139. case 2:
  140. mes "[Hunting Missions]";
  141. mes "I knew you were kidding!";
  142. mes "Keep up the good work.";
  143. emotion e_heh;
  144. close;
  145. }
  146. case 4:
  147. callsub Mission_Info;
  148. close;
  149. case 5:
  150. mes "[Hunting Missions]";
  151. mes "You have ^0055FF"+#Mission_Points+"^000000 Mission Points.";
  152. mes "Use them well!";
  153. callshop "mission_shop",1;
  154. npcshopattach "mission_shop";
  155. end;
  156. case 6:
  157. mes "[Hunting Missions]";
  158. mes "The top hunters are:";
  159. query_sql("SELECT `name`,CAST(`value` AS SIGNED) FROM `global_reg_value` LEFT JOIN `char` ON `global_reg_value`.char_id = `char`.char_id WHERE `global_reg_value`.str = 'Mission_Total' ORDER BY CAST(`value` AS SIGNED) DESC LIMIT 5",.@name$,.@val);
  160. for(set .@i,0; .@i<5; set .@i,.@i+1)
  161. mes " [Rank "+(.@i+1)+"] "+((.@name$[.@i] == "")?"^777777none":"^0055FF"+.@name$[.@i]+"^000000 : ^FF0000"+.@val[.@i]+" pt.")+"^000000";
  162. close;
  163. case 7:
  164. mes "[Hunting Missions]";
  165. mes "Nothing? Okay...";
  166. emotion e_hmm;
  167. close;
  168. }
  169.  
  170. Mission_Status:
  171. set @f,0;
  172. deletearray .@j[0], getarraysize(.@j);
  173. for(set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  174. set .@j[.@i], getd("Mission"+.@i);
  175. set .@j[.Quests], .@j[.Quests]+strmobinfo(3,.@j[.@i]);
  176. set .@j[.Quests+1], .@j[.Quests+1]+strmobinfo(6,.@j[.@i]);
  177. set .@j[.Quests+2], .@j[.Quests+2]+strmobinfo(7,.@j[.@i]);
  178. mes " > "+Chk(getd("Mission"+.@i+"_"),#Mission_Count)+strmobinfo(1,.@j[.@i])+" ("+getd("Mission"+.@i+"_")+"/"+#Mission_Count+")^000000";
  179. }
  180. set .@Mission_Points, 3+(.@j[.Quests]/.Quests/6);
  181. set .@Base_Exp, #Mission_Count*.@j[.Quests+1]/5;
  182. set .@Job_Exp, #Mission_Count*.@j[.Quests+2]/5;
  183. set .@Zeny, #Mission_Count*.Quests*.@j[.@i]*.Multiplier;
  184. next;
  185. mes "[Hunting Missions]";
  186. mes "Mission rewards:";
  187. mes " > Mission Points: ^0055FF"+.@Mission_Points+"^000000";
  188. mes " > Base Experience: ^0055FF"+Cm(.@Base_Exp)+"^000000";
  189. mes " > Job Experience: ^0055FF"+Cm(.@Job_Exp)+"^000000";
  190. mes " > Zeny: ^0055FF"+Cm(.@Zeny)+"^000000";
  191. return;
  192.  
  193. Mission_Info:
  194. mes "[Hunting Missions]";
  195. mes "If you so choose, I can assign";
  196. mes "you a random hunting quest.";
  197. mes "Some are easier than others, but";
  198. mes "the rewards increase with difficulty.";
  199. next;
  200. mes "[Hunting Missions]";
  201. mes "Missions points are shared";
  202. mes "amongst all your characters.";
  203. if (.Delay) mes "Delay time is, too.";
  204. mes "You can't take missions on";
  205. mes "multiple characters at once.";
  206. next;
  207. mes "[Hunting Missions]";
  208. mes "You can start a quest";
  209. if (.Delay) mes "every "+((.Delay == 1)?"hour.":.Delay+" hours.");
  210. else mes "whenever you want.";
  211. mes "That's everything~";
  212. return;
  213.  
  214. function Chk {
  215. if (getarg(0) < getarg(1)) { set @f,1; return "^FF0000"; }
  216. else return "^00FF00"; }
  217.  
  218. function Cm {
  219. set .@str$, getarg(0);
  220. for(set .@i,getstrlen(.@str$)-3; .@i>0; set .@i,.@i-3)
  221. set .@str$, insertchar(.@str$,",",.@i);
  222. return .@str$; }
  223.  
  224. OnBuyItem:
  225. set @cost,0;
  226. for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1)
  227. for(set .@j,0; .@j<getarraysize(.Shop); set .@j,.@j+2)
  228. if (@bought_nameid[.@i] == .Shop[.@j]) {
  229. set @cost, @cost+(.Shop[.@j+1]*@bought_quantity[.@i]);
  230. break;
  231. }
  232. mes "[Hunting Missions]";
  233. if (@cost > #Mission_Points) mes "You don't have enough Mission Points.";
  234. else {
  235. for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1) {
  236. getitem @bought_nameid[.@i], @bought_quantity[.@i];
  237. dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
  238. }
  239. set #Mission_Points, #Mission_Points-@cost;
  240. mes "Deal completed.";
  241. emotion e_cash;
  242. }
  243. set @cost,0;
  244. deletearray @bought_nameid[0], getarraysize(@bought_nameid);
  245. deletearray @bought_quantity[0], getarraysize(@bought_quantity);
  246. close;
  247.  
  248. OnNPCKillEvent:
  249. if (!#Mission_Count || !Mission1) end;
  250. for(set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  251. if (strmobinfo(1,killedrid) == strmobinfo(1,getd("Mission"+.@i))) {
  252. if (getd("Mission"+.@i+"_") < #Mission_Count) {
  253. set .@j, getd("Mission"+.@i+"_")+1;
  254. setd "Mission"+.@i+"_", .@j;
  255. dispbottom "[Hunting Mission] Killed "+.@j+" of "+#Mission_Count+" "+strmobinfo(1,killedrid)+".";
  256. }
  257. break;
  258. }
  259. }
  260. end;
  261.  
  262. OnInit:
  263. waitingroom "Hunting Mission",0;
  264. set .Delay,6; // Quest delay, in hours (0 to disable).
  265. set .Quests,4; // Number of subquests per quest (increases rewards).
  266. set .Multiplier,0; // Multiplier for Zeny reward calculation.
  267. setarray .Count[0], // Min and max monsters per subquest (increases rewards).
  268. 30,60;
  269. setarray .Shop[0], // Reward items: <ID>,<point cost> (about 10~20 points per hunt).
  270. 7960,4;
  271. setarray .Restrict$[0], // Blacklisted mob IDs.
  272. "1003,1006,1017,1021,1022,1027,1043,1062,1075,1096,"+
  273. "1108,1120,1136,1137,1168,1171,1172,1173,1198,1200,"+
  274. "1203,1204,1205,1210,1212,1217,1218,1244,1245,1247,",
  275. "1250,1259,1262,1268,1270,1311,1313,1388,1407,1411,"+
  276. "1414,1496,1501,1502,1515,1618,1624,1625,1626,1629,"+
  277. "1669,1674,1675,1676,1677,1678,1679,1681,1834,1835,"+
  278. "1868,1990,1991,1996,1997,1998";
  279. setarray .NoRange[0], // Blacklisted mob ID ranges.
  280. 1077,1094, 1180,1188, 1219,1242, 1282,1310, 1323,1365,
  281. 1392,1400, 1417,1493, 1517,1613, 1639,1652, 1657,1668,
  282. 1682,1692, 1703,1713, 1718,1769, 1784,1829, 1838,1864,
  283. 1870,1986;
  284.  
  285. npcshopdelitem "mission_shop",512;
  286. for(set .@i,0; .@i<getarraysize(.Shop); set .@i,.@i+2)
  287. npcshopadditem "mission_shop", .Shop[.@i], .Shop[.@i+1];
  288. end;
  289. }
  290. - shop mission_shop -1,512:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement