hunting_missions.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. //===== rAthena Script =======================================
  2. //= Hunting Missions
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.3b
  7. //===== Compatible With: =====================================
  8. //= rAthena Project
  9. //===== Description: =========================================
  10. //= Random hunting missions.
  11. //= Rewards are based on quest difficulty.
  12. //===== Additional Comments: =================================
  13. //= 1.0 Initial script.
  14. //= 1.1 Small improvements and fixes.
  15. //= 1.2 Added party support and replaced blacklists with an
  16. //= SQL query, both thanks to AnnieRuru.
  17. //= 1.3 Re-added a blacklist adapted for the SQL query.
  18. //= 1.3a Added mission reset options.
  19. //= 1.3b Function updates.
  20. //============================================================
  21. prontera,152,187,6 script Hunting Missions 951,{
  22. function Chk;
  23. mes "[Hunting Missions]";
  24. mes "Hello, "+strcharinfo(0)+"!";
  25. if (!#Mission_Delay) {
  26. next;
  27. mes "[Hunting Missions]";
  28. mes "I can't find any records...";
  29. mes "You must be new here!";
  30. emotion e_omg;
  31. next;
  32. callsub Mission_Info;
  33. emotion e_go;
  34. set #Mission_Delay,1;
  35. close;
  36. }
  37. mes rand(2)?"Working hard, as always...":"Not slacking, I hope...";
  38. mes "Is there anything I can help";
  39. mes "you with?";
  40. mes " ";
  41. mes "^777777~ You've completed "+callfunc("F_InsertPlural",Mission_Total,"mission",0,"^0055FF%d^777777 %s")+". ~^000000";
  42. next;
  43. switch(select(((!Mission0)?" ~ New Mission::":": ~ Mission Status: ~ Abandon Mission")+": ~ Information: ~ Mission Shop: ~ View Top Hunters: ~ ^777777Cancel^000000")) {
  44. case 1:
  45. mes "[Hunting Missions]";
  46. if (#Mission_Count) {
  47. mes "You've started a mission";
  48. mes "on another character.";
  49. close;
  50. }
  51. if (#Mission_Delay > gettimetick(2) && .Delay) {
  52. mes "I'm afraid you'll have to wait "+callfunc("Time2Str",#Mission_Delay)+" before taking another mission.";
  53. close;
  54. }
  55. mes "You must hunt:";
  56. query_sql("SELECT ID FROM `mob_db` WHERE left(Sprite, 4) != 'meta' AND left(Sprite, 2) != 'E_' AND ~Mode & 32 AND EXP > 0 AND MVP1id = 0 AND DropCardid > 4000 AND DropCardid < 5000 AND ID < 2000 AND instr('"+.Blacklist$+"',ID) = 0 ORDER BY rand() LIMIT "+.Quests, .@mob);
  57. for (set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  58. setd "Mission"+.@i, .@mob[.@i];
  59. setd "Mission"+.@i +"_",0;
  60. }
  61. set #Mission_Count, rand(.Count[0],.Count[1]);
  62. callsub Mission_Status;
  63. next;
  64. mes "[Hunting Missions]";
  65. mes "Report back when";
  66. mes "you've finished.";
  67. mes "Good luck!";
  68. close;
  69. case 2:
  70. mes "[Hunting Missions]";
  71. mes "Mission status:";
  72. callsub Mission_Status;
  73. close;
  74. case 3:
  75. mes "[Hunting Missions]";
  76. mes "Do you really want to";
  77. mes "abandon your mission?";
  78. if (.Reset < 0 && .Delay)
  79. mes "Your delay time will not be reset.";
  80. else if (.Reset > 0)
  81. mes "It will cost "+callfunc("F_InsertComma",.Reset)+" Zeny.";
  82. next;
  83. switch(select(" ~ Abandon...: ~ ^777777Cancel^000000")) {
  84. case 1:
  85. if (.Reset > 0) {
  86. if (Zeny < .Reset) {
  87. mes "[Hunting Missions]";
  88. mes "You don't have enough";
  89. mes "Zeny to drop this mission.";
  90. emotion e_sry;
  91. close;
  92. }
  93. set Zeny, Zeny-.Reset;
  94. emotion e_cash;
  95. }
  96. mes "[Hunting Missions]";
  97. mes "Alright, I've dropped";
  98. mes "your current mission.";
  99. specialeffect2 EF_STORMKICK4;
  100. for(set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  101. setd "Mission"+.@i,0;
  102. setd "Mission"+.@i+"_",0;
  103. }
  104. set #Mission_Count,0;
  105. if (.Reset < 0 && .Delay) set #Mission_Delay, gettimetick(2)+(.Delay*3600);
  106. close;
  107. case 2:
  108. mes "[Hunting Missions]";
  109. mes "I knew you were kidding!";
  110. mes "Keep up the good work.";
  111. emotion e_heh;
  112. close;
  113. }
  114. case 4:
  115. callsub Mission_Info;
  116. close;
  117. case 5:
  118. mes "[Hunting Missions]";
  119. mes "You have ^0055FF"+#Mission_Points+"^000000 Mission Points.";
  120. mes "Use them well!";
  121. callshop "mission_shop",1;
  122. npcshopattach "mission_shop";
  123. end;
  124. case 6:
  125. mes "[Hunting Missions]";
  126. mes "The top hunters are:";
  127. query_sql("SELECT char_id AS id, (SELECT `name` FROM `char` WHERE char_id = id),`value` FROM `global_reg_value` WHERE str = 'Mission_Total' ORDER BY CAST(`value` AS SIGNED) DESC LIMIT 5",.@id,.@name$,.@val);
  128. for(set .@i,0; .@i<5; set .@i,.@i+1)
  129. mes " [Rank "+(.@i+1)+"] "+((.@name$[.@i] == "")?"^777777none":"^0055FF"+.@name$[.@i]+"^000000 : ^FF0000"+.@val[.@i]+" pt.")+"^000000";
  130. close;
  131. case 7:
  132. mes "[Hunting Missions]";
  133. mes "Nothing? Okay...";
  134. emotion e_hmm;
  135. close;
  136. }
  137. Mission_Status:
  138. set @f,0;
  139. deletearray .@j[0], getarraysize(.@j);
  140. for(set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  141. set .@j[.@i], getd("Mission"+.@i);
  142. set .@j[.Quests], .@j[.Quests]+strmobinfo(3,.@j[.@i]);
  143. set .@j[.Quests+1], .@j[.Quests+1]+(strmobinfo(6,.@j[.@i])/(getbattleflag("base_exp_rate")/100)*.Modifier[0]);
  144. set .@j[.Quests+2], .@j[.Quests+2]+(strmobinfo(7,.@j[.@i])/(getbattleflag("job_exp_rate")/100)*.Modifier[1]);
  145. mes " > "+Chk(getd("Mission"+.@i+"_"),#Mission_Count)+strmobinfo(1,.@j[.@i])+" ("+getd("Mission"+.@i+"_")+"/"+#Mission_Count+")^000000";
  146. }
  147. // Reward formulas:
  148. set .@Mission_Points, 3+(.@j[.Quests]/.Quests/6);
  149. set .@Base_Exp, #Mission_Count*.@j[.Quests+1]/5;
  150. set .@Job_Exp, #Mission_Count*.@j[.Quests+2]/5;
  151. set .@Zeny, #Mission_Count*.Quests*.@j[.@i]*.Modifier[2];
  152. next;
  153. mes "[Hunting Missions]";
  154. mes "Mission rewards:";
  155. mes " > Mission Points: ^0055FF"+.@Mission_Points+"^000000";
  156. mes " > Base Experience: ^0055FF"+callfunc("F_InsertComma",.@Base_Exp)+"^000000";
  157. mes " > Job Experience: ^0055FF"+callfunc("F_InsertComma",.@Job_Exp)+"^000000";
  158. mes " > Zeny: ^0055FF"+callfunc("F_InsertComma",.@Zeny)+"^000000";
  159. if (@f) { set @f,0; return; }
  160. next;
  161. mes "[Hunting Missions]";
  162. mes "Oh, you're done!";
  163. mes "Good work.";
  164. mes "Here's your reward.";
  165. emotion e_no1;
  166. specialeffect2 EF_ANGEL;
  167. specialeffect2 EF_TRUESIGHT;
  168. set #Mission_Points, #Mission_Points+.@Mission_Points;
  169. set BaseExp, BaseExp+.@Base_Exp;
  170. set JobExp, JobExp+.@Job_Exp;
  171. set Zeny, Zeny+.@Zeny;
  172. for(set .@i,0; .@i<.Quests; set .@i,.@i+1) {
  173. setd "Mission"+.@i,0;
  174. setd "Mission"+.@i+"_",0;
  175. }
  176. set #Mission_Count,0;
  177. if (.Delay) set #Mission_Delay, gettimetick(2)+(.Delay*3600);
  178. set Mission_Total, Mission_Total+1;
  179. 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)");
  180. else query_sql("UPDATE `global_reg_value` SET `value` = "+Mission_Total+" WHERE char_id = "+getcharid(0)+" AND `str` = 'Mission_Total'");
  181. close;
  182. Mission_Info:
  183. mes "[Hunting Missions]";
  184. mes "If you so choose, I can assign";
  185. mes "you a random hunting quest.";
  186. mes "Some are easier than others, but";
  187. mes "the rewards increase with difficulty.";
  188. next;
  189. mes "[Hunting Missions]";
  190. mes "Missions points are shared";
  191. mes "amongst all your characters.";
  192. if (.Delay) mes "Delay time is, too.";
  193. mes "You can't take missions on";
  194. mes "multiple characters at once.";
  195. next;
  196. mes "[Hunting Missions]";
  197. mes "You can start a quest";
  198. if (.Delay) mes "every "+((.Delay == 1)?"hour.":.Delay+" hours.");
  199. else mes "whenever you want.";
  200. mes "That's everything~";
  201. return;
  202. function Chk {
  203. if (getarg(0) < getarg(1)) { set @f,1; return "^FF0000"; }
  204. else return "^00FF00"; }
  205. OnBuyItem:
  206. set @cost,0;
  207. for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1)
  208. for(set .@j,0; .@j<getarraysize(.Shop); set .@j,.@j+2)
  209. if (@bought_nameid[.@i] == .Shop[.@j]) {
  210. set @cost, @cost+(.Shop[.@j+1]*@bought_quantity[.@i]);
  211. break;
  212. }
  213. mes "[Hunting Missions]";
  214. if (@cost > #Mission_Points) mes "You don't have enough Mission Points.";
  215. else {
  216. for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1) {
  217. getitem @bought_nameid[.@i], @bought_quantity[.@i];
  218. dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
  219. }
  220. set #Mission_Points, #Mission_Points-@cost;
  221. mes "Deal completed.";
  222. emotion e_cash;
  223. }
  224. set @cost,0;
  225. deletearray @bought_nameid[0], getarraysize(@bought_nameid);
  226. deletearray @bought_quantity[0], getarraysize(@bought_quantity);
  227. close;
  228. OnNPCKillEvent:
  229. if (!getcharid(1) || !.Party) {
  230. if (!#Mission_Count || !Mission0) end;
  231. for (set .@i, 0; .@i<.Quests; set .@i,.@i+1) {
  232. if (strmobinfo(1,killedrid) == strmobinfo(1,getd("Mission"+.@i))) {
  233. if (getd("Mission"+.@i+"_") < #Mission_Count) {
  234. dispbottom "[Hunting Mission] Killed "+(set(getd("Mission"+.@i+"_"),getd("Mission"+.@i+"_")+1))+" of "+#Mission_Count+" "+strmobinfo(1,killedrid)+".";
  235. end;
  236. }
  237. }
  238. }
  239. } else if (.Party) {
  240. set .@mob, killedrid;
  241. getmapxy(.@map1$,.@x1,.@y1,0);
  242. getpartymember getcharid(1),1;
  243. getpartymember getcharid(1),2;
  244. for(set .@i,0; .@i<$@partymembercount; set .@i,.@i+1) {
  245. if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i])) {
  246. attachrid $@partymemberaid[.@i];
  247. if (#Mission_Count && Mission0 && HP > 0) {
  248. getmapxy(.@map2$,.@x2,.@y2,0);
  249. if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) {
  250. for(set .@j,0; .@j<.Quests; set .@j,.@j+1) {
  251. if (strmobinfo(1,.@mob) == strmobinfo(1,getd("Mission"+.@j))) {
  252. if (getd("Mission"+.@j+"_") < #Mission_Count) {
  253. dispbottom "[Hunting Mission] Killed "+(set(getd("Mission"+.@j+"_"),getd("Mission"+.@j+"_")+1))+" of "+#Mission_Count+" "+strmobinfo(1,.@mob)+".";
  254. break;
  255. }
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. end;
  264. OnInit:
  265. set .Delay,12; // Quest delay, in hours (0 to disable).
  266. set .Quests,4; // Number of subquests per mission (increases rewards).
  267. set .Party,3; // Party options: 0 (exclude party kills), 1 (include party kills), 2 (same map only), 3 (screen area only)
  268. set .Reset,-1; // Reset options: -1 (abandoning mission sets delay time), 0 (no delay time), [Zeny] (cost to abandon mission, no delay time)
  269. setarray .Count[0], // Min and max monsters per subquest (increases rewards).
  270. 40,70;
  271. setarray .Modifier[0], // Multipliers for Base Exp, Job Exp, and Zeny rewards.
  272. getbattleflag("base_exp_rate")/100,getbattleflag("job_exp_rate")/100,60;
  273. setarray .Shop[0], // Reward items: <ID>,<point cost> (about 10~20 points per hunt).
  274. 512,1,513,1,514,1,538,5,539,5,558,10,561,10;
  275. set .Blacklist$, // Blacklisted mob IDs.
  276. "1062,1088,1183,1186,1200,1212,1220,1221,1234,1235,"+
  277. "1244,1245,1250,1268,1290,1293,1294,1296,1298,1299,"+
  278. "1300,1301,1303,1304,1305,1306,1308,1309,1311,1313,"+
  279. "1515,1588,1618,1676,1677,1678,1679,1796,1797,1974,"+
  280. "1975,1976,1977,1978,1979";
  281. npcshopdelitem "mission_shop",512;
  282. for(set .@i,0; .@i<getarraysize(.Shop); set .@i,.@i+2)
  283. npcshopadditem "mission_shop", .Shop[.@i], .Shop[.@i+1];
  284. end;
  285. }
  286. - shop mission_shop -1,512:-1