This script is a result of me exploring the possibilities of NPC scripting.
It's not meant to be as much of a short / effective script, as it is an interesting script showing a few things I think are cool that can be done in npc scripting.
And yes, I know there are multiple releases allready that adress job selecting and starterpacks, this one is kinda up to date though, and as stated, had no purpose as to making those other releases obsolete, it was just me trying some things.
function start() { status = -1; action(1, 0, 0); }
function action(mode, type, selection) { if (mode == 1) status++; else if (mode == -1) status--; else { cm.dispose(); return; } if (status == 0) { if (cm.getPlayer().getLevel() >= 10 && cm.getPlayer().getLevel() < 50 ) cm.sendYesNo("Oh hello there! Here comes a though decision:\r\n\r\nEither stay on your current path, or change it by selecting a different job."); else { cm.sendOk("You may not advance yet. You must be at least level 10 to proceed."); cm.dispose(); } } else if (status == 1) { cm.sendSimple("Please, pick a job:\r\n\r\n" + "#L0#Adventurer#l\r\n" + "#L1000#Knight of Cygnus#l\r\n" + "#L3000#Resistance#l\r\n" + "#L3001#Demon#l\r\n" + "#L501#Cannoneer#l\r\n" + "#L2000#Aran#l\r\n" + "#L2001#Evan#l\r\n" + "#L2002#Mercedes#l\r\n" + "#L2003#Phantom#l\r\n" + "#L2004#Luminous#l\r\n" + "#L3002#Xenon#l\r\n" + /* "#L6000#Kaiser#l\r\n" + */ "#L6001#Angelic Buster#l\r\n" + "#L2000#Aran#l\r\n" + "#L4001#Hayato#l\r\n" + "#L4002#Kanna#l\r\n" + "#L5000#Mihile#l\r\n" + "#L2000#Aran#l\r\n" + "#L10000#Zero#l\r\n" + "#L2000#Dual Blade#l\r\n"); }else if (status == 2) { switch (selection) { case 0: // Adventurer jobSelection(0); break; case 1000: // Cygnus knight jobSelection(1); break; case 3000: // Resistance jobSelection(2); break; case 3001: // Demon jobSelection(8); break; //Special Jobs case 501: // Pirate(Cannoneer) cm.getPlayer().changeJob(530); proccespackage(); break; case 2000: // Legend(Aran) cm.getPlayer().changeJob(2100); proccespackage(); break; case 2001: // Farmer(Evan) cm.getPlayer().changeJob(2200); proccespackage(); break; case 2002: // Mercedes cm.getPlayer().changeJob(2300); proccespackage(); break; case 2003: // Phantom Jr. cm.getPlayer().changeJob(2400); proccespackage(); break; case 2004: // Luminous cm.getPlayer().changeJob(2710); proccespackage(); break; case 3002: // Xenon cm.getPlayer().changeJob(3600); proccespackage(); break; case 6000: // Kaiser cm.getPlayer().changeJob(6100); proccespackage(); break; case 6001: // Angelic Buster cm.getPlayer().changeJob(6500); proccespackage(); break; /* case 11000: // Beast Tamer cm.getPlayer().changeJob(11200); proccespackage(); break; */ case 4001: // Hayato cm.getPlayer().changeJob(4100); proccespackage(); break; case 4002: // Kanna cm.getPlayer().changeJob(4200); proccespackage(); break; case 5000: // Mihile cm.getPlayer().changeJob(5100); proccespackage(); break; case 10000: // Zero cm.getPlayer().changeJob(10000); proccespackage(); break; case 430: // Dual Blade cm.getPlayer().changeJob(430); proccespackage(); break; } } else if (status == 3) { select = selection; cm.sendYesNo("Are you sure you want to Job Advance?"); } else if (status == 4) { cm.getPlayer().changeJob(select); proccespackage(); } }
Any feedback or know of other 'cool' things I can do with npc scripting? Lemme know xD
-- Some credits to some other posts, like the job advancer which gave me the idea, and some starterpack npc released somewhere which had some nice packages to use
17-02-15
TamixPro
Re: Job selector and starter pack distributor (npc)
Nice Release! :thumbup:
17-02-15
SharpAceX
Re: Job selector and starter pack distributor (npc)
I respect the amount of time and effort put into this.
Some suggestions:
Use variables. For example, var job = cm.getPlayer().getJob(). Not doing so makes the code way longer than it has to be.
Use a switch case in proccespackage so that you can improve the readability.
Might be a challenge to dramatically shorten this script given the sheer amount of work this npc is trying to do, so honestly not bad for a beginner.
17-02-15
Novak
Re: Job selector and starter pack distributor (npc)
Quote:
Originally Posted by SharpAceX
I respect the amount of time and effort put into this.
Some suggestions:
Use variables. For example, var job = cm.getPlayer().getJob(). Not doing so makes the code way longer than it has to be.
Use a switch case in proccespackage so that you can improve the readability.
Might be a challenge to dramatically shorten this script given the sheer amount of work this npc is trying to do, so honestly not bad for a beginner.
Ah ofcource, why use a switch in one place, and not in the other? Ill be doing that now, and post a new one after a while :D
And the variables are also a good call ;)
- - - Updated - - -
Allright! Posted a new one ;) So what do you think of this one? :p
17-02-15
Eric
Re: Job selector and starter pack distributor (npc)
Quote:
Originally Posted by Novak
Ah ofcource, why use a switch in one place, and not in the other? Ill be doing that now, and post a new one after a while :D
And the variables are also a good call ;)
- - - Updated - - -
Allright! Posted a new one ;) So what do you think of this one? :p
I never tested it in JavaScript, but in Java you can't do:
case 100:
case 1100:
case 2000:
case 2100:
case 3100:
case 5100:
case 6000:
break;
Nonetheless, great script. I don't see many people using multiple functions in NPC's, usually they just have a very large start or action method repeating a long if statement or whatever upon selections.
17-02-15
Novak
Re: Job selector and starter pack distributor (npc)
Quote:
Originally Posted by chunkarama
I never tested it in JavaScript, but in Java you can't do: