functions_kafras.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. //===== eAthena Script =======================================
  2. //= Kafra Functions
  3. //===== By: ==================================================
  4. //= eAthena Dev Team
  5. //= Darlskies, Darkchild, Syrus22, Lupus, kobra_k88 (2.0)
  6. //===== Current Version: =====================================
  7. //= 5.4
  8. //===== Compatible With: =====================================
  9. //= eAthena 1.0
  10. //===== Description: =========================================
  11. //= These functions handle save, storage, cart rental, teleport,
  12. //= and Free Teleport/Warp/Rent Cart options for all Kafra NPCs.
  13. //===== Additional Comments: =================================
  14. //= v1.1 Now using functions v2.1 Added Cart Rent for Classes: Whitesmith, Professor.
  15. //= Replaced checkoption(x) into checkcart(0) [Lupus] v2.1b Added Fix Kafra Pass Func [Kobra_k88]
  16. //= 2.2 Final fix of the Kafra Pass Exploit! [Lupus] a -Izlude[4] fix
  17. //= 2.2a Minor changes to function calls. Using agruments. Added Guild options. [kobra_k88]
  18. //= 2.2b This version uses arrays for the teleport option. Rearranged next statements to make menu transitions smoother. [kobra_k88]
  19. //= 2.3 Removed SAVE from Niflheim. [Lupus]
  20. //= 2.3 removed "fix" by HawkMoon RTFM and check supernovice.txt . There's a SPECIAL Kafra which gives CARTS to SN for a special proce. [Lupus]
  21. //= 2.4 Added Baby Class Support (Baby Novice check) Removed annoying storage feature where u had to close dialog window to be able to use your storage [Lupus]
  22. //= 2.5 Added Louyang official Kafra, fixes some Kafras, not letting you to Save your position [Lupus]
  23. //= 2.6 Reverted Dungeons Kafras (they should offer only Storage). Added temp Ayothaya Kafra
  24. //= 2.7 Added correct Ayothaya, Louyang & Amatsu Kafras. [Lupus]
  25. //= 2.8 Fixed Amatsu Storage problems [Lupus] 2.9 Fixed spelling mistakes. [Nexon]
  26. //= 3.0 Added special "not working teleport menu" for Einbroch Kafras [Lupus]
  27. //= 3.1 Removed callfunc Is_####_Class in favor of baseClass [Silentdragon]
  28. //= 3.2 Fixed an exploit [Lupus]
  29. //= 4.0 Added Kafra storage password protection. [Lupus]
  30. //= to block Kafra Password, read comments at 350 line
  31. //= Note: You can change '1337' value to another to raise password protection
  32. //= 5.0 Fixed the close2;....close; end; lines. Who let them slip away? =/ [erKURITA]
  33. //= Also, the kafra upon warp was giving back the zeny. Removed. [erKURITA]
  34. //= 5.1 Optimized a little, added no tele/save arg's [Evera]
  35. //= 5.1a Temporary? Added F_ClearGarbage to clear unused/outdated variables [Lupus]
  36. //= 5.2 By default commented out custom Guilds Kafra's "Guild Storage". [Lupus]
  37. //= 5.3 uncommented Guild Storage. Confirmed kRO feature. [Lupus]
  38. //= 5.4 added -Guide option (Kafra shows you nearest Guide) Work in progress.
  39. //= Need all coords for all guides.. and somehow pass their coords to kafra.
  40. //= Removed universal Kafra Pass, added 3 new Kafra Tickets [Lupus]
  41. //============================================================
  42. // Main Function ===========================================================
  43. //= arg(0): Used to determine which welcome message to show.
  44. //= arg(1): Used to determine which menu to display.
  45. //= arg(2): Used to determine if the info menu is shown in F_KafInfo.
  46. //==========================================================================
  47. function script F_Kafra {
  48. callfunc "F_ClearGarbage"; //Clear outdated, unused variables
  49. mes "[Kafra]";
  50. switch(getarg(0)){
  51. default:
  52. case 0:
  53. mes "Welcome to Kafra Corp. We will stay with you wherever you go.";
  54. break;
  55. //Niflheim
  56. case 1:
  57. mes "Welcome... Kafra Services.... Will be with you even if you die.....";
  58. break;
  59. //Guilds Castles
  60. case 2:
  61. mes "Welcome, ^5533FF" + GetGuildName(@GID) + "^000000 members. We will stay with you wherever you go";
  62. break;
  63. //Amatsu
  64. case 3:
  65. mes "So, have you come from a faraway land to study our culture, or are you just sightseeing?";
  66. mes "In either case, why not stay awhile?";
  67. mes "The air is eternally heavy with the";
  68. mes "scent of pleasant wildflowers.";
  69. break;
  70. //Louyang, Ayothaya
  71. case 4:
  72. mes "With our many Kafra";
  73. mes "service locations, you're never";
  74. mes "far from home.";
  75. break;
  76. }
  77. next;
  78. M_Menu:
  79. cleararray @K_Menu0$[0],"",7;
  80. switch(getarg(1)){
  81. //only Save & Storage
  82. case 1:
  83. setarray @K_Menu0$[0],"-Save","-Use Storage","-Cancel";
  84. break;
  85. //only Storage
  86. case 2:
  87. setarray @K_Menu0$[0],"-Use Storage","-Cancel";
  88. break;
  89. //Common w/o teleport
  90. case 3:
  91. setarray @K_Menu0$[0],"-Guide","-Save","-Use Storage","-Rent a Cart","-Kafra Pass","-Other Information Check","-Cancel";
  92. break;
  93. //Case 4 is Einbroch no tele message.
  94. //Common w/o save and teleport
  95. case 5:
  96. setarray @K_Menu0$[0],"-Guide","-Use Storage","-Rent a Cart","-Kafra Pass","-Other Information Check","-Cancel";
  97. break;
  98. //Only storage and other info check
  99. case 6:
  100. setarray @K_Menu0$[0],"-Guide","-Use Storage","-Other Information Check","-Cancel";
  101. break;
  102. //Common Kafra
  103. default:
  104. setarray @K_Menu0$[0],"-Guide","-Save","-Use Storage","-Use Teleport Service","-Rent a Cart","-Kafra Pass","-Other Information Check","-Cancel";
  105. break;
  106. }
  107. if(getarg(0)==2) {
  108. //Guilds Kafra (free Teleport, free Storage, Free Cart)
  109. cleararray @K_Menu0$[0],"",7;
  110. setarray @K_Menu0$[0],"-Use Storage","-Use Guild Storage","-Rent a Cart","-Use Teleport Service","-Cancel";
  111. }
  112. menu @K_Menu0$[0],K_Menu0,@K_Menu0$[1],K_Menu1,@K_Menu0$[2],K_Menu2,
  113. @K_Menu0$[3],K_Menu3,@K_Menu0$[4],K_Menu4,@K_Menu0$[5],K_Menu5,
  114. @K_Menu0$[6],K_Menu6,@K_Menu0$[7],K_Menu7;
  115. K_Menu0:
  116. set @num,0;
  117. goto K_Menuf;
  118. K_Menu1:
  119. set @num,1;
  120. goto K_Menuf;
  121. K_Menu2:
  122. set @num,2;
  123. goto K_Menuf;
  124. K_Menu3:
  125. set @num,3;
  126. goto K_Menuf;
  127. K_Menu4:
  128. set @num,4;
  129. goto K_Menuf;
  130. K_Menu5:
  131. set @num,5;
  132. goto K_Menuf;
  133. K_Menu6:
  134. set @num,6;
  135. goto K_Menuf;
  136. K_Menu7:
  137. set @num,7;
  138. K_Menuf:
  139. if (@K_Menu0$[@num] == "-Save") return;
  140. if (@K_Menu0$[@num] == "-Use Storage"){
  141. //Don't charge for a common Kafra Storage in your Castle
  142. if(getarg(0) == 2) callfunc "F_KafStor",2;
  143. else callfunc "F_KafStor",0;
  144. next;
  145. goto M_Menu;
  146. }
  147. if (@K_Menu0$[@num] == "-Use Teleport Service"){
  148. if(getarg(1) == 4){ //Check for Einbroch Tele notice
  149. mes "[Kafra]";
  150. mes "Because of the ^FF0000Limited Transport Agreement^000000, the Kafra Corporation cannot provide Teleport Services in the Schwarzwald Republic.";
  151. next;
  152. mes "[Kafra]";
  153. mes "We ask that you please";
  154. mes "use the Airship Service";
  155. mes "instead. Thank you for your";
  156. mes "understanding and cooperation.";
  157. next;
  158. goto M_Menu;
  159. }
  160. callfunc "F_KafTele",getarg(0);
  161. goto M_Menu;
  162. }
  163. if (@K_Menu0$[@num] == "-Rent a Cart"){
  164. if(callfunc("F_KafCart",getarg(0)) == 1) next;
  165. goto M_Menu;
  166. }
  167. if (@K_Menu0$[@num] == "-Guide"){
  168. callfunc "F_KafGuide";
  169. goto M_Menu;
  170. }
  171. if (@K_Menu0$[@num] == "-Other Information Check"){
  172. callfunc "F_KafInfo",getarg(2);
  173. goto M_Menu;
  174. }
  175. if (@K_Menu0$[@num] == "-Cancel"){
  176. callfunc "F_KafEnd",getarg(0),0;
  177. end;
  178. }
  179. if (@K_Menu0$[@num] == "-Use Guild Storage"){
  180. callfunc "F_KafStor",1;
  181. next;
  182. goto M_Menu;
  183. }
  184. }
  185. // Storage Function =======================================================
  186. function script F_KafStor {
  187. if(getarg(0) == 1){
  188. if(guildopenstorage(0) == 1){
  189. mes "[Kafra]";
  190. mes "I'm sorry but another guild member is using the guild storage";
  191. mes "right now. Please wait until that person is finished.";
  192. close2;
  193. cutin "", 255;
  194. end;
  195. }
  196. cutin "", 255;
  197. close;
  198. }
  199. if(basicskillcheck(0) && getskilllv(1) < 6){
  200. mes "[Kafra]";
  201. mes "I am sorry but you have to be at least Novice level 6 if you want to use the storage.";
  202. return;
  203. }
  204. //don't charge for common storage in Castle
  205. if(getarg(0) != 2){
  206. //we'll use Free Ticket for Kafra Storage if available
  207. if(countitem(7059)){
  208. delitem 7059,1;
  209. } else {
  210. if(Zeny<40){
  211. mes "[Kafra]";
  212. mes "Dear you don't have enough money. The Storage fee is 40 Zeny.";
  213. return;
  214. }
  215. set Zeny, Zeny-40;
  216. set RESRVPTS, RESRVPTS + (40/5);
  217. }
  218. }
  219. mes "[Kafra]";
  220. mes "Close this window to open your storage.";
  221. mes "We hope to see you again soon.";
  222. callfunc("F_CheckKafCode"); //check your storage password, if set
  223. close2;
  224. openstorage;
  225. cutin "", 255;
  226. end;
  227. }
  228. // Teleport Function ==================================================
  229. function script F_KafTele {
  230. mes "[Kafra]";
  231. mes "Please set your destination.";
  232. next;
  233. menu @wrpC$[0],M_Wrp0, @wrpC$[1],M_Wrp1, @wrpC$[2],M_Wrp2, @wrpC$[3],M_Wrp3,
  234. @wrpC$[4],M_Wrp4, @wrpC$[5],M_Wrp5, @wrpC$[6],M_Wrp6;
  235. M_Wrp0:
  236. set @num, 0;
  237. goto L_Warp;
  238. M_Wrp1:
  239. set @num, 1;
  240. goto L_Warp;
  241. M_Wrp2:
  242. set @num, 2;
  243. goto L_Warp;
  244. M_Wrp3:
  245. set @num, 3;
  246. goto L_Warp;
  247. M_Wrp4:
  248. set @num, 4;
  249. goto L_Warp;
  250. M_Wrp5:
  251. set @num, 5;
  252. goto L_Warp;
  253. M_Wrp6:
  254. set @num, 6;
  255. L_Warp:
  256. if (@wrpC$[@num] == "Cancel") return;
  257. // we'll use Free Ticket for Kafra Transportation if available
  258. if(countitem(7060)){
  259. delitem 7060,1;
  260. } else {
  261. if (Zeny<@wrpP[@num]){
  262. mes "[Kafra]";
  263. mes "Dear you don't have enough money. Please check your funds again.";
  264. emotion e_cash;
  265. close2;
  266. cutin "", 255;
  267. end;
  268. }
  269. set Zeny, Zeny-@wrpP[@num];
  270. set RESRVPTS, RESRVPTS + (@wrpP[@num]/16);
  271. }
  272. if (@wrpD$[@num] == "Alberta") warp "alberta.gat", 117, 56;
  273. if (@wrpD$[@num] == "Al De Baran") warp "aldebaran.gat",143,110;
  274. if (@wrpD$[@num] == "Aldebaran") warp "aldebaran.gat",143,110;
  275. if (@wrpD$[@num] == "Comodo") warp "comodo.gat", 207, 144;
  276. if (@wrpD$[@num] == "Izlude") warp "izlude.gat", 91, 105;
  277. if (@wrpD$[@num] == "Geffen") warp "geffen.gat", 120, 39;
  278. if (@wrpD$[@num] == "Morroc") warp "morocc.gat", 156, 46;
  279. if (@wrpD$[@num] == "Payon") warp "payon.gat", 168, 103;
  280. if (@wrpD$[@num] == "Prontera") warp "prontera.gat", 116, 72;
  281. if (@wrpD$[@num] == "Coal Mine(Dead Pit)") warp "mjolnir_02.gat", 82, 347;
  282. if (@wrpD$[@num] == "Comodo Pharos Lighthouse") warp "cmd_fild07.gat", 127, 134;
  283. if (@wrpD$[@num] == "Orc Dungeon") warp "gef_fild10.gat", 52, 326;
  284. if (@wrpD$[@num] == "Umbala") warp "umbala.gat", 130, 130;
  285. if (@wrpD$[@num] == "Yuno") warp "yuno.gat", 157, 123;
  286. cutin "", 255;
  287. end;
  288. }
  289. // Cart Function ========================================================
  290. function script F_KafCart {
  291. if(baseClass != Job_Merchant){
  292. mes "[Kafra]";
  293. mes "I'm sorry dear. The Cart service is only provided for the Merchant and Blacksmith Class.";
  294. return 1;
  295. }
  296. if(getskilllv(39)==0){
  297. mes "[Kafra]";
  298. mes "I'm sorry but you need the skill ^0000FF'Pushcart'^000000 to rent a cart.";
  299. return 1;
  300. }
  301. if(checkcart(0) == 1){
  302. mes "[Kafra]";
  303. mes "Excuse me... but you already have a cart....";
  304. emotion e_swt;
  305. return 1;
  306. }
  307. //get Cart in Guild for free
  308. if(getarg(0) == 2) goto L_FreeCart;
  309. //use Free Ticket for the Cart Service if available
  310. if(countitem(7061)){
  311. delitem 7061,1;
  312. goto L_FreeCart;
  313. }
  314. mes "[Kafra]";
  315. mes "The Cart Fee is 800 Zeny. Do you want to Rent a Cart?";
  316. next;
  317. menu "-Rent a Cart.",-, "-Cancel.",M_End;
  318. if(Zeny<800){
  319. mes "[Kafra]";
  320. mes "Dear, you don't have enough Money. You need 800 Zeny.";
  321. emotion e_cash;
  322. return 1;
  323. }
  324. set Zeny,Zeny-800;
  325. set RESRVPTS, RESRVPTS + 48;
  326. L_FreeCart:
  327. setcart;
  328. mes "[Kafra]";
  329. mes "Here is your cart.";
  330. return 1;
  331. M_End:
  332. return 0;
  333. }
  334. // Pass Function ===============================================================
  335. function script F_KafGuide {
  336. mes "[Kafra]";
  337. mes "WIP...";
  338. return;
  339. }
  340. // Special Reserve Points Function ===========================================
  341. function script F_KafInfo {
  342. sM_Menu:
  343. //Uncomment next line to block Kafra Storage Protection
  344. // if(getarg(0) == 0) menu "-Special Reserve Check",sM_ResChk, "-Kafra Locations",sM_KafLoc, "-Cancel",sM_End;
  345. if(getarg(0) == 0) menu "-Special Reserve Check",sM_ResChk, "-Storage Password Service",sM_KafCode, "-Kafra Locations",sM_KafLoc, "-Cancel",sM_End;
  346. sM_ResChk:
  347. mes "[Kafra]";
  348. mes "Here is your current amount of special reserve points:";
  349. mes "^0000ff"+RESRVPTS+"^000000.";
  350. next;
  351. mes "[Kafra]";
  352. mes "Remember to continue using Kafra services such as Storage and Teleport, to earn more special reserve points.";
  353. next;
  354. mes "[Kafra]";
  355. mes "You can trade them in at the Kafra Main Office in Al De Baran for useful items and cool prizes.";
  356. next;
  357. if(getarg(0) == 1) return;
  358. goto sM_Menu;
  359. sM_KafLoc:
  360. mes "[Kafra]";
  361. mes "The flashing signals on your mini-map point to the locations of all of the Kafra Agents in this city.";
  362. viewpoint 1,@viewpX[0],@viewpY[0],1,0xFF00FF;
  363. viewpoint 1,@viewpX[1],@viewpY[1],2,0xFF00FF;
  364. viewpoint 1,@viewpX[2],@viewpY[2],3,0xFF00FF;
  365. viewpoint 1,@viewpX[3],@viewpY[3],4,0xFF00FF;
  366. next;
  367. viewpoint 2,@viewpX[0],@viewpY[0],1,0xFF00FF;
  368. viewpoint 2,@viewpX[1],@viewpY[1],2,0xFF00FF;
  369. viewpoint 2,@viewpX[2],@viewpY[2],3,0xFF00FF;
  370. viewpoint 2,@viewpX[3],@viewpY[3],4,0xFF00FF;
  371. goto sM_Menu;
  372. sM_KafCode:
  373. callfunc("F_SetKafCode");
  374. sM_End:
  375. return;
  376. }
  377. // End Function =====================================================
  378. // arg(0): used to determine what message to display.
  379. // arg(1): used to determine if save message is displayed.
  380. //===================================================================
  381. function script F_KafEnd {
  382. mes "[Kafra]";
  383. if(getarg(1)==1) mes "Your respawn point has been saved."; // only shown when a player uses save
  384. if(getarg(0)!=1) mes "Thank you for using Kafra Services. We hope to see you again soon.";
  385. if(getarg(0)==1) mes "We, Kafra Corporation.... Will be with you.... whenever.... wherever... therefore.... please don't forget us.....";
  386. close2;
  387. cutin "", 255;
  388. emotion e_thx;
  389. close;
  390. end;
  391. }
  392. // Check Storage Password Function ====================
  393. function script F_CheckKafCode {
  394. if(#kafra_code==0) return;
  395. mes "Enter your storage password:";
  396. set @code_,0;
  397. input @code_;
  398. if(@code_ != #kafra_code-getcharid(3)-1337) {
  399. dispbottom "Wrong storage password.";
  400. close2;
  401. cutin "",255;
  402. end;
  403. }
  404. set @kafcode_try,0;
  405. set @code_,0;
  406. return;
  407. }
  408. // Set / Change / Clear Storage Password Function ====================
  409. function script F_SetKafCode 115,{
  410. mes "[Kafra]";
  411. if(#kafra_code) {
  412. mes "Your storage is protected with a password. What would you do now?";
  413. next;
  414. menu "Change old password -> 5000z",-,
  415. "Remove storage password -> 1000z",M_CLEAR,
  416. "Cancel",M_END;
  417. } else {
  418. mes "Kafra Services proudly presents you a new service:";
  419. mes "Additional storage protection with a password.";
  420. next;
  421. menu "Set new password -> 5000z",M_SET,
  422. "Cancel",M_END;
  423. }
  424. mes "[Kafra]";
  425. mes "At first, please enter your ^0000FFold password^000000.";
  426. set @code,callfunc("F_EntKafCode");
  427. if(@code==0 || @code != #kafra_code-getcharid(3)-1337) {
  428. mes "Wrong password. You can't set a new password.";
  429. emotion e_hmm;
  430. goto M_END;
  431. }
  432. next;
  433. M_SET:
  434. mes "[Kafra]";
  435. mes "Now enter your ^FF0000new password^000000 to protect your storage from thieves.";
  436. set @code,callfunc("F_EntKafCode");
  437. if(@code==0) {
  438. mes "The password hasn't been changed.";
  439. emotion e_hmm;
  440. goto M_END;
  441. }
  442. next;
  443. mes "[Kafra]";
  444. if(Zeny < 5000) goto L_ZENY;
  445. set Zeny,Zeny-5000;
  446. set RESRVPTS, RESRVPTS + (5000/50);
  447. set #kafra_code,@code+getcharid(3)+1337;
  448. mes "You've protected your storage with a secret password.";
  449. mes "Thank you for using Kafra Services.";
  450. emotion e_thx;
  451. goto M_END;
  452. M_CLEAR:
  453. mes "[Kafra]";
  454. mes "Please, enter your password before its removal.";
  455. set @code,callfunc("F_EntKafCode");
  456. if(@code==0) {
  457. mes "The password hasn't been removed.";
  458. emotion e_hmm;
  459. goto M_END;
  460. }
  461. next;
  462. mes "[Kafra]";
  463. if(Zeny < 1000) goto L_ZENY;
  464. set Zeny,Zeny-1000;
  465. set RESRVPTS, RESRVPTS + (1000/50);
  466. if(@code == #kafra_code-getcharid(3)-1337) {
  467. set #kafra_code,0;
  468. mes "You've successfully cleared your storage password.";
  469. mes "Thank you for using Kafra Services.";
  470. emotion e_thx;
  471. } else {
  472. mes "Wrong password. We won't return your 1000z.";
  473. mes "Please, next time enter correct password.";
  474. emotion e_sry;
  475. }
  476. goto M_END;
  477. L_ZENY:
  478. mes "You don't have enough zeny.";
  479. emotion e_cash;
  480. M_END:
  481. close2;
  482. cutin "",255;
  483. end;
  484. }
  485. // Basic Password Validation Function ====================
  486. function script F_EntKafCode {
  487. mes "Enter a number 1000~10000000:";
  488. set @code_,0;
  489. set @kafcode_try,@kafcode_try+1;
  490. if(@kafcode_try>10) {
  491. set @kafcode_try,0;
  492. logmes "Hack: Tried to fit storage password.";
  493. }
  494. input @code_;
  495. if(@code_<1000) {
  496. mes "You shouldn't use such short password.";
  497. return 0;
  498. }
  499. if(@code_>10000000) {
  500. mes "You can't use such big password.";
  501. return 0;
  502. }
  503. return @code_;
  504. }