Reformat and clean up npc scripts

This commit is contained in:
P0nk
2021-09-09 23:35:02 +02:00
parent 0c1545f81d
commit d893309b4f
665 changed files with 19932 additions and 19046 deletions

View File

@@ -41,69 +41,70 @@ var advance = true;
var status;
function getTierTicket(level) {
if(level < 50) {
return 4031543;
} else if(level < 120) {
return 4031544;
} else {
return 4031545;
}
if (level < 50) {
return 4031543;
} else if (level < 120) {
return 4031544;
} else {
return 4031545;
}
}
function start() {
slctTicket = getTierTicket(cm.getPlayer().getLevel());
amntTicket = cm.getItemQuantity(slctTicket);
status = -1;
action(1, 0, 0);
slctTicket = getTierTicket(cm.getPlayer().getLevel());
amntTicket = cm.getItemQuantity(slctTicket);
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && type > 0) {
cm.dispose();
return;
}
if (mode == 1 && advance)
status++;
else
status--;
advance = true;
if(status == 0) {
cm.sendNext("Hi there, how is it going? Since you're passing by Amoria, have you heard about the instance my brother Amos is hosting? It is the #bAmorian Challenge#k, an instance for everyone above level 40.\r\n\r\nThere, you may find the #i4031543# #i4031544# #i4031545# #bWish Tickets#k that can be brought here to redeem prizes.");
} else if(status == 1) {
var listStr = "";
for(var i = 0; i < wishPrizes.length; i++) {
listStr += "#b#L" + i + "#" + wishPrizesQty[i] + " #z" + wishPrizes[i] + "##k";
listStr += " - " + wishPrizesCst[i] + " wish tickets";
listStr += "#l\r\n";
}
cm.sendSimple("You currently have #b" + amntTicket + " #i" + slctTicket + "# #t" + slctTicket + "##k.\r\n\r\nPurchase a prize:\r\n\r\n" + listStr);
} else if(status == 2) {
sel = selection;
if(amntTicket < wishPrizesCst[selection]) {
cm.sendPrev("You will need #b" + wishPrizesCst[selection] + " #t" + slctTicket + "##k to purchase that! If you want this, come back another time when you have all the tickets at hand.");
advance = false;
} else {
cm.sendYesNo("You have selected #b" + wishPrizesQty[selection] + " #z" + wishPrizes[selection] + "##k, that will require #b" + wishPrizesCst[selection] + " #t" + slctTicket + "##k. Will you purchase it?");
}
} else {
if(cm.canHold(wishPrizes[sel], wishPrizesQty[sel])) {
cm.gainItem(wishPrizes[sel], wishPrizesQty[sel]);
cm.gainItem(slctTicket, -wishPrizesCst[sel]);
cm.sendOk("There you go, have a good day!");
} else {
cm.sendOk("Please have a slot available on your inventory before claiming the item.");
}
cm.dispose();
}
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && type > 0) {
cm.dispose();
return;
}
if (mode == 1 && advance) {
status++;
} else {
status--;
}
advance = true;
if (status == 0) {
cm.sendNext("Hi there, how is it going? Since you're passing by Amoria, have you heard about the instance my brother Amos is hosting? It is the #bAmorian Challenge#k, an instance for everyone above level 40.\r\n\r\nThere, you may find the #i4031543# #i4031544# #i4031545# #bWish Tickets#k that can be brought here to redeem prizes.");
} else if (status == 1) {
var listStr = "";
for (var i = 0; i < wishPrizes.length; i++) {
listStr += "#b#L" + i + "#" + wishPrizesQty[i] + " #z" + wishPrizes[i] + "##k";
listStr += " - " + wishPrizesCst[i] + " wish tickets";
listStr += "#l\r\n";
}
cm.sendSimple("You currently have #b" + amntTicket + " #i" + slctTicket + "# #t" + slctTicket + "##k.\r\n\r\nPurchase a prize:\r\n\r\n" + listStr);
} else if (status == 2) {
sel = selection;
if (amntTicket < wishPrizesCst[selection]) {
cm.sendPrev("You will need #b" + wishPrizesCst[selection] + " #t" + slctTicket + "##k to purchase that! If you want this, come back another time when you have all the tickets at hand.");
advance = false;
} else {
cm.sendYesNo("You have selected #b" + wishPrizesQty[selection] + " #z" + wishPrizes[selection] + "##k, that will require #b" + wishPrizesCst[selection] + " #t" + slctTicket + "##k. Will you purchase it?");
}
} else {
if (cm.canHold(wishPrizes[sel], wishPrizesQty[sel])) {
cm.gainItem(wishPrizes[sel], wishPrizesQty[sel]);
cm.gainItem(slctTicket, -wishPrizesCst[sel]);
cm.sendOk("There you go, have a good day!");
} else {
cm.sendOk("Please have a slot available on your inventory before claiming the item.");
}
cm.dispose();
}
}
}