- Joined
- May 2, 2008
- Messages
- 9
- Reaction score
- 1
Hello guys,
I am DarkDevil (or DrDoom on LocalMS).
This is my first complicated NPC, so don't be too hard on me please
What it does: If you are a GM, and level 200 or above, and have the 4th job, this NPC can be very useful for you.
It can give you the best equipment there is for your class. It can give you another job, it can give you the Wizet clothes, en the best of all, it can remove all the items from a specific tab!
As for the equipment, there is a LOT of code to accomplish that. It automatically gives you almost all your items, except for the weapons because I can't know if you'd like 1h or 2h weapons
And bandits also get automatically their STR or LUK equip
The code is in the bottom of my post.
If you edit it, and want to release it again, please give me the credit and don't leech.
For the people who want to learn how arrays work, you can take a look at my code, since I used them a lot.
If you have any questions, you can post them here
Tested on V83 LocalMS and everything works fine.
Code:
I am DarkDevil (or DrDoom on LocalMS).
This is my first complicated NPC, so don't be too hard on me please
What it does: If you are a GM, and level 200 or above, and have the 4th job, this NPC can be very useful for you.
It can give you the best equipment there is for your class. It can give you another job, it can give you the Wizet clothes, en the best of all, it can remove all the items from a specific tab!
As for the equipment, there is a LOT of code to accomplish that. It automatically gives you almost all your items, except for the weapons because I can't know if you'd like 1h or 2h weapons
And bandits also get automatically their STR or LUK equip
The code is in the bottom of my post.
If you edit it, and want to release it again, please give me the credit and don't leech.
For the people who want to learn how arrays work, you can take a look at my code, since I used them a lot.
If you have any questions, you can post them here
Tested on V83 LocalMS and everything works fine.
Code:
PHP:
var status = 0;
var gmClothes = new Array(1002140, 1042003, 1062007, 1322013, 1072200); //Hat, suit, pants, suitcase, shoes
var jobs = new Array(
/*1st jobs*/ new Array(0, 100, 200, 300, 400, 500, 900, 1000, 1100, 1200, 1300, 1400, 1500, 2000, 2100),
/*2nd jobs*/ new Array(110, 120, 130, 210, 220, 230, 310, 320, 410, 420, 510, 520, 910, 1110, 1210, 1310, 1410, 1510, 2110),
/*3rd jobs*/ new Array(111, 121, 131, 211, 221, 231, 311, 321, 411, 421, 511, 521, 1111, 1211, 1311, 1411, 1511, 2111),
/*4th jobs*/ new Array(112, 122, 132, 212, 222, 232, 312, 322, 412, 421, 512, 522, 2112)
);
var weapons = new Array(
/*warrior*/ new Array(1302081, 1402046, 1312037, 1412033, 1322060, 1422037, 1432047, 1442063), /*1h sword, 2h sword, 1h axe, 2h axe, 1h bw, 2h bw, spear, polearm*/
/*magician*/ new Array(1372042, 1382052), /*elemental wand8, elemental staff8*/
/*archer*/ new Array(1452057, 1462050), /*bow, x-bow*/
/*thief*/ new Array(1472068, 1332074, 1332073), /*claw, luk dagger, str dagger*/
/*pirates*/ new Array(1482023, 1492023) /*knuckle, gun*/
);
var equips = new Array(
/*warrior*/ new Array(1003026, 1052155, 1072355, 1082223, 1102206, 1032061, 1022089, 1012186, 1122059, 1132004, 1142064, 1112405), /*scarlion hat (str), timeless overall, timeless shoe, scg, blackfist cloak, glittering altaire earrings, archeologist glasses, gras mask, MoN, black belt, dojo medal, lilins ring3*/
/*magician*/ new Array(1003023, 1052156, 1072356, 1082246, 1102042, 1032048, 1022089, 1012186, 1122059, 1132004, 1142010, 1112405, 1092057), /*targar hat (int), timeless overall, timeless shoe, flamekeeper cordon, PAC, crystal leaf earrings, archeologist glasses, gras mask, MoN, black belt, wiseman medal, lilins ring3, timeless shield*/
/*archer*/ new Array(1003025, 1052157, 1072344, 1082223, 1102206, 1032061, 1022089, 1012186, 1122059, 1132016, 1142064, 1112405), /*scar hat (dex), timeless overall, fs, scg, blackfist cloak, glittering altaire earrings, archeologist glasses, Royal Red Mardi Gras Mask, MoN, witchs belt, mu lung dojo medal, lilins ring3*/
/*thief*/ new Array(
/*luk bandit/sin*/ new Array(1003024, 1052158, 1072344, 1082223, 1102206, 1032061, 1022089, 1012186, 1122059, 1132016, 1142064, 1112405), /*targar hat (luk), Timeless overall, fs, scg, blackfist cloak, glittering altaire earrings, archeologist glasses, Royal Red Mardi Gras Mask, MoN, witchs belt, mu lung dojo medal, lilins ring3*/
/*str bandit*/ new Array(1003026, new Array(1050096, 1051090), 1072344, 1082223, 1102206, 1032061, 1022089, 1012186, 1122059, 1132016, 1142064, 1112405) /*scar hat (str), green lvl 100 overall (m/f), fs, scg, blackfist cloak, glittering altaire earrings, archeologist glasses, Royal Red Mardi Gras Mask, MoN, witchs belt, mu lung dojo medal, lilins ring3*/
),
/*pirates*/ new Array(
/*knuckle*/ new Array(1003026, 1052159, 1072344, 1082223, 1102206, 1032061, 1022089, 1012186, 1122059, 1132016, 1142064, 1112405), /*scar hat (str), timeless overall, , fs, scg, blackfist cloak, glittering altaire earrings, archeologist glasses, Royal Red Mardi Gras Mask, MoN, witchs belt, mu lung dojo medal, lilins ring3*/
/*gun*/ new Array(1003025, 1052159, 1072344, 1082223, 1102206, 1032061, 1022089, 1012186, 1122059, 1132016, 1142064, 1112405) /*scar hat (dex), timeless overall, fs, scg, blackfist cloak, glittering altaire earrings, archeologist glasses, Royal Red Mardi Gras Mask, MoN, witchs belt, mu lung dojo medal, lilins ring3*/
)
);
var tabRemove = -1; //Which tab to remove the items from
var jobNmb = -1; //Which job advance
var choices = new Array(); //contains the choices for the weapons
importPackage(Packages.client);
/**
*@creator: DrDoom
*@npcid: 2141002
*@npcname: Forgotten Temple Keeper
*@purpose: to help GMs which are level 200 or higher, and have the 4th job adv (or SUPER GM job)
*@map: Forgotten Twilight (270050200)
*@versionMaple: v83
*/
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode != 1) {
cm.dispose();
return;
}
else {
status++;
if(status == 0){
if (!cm.getPlayer().isGM()) {
cm.sendOk("Nice weather is it eh?");
cm.dispose();
return;
}
else if (cm.getLevel() < 200) {
cm.sendOk("I'm sorry #b#h ##k, but I only want to help you if you've made it to level 200. \r\nProve me that you are a true GM and use the right command!");
cm.dispose();
return;
}
else if (cm.getJobId() % 10 != 2) {
cm.sendOk("I'm sorry #b#h ##k, but I only want to help you if you've got the 4th job advancement. \r\nProve me that you are a true GM and use the right command!");
cm.dispose();
return;
}
else {
var msg = "Hello there #bGM#k! Please tell me what I can do for you!\r\n\r\n";
msg += "#b#L0#Give me the best equipment you can get!#l\r\n";
msg += "#L1#Give me a new job!#l\r\n";
msg += "#L2#Give me my Wizet equipment back!#l\r\n";
msg += "#L3#Remove all the items from my tab please! I'm lazy...#l\r\n";
cm.sendSimple(msg);
}
}
else if(status == 1){
//Equipment selection
if (selection == 0) {
var msg = "Ok than, I will give you the best equipment I have for your job...\r\nHang on a second...";
cm.sendNext(msg);
}
//Job selection
else if (selection == 1) {
var msg = "Which job stage do you want have?\r\n\r\n#b";
msg += "#L0#First job#l\r\n";
msg += "#L1#Second job#l\r\n";
msg += "#L2#Third job#l\r\n";
msg += "#L3#Fourth job#l\r\n";
cm.sendSimple(msg);
}
//Wizet equipment
else if (selection == 2) {
var msg = "";
//For all the gm clothes, check if the player has it. if it does, than dont give that one. also makes a message which tells the user which items he gained
for (var i = 0; i < gmClothes.length; i++) {
if (!cm.getPlayer().haveItem(gmClothes[i]) && !cm.getPlayer().haveItemEquipped(gmClothes[i])) {
if (msg == "") {
msg = "Ok here I am again. I gave you back your #b#z" + gmClothes[i] + "##k";
}
else {
msg += ", #b#z" + gmClothes[i] + "##k";
}
if (cm.canHold(gmClothes[i]))
cm.gainItem(gmClothes[i], 1);
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
}
if (msg == "")
msg = "You already had all of your Wizet equipment!";
msg = "Ok #b#h ##k, I will give you them back... Hang on a second...\r\n\r\n" + msg;
cm.sendOk(msg);
cm.dispose();
return;
}
//Item removal
else {
var msg = "Ok so you want me to remove #eALL#n items from your tab? Which tab?...\r\n\r\n";
msg += "#b#L4#Equiment tab#l\r\n";
msg += "#L5#Use tab#l\r\n";
msg += "#L6#Set-up tab#l\r\n";
msg += "#L7#Etc tab#l\r\n";
msg += "#L8#Cash tab (no pets)#l\r\n";
cm.sendSimple(msg);
}
}
else if (status == 2) {
//Job selections
if ((selection <= 3) && (selection >= 0)) {
var jobStage = "";
jobNmb = selection;
switch(selection) {
case 0: jobStage = "first"; break;
case 1: jobStage = "second"; break;
case 2: jobStage = "third"; break;
case 3: jobStage = "fourth"; break;
}
var msg = "So you've chosen to get the " + jobStage + "job. Which one will it be than?\r\n\r\n#b";
//Shows all the jobs of <jobStage> job
for (var i = 0; i < jobs[selection].length; i++) {
msg += "#L" + i + "#" + cm.getJobName(jobs[selection][i]) + "#l\r\n";
}
cm.sendSimple(msg);
}
//Item removal
else if ((selection >= 4) && (selection <= 8)) {
var tab = "";
switch(selection) {
case 4: tab = "equipment"; break;
case 5: tab = "use"; break;
case 6: tab = "set-up"; break;
case 7: tab = "etc"; break;
case 8: tab = "cashshop"; break;
}
var msg = "You want me to clear your whole #b" + tab + "#k tab? Are you really sure about this? \r\nI can't get your items back once you've agreed with this.";
tabRemove = (selection - 4);
cm.sendYesNo(msg);
}
//Equipment selection
else {
//Finds out the player class. First checks if its a Cygnus, than if its an Aran, else its an Adventurer
var playerClass = (cm.getJobId() >= 1000 && cm.getJobId() < 2000) ? ((Math.floor((cm.getJobId() - 1000) / 100)) - 1) : (cm.getJobId() >= 2000 ? 0 : (Math.floor((cm.getJobId() / 100)) - 1));
if (playerClass != 3 || cm.getJobId() == 412 || cm.getJobId() == 1412) {
var length = equips[playerClass].length;
switch(cm.getJobId()) {
case 412:
case 1412:
case 1512:
case 512: length = equips[playerClass][0].length; break;
case 522: length = equips[playerClass][1].length; break;
}
//Gives the equips of the corresponding class
for (var i = 0; i < length; i++) {
if (cm.getJobId() == 412 || cm.getJobId() == 1412) {
//3 = rogues, 0 = hermits
if (cm.canHold(equips[3][0][i])) {
cm.gainItem(equips[3][0][i]);
}
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
else if (cm.getJobId() == 512 || cm.getJobId() == 522 || cm.getJobId() == 1512) {
var index = 0;
if (cm.getJobId() == 522)
index = 1;
//4 = pirates, index = which subclass. 0 = bucc, 1 = corsair
if (cm.canHold(equips[4][index][i]))
cm.gainItem(equips[4][index][i]);
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
else {
if (cm.canHold(equips[playerClass][i])) {
cm.gainItem(equips[playerClass][i]);
}
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
}
//Checks which weapon should be given, if multiple options than ask
var indexWeapon = -1;
switch (cm.getJobId()) {
case 312: indexWeapon = 0; break;
case 322: indexWeapon = 1; break;
case 412: indexWeapon = 0; break;
case 512: indexWeapon = 0; break;
case 522: indexWeapon = 1; break;
case 1312: indexWeapon = 0; break;
case 1412: indexWeapon = 0; break;
case 1512: indexWeapon = 0; break;
case 2112: indexWeapon = 7; break;
}
//If the weapon can already be given and the job is not hermit
if (indexWeapon != -1) {
if (cm.canHold(weapons[playerClass][indexWeapon])) {
cm.gainItem(weapons[playerClass][indexWeapon]);
}
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
//If there needs to be given a choice
else {
switch(cm.getJobId()) {
case 112: choices = [0,1,2,3]; break;
case 122: choices = [0,1,4,5]; break;
case 132: choices = [6,7]; break;
case 212:
case 222:
case 232:
case 1212: choices = [0,1]; break;
case 1112: choices = [0,1]; break;
}
var msg = "Please select which weapon you'd like to have.\r\n\r\n#b";
for (var i = 0; i < choices.length; i++) {
//i + 20 because you can have max 19 selections from the job selections
msg += "#L" + (i + 20) + "##z" + weapons[playerClass][choices[i]] + "##l\r\n";
}
cm.sendSimple(msg);
return;
}
}
//Gives equips and weapons for the bandit subclass
else {
//Base as in str or luk based. 0 = Luk, 1 = Str
var base = 0;
//If the player is Str based, than set base to 1
if (cm.getPlayer().getLuk() < cm.getPlayer().getStr()) {
base = 1;
}
//For all equips..
for (var i = 0; i < equips[playerClass][base].length; i++) {
//For overalls, we have female and male overalls
if (i == 1) {
//1 because we only have male/female overalls available for str based. second 1 is because we need to select the overalls
if (cm.canHold(equips[playerClass][1][1][cm.getGender()])) {
cm.gainItem(equips[playerClass][1][1][cm.getGender()]);
}
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
continue;
}
if (cm.canHold(equips[playerClass][base][i])) {
cm.gainItem(equips[playerClass][base][i]);
}
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
//The shield for bandits
var shieldId = 1092059; //luk
if (base == 1) { //str
shieldId = 1092019;
}
if (cm.canHold(shieldId)) {
cm.gainItem(shieldId);
}
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
//So the base can be used for the weapons array
base += 1;
//Give the corresponding weapon for rogues
if (cm.canHold(weapons[playerClass][base]))
cm.gainItem(weapons[playerClass][base]);
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
var msg = "Okay here I am again. I gave you the best equipment I found in my storage.\r\nHave fun with it!";
cm.sendOk(msg);
cm.dispose();
}
}
else if (status == 3) {
//Job selection
if (selection < 20 && selection >= 0) {
cm.changeJobById(jobs[jobNmb][selection]);
var msg = "Ok, as you wish. I made you a #b" + cm.getPlayer().getJob();
cm.sendOk(msg);
cm.dispose();
return;
}
//Weapon selection
else if (selection >= 20 && selection <= 23) {
var playerClass = (cm.getJobId() >= 1000 && cm.getJobId() < 2000) ? ((Math.floor((cm.getJobId() - 1000) / 100)) - 1) : (cm.getJobId() >= 2000 ? 0 : (Math.floor((cm.getJobId() / 100)) - 1));
var weaponid = weapons[playerClass][choices[selection-20]];
//If we also need to give the shield to the 1h warrior
if (playerClass == 0 && (selection == 20 || selection == 22) && (cm.getJobId() != 132) && (cm.getJobId() != 2112)) {
if (cm.canHold(1092058))
cm.gainItem(1092058);
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
if (cm.getJobId() == 422) {
if (cm.canHold(1092058))
cm.gainItem(1092058);
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
}
//Give the chosen weapon
if (cm.canHold(weaponid))
cm.gainItem(weaponid);
else {
cm.sendOk("Your inventory is full. Please make some room so I can give you the items.");
cm.dispose();
return;
}
var msg = "Okay here I am again. I gave you the best equipment I found in my storage.\r\nI also gave you my #b#z" + weaponid + "##k. Have fun with it!";
cm.sendOk(msg);
cm.dispose();
}
//Tab removal
else {
//Because 0 = undefined, and we need the first to be EQUIP
tabRemove++;
var slots = cm.getPlayer().getInventory(MapleInventoryType.getByType(tabRemove)).getSlotLimit();
for (var i = 0; i < slots; i++) {
var item = cm.getPlayer().getInventory(MapleInventoryType.getByType(tabRemove)).getItem(i);
//If the item from the slot exists, and is not a pet
if (item != null && (item.getItemId() < 5000000 || item.getItemId() > 5000065))
cm.removeAll(item.getItemId());
}
var msg = "Ok I've removed all the items from your " + MapleInventoryType.getByType(tabRemove) + " tab.\r\nHappy mapling!";
cm.sendOk(msg);
cm.dispose();
}
}
}
}
Last edited:


