Global_Functions.txt 12 KB

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