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.7
  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. //============================================================
  56. // Main Function ===========================================================
  57. //= arg(0): Used to determine which welcome message to show.
  58. //= arg(1): Used to determine which menu to display.
  59. //= arg(2): Used to determine if the info menu is shown in F_KafInfo.
  60. //= arg(3): Cost to use Storage
  61. //= arg(4): Cost to Rent a Pushcart
  62. //==========================================================================
  63. function script F_Kafra {
  64. callfunc "F_ClearGarbage"; //Clear outdated, unused variables
  65. //Display Kafra Welcome Message
  66. switch(getarg(0)){
  67. //Default message (obsolete)
  68. default:
  69. case 0:
  70. mes "[Kafra Employee]";
  71. mes "Welcome to the";
  72. mes "Kafra Corporartion.";
  73. mes "The Kafra services";
  74. mes "are always on your side.";
  75. mes "How may I assist you?";
  76. break;
  77. //Niflheim specific message
  78. case 1:
  79. mes "[Kafra Employee]";
  80. mes "^666666W-weeeelc-c-come";
  81. mes "to th-the K-kaaafrrrra";
  82. mes "C-coorpoor-r-ratioooonn...^000000";
  83. break;
  84. //Guild Castle Kafra message
  85. case 2:
  86. mes "[Kafra Employee]";
  87. mes "Welcome. ^ff0000" + GetGuildName(@GID) + "^000000 Member.";
  88. mes "The Kafra Coporation will stay with you wherever you go.";
  89. break;
  90. //Amatsu specific message (obsolete)
  91. case 3:
  92. mes "[Kafra Employee]";
  93. mes "So, have you come from a faraway land to study our culture, or are you just sightseeing?";
  94. mes "In either case, why not stay awhile?";
  95. mes "The air is eternally heavy with the";
  96. mes "scent of pleasant wildflowers.";
  97. break;
  98. //Louyang and Ayothaya specific message (obsolete)
  99. case 4:
  100. mes "[Kafra Employee]";
  101. mes "With our many Kafra";
  102. mes "service locations, you're never";
  103. mes "far from home.";
  104. break;
  105. //NPC has it's own welcome message. (Display nothing)
  106. case 5:
  107. break;
  108. }
  109. next;
  110. M_Menu:
  111. cleararray @K_Menu0$[0],"",7;
  112. switch(getarg(1)){
  113. // Save and Storage only
  114. case 1:
  115. setarray @K_Menu0$[0],"Save","Use Storage","Cancel";
  116. break;
  117. // Storage only
  118. case 2:
  119. setarray @K_Menu0$[0],"Use Storage","Cancel";
  120. break;
  121. // No Teleport (Common)
  122. case 3:
  123. setarray @K_Menu0$[0],"Save","Use Storage","Rent a Pushcart","Guide","Check Other Information","Cancel";
  124. break;
  125. // Case 4 is Einbroch no tele message.
  126. // No save, or teleport. (Common)
  127. case 5:
  128. setarray @K_Menu0$[0],"Use Storage","Rent a Pushcart","Check Other Information","Guide","Cancel";
  129. break;
  130. // Storage and Check Other Information only.
  131. case 6:
  132. setarray @K_Menu0$[0],"Use Storage","Guide","Check Other Information","Cancel";
  133. break;
  134. // Save, Storage, and Pushcart only (Kafra Warehouse)
  135. case 7:
  136. setarray @K_Menu0$[0],"Save","Use Storage","Rent a Pushcart","Cancel";
  137. break;
  138. // Common Kafra Employee
  139. default:
  140. setarray @K_Menu0$[0],"Save","Use Storage","Use Teleport Service","Rent a Pushcart","Guide","Check Other Information","Cancel";
  141. break;
  142. }
  143. // Guild Kafra Menu override (free Teleport, free Storage, Free Cart)
  144. if(getarg(0)==2) {
  145. cleararray @K_Menu0$[0],"",7;
  146. setarray @K_Menu0$[0],"Use Storage","Use Guild Storage","Rent a Pushcart","Use Teleport Service","Cancel";
  147. }
  148. menu @K_Menu0$[0],K_Menu0,@K_Menu0$[1],K_Menu1,@K_Menu0$[2],K_Menu2,
  149. @K_Menu0$[3],K_Menu3,@K_Menu0$[4],K_Menu4,@K_Menu0$[5],K_Menu5,
  150. @K_Menu0$[6],K_Menu6,@K_Menu0$[7],K_Menu7;
  151. K_Menu0:
  152. set @num,0;
  153. goto K_Menuf;
  154. K_Menu1:
  155. set @num,1;
  156. goto K_Menuf;
  157. K_Menu2:
  158. set @num,2;
  159. goto K_Menuf;
  160. K_Menu3:
  161. set @num,3;
  162. goto K_Menuf;
  163. K_Menu4:
  164. set @num,4;
  165. goto K_Menuf;
  166. K_Menu5:
  167. set @num,5;
  168. goto K_Menuf;
  169. K_Menu6:
  170. set @num,6;
  171. goto K_Menuf;
  172. K_Menu7:
  173. set @num,7;
  174. K_Menuf:
  175. if (@K_Menu0$[@num] == "Save") return;
  176. if (@K_Menu0$[@num] == "Use Storage"){
  177. // Do not charge for Guild Storage
  178. if(getarg(0) == 2) callfunc "F_KafStor",2,0,0;
  179. else callfunc "F_KafStor",0,getarg(3),getarg(0);
  180. next;
  181. goto M_Menu;
  182. }
  183. if (@K_Menu0$[@num] == "Use Teleport Service"){
  184. // Display Einbroch "No Teleport Service" notice.
  185. if(getarg(1) == 4){
  186. mes "[Kafra Employee]";
  187. mes "Because of the ^FF0000Limited";
  188. mes "Transport Agreement^000000, the";
  189. mes "Kafra Corporation cannot";
  190. mes "provide Teleport Services";
  191. mes "in the Schwaltzvalt Republic.";
  192. next;
  193. mes "[Kafra Employee]";
  194. mes "We ask that you please";
  195. mes "use the Airship Service";
  196. mes "instead. Thank you for your";
  197. mes "understanding and cooperation.";
  198. next;
  199. goto M_Menu;
  200. }
  201. callfunc "F_KafTele",getarg(0);
  202. goto M_Menu;
  203. }
  204. if (@K_Menu0$[@num] == "Rent a Pushcart"){
  205. if(callfunc("F_KafCart",getarg(0),getarg(4)) == 1) next;
  206. goto M_Menu;
  207. }
  208. if (@K_Menu0$[@num] == "Guide"){
  209. callfunc "F_KafGuide";
  210. next;
  211. goto M_Menu;
  212. }
  213. if (@K_Menu0$[@num] == "Check Other Information"){
  214. callfunc "F_KafInfo",getarg(2);
  215. goto M_Menu;
  216. }
  217. if (@K_Menu0$[@num] == "Cancel"){
  218. callfunc "F_KafEnd",getarg(0),0;
  219. end;
  220. }
  221. if (@K_Menu0$[@num] == "Use Guild Storage"){
  222. callfunc "F_KafStor",1,0;
  223. next;
  224. goto M_Menu;
  225. }
  226. }
  227. // Storage Function =======================================================
  228. function script F_KafStor {
  229. // Unable to access Guild Storage (Busy)
  230. if(getarg(0) == 1){
  231. if(guildopenstorage(0) == 1){
  232. mes "[Kafra Employee]";
  233. mes "I'm sorry but another guild member is using the guild storage";
  234. mes "right now. Please wait until that person is finished.";
  235. close2;
  236. cutin "", 255;
  237. end;
  238. }
  239. cutin "", 255;
  240. close;
  241. }
  242. // Unable to access Normal Storage (Insufficient Basic Skills)
  243. if(basicskillcheck() && getskilllv(1) < 6){
  244. mes "[Kafra Employee]";
  245. // Niflheim Specific Message
  246. if (getarg(2) == 1) {
  247. mes "^666666S-s-ssoooorry,";
  248. mes "y-you're a-a-aaaa";
  249. mes "Nooviiice... N-neeeds";
  250. mes "B-basic sssskill l-level 6...^000000";
  251. return;
  252. }
  253. mes "I'm sorry, but you";
  254. mes "need the Novice's";
  255. mes "Basic Skill Level 6 to";
  256. mes "use the Storage Service.";
  257. return;
  258. }
  259. // Accessing Normal Storage (Skipped if accessing Storage from Guild castle)
  260. if(getarg(0) != 2){
  261. // Consume "Free Ticket for Kafra Storage" if available.
  262. if(countitem(7059)) delitem 7059,1;
  263. else {
  264. if(Zeny<getarg(1)){
  265. mes "[Kafra Employee]";
  266. // Niflheim Specific Message
  267. if (getarg(2) == 1) {
  268. percentheal -50,-50;
  269. mes "^666666Zeeeeeny...";
  270. mes "M-more z-zeny...!";
  271. mes "N-neeed 150... zeny...";
  272. mes "Ergh! T-taking bl-blood~!^000000";
  273. return;
  274. }
  275. //Standard Message
  276. mes "I'm sorry, but you don't";
  277. mes "have enough zeny to use";
  278. mes "the Storage Service. Our";
  279. mes "Storage access fee is "+getarg(1)+" zeny.";
  280. return;
  281. }
  282. set Zeny, Zeny-getarg(1);
  283. set RESRVPTS, RESRVPTS + (getarg(1)/5);
  284. }
  285. }
  286. // Surpress the "End" message if in guild castle.
  287. if (getarg(0) != 2) {
  288. // Niflheim specific Message
  289. if (getarg(2) == 1) {
  290. percentheal 0,-10;
  291. mes "[Kafra Employee]";
  292. mes "^666666Thank you.. for... using...";
  293. mes "Thank you.. for... using...";
  294. mes "Thank you.. for... using...";
  295. mes "Thank you.. for... using...";
  296. mes "Thank you.. for... using...^000000";
  297. }
  298. // Normal message
  299. else {
  300. mes "[Kafra Employee]";
  301. mes "Here, let me open";
  302. mes "your Storage for you.";
  303. mes "Thank you for using";
  304. mes "the Kafra Service.";
  305. }
  306. }
  307. callfunc("F_CheckKafCode"); //check your storage password, if set
  308. close2;
  309. openstorage;
  310. cutin "", 255;
  311. end;
  312. }
  313. // Teleport Function ==================================================
  314. function script F_KafTele {
  315. mes "[Kafra Employee]";
  316. mes "Please choose";
  317. mes "your destination.";
  318. next;
  319. menu @wrpC$[0],M_Wrp0, @wrpC$[1],M_Wrp1, @wrpC$[2],M_Wrp2, @wrpC$[3],M_Wrp3,
  320. @wrpC$[4],M_Wrp4, @wrpC$[5],M_Wrp5, @wrpC$[6],M_Wrp6;
  321. M_Wrp0:
  322. set @num, 0;
  323. goto L_Warp;
  324. M_Wrp1:
  325. set @num, 1;
  326. goto L_Warp;
  327. M_Wrp2:
  328. set @num, 2;
  329. goto L_Warp;
  330. M_Wrp3:
  331. set @num, 3;
  332. goto L_Warp;
  333. M_Wrp4:
  334. set @num, 4;
  335. goto L_Warp;
  336. M_Wrp5:
  337. set @num, 5;
  338. goto L_Warp;
  339. M_Wrp6:
  340. set @num, 6;
  341. L_Warp:
  342. if (@wrpC$[@num] == "Cancel") return;
  343. // Consume "Free Ticket for Kafra Transportation" if available.
  344. // Do not consume if in Guild castle
  345. if(countitem(7060) > 0 && getarg(0) != 2) delitem 7060,1;
  346. else {
  347. if (Zeny<@wrpP[@num]){
  348. mes "[Kafra Employee]";
  349. mes "I'm sorry, but you don't have";
  350. mes "enough zeny for the Teleport";
  351. mes "Service. The fee to teleport";
  352. mes "to "+@wrpD$[@num]+" is "+@wrpP[@num]+" zeny.";
  353. close2;
  354. cutin "", 255;
  355. end;
  356. }
  357. set Zeny, Zeny-@wrpP[@num];
  358. set RESRVPTS, RESRVPTS + (@wrpP[@num]/16);
  359. }
  360. if (@wrpD$[@num] == "Alberta") warp "alberta", 117, 56;
  361. if (@wrpD$[@num] == "Al De Baran") warp "aldebaran",143,110;
  362. if (@wrpD$[@num] == "Aldebaran") warp "aldebaran",143,110;
  363. if (@wrpD$[@num] == "Comodo") warp "comodo", 207, 144;
  364. if (@wrpD$[@num] == "Izlude") warp "izlude", 91, 105;
  365. if (@wrpD$[@num] == "Geffen") warp "geffen", 120, 39;
  366. if (@wrpD$[@num] == "Morroc") warp "morocc", 156, 46;
  367. if (@wrpD$[@num] == "Payon") warp "payon", 168, 103;
  368. if (@wrpD$[@num] == "Prontera") warp "prontera", 116, 72;
  369. if (@wrpD$[@num] == "Mjolnir Dead Pit") warp "mjolnir_02", 82, 347;
  370. if (@wrpD$[@num] == "Comodo Pharos Beacon") warp "cmd_fild07", 127, 134;
  371. if (@wrpD$[@num] == "Orc Dungeon") warp "gef_fild10", 52, 326;
  372. if (@wrpD$[@num] == "Umbala") warp "umbala", 130, 130;
  373. if (@wrpD$[@num] == "Juno") warp "yuno", 157, 123;
  374. cutin "", 255;
  375. end;
  376. }
  377. // Cart Function ========================================================
  378. function script F_KafCart {
  379. // Ensure that the class wanting to rent a pushcart is a merchant
  380. if(baseClass != Job_Merchant){
  381. mes "[Kafra Employee]";
  382. mes "I'm sorry, but the";
  383. mes "Pushcart rental service";
  384. mes "is only available to Merchants,";
  385. mes "Blacksmiths, Master Smiths,";
  386. mes "Alchemists and Biochemists.";
  387. return 1;
  388. }
  389. // Make sure the invoking character does not have a cart already
  390. else if(checkcart() == 1){
  391. mes "[Kafra Employee]";
  392. mes "You already have";
  393. mes "a Pushcart equipped.";
  394. mes "Unfortunately, we can't";
  395. mes "rent more than one to";
  396. mes "each customer at a time.";
  397. return 1;
  398. }
  399. // Consume "Free Ticket for the Cart Service" if available.
  400. // Do not consume if in Guild castle.
  401. if(countitem(7061) > 0 && getarg(0) != 2) delitem 7061,1;
  402. else {
  403. mes "[Kafra Employee]";
  404. mes "The Pushcart rental";
  405. mes "fee is "+getarg(1)+" zeny. Would";
  406. mes "you like to rent a Pushcart?";
  407. next;
  408. menu "Rent a Pushcart.",-, "Cancel.",M_End;
  409. if(Zeny<getarg(1)){
  410. mes "[Kafra Employee]";
  411. mes "I'm sorry, but you";
  412. mes "don't have enough";
  413. mes "zeny to pay the Pushcart";
  414. mes "rental fee of "+getarg(1)+" zeny.";
  415. return 1;
  416. }
  417. set Zeny,Zeny-getarg(1);
  418. set RESRVPTS, RESRVPTS + 48;
  419. }
  420. setcart;
  421. return 1;
  422. M_End:
  423. return 0;
  424. }
  425. // Pass Function ===============================================================
  426. function script F_KafGuide {
  427. mes "[Kafra Employee]";
  428. mes "WIP...";
  429. return;
  430. }
  431. // Special Reserve Points Function ===========================================
  432. function script F_KafInfo {
  433. sM_Menu:
  434. //Uncomment next line to block Kafra Storage Protection
  435. // if(getarg(0) == 0) menu "Check Special Reserve Points.",sM_ResChk, "Kafra Employee Locations",sM_KafLoc, "Cancel",sM_End;
  436. if(getarg(0) == 0) menu "Check Special Reserve Points.",sM_ResChk, "Storage Password Service",sM_KafCode, "Kafra Employee Locations",sM_KafLoc, "Cancel",sM_End;
  437. sM_ResChk:
  438. mes "[Kafra Employee]";
  439. mes "Let's see...";
  440. mes strcharinfo(0) + "...";
  441. mes "Ah, you have a total of";
  442. mes RESRVPTS+ " Special Reserve Points.";
  443. next;
  444. mes "[Kafra Employee]";
  445. mes "You can exchange your";
  446. mes "Special Reserve Points for";
  447. mes "rewards at the Kafra Main Office in Al De Baran. Please use our";
  448. mes "convenient services to see the benefits of our rewards program.";
  449. next;
  450. if(getarg(0) == 1) return;
  451. goto sM_Menu;
  452. sM_KafLoc:
  453. viewpoint 1,@viewpX[0],@viewpY[0],1,0xFF00FF;
  454. viewpoint 1,@viewpX[1],@viewpY[1],2,0xFF00FF;
  455. viewpoint 1,@viewpX[2],@viewpY[2],3,0xFF00FF;
  456. viewpoint 1,@viewpX[3],@viewpY[3],4,0xFF00FF;
  457. next;
  458. viewpoint 2,@viewpX[0],@viewpY[0],1,0xFF00FF;
  459. viewpoint 2,@viewpX[1],@viewpY[1],2,0xFF00FF;
  460. viewpoint 2,@viewpX[2],@viewpY[2],3,0xFF00FF;
  461. viewpoint 2,@viewpX[3],@viewpY[3],4,0xFF00FF;
  462. goto sM_Menu;
  463. sM_KafCode:
  464. callfunc("F_SetKafCode");
  465. sM_End:
  466. return;
  467. }
  468. // End Function =====================================================
  469. // arg(0): used to determine what message to display.
  470. // arg(1): used to determine if save message is displayed.
  471. // arg(2): used to display the name of the area you're saving in.
  472. //===================================================================
  473. function script F_KafEnd {
  474. mes "[Kafra Employee]";
  475. //Save
  476. if(getarg(1)==1) {
  477. mes "[Kafra Employee]";
  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. }