hunting_missions.txt 12 KB

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