functions_kafras.txt 19 KB

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