jobmaster.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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 )
  71. return false; // Already Rebirthed
  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. deletearray .@job_opt[0],getarraysize(.@job_opt);
  121. .@eac = eaclass();
  122. .@third_possible = Can_Change_Third();
  123. .@rebirth_possible = Can_Rebirth();
  124. .@first_eac = .@eac&EAJ_BASEMASK;
  125. .@second_eac = .@eac&EAJ_UPPERMASK;
  126. // Note: These are already set in pc.c
  127. // BaseClass = roclass(.@eac&EAJ_BASEMASK) which is the players First Class
  128. // BaseJob = roclass(.@eac&EAJ_UPPERMASK) which is the players Second Class
  129. //dispbottom "Debug: eac ("+.@eac+"), third ("+.@third_possible+"), rebirth("+.@rebirth_possible+"), BaseClass ("+BaseClass+"), BaseJob ("+BaseJob+")";
  130. // From here on the jobmaster checks the current class
  131. // and fills the the array `.@job_opt` with possible
  132. // job options for the player.
  133. if( .@rebirth_possible ) {
  134. // Rebirth option (displayed on the top of the menu)
  135. Require_Level(.Req_Rebirth[0], .Req_Rebirth[1]);
  136. Job_Options(.@job_opt, Job_Novice_High);
  137. }
  138. if( .@third_possible ) {
  139. // Third Job change (displayed below rebirth)
  140. Require_Level(.Req_Third[0], .Req_Third[1]);
  141. Job_Options(.@job_opt, roclass(.@eac|EAJL_THIRD));
  142. }
  143. if (.SecondExpanded &&
  144. (.@eac&EAJ_UPPERMASK) == EAJ_SUPER_NOVICE && // is Super Novice
  145. !(eaclass()&EAJL_THIRD) ) { // not already Expanded SN
  146. // (Baby) Super Novice to Expanded (Baby) Super Novice
  147. if( !Is_Baby(.@eac) || (.BabyClass && .BabyExpanded) ) {
  148. // .BabyClass & .BabyExpanded must be enabled if the is a baby
  149. Require_Level(.Req_Exp_SNOVI[0], .Req_Exp_SNOVI[1]);
  150. Job_Options(.@job_opt,roclass(.@eac|EAJL_THIRD)); // Expanded SN is "third" cls
  151. }
  152. }
  153. if (.SecondExpanded &&
  154. ((.@eac&(~EAJL_BABY)) == EAJ_NINJA || // is (Baby) Ninja
  155. (.@eac&(~EAJL_BABY)) == EAJ_GUNSLINGER)) { // is (Baby) Gunslinger
  156. // (Baby) Ninja to (Baby) Kagerou / Oboro
  157. // (Baby) Gunslinger to (Baby) Rebellion
  158. if( !Is_Baby(.@eac) || (.BabyClass && .BabyExpanded) ) {
  159. // .BabyClass & .BabyExpanded must be enabled if the is a baby
  160. Require_Level(.Req_Exp_NJ_GS[0], .Req_Exp_NJ_GS[1]);
  161. // Kagerou, Oboro, Rebellion are considered as a 2-1 class
  162. Job_Options(.@job_opt, roclass(.@eac|EAJL_2_1));
  163. }
  164. }
  165. // Player is Job_Novice, Job_Novice_High or Job_Baby
  166. if (.@first_eac == EAJ_NOVICE && .@second_eac != EAJ_SUPER_NOVICE) {
  167. // MAPID_NOVICE, MAPID_SUPER_NOVICE, MAPID_NOVICE_HIGH, MAPID_BABY
  168. Require_Level(.Req_First[0], .Req_First[1]);
  169. switch(Class) {
  170. case Job_Novice:
  171. // First job change
  172. Job_Options(.@job_opt,Job_Swordman,
  173. Job_Mage, Job_Archer, Job_Acolyte, Job_Merchant, Job_Thief,
  174. Job_Super_Novice, Job_Taekwon, Job_Gunslinger, Job_Ninja);
  175. if( .BabyNovice )
  176. Job_Options(.@job_opt, Job_Baby);
  177. break;
  178. case Job_Novice_High:
  179. // Job change after rebirth
  180. if( .LastJob && lastJob )
  181. Job_Options(.@job_opt,
  182. roclass((eaclass(lastJob)&EAJ_BASEMASK)|EAJL_UPPER));
  183. else
  184. Job_Options(.@job_opt,
  185. Job_Swordman_High, Job_Mage_High, Job_Archer_High,
  186. Job_Acolyte_High, Job_Merchant_High, Job_Thief_High);
  187. break;
  188. case Job_Baby:
  189. if( !.BabyClass )
  190. break;
  191. // First job change as a baby
  192. Job_Options(.@job_opt, Job_Baby_Swordman, Job_Baby_Mage,
  193. Job_Baby_Archer,Job_Baby_Acolyte, Job_Baby_Merchant,
  194. Job_Baby_Thief);
  195. if( .BabyExpanded )
  196. Job_Options(.@job_opt, Job_Super_Baby, Job_Baby_Taekwon,
  197. Job_Baby_Gunslinger, Job_Baby_Ninja);
  198. if( .BabySummoner )
  199. Job_Options(.@job_opt, Job_Baby_Summoner);
  200. break;
  201. default:
  202. mes "An error has occurred.";
  203. close;
  204. }
  205. } else if( Is_First_Cls(.@eac) || // First Class
  206. Is_First_Cls(.@eac&(~EAJL_UPPER)) || // Trans. First Cls
  207. (.BabyClass && Is_First_Cls(.@eac&(~EAJL_BABY))) ) { // Baby First Cls
  208. // Player is First Class (not Novice)
  209. // most jobs should have two options here (2-1 and 2-2)
  210. .@class1 = roclass(.@eac|EAJL_2_1); // 2-1
  211. .@class2 = roclass(.@eac|EAJL_2_2); // 2-2
  212. // dispbottom "Debug: Classes: class1 ("+.@class1+"), class2 ("+.@class2+")";
  213. if(.LastJob && lastJob && (.@eac&EAJL_UPPER)) {
  214. // Player is rebirth Cls and linear class changes are enforced
  215. Require_Level(.Req_Second[0], .Req_Second[1]);
  216. Job_Options(.@job_opt, lastJob + Job_Novice_High);
  217. } else {
  218. // Class is not enforced, player can decide.
  219. if( .@class1 > 0 ) { // 2-1
  220. Require_Level(.Req_Second[0], .Req_Second[1]);
  221. Job_Options(.@job_opt, .@class1);
  222. }
  223. if( .@class2 > 0 ) { // 2-2
  224. Require_Level(.Req_Second[0], .Req_Second[1]);
  225. Job_Options(.@job_opt, .@class2);
  226. }
  227. }
  228. }
  229. // Displaying the Job Menu defined by .@job_opt.
  230. // .@job_opt should not be changed below this line.
  231. function Job_Menu;
  232. Job_Menu(.@job_opt);
  233. close;
  234. // Displays the job menu
  235. function Job_Menu {
  236. // getarg(0) is the .@job_opt array holding all available job changes.
  237. function Confirm_Change;
  238. while(true) {
  239. .@opt_cnt = getarraysize(getarg(0));
  240. if( .@opt_cnt <= 0 ) {
  241. mes "No more jobs are available.";
  242. close;
  243. }
  244. .@selected = 0; // Just a single job class given, no select needed
  245. if (.@opt_cnt > 1) {
  246. // Multiple job classes given. Select one and save it to .@class
  247. // After that confirm .@class
  248. mes "Select a job.";
  249. .@menu$ = "";
  250. for (.@i = 0; .@i < .@opt_cnt; .@i++) {
  251. if( getelementofarray(getarg(0), .@i) == Job_Novice_High)
  252. .@jobname$ = "^0055FFRebirth^000000";
  253. else
  254. .@jobname$ = jobname(getelementofarray(getarg(0), .@i));
  255. .@menu$ = .@menu$ + " ~ " + .@jobname$ + ":";
  256. }
  257. .@menu$ = .@menu$+" ~ ^777777Cancel^000000";
  258. .@selected = select(.@menu$) - 1;
  259. if( .@selected < 0 || .@selected >= .@opt_cnt )
  260. close;
  261. next;
  262. mes .NPCName$;
  263. }
  264. .@class = getelementofarray(getarg(0), .@selected);
  265. if ((.@class == Job_Super_Novice || .@class == Job_Super_Baby) &&
  266. BaseLevel < .SNovice) {
  267. // Special Level Requirement because Super Novice and
  268. // Supber Baby can both be selected in one of the first class
  269. // changes. That's why the Levelrequirement is after and not before
  270. // the selection.
  271. mes "A base level of " + .SNovice +
  272. " is required to turn into a " + jobname(.@class) + ".";
  273. return;
  274. }
  275. // Confirm the Class
  276. Confirm_Change(.@class, .@opt_cnt > 1);
  277. next;
  278. mes .NPCName$;
  279. }
  280. return;
  281. }
  282. // Executes the actual jobchange and closes.
  283. function Job_Change {
  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 (.Platinum)
  301. callfunc "F_GetPlatinumSkills";
  302. if (.GetJobEquip)
  303. Get_Job_Equip();
  304. close; // Always closes after the change
  305. }
  306. function Confirm_Change {
  307. // Player confirms he want to change into .@class
  308. .@class = getarg(0, -1);
  309. .@back = getarg(1, false);
  310. if( .@class < 0 ) {
  311. mes "Unknow Class Error.";
  312. close;
  313. }
  314. mes "Do you want to change into ^0055FF"+jobname(.@class)+"^000000 class?";
  315. .@job_option$ = " ~ Change into ^0055FF"+jobname(.@class)+"^000000 class";
  316. if( .@class == Job_Novice_High)
  317. .@job_option$ = " ~ ^0055FFRebirth^000000";
  318. if (select(.@job_option$+": ~ ^777777" +
  319. ((.@back) ?"Go back" : "Cancel") + "^000000") == 1) {
  320. Job_Change(.@class);
  321. }
  322. if (!.@back)
  323. close; // "Cancel" pressed
  324. return;
  325. }
  326. // Function which gives a job related item to the player
  327. // the items are the rewards from the original job change quests
  328. function Get_Job_Equip {
  329. // Note: The item is dropping, when the player can't hold it.
  330. // But that's better than not giving the item at all.
  331. .@eac = eaclass();
  332. if( .@eac&EAJL_THIRD ) {
  333. // Third Class Items
  334. getitem 2795,1; // Green Apple Ring for every 3rd Class
  335. switch(BaseJob) {
  336. // BaseJob of Third Cls
  337. // For Normal Third, Baby Third and Transcended Third Cls
  338. case Job_Knight:
  339. getitem 5746,1; break; // Rune Circlet [1]
  340. case Job_Wizard:
  341. getitem 5753,1; break; // Magic Stone Hat [1]
  342. case Job_Hunter:
  343. getitem 5748,1; break; // Sniper Goggle [1]
  344. case Job_Priest:
  345. getitem 5747,1; break; // Mitra [1]
  346. case Job_Blacksmith:
  347. getitem 5749,1; break; // Driver Band [1]
  348. case Job_Assassin:
  349. getitem 5755,1; break; // Silent Executor [1]
  350. case Job_Crusader:
  351. getitem 5757,1; break; // Dip Schmidt Helm [1]
  352. case Job_Sage:
  353. getitem 5756,1; break; // Wind Whisper [1]
  354. case Job_Bard:
  355. getitem 5751,1; break; // Maestro Song's Hat [1]
  356. case Job_Dancer:
  357. getitem 5758,1; break; // Dying Swan [1]
  358. case Job_Monk:
  359. getitem 5754,1; break; // Blazing Soul [1]
  360. case Job_Alchemist:
  361. getitem 5752,1; break; // Midas Whisper[1]
  362. case Job_Rogue:
  363. getitem 5750,1; // Shadow Handicraft [1]
  364. getitem 6121,1; // Makeover Brush
  365. getitem 6122,1; break; // Paint Brush
  366. }
  367. } else if (.@eac&EAJL_2) {
  368. // Second Class (And not Third Class)
  369. switch(BaseJob) {
  370. // Second Class
  371. case Job_Knight:
  372. getitem 1163,1; break; // Claymore [0]
  373. case Job_Priest:
  374. getitem 1522,1; break; // Stunner [0]
  375. case Job_Wizard:
  376. getitem 1617,1; break; // Survivor's Rod [0]
  377. case Job_Blacksmith:
  378. getitem 1360,1; break; // Two-Handed-Axe [1]
  379. case Job_Hunter:
  380. getitem 1718,1; break; // Hunter Bow [0]
  381. case Job_Assassin:
  382. getitem 1254,1; break; // Jamadhar [0]
  383. case Job_Crusader:
  384. getitem 1410,1; break; // Lance [0]
  385. case Job_Monk:
  386. getitem 1807,1; break; // Fist [0]
  387. case Job_Sage:
  388. getitem 1550,1; break; // Book [3]
  389. case Job_Rogue:
  390. getitem 1222,1; break; // Damascus [1]
  391. case Job_Alchemist:
  392. getitem 1126,1; break; // Saber [2]
  393. case Job_Bard:
  394. getitem 1907,1; break; // Guitar [0]
  395. case Job_Dancer:
  396. getitem 1960,1; break; // Whip [1]
  397. case Job_Super_Novice:
  398. getitem 1208,1; break; // Main Gauche [4]
  399. case Job_Gunslinger:
  400. getitem 13101,1; break; // Six Shooter [2]
  401. case Job_Ninja:
  402. getitem 13010,1; break; // Asura [2]
  403. case Job_Star_Gladiator:
  404. getitem 1550,1; break; // Book [3]
  405. case Job_Soul_Linker:
  406. getitem 1617,1; break; // Survivor's Rod [0]
  407. }
  408. } else {
  409. // Neither Second or Third Cls
  410. // => First Cls or not covered by the switch
  411. switch(BaseClass) {
  412. // First Class
  413. case Job_Swordman:
  414. getitem 1108,1; break; // Blade [4]
  415. case Job_Mage:
  416. getitem 1602,1; break; // Rod [4]
  417. case Job_Archer:
  418. getitem 1705,1; break; // Composite Bow [4]
  419. case Job_Acolyte:
  420. getitem 1505,1; break; // Mace [4]
  421. case Job_Merchant:
  422. getitem 1302,1; break; // Axe [4]
  423. case Job_Thief:
  424. getitem 1208,1; break; // Main Gauche [4]
  425. }
  426. }
  427. return;
  428. }
  429. OnInit:
  430. // Initialisation, do not edit these
  431. .NPCName$ = "[Job Master]";
  432. // Settings
  433. .ThirdClass = true; // Enable third classes?
  434. .RebirthClass = true; // Enable rebirth classes?
  435. .SecondExpanded = true; // Enable new expanded second classes: Ex. Super Novice, Kagerou/Oboro, Rebellion?
  436. .BabyNovice = true; // Enable Baby novice classes? Disable it if you like player must have parent to get job baby.
  437. .BabyClass = true; // Enable Baby classes?
  438. .BabyThird = true; // Enable Baby third classes?
  439. .BabyExpanded = true; // Enable Baby Expanded classes: Ex. Baby Ninja, Baby Taekwon, etc.
  440. .BabySummoner = true; // Enable Baby Summoner?
  441. .LastJob = true; // Enforce linear class changes?
  442. .SkillPointCheck = true; // Force player to use up all skill points?
  443. .Platinum = true; // Get platinum skills automatically?
  444. .GetJobEquip = false; // Get job equipment (mostly weapons) on job change?
  445. // Level Requirements
  446. setarray .Req_First[0],1,10; // Minimum base level, job level to turn into 1st class
  447. setarray .Req_Second[0],1,40; // Minimum base level, job level to turn into 2nd class
  448. setarray .Req_Rebirth[0],99,50; // Minimum base level, job level to rebirth
  449. setarray .Req_Third[0],99,50; // Minimum base level, job level to change to third class
  450. setarray .Req_Exp_NJ_GS[0],99,70; // Minimum base level, job level to turn into Expanded Ninja and Gunslinger
  451. setarray .Req_Exp_SNOVI[0],99,99; // Minimum base level, job level to turn into Expanded Super Novice
  452. .SNovice = 45; // Minimum base level to turn into Super Novice
  453. // Setting adjustments by PACKETVER
  454. if( PACKETVER < 20161207 ) {
  455. if( .BabyExpanded )
  456. debugmes "jobmaster: BabyExpanded is disabled due to outdated PACKETVER.";
  457. if( .BabySummoner )
  458. debugmes "jobmaster: BabySummoner is disabled due to outdated PACKETVER.";
  459. .BabyExpanded = false;
  460. .BabySummoner = false;
  461. }
  462. end;
  463. }