jobmaster.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. //===== rAthena Script =======================================
  2. //= Job Master
  3. //===== Description: =========================================
  4. //= A fully functional job changer.
  5. //===== Additional Comments: =================================
  6. //= 1.0 Initial script. [Euphy]
  7. //= 1.1 Fixed reset on Baby job change.
  8. //= 1.2 Added Expanded Super Novice support and initial Kagerou/Oboro support.
  9. //= 1.3 Kagerou/Oboro added.
  10. //= 1.4 Rebellion added.
  11. //= 1.5 Added option to disable RebirthClass. [mazvi]
  12. //= 1.6 Added option to get job related equipment on change. [Braniff]
  13. //= 1.7 Readability changes. Also added BabyExpanded and BabySummoner classes. [Jey]
  14. //= 1.8 Added option to disable Baby Novice Only but Baby Class can be Enabled [mazvi]
  15. //= 1.9 Migrate/Integrate to Global Functions Platinum Skills. [mazvi]
  16. //============================================================
  17. prontera,153,193,6 script Job Master 123,{
  18. function Get_Job_Equip;
  19. // Checks if the Player has the required level.
  20. // closes if not, returns if yes
  21. function Require_Level {
  22. if (BaseLevel < getarg(0) || JobLevel < getarg(1)) {
  23. .@blvl = getarg(0) - BaseLevel;
  24. .@jlvl = getarg(1) - JobLevel;
  25. mes "Level requirement:";
  26. mes ((getarg(0)>1)?
  27. "^bb0000"+getarg(0)+"^000000 (^bb0000Base^000000) / ":"")+"^00bb00"+
  28. getarg(1)+"^000000 (^00bb00Job^000000)";
  29. mes "You need " +
  30. ((.@blvl > 0) ? "^bb0000"+.@blvl+"^000000 more base levels " +
  31. ((.@jlvl > 0) ? "and " : "") : "") +
  32. ((.@jlvl > 0) ? "^00bb00"+.@jlvl+"^000000 more job levels " : "") +
  33. "to continue.";
  34. close;
  35. }
  36. return;
  37. }
  38. // Checks if the given eac is a baby class
  39. function Is_Baby {
  40. return ((getarg(0, eaclass())&EAJL_BABY)>0);
  41. }
  42. // Checks if the player can change to third class.
  43. // Note: This does not include the level checks.
  44. function Can_Change_Third {
  45. // To change to third class you either need to be:
  46. // * Second Class
  47. // * Transcendent Second Class
  48. // * Baby Second Class
  49. if( !.ThirdClass )
  50. return false; // Third job change disabled
  51. if( !(eaclass()&EAJL_2) )
  52. return false; // Not second Class
  53. if( eaclass()&EAJL_THIRD )
  54. return false; // Already Third Class
  55. if( roclass(eaclass()|EAJL_THIRD) < 0 )
  56. return false; // Job has no third Class
  57. if( (eaclass()&EAJ_UPPERMASK) == EAJ_SUPER_NOVICE )
  58. return false; // Exp. Super Novice equals 3rd Cls, but has it's own case
  59. if( Is_Baby() && (!.BabyClass || !.BabyThird) )
  60. return false; // No Baby (Third) change allowed
  61. return true;
  62. }
  63. function Can_Rebirth {
  64. // To rebirth, you need to be:
  65. // * Second Class
  66. if( !.RebirthClass )
  67. return false; // Rebirth disabled
  68. if( !(eaclass()&EAJL_2) )
  69. return false; // Not second Class
  70. if( eaclass()&(EAJL_UPPER|EAJL_THIRD) )
  71. return false; // Already Rebirthed/ Third Class
  72. if( roclass(eaclass()|EAJL_UPPER) < 0 )
  73. return false; // Job has no transcended class
  74. if( Is_Baby() && !.BabyClass )
  75. return false; // No Baby changes allowed
  76. return true;
  77. }
  78. // Checks if the given eac is a first class
  79. function Is_First_Cls {
  80. return (getarg(0) <= EAJ_TAEKWON);
  81. }
  82. function Check_Riding {
  83. // Note: Why we should always check for Riding:
  84. // Mounts are considered as another class, which
  85. // would make this NPC bigger just to handle with
  86. // those special cases.
  87. if (checkfalcon() || checkcart() || checkriding() || ismounting()) {
  88. mes "Please remove your " +
  89. ((checkfalcon()) ? "falcon" : "") +
  90. ((checkcart()) ? "cart" : "") +
  91. ((checkriding()) ? "Peco" : "") +
  92. ((ismounting()) ? "mount" : "") +
  93. " before proceeding.";
  94. close;
  95. }
  96. return;
  97. }
  98. function Check_SkillPoints {
  99. if (.SkillPointCheck && SkillPoint) {
  100. mes "Please use all your skill points before proceeding.";
  101. close;
  102. }
  103. return;
  104. }
  105. // addJobOptions is essentially the same like
  106. // setarray .@array[getarraysize(.@array)],opt1,opt2,...;
  107. // It's just easier to read, since we're using it very often
  108. function Job_Options {
  109. .@argcount = getargcount();
  110. .@arr_size = getarraysize(getarg(0));
  111. for( .@i = 1; .@i < .@argcount; .@i++) {
  112. setarray getelementofarray(getarg(0), .@arr_size++),getarg(.@i);
  113. }
  114. }
  115. // Begin of the NPC
  116. mes .NPCName$;
  117. Check_Riding();
  118. Check_SkillPoints();
  119. // initialisation
  120. .@eac = eaclass();
  121. .@third_possible = Can_Change_Third();
  122. .@rebirth_possible = Can_Rebirth();
  123. .@first_eac = .@eac&EAJ_BASEMASK;
  124. .@second_eac = .@eac&EAJ_UPPERMASK;
  125. // Note: These are already set in pc.cpp
  126. // BaseClass = roclass(.@eac&EAJ_BASEMASK) which is the players First Class
  127. // BaseJob = roclass(.@eac&EAJ_UPPERMASK) which is the players Second Class
  128. //dispbottom "Debug: eac ("+.@eac+"), third ("+.@third_possible+"), rebirth("+.@rebirth_possible+"), BaseClass ("+BaseClass+"), BaseJob ("+BaseJob+")";
  129. // From here on the jobmaster checks the current class
  130. // and fills the the array `.@job_opt` with possible
  131. // job options for the player.
  132. if( .@rebirth_possible ) {
  133. // Rebirth option (displayed on the top of the menu)
  134. Require_Level(.Req_Rebirth[0], .Req_Rebirth[1]);
  135. Job_Options(.@job_opt, Job_Novice_High);
  136. }
  137. if( .@third_possible ) {
  138. // Third Job change (displayed below rebirth)
  139. Require_Level(.Req_Third[0], .Req_Third[1]);
  140. Job_Options(.@job_opt, roclass(.@eac|EAJL_THIRD));
  141. }
  142. if (.SecondExpanded &&
  143. (.@eac&EAJ_UPPERMASK) == EAJ_SUPER_NOVICE && // is Super Novice
  144. !(eaclass()&EAJL_THIRD) ) { // not already Expanded SN
  145. // (Baby) Super Novice to Expanded (Baby) Super Novice
  146. if( !Is_Baby(.@eac) || (.BabyClass && .BabyExpanded) ) {
  147. // .BabyClass & .BabyExpanded must be enabled if the is a baby
  148. Require_Level(.Req_Exp_SNOVI[0], .Req_Exp_SNOVI[1]);
  149. Job_Options(.@job_opt,roclass(.@eac|EAJL_THIRD)); // Expanded SN is "third" cls
  150. }
  151. }
  152. if (.SecondExpanded &&
  153. ((.@eac&(~EAJL_BABY)) == EAJ_NINJA || // is (Baby) Ninja
  154. (.@eac&(~EAJL_BABY)) == EAJ_GUNSLINGER)) { // is (Baby) Gunslinger
  155. // (Baby) Ninja to (Baby) Kagerou / Oboro
  156. // (Baby) Gunslinger to (Baby) Rebellion
  157. if( !Is_Baby(.@eac) || (.BabyClass && .BabyExpanded) ) {
  158. // .BabyClass & .BabyExpanded must be enabled if the is a baby
  159. Require_Level(.Req_Exp_NJ_GS[0], .Req_Exp_NJ_GS[1]);
  160. // Kagerou, Oboro, Rebellion are considered as a 2-1 class
  161. Job_Options(.@job_opt, roclass(.@eac|EAJL_2_1));
  162. }
  163. }
  164. // Player is Job_Novice, Job_Novice_High or Job_Baby
  165. if (.@first_eac == EAJ_NOVICE && .@second_eac != EAJ_SUPER_NOVICE) {
  166. // MAPID_NOVICE, MAPID_SUPER_NOVICE, MAPID_NOVICE_HIGH, MAPID_BABY
  167. Require_Level(.Req_First[0], .Req_First[1]);
  168. switch(Class) {
  169. case Job_Novice:
  170. // First job change
  171. Job_Options(.@job_opt,Job_Swordman,
  172. Job_Mage, Job_Archer, Job_Acolyte, Job_Merchant, Job_Thief,
  173. Job_Super_Novice, Job_Taekwon, Job_Gunslinger, Job_Ninja);
  174. if( .BabyNovice )
  175. Job_Options(.@job_opt, Job_Baby);
  176. break;
  177. case Job_Novice_High:
  178. // Job change after rebirth
  179. if( .LastJob && lastJob )
  180. Job_Options(.@job_opt,
  181. roclass((eaclass(lastJob)&EAJ_BASEMASK)|EAJL_UPPER));
  182. else
  183. Job_Options(.@job_opt,
  184. Job_Swordman_High, Job_Mage_High, Job_Archer_High,
  185. Job_Acolyte_High, Job_Merchant_High, Job_Thief_High);
  186. break;
  187. case Job_Baby:
  188. if( !.BabyClass )
  189. break;
  190. // First job change as a baby
  191. Job_Options(.@job_opt, Job_Baby_Swordman, Job_Baby_Mage,
  192. Job_Baby_Archer,Job_Baby_Acolyte, Job_Baby_Merchant,
  193. Job_Baby_Thief);
  194. if( .BabyExpanded )
  195. Job_Options(.@job_opt, Job_Super_Baby, Job_Baby_Taekwon,
  196. Job_Baby_Gunslinger, Job_Baby_Ninja);
  197. if( .BabySummoner )
  198. Job_Options(.@job_opt, Job_Baby_Summoner);
  199. break;
  200. default:
  201. mes "An error has occurred.";
  202. close;
  203. }
  204. } else if( Is_First_Cls(.@eac) || // First Class
  205. Is_First_Cls(.@eac&(~EAJL_UPPER)) || // Trans. First Cls
  206. (.BabyClass && Is_First_Cls(.@eac&(~EAJL_BABY))) ) { // Baby First Cls
  207. // Player is First Class (not Novice)
  208. // most jobs should have two options here (2-1 and 2-2)
  209. .@class1 = roclass(.@eac|EAJL_2_1); // 2-1
  210. .@class2 = roclass(.@eac|EAJL_2_2); // 2-2
  211. // dispbottom "Debug: Classes: class1 ("+.@class1+"), class2 ("+.@class2+")";
  212. if(.LastJob && lastJob && (.@eac&EAJL_UPPER)) {
  213. // Player is rebirth Cls and linear class changes are enforced
  214. Require_Level(.Req_Second[0], .Req_Second[1]);
  215. Job_Options(.@job_opt, lastJob + Job_Novice_High);
  216. } else {
  217. // Class is not enforced, player can decide.
  218. if( .@class1 > 0 ) { // 2-1
  219. Require_Level(.Req_Second[0], .Req_Second[1]);
  220. Job_Options(.@job_opt, .@class1);
  221. }
  222. if( .@class2 > 0 ) { // 2-2
  223. Require_Level(.Req_Second[0], .Req_Second[1]);
  224. Job_Options(.@job_opt, .@class2);
  225. }
  226. }
  227. }
  228. // Displaying the Job Menu defined by .@job_opt.
  229. // .@job_opt should not be changed below this line.
  230. function Job_Menu;
  231. Job_Menu(.@job_opt);
  232. close;
  233. // Displays the job menu
  234. function Job_Menu {
  235. // getarg(0) is the .@job_opt array holding all available job changes.
  236. function Confirm_Change;
  237. while(true) {
  238. .@opt_cnt = getarraysize(getarg(0));
  239. if( .@opt_cnt <= 0 ) {
  240. mes "No more jobs are available.";
  241. close;
  242. }
  243. .@selected = 0; // Just a single job class given, no select needed
  244. if (.@opt_cnt > 1) {
  245. // Multiple job classes given. Select one and save it to .@class
  246. // After that confirm .@class
  247. mes "Select a job.";
  248. .@menu$ = "";
  249. for (.@i = 0; .@i < .@opt_cnt; .@i++) {
  250. if( getelementofarray(getarg(0), .@i) == Job_Novice_High)
  251. .@jobname$ = "^0055FFRebirth^000000";
  252. else
  253. .@jobname$ = jobname(getelementofarray(getarg(0), .@i));
  254. .@menu$ = .@menu$ + " ~ " + .@jobname$ + ":";
  255. }
  256. .@menu$ = .@menu$+" ~ ^777777Cancel^000000";
  257. .@selected = select(.@menu$) - 1;
  258. if( .@selected < 0 || .@selected >= .@opt_cnt )
  259. close;
  260. next;
  261. mes .NPCName$;
  262. }
  263. .@class = getelementofarray(getarg(0), .@selected);
  264. if ((.@class == Job_Super_Novice || .@class == Job_Super_Baby) &&
  265. BaseLevel < .SNovice) {
  266. // Special Level Requirement because Super Novice and
  267. // Super Baby can both be selected in one of the first class
  268. // changes. That's why the Level Requirement is after and not before
  269. // the selection.
  270. mes "A base level of " + .SNovice +
  271. " is required to turn into a " + jobname(.@class) + ".";
  272. return;
  273. }
  274. // Confirm the Class
  275. Confirm_Change(.@class, .@opt_cnt > 1);
  276. next;
  277. mes .NPCName$;
  278. }
  279. return;
  280. }
  281. // Executes the actual jobchange and closes.
  282. function Job_Change {
  283. .@previous_class = Class;
  284. .@to_cls = getarg(0);
  285. next;
  286. mes .NPCName$;
  287. mes "You are now " + callfunc("F_InsertArticle", jobname(.@to_cls)) + "!";
  288. if (.@to_cls == Job_Novice_High && .LastJob)
  289. lastJob = Class; // Saves the lastJob for rebirth
  290. jobchange .@to_cls;
  291. if (.@to_cls == Job_Novice_High)
  292. resetlvl(1);
  293. else if (.@to_cls == Job_Baby) {
  294. resetstatus;
  295. resetskill;
  296. set SkillPoint,0;
  297. }
  298. specialeffect2 EF_ANGEL2;
  299. specialeffect2 EF_ELECTRIC;
  300. if (.@previous_class != Class) {
  301. if (.Platinum)
  302. callfunc "F_GetPlatinumSkills";
  303. if (.GetJobEquip)
  304. Get_Job_Equip();
  305. }
  306. close; // Always closes after the change
  307. }
  308. function Confirm_Change {
  309. // Player confirms he want to change into .@class
  310. .@class = getarg(0, -1);
  311. .@back = getarg(1, false);
  312. if( .@class < 0 || eaclass(.@class) == -1 ) {
  313. mes "Unknown Class Error.";
  314. close;
  315. }
  316. mes "Do you want to change into ^0055FF"+jobname(.@class)+"^000000 class?";
  317. .@job_option$ = " ~ Change into ^0055FF"+jobname(.@class)+"^000000 class";
  318. if( .@class == Job_Novice_High)
  319. .@job_option$ = " ~ ^0055FFRebirth^000000";
  320. if (select(.@job_option$+": ~ ^777777" +
  321. ((.@back) ?"Go back" : "Cancel") + "^000000") == 1) {
  322. Job_Change(.@class);
  323. }
  324. if (!.@back)
  325. close; // "Cancel" pressed
  326. return;
  327. }
  328. // Function which gives a job related item to the player
  329. // the items are the rewards from the original job change quests
  330. function Get_Job_Equip {
  331. // Note: The item is dropping, when the player can't hold it.
  332. // But that's better than not giving the item at all.
  333. .@eac = eaclass();
  334. if( .@eac&EAJL_THIRD ) {
  335. // Third Class Items
  336. getitem 2795,1; // Green Apple Ring for every 3rd Class
  337. switch(BaseJob) {
  338. // BaseJob of Third Cls
  339. // For Normal Third, Baby Third and Transcended Third Cls
  340. case Job_Knight:
  341. getitem 5746,1; break; // Rune Circlet [1]
  342. case Job_Wizard:
  343. getitem 5753,1; break; // Magic Stone Hat [1]
  344. case Job_Hunter:
  345. getitem 5748,1; break; // Sniper Goggle [1]
  346. case Job_Priest:
  347. getitem 5747,1; break; // Mitra [1]
  348. case Job_Blacksmith:
  349. getitem 5749,1; break; // Driver Band [1]
  350. case Job_Assassin:
  351. getitem 5755,1; break; // Silent Executor [1]
  352. case Job_Crusader:
  353. getitem 5757,1; break; // Dip Schmidt Helm [1]
  354. case Job_Sage:
  355. getitem 5756,1; break; // Wind Whisper [1]
  356. case Job_Bard:
  357. getitem 5751,1; break; // Maestro Song's Hat [1]
  358. case Job_Dancer:
  359. getitem 5758,1; break; // Dying Swan [1]
  360. case Job_Monk:
  361. getitem 5754,1; break; // Blazing Soul [1]
  362. case Job_Alchemist:
  363. getitem 5752,1; break; // Midas Whisper[1]
  364. case Job_Rogue:
  365. getitem 5750,1; // Shadow Handicraft [1]
  366. getitem 6121,1; // Makeover Brush
  367. getitem 6122,1; break; // Paint Brush
  368. }
  369. } else if (.@eac&EAJL_2) {
  370. // Second Class (And not Third Class)
  371. switch(BaseJob) {
  372. // Second Class
  373. case Job_Knight:
  374. getitem 1163,1; break; // Claymore [0]
  375. case Job_Priest:
  376. getitem 1522,1; break; // Stunner [0]
  377. case Job_Wizard:
  378. getitem 1617,1; break; // Survivor's Rod [0]
  379. case Job_Blacksmith:
  380. getitem 1360,1; break; // Two-Handed-Axe [1]
  381. case Job_Hunter:
  382. getitem 1718,1; break; // Hunter Bow [0]
  383. case Job_Assassin:
  384. getitem 1254,1; break; // Jamadhar [0]
  385. case Job_Crusader:
  386. getitem 1410,1; break; // Lance [0]
  387. case Job_Monk:
  388. getitem 1807,1; break; // Fist [0]
  389. case Job_Sage:
  390. getitem 1550,1; break; // Book [3]
  391. case Job_Rogue:
  392. getitem 1222,1; break; // Damascus [1]
  393. case Job_Alchemist:
  394. getitem 1126,1; break; // Saber [2]
  395. case Job_Bard:
  396. getitem 1907,1; break; // Guitar [0]
  397. case Job_Dancer:
  398. getitem 1960,1; break; // Whip [1]
  399. case Job_Super_Novice:
  400. getitem 1208,1; break; // Main Gauche [4]
  401. case Job_Star_Gladiator:
  402. getitem 1550,1; break; // Book [3]
  403. case Job_Soul_Linker:
  404. getitem 1617,1; break; // Survivor's Rod [0]
  405. }
  406. } else {
  407. // Neither Second or Third Cls
  408. // => First Cls or not covered by the switch
  409. switch(BaseClass) {
  410. // First Class
  411. case Job_Swordman:
  412. getitem 1108,1; break; // Blade [4]
  413. case Job_Mage:
  414. getitem 1602,1; break; // Rod [4]
  415. case Job_Archer:
  416. getitem 1705,1; break; // Composite Bow [4]
  417. case Job_Acolyte:
  418. getitem 1505,1; break; // Mace [4]
  419. case Job_Merchant:
  420. getitem 1302,1; break; // Axe [4]
  421. case Job_Thief:
  422. getitem 1208,1; break; // Main Gauche [4]
  423. case Job_Gunslinger:
  424. getitem 13101,1; break; // Six Shooter [2]
  425. case Job_Ninja:
  426. getitem 13010,1; break; // Asura [2]
  427. }
  428. }
  429. return;
  430. }
  431. OnInit:
  432. // Initialisation, do not edit these
  433. .NPCName$ = "[Job Master]";
  434. // Settings
  435. .ThirdClass = true; // Enable third classes?
  436. .RebirthClass = true; // Enable rebirth classes?
  437. .SecondExpanded = true; // Enable new expanded second classes: Ex. Super Novice, Kagerou/Oboro, Rebellion?
  438. .BabyNovice = true; // Enable Baby novice classes? Disable it if you like player must have parent to get job baby.
  439. .BabyClass = true; // Enable Baby classes?
  440. .BabyThird = true; // Enable Baby third classes?
  441. .BabyExpanded = true; // Enable Baby Expanded classes: Ex. Baby Ninja, Baby Taekwon, etc.
  442. .BabySummoner = true; // Enable Baby Summoner?
  443. .LastJob = true; // Enforce linear class changes?
  444. .SkillPointCheck = true; // Force player to use up all skill points?
  445. .Platinum = true; // Get platinum skills automatically?
  446. .GetJobEquip = false; // Get job equipment (mostly weapons) on job change?
  447. // Level Requirements
  448. setarray .Req_First[0],1,10; // Minimum base level, job level to turn into 1st class
  449. setarray .Req_Second[0],1,40; // Minimum base level, job level to turn into 2nd class
  450. setarray .Req_Rebirth[0],99,50; // Minimum base level, job level to rebirth
  451. setarray .Req_Third[0],99,50; // Minimum base level, job level to change to third class
  452. setarray .Req_Exp_NJ_GS[0],99,70; // Minimum base level, job level to turn into Expanded Ninja and Gunslinger
  453. setarray .Req_Exp_SNOVI[0],99,99; // Minimum base level, job level to turn into Expanded Super Novice
  454. .SNovice = 45; // Minimum base level to turn into Super Novice
  455. // Setting adjustments by PACKETVER
  456. if( PACKETVER < 20161207 ) {
  457. if( .BabyExpanded )
  458. debugmes "jobmaster: BabyExpanded is disabled due to outdated PACKETVER.";
  459. if( .BabySummoner )
  460. debugmes "jobmaster: BabySummoner is disabled due to outdated PACKETVER.";
  461. .BabyExpanded = false;
  462. .BabySummoner = false;
  463. }
  464. end;
  465. }