functions_kafras.txt 19 KB

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