ea_job_system.txt 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. //===== rAthena Documentation ================================
  2. //= eAthena Job System
  3. //===== By: ==================================================
  4. //= Skotlex
  5. //===== Last Updated: ========================================
  6. //= 20130209
  7. //===== Description: =========================================
  8. //= A reference description of eA's inner job system (for use
  9. //= in scripts through the eaclass and roclass script commands).
  10. //============================================================
  11. Preface:
  12. -------------------------------------------------------------------------------
  13. Most scripters are aware of the class values used in RO and their constants
  14. specified in src/map/script_constants.hpp. Each class has a number associated
  15. to it for referencing, so when someone's class is 9 that means they are a
  16. wizard. However, this list of job numbers has no real order behind it, and
  17. no logic behind it's assignation.
  18. You can add 3999 to a job to get their rebirth ID, but if you try to do the
  19. same to get the Baby class ID, that fails on the super Baby class. Also,
  20. there's no way to calculate, from a given first class, which classes would
  21. be their "evolution". That is, given the Archer's ID, you cannot just add
  22. a value that will return you "Hunter", and will still work if applied to
  23. the other classes. It didn't help much when they added Taekwon Boy, a first
  24. class, with an ID of 4046, and much later they added Ninja/Gunslinger with
  25. the IDs 25/24. How do you identify a first class on all this mess without
  26. recurring to very ugly range checks?
  27. The eA Job System:
  28. -------------------------------------------------------------------------------
  29. Since the code also required to do this kind of checks for various skills
  30. (the Soul Linker Spirit buffs specifically come to mind), an alternate job
  31. ID system was developed, which attempts to make more sense and make it
  32. easier to check where a particular job stands in relation to the rest.
  33. The scheme consists in that every job can be broken down by 3 criteria:
  34. - Base Job: This determines to which class-tree a job belongs. All jobs can be
  35. traced back to their root. The base job of all classes has to be one of the
  36. following:
  37. EAJ_NOVICE 0x0
  38. EAJ_SWORDMAN 0x1
  39. EAJ_MAGE 0x2
  40. EAJ_ARCHER 0x3
  41. EAJ_ACOLYTE 0x4
  42. EAJ_MERCHANT 0x5
  43. EAJ_THIEF 0x6
  44. EAJ_TAEKWON 0x7
  45. EAJ_GUNSLINGER 0x9
  46. EAJ_NINJA 0x0A
  47. EAJ_GANGSI 0x0D
  48. EAJ_SUMMONER 0x10
  49. - Branch: All classes can be classified as "1st Class", "2-1 Class" or
  50. "2-2 Class":
  51. EAJL_2_1 0x100
  52. EAJL_2_2 0x200
  53. EAJL_2 0x300
  54. - The third category is type. Classes can either be normal, rebirth/advanced,
  55. adopted, third class or fourth class.
  56. EAJL_UPPER 0x1000
  57. EAJL_BABY 0x2000
  58. EAJL_THIRD 0x4000
  59. EAJL_FOURTH 0x8000
  60. So using these three categories, any job class can be constructed from the
  61. others. Let's take a swordman, for example.
  62. The first step is basic swordman, with nothing else:
  63. EAJ_SWORDMAN
  64. If a swordman is adopted...
  65. EAJ_SWORDMAN|EAJL_BABY -> EAJ_BABY_SWORDMAN
  66. The next step is to either become a 2-1 or a 2-2 job:
  67. EAJ_SWORDMAN|EAJL_2_1 -> EAJ_KNIGHT
  68. EAJ_SWORDMAN|EAJL_2_2 -> EAJ_CRUSADER
  69. Getting out the rebirth versions of a swordman:
  70. EAJ_SWORDMAN|EAJL_UPPER -> EAJ_SWORDMAN_HIGH
  71. EAJ_SWORDMAN|EAJL_2_1|EAJL_UPPER -> EAJ_LORD_KNIGHT
  72. EAJ_SWORDMAN|EAJL_2_2|EAJL_UPPER -> EAJ_PALADIN
  73. Or getting the third job versions:
  74. EAJ_SWORDMAN|EAJL_2_1|EAJL_THIRD -> EAJ_RUNE_KNIGHT
  75. EAJ_SWORDMAN|EAJL_2_2|EAJL_THIRD -> EAJ_ROYAL_GUARD
  76. Why are we using the bitwise OR operand ('|') rather than just adding? Because
  77. the OR is wreck-proof:
  78. EAJ_SWORDMAN_HIGH|EAJL_UPPER -> EAJ_SWORDMAN_HIGH
  79. If we had used addition, we would have gotten a completely different result.
  80. The EAJL (eA Job Level) constants
  81. -------------------------------------------------------------------------------
  82. There are a few constants which can be used to filter out and make job
  83. comparisons easier. The comparisons involve eA job IDs, not classic job
  84. IDs, using the eaclass() command explained in the next section.
  85. set @eac, eaclass();
  86. EAJL_2_1:
  87. Checks if the class is a 2-1 class:
  88. if (@eac&EAJL_2_1)
  89. mes "Using the classic 2-1 job, huh?";
  90. EAJL_2_2:
  91. Checks if the class is a 2-2 class:
  92. if (@eac&EAJL_2_2)
  93. mes "Oh, a 2-2 job!";
  94. EAJL_2:
  95. Checks if the class is a 2nd Class. If the check fails, you can be sure
  96. the character is a first class.
  97. if (!(@eac&EAJL_2))
  98. mes "Will you wait until Job 50 to change?";
  99. EAJL_UPPER:
  100. Check if a class is Rebirth/Advanced:
  101. if(@eac&EAJL_UPPER)
  102. mes "It must have taken you a LONG time...";
  103. EAJL_BABY:
  104. Check if a class is an adopted class.
  105. if (@eac&EAJL_BABY)
  106. mes "Don't you hate being weak?";
  107. EAJL_THIRD:
  108. Checks if a class is a third job.
  109. if(@eac&EAJL_THIRD)
  110. mes "Wow, you've really grown!";
  111. EAJL_FOURTH:
  112. Checks if a class is a fourth job.
  113. if(@eac&EAJL_FOURTH)
  114. mes "Wow, you've really grown!";
  115. EAJ_UPPERMASK:
  116. The upper mask can be used to "strip" the upper/baby characteristics of a
  117. class, used when you want to know if someone is a certain class regardless
  118. of rebirth/adopted status. For example, the following code would go through
  119. for Monks, Champions and Baby Monks:
  120. if ((@eac&EAJ_UPPERMASK) == EAJ_MONK)
  121. mes "Aren't knuckles such a cool weapon?";
  122. Note that if instead of EAJ_MONK you used EAJ_CHAMPION or EAJ_BABY_MONK,
  123. the check would had never passed, since the upper/baby state has been
  124. removed from the original job when checking.
  125. EAJ_BASEMASK:
  126. This mask strips also the 2nd class attributes. It can be used to check
  127. against the basic job of a character. For example, the following code would
  128. go through for Merchants (+Baby Merchant and High Merchant), Blacksmiths
  129. (+Baby blacksmiths and Whitesmith) and Alchemist (+Baby Alchemist and
  130. +Creator):
  131. if ((@eac&EAJ_BASEMASK) == EAJ_MERCHANT)
  132. mes "Why I can't have discount like you guys do?";
  133. Note that, like before, if you try to check versus any of the other
  134. classes (High merchant, blacksmith, etc) instead of basic merchant, the
  135. check will always fail for the same reasons previously explained.
  136. EAJ_THIRDMASK:
  137. This mask strips 3rd class attributes. It will give the "normal" class of
  138. a third job, regardless of rebirth/adopted status. When used on non-third
  139. class characters, it will return the second job, or, if that also doesn't
  140. exist, the first.
  141. if ((@eac&EAJ_THIRDMASK) == EAJ_WARLOCK_T)
  142. mes "You've gone through rebirth, I see.";
  143. EAJ_FOURTHMASK:
  144. This mask strips 4th class attributes. Although currently there are none,
  145. it is suggested to use this for checking.
  146. if ((@eac&EAJ_FOURTHMASK) == EAJ_DRAGON_KNIGHT)
  147. mes "Oh you are a Dragon Knight, I see.";
  148. The script commands eaclass, roclass:
  149. -------------------------------------------------------------------------------
  150. These script commands are what you can use in scripts to convert between
  151. the RO classic job id, and eA's job system. The following script code
  152. demonstrates how to use these script commands to guess what your next job
  153. will be:
  154. set @eac, eaclass();
  155. if (@eac&EAJL_2)
  156. { //2nd class
  157. //If upper or baby, you can't rebirth
  158. if (@eac&(EAJL_UPPER|EAJL_BABY)) {
  159. mes "You can't go anywhere, can you?";
  160. close;
  161. }
  162. //Note that if we remove the EAJL_BABY check up there, the following
  163. //check will also fail, because there's no such thing as Rebirth-Baby
  164. //classes.
  165. set @newclass, roclass(@eac|EAJL_UPPER);
  166. if (@newclass == -1) {
  167. //Don't you hate this of SG and SL?
  168. mes "Haha, your class doesn't has a rebirth version yet!";
  169. close;
  170. }
  171. mes "Still dreaming of the day you become a "+jobname(@newclass)+"?";
  172. close;
  173. }
  174. set @class1, roclass(@eac|EAJL_2_1);
  175. set @class2, roclass(@eac|EAJL_2_2);
  176. if (@class1 == -1) {
  177. mes "Looks like you are stuck forever on that class.";
  178. close;
  179. }
  180. if (@class2 == -1) {
  181. //Not quite true, currently the only 1st class that doesn't has two
  182. //choices is Novice -> Supernovice (see s.novice section below)
  183. mes "Looks like you have no choice but to be a "+jobname(@class1)+".";
  184. close;
  185. }
  186. mes "Have you decided yet if you want to be a "+jobname(@class1)+" or a "+jobname(@class2)+"?";
  187. close;
  188. Oddities of the System:
  189. -------------------------------------------------------------------------------
  190. About Bards and Dancers:
  191. These two classes are considered the same in eA's job system, since they
  192. both are the 2-2 job of archers. The only way to tell them apart is by
  193. using the gender of the character we are referring to. The script command
  194. roclass() will automatically use the gender of the attached player (or
  195. 'male' if there's no such player), but you can also explicitly pass the
  196. gender to the script command when there's no player attached.
  197. About Novices and Super Novices:
  198. These are treated a bit differently from you'd expect. Because.. for
  199. instance, a novice is not supposed to be a 1st class, but it is considered
  200. as one on this tree system:
  201. EAJ_NOVICE -> Novice
  202. EAJ_NOVICE|EAJL_2_1 -> EAJ_SUPER_NOVICE
  203. EAJ_NOVICE|EAJL_UPPER -> EAJ_NOVICE_HIGH
  204. EAJ_NOVICE|EAJL_BABY -> EAJ_BABY
  205. EAJ_NOVICE|EAJL_BABY|EAJL_2_1 -> EAJ_SUPER_BABY
  206. So as you can see, on this job system, the Super Novice is treated as the
  207. 2-1 job of a Novice, and the Novice job it's at the same level of the other
  208. 1st jobs. Even though that may seem like a hindrance, it makes it very easy
  209. to add a check to discard Novice types from a quest:
  210. if ((eaclass()&EAJ_BASEMASK) == EAJ_NOVICE)
  211. //Novice class detected.