Global_Functions.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. //===== eAthena Script =======================================
  2. //= Global Functions
  3. //===== By: ==================================================
  4. //= Lupus, kobra_k88
  5. //===== Current Version: =====================================
  6. //= 2.10
  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 fuction F_CheckMaxCount. Not needed. [L0ne_W0lf]
  36. //============================================================
  37. //////////////////////////////////////////////////////////////////////////////////
  38. // Function that clears job quest variables
  39. //////////////////////////////////////////////////////////////////////////////////
  40. function script F_ClearJobVar {
  41. // Misc ---------------------------------
  42. set JBLVL,0;
  43. set FIRSTAID,0;
  44. set PLAYDEAD,0;
  45. set got_bandage,0;
  46. set got_novnametag,0;
  47. // First Class Jobs ---------------------
  48. set job_acolyte_q,0; set job_acolyte_q2,0;
  49. set job_archer_q,0;
  50. set job_magician_q,0;
  51. set job_merchant_q,0; set job_merchant_q2,0; set job_merchant_q3,0;
  52. set job_sword_q,0; set SWTEST, 0;
  53. set job_thief_q,0;
  54. // Super Novice
  55. set SUPNOV_Q,0;
  56. // 2-1 Jobs ------------------------------
  57. set ASSIN_Q,0; set ASSIN_Q2,0; set ASSIN_Q3,0;
  58. set BSMITH_Q,0; set BSMITH_Q2,0;
  59. set HNTR_Q,0; set HNTR_Q2,0;
  60. set KNIGHT_Q,0; set KNIGHT_Q2,0;
  61. set PRIEST_Q,0; set PRIEST_Q2,0; set PRIEST_Q3,0;
  62. set WIZ_Q,0; set WIZ_Q2,0;
  63. // 2-2 Jobs ------------------------------
  64. set ROGUE_Q,0; set ROGUE_Q2,0;
  65. set ALCH_Q,0; set ALCH_Q2,0;
  66. set CRUS_Q,0;
  67. set MONK_Q,0; set JOB_MONK_C,0;
  68. set SAGE_Q,0; set SAGE_Q2,0;
  69. set DANC_Q,0;
  70. set BARD_Q,0;
  71. // Extended Classes
  72. set TAEK_Q,0; set TK_Q,0;
  73. set STGL_Q,0;
  74. set SOUL_Q,0;
  75. set GUNS_Q,0;
  76. set NINJ_Q,0;
  77. return;
  78. }
  79. function script F_ClearGarbage {
  80. // Clear outdated global VARS
  81. //Shinkskas Quest garbage
  82. if(Shinokas_Quest > 7){
  83. set ein_scientist,0;
  84. set ein_stuff,0;
  85. }
  86. return;
  87. }
  88. //////////////////////////////////////////////////////////////////////////////////
  89. // Used in REBIRTH scripts
  90. // Class = Internal Class ID
  91. // BaseJob = Base Job (0..23)
  92. // Upper : 0 - Default, 1 - Advanced, 2 - Baby
  93. //////////////////////////////////////////////////////////////////////////////////
  94. function script Job_Change {
  95. if (Upper<2)
  96. jobchange getarg(0); // Common jobchange
  97. else
  98. jobchange getarg(0) + Job_Baby; //Change Job For Baby Class
  99. logmes "CLASS CHANGE: " +strcharinfo(0)+ " become a "+jobname(Class);
  100. return;
  101. }
  102. //////////////////////////////////////////////////////////////////////////////////
  103. // FOT BACKWISE COMPATIBILITY: Functions used to check a players job class
  104. // HOW TO USE:
  105. // i.e. We need all holy classes but monks
  106. // if ( callfunc("Is_Holy_Class") && callfunc("Is_Monk")==0 ) goto L_Start;
  107. //////////////////////////////////////////////////////////////////////////////////
  108. //////////////////////////////////////////////////////////////////////////////////
  109. // returns 1 if the player is either Aco,Monk,Priest,Aco High,High Priest,
  110. // Champion, 0 otherwise
  111. //////////////////////////////////////////////////////////////////////////////////
  112. function script Is_Holy_Class {
  113. return ( BaseJob==Job_Acolyte || BaseJob==Job_Priest || BaseJob==Job_Monk );
  114. }
  115. //////////////////////////////////////////////////////////////////////////////////
  116. // returns 1 if the player is either Archer,Hunter,Bard,Dancer,Archer High,Sniper,
  117. // Clown,Gypsy, 0 otherwise
  118. //////////////////////////////////////////////////////////////////////////////////
  119. function script Is_Bow_Class {
  120. return ( BaseJob==Job_Archer || BaseJob==Job_Hunter || BaseJob==Job_Bard || BaseJob==Job_Dancer );
  121. }
  122. //////////////////////////////////////////////////////////////////////////////////
  123. // returns 1 if the player is either Mage,Wizard,Sage,Mage High,High Wizard,
  124. // Professor, 0 otherwise
  125. //////////////////////////////////////////////////////////////////////////////////
  126. function script Is_Magic_Class {
  127. return ( BaseJob==Job_Mage || BaseJob==Job_Wizard || BaseJob==Job_Sage );
  128. }
  129. //////////////////////////////////////////////////////////////////////////////////
  130. // returns 1 if the player is either Merc,Blacksmith,Alchemist,Merc High,
  131. // Whitesmith,Creator, 0 otherwise
  132. //////////////////////////////////////////////////////////////////////////////////
  133. function script Is_Merc_Class {
  134. return ( BaseJob==Job_Merchant || BaseJob==Job_Blacksmith || BaseJob==Job_Alchemist );
  135. }
  136. //////////////////////////////////////////////////////////////////////////////////
  137. // returns 1 if the player is either Thief,Assassin,Rogue,Thief High, Assassin Cross
  138. // Stalker, 0 otherwise
  139. //////////////////////////////////////////////////////////////////////////////////
  140. function script Is_Thief_Class {
  141. return ( BaseJob==Job_Thief || BaseJob==Job_Assassin || BaseJob==Job_Rogue );
  142. }
  143. //////////////////////////////////////////////////////////////////////////////////
  144. // returns 1 if the player is either Swordy,Knight,Crusader,Swordy High,
  145. // Lord Knight,Paladin, 0 otherwise
  146. //////////////////////////////////////////////////////////////////////////////////
  147. function script Is_Sword_Class {
  148. return ( BaseJob==Job_Swordman || BaseJob==Job_Knight || BaseJob==Job_Knight2 || BaseJob==Job_Crusader || BaseJob==Job_Crusader2 );
  149. }
  150. //////////////////////////////////////////////////////////////////////////////////
  151. // returns 1 if the player is either Taekwon, Star Gladiator,Soul Linker, 0 otherwise
  152. // these classes can't be adopted nor reborn ()
  153. //////////////////////////////////////////////////////////////////////////////////
  154. function script Is_Taekwon_Class {
  155. return ( Class==Job_Taekwon || Class==Job_Star_Gladiator || Class==Job_Star_Gladiator2 || Class==Job_Soul_Linker );
  156. }
  157. //////////////////////////////////////////////////////////////////////////////////
  158. // Functions used to spiff up dialoges [Lupus]
  159. //////////////////////////////////////////////////////////////////////////////////
  160. //////////////////////////////////////////////////////////////////////////////////
  161. // *** Function "F_RandMes"
  162. //////////////////////////////////////////////////////////////////////////////////
  163. //returns random string
  164. // Example: check F_Bye or F_Hi functions
  165. // READ AND THINK: You can use it to pick a random number form list:
  166. // set @itemIDfromList, callfunc("F_RandMes",8,1129,1222,1163,1357,1360,1522,1811,1410);
  167. function script F_RandMes {
  168. return getarg(rand(1,getarg(0)));
  169. }
  170. //////////////////////////////////////////////////////////////////////////////////
  171. // *** Function "F_Sex"
  172. //////////////////////////////////////////////////////////////////////////////////
  173. //returns 1st string if female, 2nd string otherwise
  174. // Example: mes callfunc("F_Sex","What a beautiful lady!","What a handsome man!");
  175. function script F_SexMes {
  176. return getarg(Sex);
  177. }
  178. //////////////////////////////////////////////////////////////////////////////////
  179. // *** Function "F_Hi"
  180. //////////////////////////////////////////////////////////////////////////////////
  181. //returns random HELLO message
  182. function script F_Hi {
  183. return callfunc("F_RandMes",5,"Hi!","Hello!","Good day!","How are you?","Hello there.");
  184. }
  185. //////////////////////////////////////////////////////////////////////////////////
  186. // *** Function "F_Bye"
  187. //////////////////////////////////////////////////////////////////////////////////
  188. //returns random BYE message
  189. function script F_Bye {
  190. return callfunc("F_RandMes",6,"Bye. See you again.","Later.","Goodbye.","Good luck!","Have a nice day!","Byebye!!!");
  191. }
  192. //////////////////////////////////////////////////////////////////////////////////
  193. // *** Function "F_ItemName"
  194. //////////////////////////////////////////////////////////////////////////////////
  195. // Returns expanded item name string
  196. //Argumentss
  197. // 0 - Item ID
  198. // 1 - Element N (0=none,1=Ice,2=Earth,3=Fire,4=Wind)
  199. // 2 - VVS meter 0..3
  200. // 3 - Refine
  201. // Example: mes "Show me your "+callfunc("F_ItemName",1201,1,2,5)+"...";
  202. // is equal to: mes "Show me your ^000090 +5 VVS Fire Knife ^000000..."
  203. function script F_ItemName {
  204. set @t$,"^000090";
  205. if(getarg(3)) set @t$,@t$+"+"+getarg(3)+" ";
  206. if(getarg(2)==1) set @t$,@t$+"VS ";
  207. if(getarg(2)==2) set @t$,@t$+"VVS ";
  208. if(getarg(2)==3) set @t$,@t$+"VVVS ";
  209. if(getarg(2)>3) set @t$,@t$+getarg(2)+"xVS ";
  210. if(getarg(1)==1) set @t$,@t$+"Ice ";
  211. if(getarg(1)==2) set @t$,@t$+"Earth ";
  212. if(getarg(1)==3) set @t$,@t$+"Fire ";
  213. if(getarg(1)==4) set @t$,@t$+"Wind ";
  214. if(getarg(1)>4) set @t$,@t$+"Strange ";
  215. return @t$+getitemname(getarg(0))+"^000000";
  216. }
  217. //////////////////////////////////////////////////////////////////////////////////
  218. // *** Function "getJobName" //
  219. // [Usage] : callfunc("getJobName",Class); //
  220. //////////////////////////////////////////////////////////////////////////////////
  221. function script getJobName {
  222. return jobname(getarg(0));
  223. }
  224. //////////////////////////////////////////////////////////////////////////////////
  225. // *** Function "F_SaveQuestSkills": Store learnt quest skills
  226. //////////////////////////////////////////////////////////////////////////////////
  227. function script F_SaveQuestSkills {
  228. set ADV_QSK,0; set ADV_QSK2,0;
  229. //1st classes quest skills
  230. for(set @i, 0; @i < 14; set @i, @i + 1){
  231. if(getskilllv(144+@i)) set ADV_QSK,ADV_QSK|pow(2,@i);
  232. }
  233. //2nd classes quest skills
  234. for(set @i, 0; @i < 19; set @i, @i + 1){
  235. if(getskilllv(1001+@i)) set ADV_QSK2,ADV_QSK2|pow(2,@i);
  236. }
  237. return;
  238. }
  239. //////////////////////////////////////////////////////////////////////////////////
  240. // *** Function "F_Load1Skills": Restore learnt 1st class quest skills
  241. //////////////////////////////////////////////////////////////////////////////////
  242. function script F_Load1Skills {
  243. //1st classes quest skills
  244. for(set @i, 0; @i < 14; set @i, @i + 1){
  245. if(ADV_QSK|pow(2,@i) == ADV_QSK) skill 144+@i,1,0;
  246. }
  247. set ADV_QSK,0; //Clear var
  248. return;
  249. }
  250. //////////////////////////////////////////////////////////////////////////////////
  251. // *** Function "F_Load2Skills": Restore learnt 2nd class quest skills
  252. //////////////////////////////////////////////////////////////////////////////////
  253. function script F_Load2Skills {
  254. //2nd classes quest skills
  255. for(set @i, 0; @i < 19; set @i, @i + 1){
  256. if(ADV_QSK2|pow(2,@i) == ADV_QSK2) skill 1001+@i,1,0;
  257. }
  258. set ADV_QSK2,0; //Clear var
  259. return;
  260. }