functions_kafras.txt 20 KB

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