Global_Functions.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. //===== eAthena Script =======================================
  2. //= Global Functions
  3. //===== By: ==================================================
  4. //= Lupus, kobra_k88
  5. //===== Current Version: =====================================
  6. //= 2.08
  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 [Lupus]
  33. //- 2.08 Added NINJ_Q variable clear [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;
  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. //DTS Vote System
  80. if($dtsglobalelig) set $dtsglobalelig,0;
  81. if($dts&(1<<6)) set $dts,$dts&~(1<<6);
  82. //Cube Room
  83. if(hzdun) {
  84. set MISC_QUEST,MISC_QUEST|512;
  85. set num1,0; set num2,0; set num3,0; set num4,0; set num5,0;
  86. set num6,0; set num7,0; set num8,0; set num9,0;
  87. set hzdun,0; set cubekey,0; set piciburn,0;
  88. }
  89. //Airship
  90. if($lengths){
  91. cleararray $textstringsa$[0],"",getarraysize($textstringsa$);
  92. cleararray $textstringsb$[0],"",getarraysize($textstringsb$);
  93. cleararray $textstringsc$[0],"",getarraysize($textstringsc$);
  94. cleararray $compstring$[0],"",getarraysize($compstring$);
  95. cleararray $lengths[0],0,getarraysize($lengths);
  96. }
  97. //Shinkskas Quest garbage
  98. if(Shinokas_Quest > 7){
  99. set ein_scientist,0;
  100. set ein_stuff,0;
  101. }
  102. return;
  103. }
  104. //////////////////////////////////////////////////////////////////////////////////
  105. // Used in REBIRTH scripts
  106. // Class = Internal Class ID
  107. // BaseJob = Base Job (0..23)
  108. // Upper : 0 - Default, 1 - Advanced, 2 - Baby
  109. //////////////////////////////////////////////////////////////////////////////////
  110. function script Job_Change {
  111. if (Upper<2)
  112. jobchange getarg(0); // Common jobchange
  113. else
  114. jobchange getarg(0) + Job_Baby; //Change Job For Baby Class
  115. logmes "CLASS CHANGE: " +strcharinfo(0)+ " become a "+jobname(Class);
  116. return;
  117. }
  118. //////////////////////////////////////////////////////////////////////////////////
  119. // FOT BACKWISE COMPATIBILITY: Functions used to check a players job class
  120. // HOW TO USE:
  121. // i.e. We need all holy classes but monks
  122. // if ( callfunc("Is_Holy_Class") && callfunc("Is_Monk")==0 ) goto L_Start;
  123. //////////////////////////////////////////////////////////////////////////////////
  124. //////////////////////////////////////////////////////////////////////////////////
  125. // returns 1 if the player is either Aco,Monk,Priest,Aco High,High Priest,
  126. // Champion, 0 otherwise
  127. //////////////////////////////////////////////////////////////////////////////////
  128. function script Is_Holy_Class {
  129. return ( BaseJob==Job_Acolyte || BaseJob==Job_Priest || BaseJob==Job_Monk );
  130. }
  131. //////////////////////////////////////////////////////////////////////////////////
  132. // returns 1 if the player is either Archer,Hunter,Bard,Dancer,Archer High,Sniper,
  133. // Clown,Gypsy, 0 otherwise
  134. //////////////////////////////////////////////////////////////////////////////////
  135. function script Is_Bow_Class {
  136. return ( BaseJob==Job_Archer || BaseJob==Job_Hunter || BaseJob==Job_Bard || BaseJob==Job_Dancer );
  137. }
  138. //////////////////////////////////////////////////////////////////////////////////
  139. // returns 1 if the player is either Mage,Wizard,Sage,Mage High,High Wizard,
  140. // Professor, 0 otherwise
  141. //////////////////////////////////////////////////////////////////////////////////
  142. function script Is_Magic_Class {
  143. return ( BaseJob==Job_Mage || BaseJob==Job_Wizard || BaseJob==Job_Sage );
  144. }
  145. //////////////////////////////////////////////////////////////////////////////////
  146. // returns 1 if the player is either Merc,Blacksmith,Alchemist,Merc High,
  147. // Whitesmith,Creator, 0 otherwise
  148. //////////////////////////////////////////////////////////////////////////////////
  149. function script Is_Merc_Class {
  150. return ( BaseJob==Job_Merchant || BaseJob==Job_Blacksmith || BaseJob==Job_Alchem );
  151. }
  152. //////////////////////////////////////////////////////////////////////////////////
  153. // returns 1 if the player is either Thief,Assassin,Rogue,Thief High, Assassin Cross
  154. // Stalker, 0 otherwise
  155. //////////////////////////////////////////////////////////////////////////////////
  156. function script Is_Thief_Class {
  157. return ( BaseJob==Job_Thief || BaseJob==Job_Assassin || BaseJob==Job_Rogue );
  158. }
  159. //////////////////////////////////////////////////////////////////////////////////
  160. // returns 1 if the player is either Swordy,Knight,Crusader,Swordy High,
  161. // Lord Knight,Paladin, 0 otherwise
  162. //////////////////////////////////////////////////////////////////////////////////
  163. function script Is_Sword_Class {
  164. return ( BaseJob==Job_Swordman || BaseJob==Job_Knight || BaseJob==Job_Knight2 || BaseJob==Job_Crusader || BaseJob==Job_Crusader2 );
  165. }
  166. //////////////////////////////////////////////////////////////////////////////////
  167. // returns 1 if the player is either Taekwon, Star Gladiator,Soul Linker, 0 otherwise
  168. // these classes can't be adopted nor reborn ()
  169. //////////////////////////////////////////////////////////////////////////////////
  170. function script Is_Taekwon_Class {
  171. return ( Class==Job_Taekwon || Class==Job_Star_Gladiator || Class==Job_Star_Gladiator2 || Class==Job_Soul_Linker );
  172. }
  173. //////////////////////////////////////////////////////////////////////////////////
  174. // Functions used to spiff up dialoges [Lupus]
  175. //////////////////////////////////////////////////////////////////////////////////
  176. //////////////////////////////////////////////////////////////////////////////////
  177. // *** Function "F_RandMes"
  178. //////////////////////////////////////////////////////////////////////////////////
  179. //returns random string
  180. // Example: check F_Bye or F_Hi functions
  181. // READ AND THINK: You can use it to pick a random number form list:
  182. // set @itemIDfromList, callfunc("F_RandMes",8,1129,1222,1163,1357,1360,1522,1811,1410);
  183. function script F_RandMes {
  184. return getarg(rand(1,getarg(0)));
  185. }
  186. //////////////////////////////////////////////////////////////////////////////////
  187. // *** Function "F_Sex"
  188. //////////////////////////////////////////////////////////////////////////////////
  189. //returns 1st string if female, 2nd string otherwise
  190. // Example: mes callfunc("F_Sex","What a beautiful lady!","What a handsom man!");
  191. function script F_SexMes {
  192. return getarg(Sex);
  193. }
  194. //////////////////////////////////////////////////////////////////////////////////
  195. // *** Function "F_Hi"
  196. //////////////////////////////////////////////////////////////////////////////////
  197. //returns random HELLO message
  198. function script F_Hi {
  199. return callfunc("F_RandMes",5,"Hi!","Hello!","Good day!","How are you?","Hello there.");
  200. }
  201. //////////////////////////////////////////////////////////////////////////////////
  202. // *** Function "F_Bye"
  203. //////////////////////////////////////////////////////////////////////////////////
  204. //returns random BYE message
  205. function script F_Bye {
  206. return callfunc("F_RandMes",6,"Bye. See you again.","Later.","Goodbye.","Good luck!","Have a nice day!","Byebye!!!");
  207. }
  208. //////////////////////////////////////////////////////////////////////////////////
  209. // *** Function "F_ItemName"
  210. //////////////////////////////////////////////////////////////////////////////////
  211. // Returns expanded item name string
  212. //Argumentss
  213. // 0 - Item ID
  214. // 1 - Element N (0=none,1=Ice,2=Earth,3=Fire,4=Wind)
  215. // 2 - VVS meter 0..3
  216. // 3 - Refine
  217. // Example: mes "Show me your "+callfunc("F_ItemName",1201,1,2,5)+"...";
  218. // is equal to: mes "Show me your ^000090 +5 VVS Fire Knife ^000000..."
  219. function script F_ItemName {
  220. set @t$,"^000090";
  221. if(getarg(3)) set @t$,@t$+"+"+getarg(3)+" ";
  222. if(getarg(2)==1) set @t$,@t$+"VS ";
  223. if(getarg(2)==2) set @t$,@t$+"VVS ";
  224. if(getarg(2)==3) set @t$,@t$+"VVVS ";
  225. if(getarg(2)>3) set @t$,@t$+getarg(2)+"xVS ";
  226. if(getarg(1)==1) set @t$,@t$+"Ice ";
  227. if(getarg(1)==2) set @t$,@t$+"Earth ";
  228. if(getarg(1)==3) set @t$,@t$+"Fire ";
  229. if(getarg(1)==4) set @t$,@t$+"Wind ";
  230. if(getarg(1)>4) set @t$,@t$+"Strange ";
  231. return @t$+getitemname(getarg(0))+"^000000";
  232. }
  233. //////////////////////////////////////////////////////////////////////////////////
  234. // *** Function "getJobName" //
  235. // [Usage] : callfunc("getJobName",Class); //
  236. //////////////////////////////////////////////////////////////////////////////////
  237. function script getJobName {
  238. return jobname(getarg(0));
  239. }
  240. //////////////////////////////////////////////////////////////////////////////////
  241. // *** Function "F_SaveQuestSkills": Store learnt quest skills
  242. //////////////////////////////////////////////////////////////////////////////////
  243. function script F_SaveQuestSkills {
  244. set ADV_QSK,0; set ADV_QSK2,0;
  245. //1st classes quest skills
  246. for(set @i, 0; @i < 14; set @i, @i + 1){
  247. if(getskilllv(144+@i)) set ADV_QSK,ADV_QSK|pow(2,@i);
  248. }
  249. //2nd classes quest skills
  250. for(set @i, 0; @i < 19; set @i, @i + 1){
  251. if(getskilllv(1001+@i)) set ADV_QSK2,ADV_QSK2|pow(2,@i);
  252. }
  253. return;
  254. }
  255. //////////////////////////////////////////////////////////////////////////////////
  256. // *** Function "F_Load1Skills": Restore learnt 1st class quest skills
  257. //////////////////////////////////////////////////////////////////////////////////
  258. function script F_Load1Skills {
  259. //1st classes quest skills
  260. for(set @i, 0; @i < 14; set @i, @i + 1){
  261. if(ADV_QSK|pow(2,@i) == ADV_QSK) skill 144+@i,1,0;
  262. }
  263. set ADV_QSK,0; //Clear var
  264. return;
  265. }
  266. //////////////////////////////////////////////////////////////////////////////////
  267. // *** Function "F_Load2Skills": Restore learnt 2nd class quest skills
  268. //////////////////////////////////////////////////////////////////////////////////
  269. function script F_Load2Skills {
  270. //2nd classes quest skills
  271. for(set @i, 0; @i < 19; set @i, @i + 1){
  272. if(ADV_QSK2|pow(2,@i) == ADV_QSK2) skill 1001+@i,1,0;
  273. }
  274. set ADV_QSK2,0; //Clear var
  275. return;
  276. }