functions_kafras.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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.4a
  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","-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","-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","-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. next;
  170. goto M_Menu;
  171. }
  172. if (@K_Menu0$[@num] == "-Other Information Check"){
  173. callfunc "F_KafInfo",getarg(2);
  174. goto M_Menu;
  175. }
  176. if (@K_Menu0$[@num] == "-Cancel"){
  177. callfunc "F_KafEnd",getarg(0),0;
  178. end;
  179. }
  180. if (@K_Menu0$[@num] == "-Use Guild Storage"){
  181. callfunc "F_KafStor",1;
  182. next;
  183. goto M_Menu;
  184. }
  185. }
  186. // Storage Function =======================================================
  187. function script F_KafStor {
  188. if(getarg(0) == 1){
  189. if(guildopenstorage(0) == 1){
  190. mes "[Kafra]";
  191. mes "I'm sorry but another guild member is using the guild storage";
  192. mes "right now. Please wait until that person is finished.";
  193. close2;
  194. cutin "", 255;
  195. end;
  196. }
  197. cutin "", 255;
  198. close;
  199. }
  200. if(basicskillcheck(0) && getskilllv(1) < 6){
  201. mes "[Kafra]";
  202. mes "I am sorry but you have to be at least Novice level 6 if you want to use the storage.";
  203. return;
  204. }
  205. //don't charge for common storage in Castle
  206. if(getarg(0) != 2){
  207. //we'll use Free Ticket for Kafra Storage if available
  208. if(countitem(7059)){
  209. delitem 7059,1;
  210. } else {
  211. if(Zeny<40){
  212. mes "[Kafra]";
  213. mes "Dear you don't have enough money. The Storage fee is 40 Zeny.";
  214. return;
  215. }
  216. set Zeny, Zeny-40;
  217. set RESRVPTS, RESRVPTS + (40/5);
  218. }
  219. }
  220. mes "[Kafra]";
  221. mes "Close this window to open your storage.";
  222. mes "We hope to see you again soon.";
  223. callfunc("F_CheckKafCode"); //check your storage password, if set
  224. close2;
  225. openstorage;
  226. cutin "", 255;
  227. end;
  228. }
  229. // Teleport Function ==================================================
  230. function script F_KafTele {
  231. mes "[Kafra]";
  232. mes "Please set your destination.";
  233. next;
  234. menu @wrpC$[0],M_Wrp0, @wrpC$[1],M_Wrp1, @wrpC$[2],M_Wrp2, @wrpC$[3],M_Wrp3,
  235. @wrpC$[4],M_Wrp4, @wrpC$[5],M_Wrp5, @wrpC$[6],M_Wrp6;
  236. M_Wrp0:
  237. set @num, 0;
  238. goto L_Warp;
  239. M_Wrp1:
  240. set @num, 1;
  241. goto L_Warp;
  242. M_Wrp2:
  243. set @num, 2;
  244. goto L_Warp;
  245. M_Wrp3:
  246. set @num, 3;
  247. goto L_Warp;
  248. M_Wrp4:
  249. set @num, 4;
  250. goto L_Warp;
  251. M_Wrp5:
  252. set @num, 5;
  253. goto L_Warp;
  254. M_Wrp6:
  255. set @num, 6;
  256. L_Warp:
  257. if (@wrpC$[@num] == "Cancel") return;
  258. // we'll use Free Ticket for Kafra Transportation if available
  259. if(countitem(7060)){
  260. delitem 7060,1;
  261. } else {
  262. if (Zeny<@wrpP[@num]){
  263. mes "[Kafra]";
  264. mes "Dear you don't have enough money. Please check your funds again.";
  265. emotion e_cash;
  266. close2;
  267. cutin "", 255;
  268. end;
  269. }
  270. set Zeny, Zeny-@wrpP[@num];
  271. set RESRVPTS, RESRVPTS + (@wrpP[@num]/16);
  272. }
  273. if (@wrpD$[@num] == "Alberta") warp "alberta.gat", 117, 56;
  274. if (@wrpD$[@num] == "Al De Baran") warp "aldebaran.gat",143,110;
  275. if (@wrpD$[@num] == "Aldebaran") warp "aldebaran.gat",143,110;
  276. if (@wrpD$[@num] == "Comodo") warp "comodo.gat", 207, 144;
  277. if (@wrpD$[@num] == "Izlude") warp "izlude.gat", 91, 105;
  278. if (@wrpD$[@num] == "Geffen") warp "geffen.gat", 120, 39;
  279. if (@wrpD$[@num] == "Morroc") warp "morocc.gat", 156, 46;
  280. if (@wrpD$[@num] == "Payon") warp "payon.gat", 168, 103;
  281. if (@wrpD$[@num] == "Prontera") warp "prontera.gat", 116, 72;
  282. if (@wrpD$[@num] == "Coal Mine(Dead Pit)") warp "mjolnir_02.gat", 82, 347;
  283. if (@wrpD$[@num] == "Comodo Pharos Lighthouse") warp "cmd_fild07.gat", 127, 134;
  284. if (@wrpD$[@num] == "Orc Dungeon") warp "gef_fild10.gat", 52, 326;
  285. if (@wrpD$[@num] == "Umbala") warp "umbala.gat", 130, 130;
  286. if (@wrpD$[@num] == "Yuno") warp "yuno.gat", 157, 123;
  287. cutin "", 255;
  288. end;
  289. }
  290. // Cart Function ========================================================
  291. function script F_KafCart {
  292. if(baseClass != Job_Merchant){
  293. mes "[Kafra]";
  294. mes "I'm sorry dear. The Cart service is only provided for the Merchant and Blacksmith Class.";
  295. return 1;
  296. }
  297. if(getskilllv(39)==0){
  298. mes "[Kafra]";
  299. mes "I'm sorry but you need the skill ^0000FF'Pushcart'^000000 to rent a cart.";
  300. return 1;
  301. }
  302. if(checkcart(0) == 1){
  303. mes "[Kafra]";
  304. mes "Excuse me... but you already have a cart....";
  305. emotion e_swt;
  306. return 1;
  307. }
  308. //get Cart in Guild for free
  309. if(getarg(0) == 2) goto L_FreeCart;
  310. //use Free Ticket for the Cart Service if available
  311. if(countitem(7061)){
  312. delitem 7061,1;
  313. goto L_FreeCart;
  314. }
  315. mes "[Kafra]";
  316. mes "The Cart Fee is 800 Zeny. Do you want to Rent a Cart?";
  317. next;
  318. menu "-Rent a Cart.",-, "-Cancel.",M_End;
  319. if(Zeny<800){
  320. mes "[Kafra]";
  321. mes "Dear, you don't have enough Money. You need 800 Zeny.";
  322. emotion e_cash;
  323. return 1;
  324. }
  325. set Zeny,Zeny-800;
  326. set RESRVPTS, RESRVPTS + 48;
  327. L_FreeCart:
  328. setcart;
  329. mes "[Kafra]";
  330. mes "Here is your cart.";
  331. return 1;
  332. M_End:
  333. return 0;
  334. }
  335. // Pass Function ===============================================================
  336. function script F_KafGuide {
  337. mes "[Kafra]";
  338. mes "WIP...";
  339. return;
  340. }
  341. // Special Reserve Points Function ===========================================
  342. function script F_KafInfo {
  343. sM_Menu:
  344. //Uncomment next line to block Kafra Storage Protection
  345. // if(getarg(0) == 0) menu "-Special Reserve Check",sM_ResChk, "-Kafra Locations",sM_KafLoc, "-Cancel",sM_End;
  346. if(getarg(0) == 0) menu "-Special Reserve Check",sM_ResChk, "-Storage Password Service",sM_KafCode, "-Kafra Locations",sM_KafLoc, "-Cancel",sM_End;
  347. sM_ResChk:
  348. mes "[Kafra]";
  349. mes "Here is your current amount of special reserve points:";
  350. mes "^0000ff"+RESRVPTS+"^000000.";
  351. next;
  352. mes "[Kafra]";
  353. mes "Remember to continue using Kafra services such as Storage and Teleport, to earn more special reserve points.";
  354. next;
  355. mes "[Kafra]";
  356. mes "You can trade them in at the Kafra Main Office in Al De Baran for useful items and cool prizes.";
  357. next;
  358. if(getarg(0) == 1) return;
  359. goto sM_Menu;
  360. sM_KafLoc:
  361. mes "[Kafra]";
  362. mes "The flashing signals on your mini-map point to the locations of all of the Kafra Agents in this city.";
  363. viewpoint 1,@viewpX[0],@viewpY[0],1,0xFF00FF;
  364. viewpoint 1,@viewpX[1],@viewpY[1],2,0xFF00FF;
  365. viewpoint 1,@viewpX[2],@viewpY[2],3,0xFF00FF;
  366. viewpoint 1,@viewpX[3],@viewpY[3],4,0xFF00FF;
  367. next;
  368. viewpoint 2,@viewpX[0],@viewpY[0],1,0xFF00FF;
  369. viewpoint 2,@viewpX[1],@viewpY[1],2,0xFF00FF;
  370. viewpoint 2,@viewpX[2],@viewpY[2],3,0xFF00FF;
  371. viewpoint 2,@viewpX[3],@viewpY[3],4,0xFF00FF;
  372. goto sM_Menu;
  373. sM_KafCode:
  374. callfunc("F_SetKafCode");
  375. sM_End:
  376. return;
  377. }
  378. // End Function =====================================================
  379. // arg(0): used to determine what message to display.
  380. // arg(1): used to determine if save message is displayed.
  381. //===================================================================
  382. function script F_KafEnd {
  383. mes "[Kafra]";
  384. if(getarg(1)==1) mes "Your respawn point has been saved."; // only shown when a player uses save
  385. if(getarg(0)!=1) mes "Thank you for using Kafra Services. We hope to see you again soon.";
  386. if(getarg(0)==1) mes "We, Kafra Corporation.... Will be with you.... whenever.... wherever... therefore.... please don't forget us.....";
  387. close2;
  388. cutin "", 255;
  389. emotion e_thx;
  390. close;
  391. end;
  392. }
  393. // Check Storage Password Function ====================
  394. function script F_CheckKafCode {
  395. if(#kafra_code==0) return;
  396. mes "Enter your storage password:";
  397. set @code_,0;
  398. input @code_;
  399. if(@code_ != #kafra_code-getcharid(3)-1337) {
  400. dispbottom "Wrong storage password.";
  401. close2;
  402. cutin "",255;
  403. end;
  404. }
  405. set @kafcode_try,0;
  406. set @code_,0;
  407. return;
  408. }
  409. // Set / Change / Clear Storage Password Function ====================
  410. function script F_SetKafCode 115,{
  411. mes "[Kafra]";
  412. if(#kafra_code) {
  413. mes "Your storage is protected with a password. What would you do now?";
  414. next;
  415. menu "Change old password -> 5000z",-,
  416. "Remove storage password -> 1000z",M_CLEAR,
  417. "Cancel",M_END;
  418. } else {
  419. mes "Kafra Services proudly presents you a new service:";
  420. mes "Additional storage protection with a password.";
  421. next;
  422. menu "Set new password -> 5000z",M_SET,
  423. "Cancel",M_END;
  424. }
  425. mes "[Kafra]";
  426. mes "At first, please enter your ^0000FFold password^000000.";
  427. set @code,callfunc("F_EntKafCode");
  428. if(@code==0 || @code != #kafra_code-getcharid(3)-1337) {
  429. mes "Wrong password. You can't set a new password.";
  430. emotion e_hmm;
  431. goto M_END;
  432. }
  433. next;
  434. M_SET:
  435. mes "[Kafra]";
  436. mes "Now enter your ^FF0000new password^000000 to protect your storage from thieves.";
  437. set @code,callfunc("F_EntKafCode");
  438. if(@code==0) {
  439. mes "The password hasn't been changed.";
  440. emotion e_hmm;
  441. goto M_END;
  442. }
  443. next;
  444. mes "[Kafra]";
  445. if(Zeny < 5000) goto L_ZENY;
  446. set Zeny,Zeny-5000;
  447. set RESRVPTS, RESRVPTS + (5000/50);
  448. set #kafra_code,@code+getcharid(3)+1337;
  449. mes "You've protected your storage with a secret password.";
  450. mes "Thank you for using Kafra Services.";
  451. emotion e_thx;
  452. goto M_END;
  453. M_CLEAR:
  454. mes "[Kafra]";
  455. mes "Please, enter your password before its removal.";
  456. set @code,callfunc("F_EntKafCode");
  457. if(@code==0) {
  458. mes "The password hasn't been removed.";
  459. emotion e_hmm;
  460. goto M_END;
  461. }
  462. next;
  463. mes "[Kafra]";
  464. if(Zeny < 1000) goto L_ZENY;
  465. set Zeny,Zeny-1000;
  466. set RESRVPTS, RESRVPTS + (1000/50);
  467. if(@code == #kafra_code-getcharid(3)-1337) {
  468. set #kafra_code,0;
  469. mes "You've successfully cleared your storage password.";
  470. mes "Thank you for using Kafra Services.";
  471. emotion e_thx;
  472. } else {
  473. mes "Wrong password. We won't return your 1000z.";
  474. mes "Please, next time enter correct password.";
  475. emotion e_sry;
  476. }
  477. goto M_END;
  478. L_ZENY:
  479. mes "You don't have enough zeny.";
  480. emotion e_cash;
  481. M_END:
  482. close2;
  483. cutin "",255;
  484. end;
  485. }
  486. // Basic Password Validation Function ====================
  487. function script F_EntKafCode {
  488. mes "Enter a number 1000~10000000:";
  489. set @code_,0;
  490. set @kafcode_try,@kafcode_try+1;
  491. if(@kafcode_try>10) {
  492. set @kafcode_try,0;
  493. logmes "Hack: Tried to fit storage password.";
  494. }
  495. input @code_;
  496. if(@code_<1000) {
  497. mes "You shouldn't use such short password.";
  498. return 0;
  499. }
  500. if(@code_>10000000) {
  501. mes "You can't use such big password.";
  502. return 0;
  503. }
  504. return @code_;
  505. }