ea_job_system.txt 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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.h. 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. - Branch: All classes can be classified as "1st Class", "2-1 Class" or
  49. "2-2 Class":
  50. EAJL_2_1 0x100
  51. EAJL_2_2 0x200
  52. EAJL_2 0x300
  53. - The third category is type. Classes can either be normal, rebirth/advanced,
  54. adopted, or third class.
  55. EAJL_UPPER 0x1000
  56. EAJL_BABY 0x2000
  57. EAJL_THIRD 0x4000
  58. So using these three categories, any job class can be constructed from the
  59. others. Let's take a swordman, for example.
  60. The first step is basic swordman, with nothing else:
  61. EAJ_SWORDMAN
  62. If a swordman is adopted...
  63. EAJ_SWORDMAN|EAJL_BABY -> EAJ_BABY_SWORDMAN
  64. The next step is to either become a 2-1 or a 2-2 job:
  65. EAJ_SWORDMAN|EAJL_2_1 -> EAJ_KNIGHT
  66. EAJ_SWORDMAN|EAJL_2_2 -> EAJ_CRUSADER
  67. Getting out the rebirth versions of a swordman:
  68. EAJ_SWORDMAN|EAJL_UPPER -> EAJ_SWORDMAN_HIGH
  69. EAJ_SWORDMAN|EAJL_2_1|EAJL_UPPER -> EAJ_LORD_KNIGHT
  70. EAJ_SWORDMAN|EAJL_2_2|EAJL_UPPER -> EAJ_PALADIN
  71. Or getting the third job versions:
  72. EAJ_SWORDMAN|EAJL_2_1|EAJL_THIRD -> EAJ_RUNE_KNIGHT
  73. EAJ_SWORDMAN|EAJL_2_2|EAJL_THIRD -> EAJ_ROYAL_GUARD
  74. Why are we using the bitwise OR operand ('|') rather than just adding? Because
  75. the OR is wreck-proof:
  76. EAJ_SWORDMAN_HIGH|EAJL_UPPER -> EAJ_SWORDMAN_HIGH
  77. If we had used addition, we would have gotten a completely different result.
  78. The EAJL (eA Job Level) constants
  79. -------------------------------------------------------------------------------
  80. There are a few constants which can be used to filter out and make job
  81. comparisons easier. The comparisons involve eA job IDs, not classic job
  82. IDs, using the eaclass() command explained in the next section.
  83. set @eac, eaclass();
  84. EAJL_2_1:
  85. Checks if the class is a 2-1 class:
  86. if (@eac&EAJL_2_1)
  87. mes "Using the classic 2-1 job, huh?";
  88. EAJL_2_2:
  89. Checks if the class is a 2-2 class:
  90. if (@eac&EAJL_2_2)
  91. mes "Oh, a 2-2 job!";
  92. EAJL_2:
  93. Checks if the class is a 2nd Class. If the check fails, you can be sure
  94. the character is a first class.
  95. if (!(@eac&EAJL_2))
  96. mes "Will you wait until Job 50 to change?";
  97. EAJL_UPPER:
  98. Check if a class is Rebirth/Advanced:
  99. if(@eac&EAJL_UPPER)
  100. mes "It must have taken you a LONG time...";
  101. EAJL_BABY:
  102. Check if a class is an adopted class.
  103. if (@eac&EAJL_BABY)
  104. mes "Don't you hate being weak?";
  105. EAJL_THIRD:
  106. Checks if a class is a third job.
  107. if(@eac&EAJL_THIRD)
  108. mes "Wow, you've really grown!";
  109. EAJ_UPPERMASK:
  110. The upper mask can be used to "strip" the upper/baby characteristics of a
  111. class, used when you want to know if someone is a certain class regardless
  112. of rebirth/adopted status. For example, the following code would go through
  113. for Monks, Champions and Baby Monks:
  114. if ((@eac&EAJ_UPPERMASK) == EAJ_MONK)
  115. mes "Aren't knuckles such a cool weapon?";
  116. Note that if instead of EAJ_MONK you used EAJ_CHAMPION or EAJ_BABY_MONK,
  117. the check would had never passed, since the upper/baby state has been
  118. removed from the original job when checking.
  119. EAJ_BASEMASK:
  120. This mask strips also the 2nd class attributes. It can be used to check
  121. against the basic job of a character. For example, the following code would
  122. go through for Merchants (+Baby Merchant and High Merchant), Blacksmiths
  123. (+Baby blacksmiths and Whitesmith) and Alchemist (+Baby Alchemist and
  124. +Creator):
  125. if ((@eac&EAJ_BASEMASK) == EAJ_MERCHANT)
  126. mes "Why I can't have discount like you guys do?";
  127. Note that, like before, if you try to check versus any of the other
  128. classes (High merchant, blacksmith, etc) instead of basic merchant, the
  129. check will always fail for the same reasons previously explained.
  130. EAJ_THIRDMASK:
  131. This mask strips 3rd class attributes. It will give the "normal" class of
  132. a third job, regardless of rebirth/adopted status. When used on non-third
  133. class characters, it will return the second job, or, if that also doesn't
  134. exist, the first.
  135. if ((@eac&EAJ_THIRDMASK) == EAJ_WARLOCK_T)
  136. mes "You've gone through rebirth, I see.";
  137. The script commands eaclass, roclass:
  138. -------------------------------------------------------------------------------
  139. These script commands are what you can use in scripts to convert between
  140. the RO classic job id, and eA's job system. The following script code
  141. demonstrates how to use these script commands to guess what your next job
  142. will be:
  143. set @eac, eaclass();
  144. if (@eac&EAJL_2)
  145. { //2nd class
  146. //If upper or baby, you can't rebirth
  147. if (@eac&(EAJL_UPPER|EAJL_BABY)) {
  148. mes "You can't go anywhere, can you?";
  149. close;
  150. }
  151. //Note that if we remove the EAJL_BABY check up there, the following
  152. //check will also fail, because there's no such thing as Rebirth-Baby
  153. //classes.
  154. set @newclass, roclass(@eac|EAJL_UPPER);
  155. if (@newclass == -1) {
  156. //Don't you hate this of SG and SL?
  157. mes "Haha, your class doesn't has a rebirth version yet!";
  158. close;
  159. }
  160. mes "Still dreaming of the day you become a "+jobname(@newclass)+"?";
  161. close;
  162. }
  163. set @class1, roclass(@eac|EAJL_2_1);
  164. set @class2, roclass(@eac|EAJL_2_2);
  165. if (@class1 == -1) {
  166. mes "Looks like you are stuck forever on that class.";
  167. close;
  168. }
  169. if (@class2 == -1) {
  170. //Not quite true, currently the only 1st class that doesn't has two
  171. //choices is Novice -> Supernovice (see s.novice section below)
  172. mes "Looks like you have no choice but to be a "+jobname(@class1)+".";
  173. close;
  174. }
  175. mes "Have you decided yet if you want to be a "+jobname(@class1)+" or a "+jobname(@class2)+"?";
  176. close;
  177. Oddities of the System:
  178. -------------------------------------------------------------------------------
  179. About Bards and Dancers:
  180. These two classes are considered the same in eA's job system, since they
  181. both are the 2-2 job of archers. The only way to tell them apart is by
  182. using the gender of the character we are referring to. The script command
  183. roclass() will automatically use the gender of the attached player (or
  184. 'male' if there's no such player), but you can also explicitly pass the
  185. gender to the script command when there's no player attached.
  186. About Novices and Super Novices:
  187. These are treated a bit differently from you'd expect. Because.. for
  188. instance, a novice is not supposed to be a 1st class, but it is considered
  189. as one on this tree system:
  190. EAJ_NOVICE -> Novice
  191. EAJ_NOVICE|EAJL_2_1 -> EAJ_SUPER_NOVICE
  192. EAJ_NOVICE|EAJL_UPPER -> EAJ_NOVICE_HIGH
  193. EAJ_NOVICE|EAJL_BABY -> EAJ_BABY
  194. EAJ_NOVICE|EAJL_BABY|EAJL_2_1 -> EAJ_SUPER_BABY
  195. So as you can see, on this job system, the Super Novice is treated as the
  196. 2-1 job of a Novice, and the Novice job it's at the same level of the other
  197. 1st jobs. Even though that may seem like a hindrance, it makes it very easy
  198. to add a check to discard Novice types from a quest:
  199. if ((eaclass()&EAJ_BASEMASK) == EAJ_NOVICE)
  200. //Novice class detected.