functions_kafras.txt 20 KB

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