Advertisement
johnlol

jobmasterFULL

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