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

@@ -25,69 +25,70 @@
var status;
var dList;
function start() {
status = -1;
dList = cm.getDriedPets();
if(dList.size() == 0) {
cm.playerMessage(5, "You currently do not own a pet that needs to be treated with Water of Life.");
cm.dispose();
return;
}
action(1, 0, 0);
status = -1;
dList = cm.getDriedPets();
if (dList.size() == 0) {
cm.playerMessage(5, "You currently do not own a pet that needs to be treated with Water of Life.");
cm.dispose();
return;
}
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)
status++;
else
status--;
if (status == 0) {
cm.sendYesNo("I am Mar the Fairy. You have the #bWater of Life#k... With this, I can bring a doll back to life with my magic. What do you think? Do you want to use this item and reawaken your pet ...?");
} else if (status == 1) {
var talkStr = "So which pet you want to reawaken? Please choose the pet you'd most like to reawaken...\r\n\r\n";
var listStr = "";
var i = 0;
var dIter = dList.iterator();
while (dIter.hasNext()){
var dPet = dIter.next();
listStr += "#b#L" + i + "# " + dPet.getName() + " #k - Lv " + dPet.getLevel() + " Closeness " + dPet.getCloseness();
listStr += "#l\r\n";
i++;
}
cm.sendSimple(talkStr + listStr);
} else if (status == 2) {
var sPet = dList.get(selection);
if(sPet != null) {
cm.sendNext("Your doll has now reawaken as your pet! However, my magic isn't perfect, so I can't promise an eternal life for your pet... Please take care of that pet before the Water of Life dries. Well then, good bye...");
const InventoryType = Java.type('client.inventory.InventoryType');
var it = cm.getPlayer().getInventory(InventoryType.CASH).getItem(sPet.getPosition());
it.setExpiration(Date.now() + (1000 * 60 * 60 * 24 * 90));
cm.getPlayer().forceUpdateItem(it);
cm.gainItem(5180000, -1);
} else {
cm.sendNext("Oh, well then. Good bye...");
}
cm.dispose();
}
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && type > 0) {
cm.dispose();
return;
}
if (mode == 1) {
status++;
} else {
status--;
}
if (status == 0) {
cm.sendYesNo("I am Mar the Fairy. You have the #bWater of Life#k... With this, I can bring a doll back to life with my magic. What do you think? Do you want to use this item and reawaken your pet ...?");
} else if (status == 1) {
var talkStr = "So which pet you want to reawaken? Please choose the pet you'd most like to reawaken...\r\n\r\n";
var listStr = "";
var i = 0;
var dIter = dList.iterator();
while (dIter.hasNext()) {
var dPet = dIter.next();
listStr += "#b#L" + i + "# " + dPet.getName() + " #k - Lv " + dPet.getLevel() + " Closeness " + dPet.getCloseness();
listStr += "#l\r\n";
i++;
}
cm.sendSimple(talkStr + listStr);
} else if (status == 2) {
var sPet = dList.get(selection);
if (sPet != null) {
cm.sendNext("Your doll has now reawaken as your pet! However, my magic isn't perfect, so I can't promise an eternal life for your pet... Please take care of that pet before the Water of Life dries. Well then, good bye...");
const InventoryType = Java.type('client.inventory.InventoryType');
var it = cm.getPlayer().getInventory(InventoryType.CASH).getItem(sPet.getPosition());
it.setExpiration(Date.now() + (1000 * 60 * 60 * 24 * 90));
cm.getPlayer().forceUpdateItem(it);
cm.gainItem(5180000, -1);
} else {
cm.sendNext("Oh, well then. Good bye...");
}
cm.dispose();
}
}
}