functions_kafras.txt 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. //===== eAthena Script =======================================
  2. //= Kafra Functions
  3. //===== By: ==================================================
  4. //= eAthena Dev Team
  5. //= Darlskies, Darkchild, Syrus22, Lupus, kobra_k88 (2.0)
  6. //= L0ne_W0lf
  7. //===== Current Version: =====================================
  8. //= 5.9
  9. //===== Compatible With: =====================================
  10. //= eAthena 1.0
  11. //===== Description: =========================================
  12. //= These functions handle save, storage, cart rental, teleport,
  13. //= and Free Teleport/Warp/Rent Cart options for all Kafra NPCs.
  14. //=
  15. //= Kafra's will need a lot of work. The Welcome Message argument
  16. //= may become obsolete, as most kafras have a slightly differing
  17. //= Welcome message.
  18. //===== Additional Comments: =================================
  19. //= v1.1 Now using functions v2.1 Added Cart Rent for Classes: Whitesmith, Professor.
  20. //= Replaced checkoption(x) into checkcart(0) [Lupus] v2.1b Added Fix Kafra Pass Func [Kobra_k88]
  21. //= 2.2 Final fix of the Kafra Pass Exploit! [Lupus] a -Izlude[4] fix
  22. //= 2.2a Minor changes to function calls. Using agruments. Added Guild options. [kobra_k88]
  23. //= 2.2b This version uses arrays for the teleport option. Rearranged next statements to make menu transitions smoother. [kobra_k88]
  24. //= 2.3 Removed SAVE from Niflheim. [Lupus]
  25. //= 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]
  26. //= 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]
  27. //= 2.5 Added Louyang official Kafra, fixes some Kafras, not letting you to Save your position [Lupus]
  28. //= 2.6 Reverted Dungeons Kafras (they should offer only Storage). Added temp Ayothaya Kafra
  29. //= 2.7 Added correct Ayothaya, Louyang & Amatsu Kafras. [Lupus]
  30. //= 2.8 Fixed Amatsu Storage problems [Lupus] 2.9 Fixed spelling mistakes. [Nexon]
  31. //= 3.0 Added special "not working teleport menu" for Einbroch Kafras [Lupus]
  32. //= 3.1 Removed callfunc Is_####_Class in favor of baseClass [Silentdragon]
  33. //= 3.2 Fixed an exploit [Lupus]
  34. //= 4.0 Added Kafra storage password protection. [Lupus]
  35. //= to block Kafra Password, read comments at 350 line
  36. //= Note: You can change '1337' value to another to raise password protection
  37. //= 5.0 Fixed the close2;....close; end; lines. Who let them slip away? =/ [erKURITA]
  38. //= Also, the kafra upon warp was giving back the zeny. Removed. [erKURITA]
  39. //= 5.1 Optimized a little, added no tele/save arg's [Evera]
  40. //= 5.1a Temporary? Added F_ClearGarbage to clear unused/outdated variables [Lupus]
  41. //= 5.2 By default commented out custom Guilds Kafra's "Guild Storage". [Lupus]
  42. //= 5.3 uncommented Guild Storage. Confirmed kRO feature. [Lupus]
  43. //= 5.4 added -Guide option (Kafra shows you nearest Guide) Work in progress.
  44. //= Need all coords for all guides.. and somehow pass their coords to kafra.
  45. //= Removed universal Kafra Pass, added 3 new Kafra Tickets [Lupus]
  46. //= 5.4b temporary moved "-Guide" from the 1st menu punct [Lupus]
  47. //= 5.5 Added proper Niflheim welcome message. [L0ne_W0lf]
  48. //= Cleaned up the menus a bit. Got rid of the proceeding "-" prefix.
  49. //= 5.5b Missed a preceeding hyphen, which was screwing up teleporting. [L0ne_W0lf]
  50. //= 5.6 Further dialog updates, added dynamic costs for cart and storage use. [L0ne_W0lf]
  51. //= Updated some functions to handle Guild Kafras the way they should.
  52. //= 5.6a Corrected a few wrong names in the teleport function. [L0ne_W0lf]
  53. //= 5.7 Correced end message no longer displaying, and the duplicate names [L0ne_W0lf]
  54. //= Thanks to Barron-Monster for pointing out the issues.
  55. //= 5.8 Fixed another double name being shown when "saving" [L0ne_W0lf]
  56. //= 5.9 Fixed the Kafra Welcome message for guilds. Thanks Barron-Monster. [L0ne_W0lf]
  57. //============================================================
  58. // Main Function ===========================================================
  59. //= arg(0): Used to determine which welcome message to show.
  60. //= arg(1): Used to determine which menu to display.
  61. //= arg(2): Used to determine if the info menu is shown in F_KafInfo.
  62. //= arg(3): Cost to use Storage
  63. //= arg(4): Cost to Rent a Pushcart
  64. //==========================================================================
  65. function script F_Kafra {
  66. callfunc "F_ClearGarbage"; //Clear outdated, unused variables
  67. //Display Kafra Welcome Message
  68. switch(getarg(0)){
  69. //Default message (obsolete)
  70. default:
  71. case 0:
  72. mes "[Kafra Employee]";
  73. mes "Welcome to the";
  74. mes "Kafra Corporartion.";
  75. mes "The Kafra services";
  76. mes "are always on your side.";
  77. mes "How may I assist you?";
  78. break;
  79. //Niflheim specific message
  80. case 1:
  81. mes "[Kafra Employee]";
  82. mes "^666666W-weeeelc-c-come";
  83. mes "to th-the K-kaaafrrrra";
  84. mes "C-coorpoor-r-ratioooonn...^000000";
  85. break;
  86. //Guild Castle Kafra message
  87. case 2:
  88. set @GID,getcharid(2);
  89. mes "[Kafra Employee]";
  90. mes "Welcome. ^ff0000" + GetGuildName(@GID) + "^000000 Member.";
  91. mes "The Kafra Coporation will stay with you wherever you go.";
  92. break;
  93. //Amatsu specific message (obsolete)
  94. case 3:
  95. mes "[Kafra Employee]";
  96. mes "So, have you come from a faraway land to study our culture, or are you just sightseeing?";
  97. mes "In either case, why not stay awhile?";
  98. mes "The air is eternally heavy with the";
  99. mes "scent of pleasant wildflowers.";
  100. break;
  101. //Louyang and Ayothaya specific message (obsolete)
  102. case 4:
  103. mes "[Kafra Employee]";
  104. mes "With our many Kafra";
  105. mes "service locations, you're never";
  106. mes "far from home.";
  107. break;
  108. //NPC has it's own welcome message. (Display nothing)
  109. case 5:
  110. break;
  111. }
  112. next;
  113. M_Menu:
  114. cleararray @K_Menu0$[0],"",7;
  115. switch(getarg(1)){
  116. // Save and Storage only
  117. case 1:
  118. setarray @K_Menu0$[0],"Save","Use Storage","Cancel";
  119. break;
  120. // Storage only
  121. case 2:
  122. setarray @K_Menu0$[0],"Use Storage","Cancel";
  123. break;
  124. // No Teleport (Common)
  125. case 3:
  126. setarray @K_Menu0$[0],"Save","Use Storage","Rent a Pushcart","Guide","Check Other Information","Cancel";
  127. break;
  128. // Case 4 is Einbroch no tele message.
  129. // No save, or teleport. (Common)
  130. case 5:
  131. setarray @K_Menu0$[0],"Use Storage","Rent a Pushcart","Check Other Information","Guide","Cancel";
  132. break;
  133. // Storage and Check Other Information only.
  134. case 6:
  135. setarray @K_Menu0$[0],"Use Storage","Guide","Check Other Information","Cancel";
  136. break;
  137. // Save, Storage, and Pushcart only (Kafra Warehouse)
  138. case 7:
  139. setarray @K_Menu0$[0],"Save","Use Storage","Rent a Pushcart","Cancel";
  140. break;
  141. // Common Kafra Employee
  142. default:
  143. setarray @K_Menu0$[0],"Save","Use Storage","Use Teleport Service","Rent a Pushcart","Guide","Check Other Information","Cancel";
  144. break;
  145. }
  146. // Guild Kafra Menu override (free Teleport, free Storage, Free Cart)
  147. if(getarg(0)==2) {
  148. cleararray @K_Menu0$[0],"",7;
  149. setarray @K_Menu0$[0],"Use Storage","Use Guild Storage","Rent a Pushcart","Use Teleport Service","Cancel";
  150. }
  151. menu @K_Menu0$[0],K_Menu0,@K_Menu0$[1],K_Menu1,@K_Menu0$[2],K_Menu2,
  152. @K_Menu0$[3],K_Menu3,@K_Menu0$[4],K_Menu4,@K_Menu0$[5],K_Menu5,
  153. @K_Menu0$[6],K_Menu6,@K_Menu0$[7],K_Menu7;
  154. K_Menu0:
  155. set @num,0;
  156. goto K_Menuf;
  157. K_Menu1:
  158. set @num,1;
  159. goto K_Menuf;
  160. K_Menu2:
  161. set @num,2;
  162. goto K_Menuf;
  163. K_Menu3:
  164. set @num,3;
  165. goto K_Menuf;
  166. K_Menu4:
  167. set @num,4;
  168. goto K_Menuf;
  169. K_Menu5:
  170. set @num,5;
  171. goto K_Menuf;
  172. K_Menu6:
  173. set @num,6;
  174. goto K_Menuf;
  175. K_Menu7:
  176. set @num,7;
  177. K_Menuf:
  178. if (@K_Menu0$[@num] == "Save") return;
  179. if (@K_Menu0$[@num] == "Use Storage"){
  180. // Do not charge for Guild Storage
  181. if(getarg(0) == 2) callfunc "F_KafStor",2,0,0;
  182. else callfunc "F_KafStor",0,getarg(3),getarg(0);
  183. next;
  184. goto M_Menu;
  185. }
  186. if (@K_Menu0$[@num] == "Use Teleport Service"){
  187. // Display Einbroch "No Teleport Service" notice.
  188. if(getarg(1) == 4){
  189. mes "[Kafra Employee]";
  190. mes "Because of the ^FF0000Limited";
  191. mes "Transport Agreement^000000, the";
  192. mes "Kafra Corporation cannot";
  193. mes "provide Teleport Services";
  194. mes "in the Schwaltzvalt Republic.";
  195. next;
  196. mes "[Kafra Employee]";
  197. mes "We ask that you please";
  198. mes "use the Airship Service";
  199. mes "instead. Thank you for your";
  200. mes "understanding and cooperation.";
  201. next;
  202. goto M_Menu;
  203. }
  204. callfunc "F_KafTele",getarg(0);
  205. goto M_Menu;
  206. }
  207. if (@K_Menu0$[@num] == "Rent a Pushcart"){
  208. if(callfunc("F_KafCart",getarg(0),getarg(4)) == 1) next;
  209. goto M_Menu;
  210. }
  211. if (@K_Menu0$[@num] == "Guide"){
  212. callfunc "F_KafGuide";
  213. next;
  214. goto M_Menu;
  215. }
  216. if (@K_Menu0$[@num] == "Check Other Information"){
  217. callfunc "F_KafInfo",getarg(2);
  218. goto M_Menu;
  219. }
  220. if (@K_Menu0$[@num] == "Cancel"){
  221. callfunc "F_KafEnd",getarg(0),0;
  222. end;
  223. }
  224. if (@K_Menu0$[@num] == "Use Guild Storage"){
  225. callfunc "F_KafStor",1,0;
  226. next;
  227. goto M_Menu;
  228. }
  229. }
  230. // Storage Function =======================================================
  231. function script F_KafStor {
  232. // Unable to access Guild Storage (Busy)
  233. if(getarg(0) == 1){
  234. if(guildopenstorage(0) == 1){
  235. mes "[Kafra Employee]";
  236. mes "I'm sorry but another guild member is using the guild storage";
  237. mes "right now. Please wait until that person is finished.";
  238. close2;
  239. cutin "", 255;
  240. end;
  241. }
  242. cutin "", 255;
  243. close;
  244. }
  245. // Unable to access Normal Storage (Insufficient Basic Skills)
  246. if(basicskillcheck() && getskilllv(1) < 6){
  247. mes "[Kafra Employee]";
  248. // Niflheim Specific Message
  249. if (getarg(2) == 1) {
  250. mes "^666666S-s-ssoooorry,";
  251. mes "y-you're a-a-aaaa";
  252. mes "Nooviiice... N-neeeds";
  253. mes "B-basic sssskill l-level 6...^000000";
  254. return;
  255. }
  256. mes "I'm sorry, but you";
  257. mes "need the Novice's";
  258. mes "Basic Skill Level 6 to";
  259. mes "use the Storage Service.";
  260. return;
  261. }
  262. // Accessing Normal Storage (Skipped if accessing Storage from Guild castle)
  263. if(getarg(0) != 2){
  264. // Consume "Free Ticket for Kafra Storage" if available.
  265. if(countitem(7059)) delitem 7059,1;
  266. else {
  267. if(Zeny<getarg(1)){
  268. mes "[Kafra Employee]";
  269. // Niflheim Specific Message
  270. if (getarg(2) == 1) {
  271. percentheal -50,-50;
  272. mes "^666666Zeeeeeny...";
  273. mes "M-more z-zeny...!";
  274. mes "N-neeed 150... zeny...";
  275. mes "Ergh! T-taking bl-blood~!^000000";
  276. return;
  277. }
  278. //Standard Message
  279. mes "I'm sorry, but you don't";
  280. mes "have enough zeny to use";
  281. mes "the Storage Service. Our";
  282. mes "Storage access fee is "+getarg(1)+" zeny.";
  283. return;
  284. }
  285. set Zeny, Zeny-getarg(1);
  286. set RESRVPTS, RESRVPTS + (getarg(1)/5);
  287. }
  288. }
  289. // Surpress the "End" message if in guild castle.
  290. if (getarg(0) != 2) {
  291. // Niflheim specific Message
  292. if (getarg(2) == 1) {
  293. percentheal 0,-10;
  294. mes "[Kafra Employee]";
  295. mes "^666666Thank you.. for... using...";
  296. mes "Thank you.. for... using...";
  297. mes "Thank you.. for... using...";
  298. mes "Thank you.. for... using...";
  299. mes "Thank you.. for... using...^000000";
  300. }
  301. // Normal message
  302. else {
  303. mes "[Kafra Employee]";
  304. mes "Here, let me open";
  305. mes "your Storage for you.";
  306. mes "Thank you for using";
  307. mes "the Kafra Service.";
  308. }
  309. }
  310. callfunc("F_CheckKafCode"); //check your storage password, if set
  311. close2;
  312. openstorage;
  313. cutin "", 255;
  314. end;
  315. }
  316. // Teleport Function ==================================================
  317. function script F_KafTele {
  318. mes "[Kafra Employee]";
  319. mes "Please choose";
  320. mes "your destination.";
  321. next;
  322. menu @wrpC$[0],M_Wrp0, @wrpC$[1],M_Wrp1, @wrpC$[2],M_Wrp2, @wrpC$[3],M_Wrp3,
  323. @wrpC$[4],M_Wrp4, @wrpC$[5],M_Wrp5, @wrpC$[6],M_Wrp6;
  324. M_Wrp0:
  325. set @num, 0;
  326. goto L_Warp;
  327. M_Wrp1:
  328. set @num, 1;
  329. goto L_Warp;
  330. M_Wrp2:
  331. set @num, 2;
  332. goto L_Warp;
  333. M_Wrp3:
  334. set @num, 3;
  335. goto L_Warp;
  336. M_Wrp4:
  337. set @num, 4;
  338. goto L_Warp;
  339. M_Wrp5:
  340. set @num, 5;
  341. goto L_Warp;
  342. M_Wrp6:
  343. set @num, 6;
  344. L_Warp:
  345. if (@wrpC$[@num] == "Cancel") return;
  346. // Consume "Free Ticket for Kafra Transportation" if available.
  347. // Do not consume if in Guild castle
  348. if(countitem(7060) > 0 && getarg(0) != 2) delitem 7060,1;
  349. else {
  350. if (Zeny<@wrpP[@num]){
  351. mes "[Kafra Employee]";
  352. mes "I'm sorry, but you don't have";
  353. mes "enough zeny for the Teleport";
  354. mes "Service. The fee to teleport";
  355. mes "to "+@wrpD$[@num]+" is "+@wrpP[@num]+" zeny.";
  356. close2;
  357. cutin "", 255;
  358. end;
  359. }
  360. set Zeny, Zeny-@wrpP[@num];
  361. set RESRVPTS, RESRVPTS + (@wrpP[@num]/16);
  362. }
  363. if (@wrpD$[@num] == "Alberta") warp "alberta", 117, 56;
  364. if (@wrpD$[@num] == "Al De Baran") warp "aldebaran",143,110;
  365. if (@wrpD$[@num] == "Aldebaran") warp "aldebaran",143,110;
  366. if (@wrpD$[@num] == "Comodo") warp "comodo", 207, 144;
  367. if (@wrpD$[@num] == "Izlude") warp "izlude", 91, 105;
  368. if (@wrpD$[@num] == "Geffen") warp "geffen", 120, 39;
  369. if (@wrpD$[@num] == "Morroc") warp "morocc", 156, 46;
  370. if (@wrpD$[@num] == "Payon") warp "payon", 168, 103;
  371. if (@wrpD$[@num] == "Prontera") warp "prontera", 116, 72;
  372. if (@wrpD$[@num] == "Mjolnir Dead Pit") warp "mjolnir_02", 82, 347;
  373. if (@wrpD$[@num] == "Comodo Pharos Beacon") warp "cmd_fild07", 127, 134;
  374. if (@wrpD$[@num] == "Orc Dungeon") warp "gef_fild10", 52, 326;
  375. if (@wrpD$[@num] == "Umbala") warp "umbala", 130, 130;
  376. if (@wrpD$[@num] == "Juno") warp "yuno", 157, 123;
  377. cutin "", 255;
  378. end;
  379. }
  380. // Cart Function ========================================================
  381. function script F_KafCart {
  382. // Ensure that the class wanting to rent a pushcart is a merchant
  383. if(baseClass != Job_Merchant){
  384. mes "[Kafra Employee]";
  385. mes "I'm sorry, but the";
  386. mes "Pushcart rental service";
  387. mes "is only available to Merchants,";
  388. mes "Blacksmiths, Master Smiths,";
  389. mes "Alchemists and Biochemists.";
  390. return 1;
  391. }
  392. // Make sure the invoking character does not have a cart already
  393. else if(checkcart() == 1){
  394. mes "[Kafra Employee]";
  395. mes "You already have";
  396. mes "a Pushcart equipped.";
  397. mes "Unfortunately, we can't";
  398. mes "rent more than one to";
  399. mes "each customer at a time.";
  400. return 1;
  401. }
  402. // Consume "Free Ticket for the Cart Service" if available.
  403. // Do not consume if in Guild castle.
  404. if(countitem(7061) > 0 && getarg(0) != 2) delitem 7061,1;
  405. else {
  406. mes "[Kafra Employee]";
  407. mes "The Pushcart rental";
  408. mes "fee is "+getarg(1)+" zeny. Would";
  409. mes "you like to rent a Pushcart?";
  410. next;
  411. menu "Rent a Pushcart.",-, "Cancel.",M_End;
  412. if(Zeny<getarg(1)){
  413. mes "[Kafra Employee]";
  414. mes "I'm sorry, but you";
  415. mes "don't have enough";
  416. mes "zeny to pay the Pushcart";
  417. mes "rental fee of "+getarg(1)+" zeny.";
  418. return 1;
  419. }
  420. set Zeny,Zeny-getarg(1);
  421. set RESRVPTS, RESRVPTS + 48;
  422. }
  423. setcart;
  424. return 1;
  425. M_End:
  426. return 0;
  427. }
  428. // Pass Function ===============================================================
  429. function script F_KafGuide {
  430. mes "[Kafra Employee]";
  431. mes "WIP...";
  432. return;
  433. }
  434. // Special Reserve Points Function ===========================================
  435. function script F_KafInfo {
  436. sM_Menu:
  437. //Uncomment next line to block Kafra Storage Protection
  438. // if(getarg(0) == 0) menu "Check Special Reserve Points.",sM_ResChk, "Kafra Employee Locations",sM_KafLoc, "Cancel",sM_End;
  439. if(getarg(0) == 0) menu "Check Special Reserve Points.",sM_ResChk, "Storage Password Service",sM_KafCode, "Kafra Employee Locations",sM_KafLoc, "Cancel",sM_End;
  440. sM_ResChk:
  441. mes "[Kafra Employee]";
  442. mes "Let's see...";
  443. mes strcharinfo(0) + "...";
  444. mes "Ah, you have a total of";
  445. mes RESRVPTS+ " Special Reserve Points.";
  446. next;
  447. mes "[Kafra Employee]";
  448. mes "You can exchange your";
  449. mes "Special Reserve Points for";
  450. mes "rewards at the Kafra Main Office in Al De Baran. Please use our";
  451. mes "convenient services to see the benefits of our rewards program.";
  452. next;
  453. if(getarg(0) == 1) return;
  454. goto sM_Menu;
  455. sM_KafLoc:
  456. viewpoint 1,@viewpX[0],@viewpY[0],1,0xFF00FF;
  457. viewpoint 1,@viewpX[1],@viewpY[1],2,0xFF00FF;
  458. viewpoint 1,@viewpX[2],@viewpY[2],3,0xFF00FF;
  459. viewpoint 1,@viewpX[3],@viewpY[3],4,0xFF00FF;
  460. next;
  461. viewpoint 2,@viewpX[0],@viewpY[0],1,0xFF00FF;
  462. viewpoint 2,@viewpX[1],@viewpY[1],2,0xFF00FF;
  463. viewpoint 2,@viewpX[2],@viewpY[2],3,0xFF00FF;
  464. viewpoint 2,@viewpX[3],@viewpY[3],4,0xFF00FF;
  465. goto sM_Menu;
  466. sM_KafCode:
  467. callfunc("F_SetKafCode");
  468. sM_End:
  469. return;
  470. }
  471. // End Function =====================================================
  472. // arg(0): used to determine what message to display.
  473. // arg(1): used to determine if save message is displayed.
  474. // arg(2): used to display the name of the area you're saving in.
  475. //===================================================================
  476. function script F_KafEnd {
  477. mes "[Kafra Employee]";
  478. //Save
  479. if(getarg(1)==1) {
  480. mes "Your Respawn Point";
  481. mes "has been saved here";
  482. mes getarg(2)+".";
  483. mes "Thank you for using";
  484. mes "the Kafra Services.";
  485. }
  486. // Generic End
  487. else if(getarg(0)==0 || getarg(0)==5) {
  488. mes "We, here at Kafra Corporation,";
  489. mes "are always endeavoring to provide you with the best services. We hope that we meet your adventuring needs and standards of excellence.";
  490. }
  491. // Niflheim End
  492. else if(getarg(0)==1) {
  493. percentheal 0,- 25;
  494. mes "^666666Kaffffra n-never";
  495. mes "diiiiiiiiiiiiiies. On...";
  496. mes "On y-yooour siiiiide~^000000";
  497. }
  498. close2;
  499. cutin "", 255;
  500. end;
  501. }
  502. // Check Storage Password Function ====================
  503. function script F_CheckKafCode {
  504. if(#kafra_code==0) return;
  505. mes "Enter your storage password:";
  506. set @code_,0;
  507. input @code_;
  508. if(@code_ != #kafra_code-getcharid(3)-1337) {
  509. dispbottom "Wrong storage password.";
  510. close2;
  511. cutin "",255;
  512. end;
  513. }
  514. set @kafcode_try,0;
  515. set @code_,0;
  516. return;
  517. }
  518. // Set / Change / Clear Storage Password Function ====================
  519. function script F_SetKafCode {
  520. mes "[Kafra Employee]";
  521. if(#kafra_code) {
  522. mes "Your storage is protected with a password. What would you do now?";
  523. next;
  524. menu "Change old password -> 5000z",-,
  525. "Remove storage password -> 1000z",M_CLEAR,
  526. "Cancel",M_END;
  527. } else {
  528. mes "Kafra Services proudly presents you a new service:";
  529. mes "Additional storage protection with a password.";
  530. next;
  531. menu "Set new password -> 5000z",M_SET,
  532. "Cancel",M_END;
  533. }
  534. mes "[Kafra Employee]";
  535. mes "At first, please enter your ^0000FFold password^000000.";
  536. set @code,callfunc("F_EntKafCode");
  537. if(@code==0 || @code != #kafra_code-getcharid(3)-1337) {
  538. mes "Wrong password. You can't set a new password.";
  539. emotion e_hmm;
  540. goto M_END;
  541. }
  542. next;
  543. M_SET:
  544. mes "[Kafra Employee]";
  545. mes "Now enter your ^FF0000new password^000000 to protect your storage from thieves.";
  546. set @code,callfunc("F_EntKafCode");
  547. if(@code==0) {
  548. mes "The password hasn't been changed.";
  549. emotion e_hmm;
  550. goto M_END;
  551. }
  552. next;
  553. mes "[Kafra Employee]";
  554. if(Zeny < 5000) goto L_ZENY;
  555. set Zeny,Zeny-5000;
  556. set RESRVPTS, RESRVPTS + (5000/50);
  557. set #kafra_code,@code+getcharid(3)+1337;
  558. mes "You've protected your storage with a secret password.";
  559. mes "Thank you for using Kafra Services.";
  560. emotion e_thx;
  561. goto M_END;
  562. M_CLEAR:
  563. mes "[Kafra Employee]";
  564. mes "Please, enter your password before its removal.";
  565. set @code,callfunc("F_EntKafCode");
  566. if(@code==0) {
  567. mes "The password hasn't been removed.";
  568. emotion e_hmm;
  569. goto M_END;
  570. }
  571. next;
  572. mes "[Kafra Employee]";
  573. if(Zeny < 1000) goto L_ZENY;
  574. set Zeny,Zeny-1000;
  575. set RESRVPTS, RESRVPTS + (1000/50);
  576. if(@code == #kafra_code-getcharid(3)-1337) {
  577. set #kafra_code,0;
  578. mes "You've successfully cleared your storage password.";
  579. mes "Thank you for using Kafra Services.";
  580. emotion e_thx;
  581. } else {
  582. mes "Wrong password. We won't return your 1000z.";
  583. mes "Please, next time enter correct password.";
  584. emotion e_sry;
  585. }
  586. goto M_END;
  587. L_ZENY:
  588. mes "You don't have enough zeny.";
  589. emotion e_cash;
  590. M_END:
  591. close2;
  592. cutin "",255;
  593. end;
  594. }
  595. // Basic Password Validation Function ====================
  596. function script F_EntKafCode {
  597. mes "Enter a number 1000~10000000:";
  598. set @code_,0;
  599. set @kafcode_try,@kafcode_try+1;
  600. if(@kafcode_try>10) {
  601. set @kafcode_try,0;
  602. logmes "Hack: Tried to fit storage password.";
  603. }
  604. input @code_;
  605. if(@code_<1000) {
  606. mes "You shouldn't use such short password.";
  607. return 0;
  608. }
  609. if(@code_>10000000) {
  610. mes "You can't use such big password.";
  611. return 0;
  612. }
  613. return @code_;
  614. }