functions_kafras.txt 16 KB

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