Global_Functions.txt 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. //===== eAthena Script =======================================
  2. //= Global Functions
  3. //===== By: ==================================================
  4. //= Lupus, kobra_k88
  5. //===== Current Version: =====================================
  6. //= 2.13
  7. //===== Compatible With: =====================================
  8. //= eAthena 1.0
  9. //===== Description: =========================================
  10. //= <Description>
  11. //===== Additional Comments: =================================
  12. //= Added F_ClearJobVar - on getting a new job it clears all Job Quest variables
  13. //= Removed individual job check functions as they were redundant [kobra_k88]
  14. //= 1.3 Added Job Change Function for Baby/Normal Classes
  15. //= 1.3b a fix, due to const.txt change [Lupus]
  16. //= 1.4 Added Is_Taekwon_Class: Taekwondo, Star Knight(Gladiator),Soul Linker [Lupus]
  17. //= 1.5 Added clear of Bard Quest variables. 1.5a updated [Lupus]
  18. //= 1.6 Added F_RandMes, F_SexMes, F_Hi, F_Bye functions [Lupus]
  19. //= Moved here useful function 'getJobName'
  20. //= 1.7 Added "F_ItemName" function, added a great sample for "F_ItemName"
  21. //= 1.8 Added Job Vars clear for Extended classes: TK,SL,SG [Lupus]
  22. //= 1.9 Added "F_ClearGarbage" func that clears outdated, wasted variables [Lupus]
  23. //= 1.91 Added "F_SaveQuestSkills","F_Load?Skills" functions [Lupus]
  24. //= 2.0 Fixed F_Save/LoadQuestSkills functions. Had to split in into 2 vars [Lupus]
  25. //= 2.01 Added $talk to F_ClearGarbage [Evera]
  26. //= 2.02 Added $dtsglobalelig and $dts|(1<<6) to F_ClearGarbage [Evera]
  27. //= 2.03 Added Gunslinger vars to F_ClearJobVar [Lupus]
  28. //= 2.04 Added dtseligible 2 (becomes MISC_QUEST|128) to F_ClearGarbage [Evera]
  29. //= 2.05 Book of Devil -> MISC_QUEST|256, clear other Niflheim garbage vars [Lupus]
  30. //= +more garbage clean
  31. //= 2.06 Pass to Bio-Lab -> MISC_QUEST|512 [Lupus]
  32. //= 2.07 Added TK_Q variable clear. 2.08 Added NINJ_Q variable clear [Lupus]
  33. //= 2.09 Cleared F_ClearGarbage [Lupus]
  34. //= 2.10 Added F_CheckMaxCount to check count of carrid items. [L0ne_w0lf]
  35. //= 2.10a Removed function F_CheckMaxCount. Not needed. [L0ne_W0lf]
  36. //= 2.11 Updated function Job_Change to jobchange based on Upper value. [Paradox924X]
  37. //= 2.12 Added more unused vars to F_ClearGarbage [Lupus]
  38. //= 2.13 Added more unused vars to F_ClearGarbage [Lupus]
  39. //= 2,14 Added old novice variables to F_ClearGarbage. [L0ne_W0lf]
  40. //============================================================
  41. //////////////////////////////////////////////////////////////////////////////////
  42. // Function that clears job quest variables
  43. //////////////////////////////////////////////////////////////////////////////////
  44. function script F_ClearJobVar {
  45. // Misc ---------------------------------
  46. set JBLVL,0;
  47. set FIRSTAID,0;
  48. set PLAYDEAD,0;
  49. set got_bandage,0;
  50. set got_novnametag,0;
  51. // First Class Jobs ---------------------
  52. set job_acolyte_q,0; set job_acolyte_q2,0;
  53. set job_archer_q,0;
  54. set job_magician_q,0;
  55. set job_merchant_q,0; set job_merchant_q2,0; set job_merchant_q3,0;
  56. set job_sword_q,0; set SWTEST, 0;
  57. set job_thief_q,0;
  58. // Super Novice
  59. set SUPNOV_Q,0;
  60. // 2-1 Jobs ------------------------------
  61. set ASSIN_Q,0; set ASSIN_Q2,0; set ASSIN_Q3,0;
  62. set BSMITH_Q,0; set BSMITH_Q2,0;
  63. set HNTR_Q,0; set HNTR_Q2,0;
  64. set KNIGHT_Q,0; set KNIGHT_Q2,0;
  65. set PRIEST_Q,0; set PRIEST_Q2,0; set PRIEST_Q3,0;
  66. set WIZ_Q,0; set WIZ_Q2,0;
  67. // 2-2 Jobs ------------------------------
  68. set ROGUE_Q,0; set ROGUE_Q2,0;
  69. set ALCH_Q,0; set ALCH_Q2,0;
  70. set CRUS_Q,0;
  71. set MONK_Q,0; set JOB_MONK_C,0;
  72. set SAGE_Q,0; set SAGE_Q2,0;
  73. set DANC_Q,0;
  74. set BARD_Q,0;
  75. // Extended Classes
  76. set TAEK_Q,0; set TK_Q,0;
  77. set STGL_Q,0;
  78. set SOUL_Q,0;
  79. set GUNS_Q,0;
  80. set NINJ_Q,0;
  81. return;
  82. }
  83. function script F_ClearGarbage {
  84. // Clear outdated global VARS
  85. //Clear TURTLE var if the Turtle Islans Quest is already done
  86. if(TURTLE==20) set MISC_QUEST,MISC_QUEST | 65536;
  87. if(MISC_QUEST & 65536) set TURTLE,0; //now clear the var if the quest is over
  88. //Clear previously saved Quest Skills (now it isn't used)
  89. set ADV_QSK,0;
  90. set ADV_QSK2,0;
  91. //Old Seset Skill Event used to use RES_SKILL var
  92. set RES_SKILL,0;
  93. //Here you put outdated variables from your outdated EVENTS
  94. //e.g. Is XMAS done? Add the EVENT var clearing code here.
  95. //due to bugs in BS quest:
  96. set wizard_m2,0;
  97. // Old Novice Ground Variables.
  98. set NEW_MES_FLAG0,0;
  99. set NEW_MES_FLAG1,0;
  100. set NEW_MES_FLAG2,0;
  101. set NEW_MES_FLAG3,0;
  102. set NEW_MES_FLAG4,0;
  103. set NEW_MES_FLAG5,0;
  104. set NEW_LVUP0,0;
  105. set NEW_LVUP1,0;
  106. set NEW_JOBLVUP,0;
  107. return;
  108. }
  109. //////////////////////////////////////////////////////////////////////////////////
  110. // Used in REBIRTH scripts
  111. // Class = Internal Class ID
  112. // BaseJob = Base Job (0..23)
  113. // Upper : 0 - Default, 1 - Advanced, 2 - Baby
  114. //////////////////////////////////////////////////////////////////////////////////
  115. function script Job_Change {
  116. jobchange getarg(0),Upper; //Jobchange based on Upper
  117. logmes "CLASS CHANGE: " +strcharinfo(0)+ " become a "+jobname(Class);
  118. return;
  119. }
  120. //////////////////////////////////////////////////////////////////////////////////
  121. // Functions used to spiff up dialoges [Lupus]
  122. //////////////////////////////////////////////////////////////////////////////////
  123. //////////////////////////////////////////////////////////////////////////////////
  124. // *** Function "F_RandMes"
  125. //////////////////////////////////////////////////////////////////////////////////
  126. //returns random string
  127. // Example: check F_Bye or F_Hi functions
  128. // READ AND THINK: You can use it to pick a random number form list:
  129. // set @itemIDfromList, callfunc("F_RandMes",8,1129,1222,1163,1357,1360,1522,1811,1410);
  130. function script F_RandMes {
  131. return getarg(rand(1,getarg(0)));
  132. }
  133. //////////////////////////////////////////////////////////////////////////////////
  134. // *** Function "F_Sex"
  135. //////////////////////////////////////////////////////////////////////////////////
  136. //returns 1st string if female, 2nd string otherwise
  137. // Example: mes callfunc("F_Sex","What a beautiful lady!","What a handsome man!");
  138. function script F_SexMes {
  139. return getarg(Sex);
  140. }
  141. //////////////////////////////////////////////////////////////////////////////////
  142. // *** Function "F_Hi"
  143. //////////////////////////////////////////////////////////////////////////////////
  144. //returns random HELLO message
  145. function script F_Hi {
  146. return callfunc("F_RandMes",5,"Hi!","Hello!","Good day!","How are you?","Hello there.");
  147. }
  148. //////////////////////////////////////////////////////////////////////////////////
  149. // *** Function "F_Bye"
  150. //////////////////////////////////////////////////////////////////////////////////
  151. //returns random BYE message
  152. function script F_Bye {
  153. return callfunc("F_RandMes",6,"Bye. See you again.","Later.","Goodbye.","Good luck!","Have a nice day!","Byebye!!!");
  154. }
  155. //////////////////////////////////////////////////////////////////////////////////
  156. // *** Function "F_ItemName"
  157. //////////////////////////////////////////////////////////////////////////////////
  158. // Returns expanded item name string
  159. //Argumentss
  160. // 0 - Item ID
  161. // 1 - Element N (0=none,1=Ice,2=Earth,3=Fire,4=Wind)
  162. // 2 - VVS meter 0..3
  163. // 3 - Refine
  164. // Example: mes "Show me your "+callfunc("F_ItemName",1201,1,2,5)+"...";
  165. // is equal to: mes "Show me your ^000090 +5 VVS Fire Knife ^000000..."
  166. function script F_ItemName {
  167. set @t$,"^000090";
  168. if(getarg(3)) set @t$,@t$+"+"+getarg(3)+" ";
  169. if(getarg(2)==1) set @t$,@t$+"VS ";
  170. if(getarg(2)==2) set @t$,@t$+"VVS ";
  171. if(getarg(2)==3) set @t$,@t$+"VVVS ";
  172. if(getarg(2)>3) set @t$,@t$+getarg(2)+"xVS ";
  173. if(getarg(1)==1) set @t$,@t$+"Ice ";
  174. if(getarg(1)==2) set @t$,@t$+"Earth ";
  175. if(getarg(1)==3) set @t$,@t$+"Fire ";
  176. if(getarg(1)==4) set @t$,@t$+"Wind ";
  177. if(getarg(1)>4) set @t$,@t$+"Strange ";
  178. return @t$+getitemname(getarg(0))+"^000000";
  179. }
  180. //////////////////////////////////////////////////////////////////////////////////
  181. // *** Function "getJobName" //
  182. // [Usage] : callfunc("getJobName",Class); //
  183. //////////////////////////////////////////////////////////////////////////////////
  184. function script getJobName {
  185. return jobname(getarg(0));
  186. }
  187. //////////////////////////////////////////////////////////////////////////////////
  188. // *** Function "F_SaveQuestSkills": Store learnt quest skills
  189. //////////////////////////////////////////////////////////////////////////////////
  190. function script F_SaveQuestSkills {
  191. set ADV_QSK,0; set ADV_QSK2,0;
  192. //1st classes quest skills
  193. for(set @i, 0; @i < 14; set @i, @i + 1){
  194. if(getskilllv(144+@i)) set ADV_QSK,ADV_QSK|pow(2,@i);
  195. }
  196. //2nd classes quest skills
  197. for(set @i, 0; @i < 19; set @i, @i + 1){
  198. if(getskilllv(1001+@i)) set ADV_QSK2,ADV_QSK2|pow(2,@i);
  199. }
  200. return;
  201. }
  202. //////////////////////////////////////////////////////////////////////////////////
  203. // *** Function "F_Load1Skills": Restore learnt 1st class quest skills
  204. //////////////////////////////////////////////////////////////////////////////////
  205. function script F_Load1Skills {
  206. //1st classes quest skills
  207. for(set @i, 0; @i < 14; set @i, @i + 1){
  208. if(ADV_QSK|pow(2,@i) == ADV_QSK) skill 144+@i,1,0;
  209. }
  210. set ADV_QSK,0; //Clear var
  211. return;
  212. }
  213. //////////////////////////////////////////////////////////////////////////////////
  214. // *** Function "F_Load2Skills": Restore learnt 2nd class quest skills
  215. //////////////////////////////////////////////////////////////////////////////////
  216. function script F_Load2Skills {
  217. //2nd classes quest skills
  218. for(set @i, 0; @i < 19; set @i, @i + 1){
  219. if(ADV_QSK2|pow(2,@i) == ADV_QSK2) skill 1001+@i,1,0;
  220. }
  221. set ADV_QSK2,0; //Clear var
  222. return;
  223. }