CPQ 1 CPQ 2 CASAMENTO

This commit is contained in:
Diego Armando de Freitas Matos
2019-03-06 21:55:47 -03:00
parent 799870df63
commit 90ad58f17f
60 changed files with 17442 additions and 15142 deletions

View File

@@ -1,232 +1,84 @@
/*
This file is part of the HeavenMS MapleStory Server
Copyleft (L) 2016 - 2018 RonanLana
var map = 980000000;
var minLvl = 0;
var maxLvl = 255;
var minAmt = 0;
var maxAmt = 6;
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Spiegelmann
Refining NPC:
* Auto ore refiner
*
* @author RonanLana
*/
var status;
var refineRocks = true; // enables moon rock, star rock
var refineCrystals = true; // enables common crystals
var refineSpecials = true; // enables lithium, special crystals
var feeMultiplier = 7.0;
function start() {
status = -1;
action(1, 0, 0);
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)
status++;
else
status--;
if(status == 0) {
if (!Packages.constants.ServerConstants.USE_ENABLE_CUSTOM_NPC_SCRIPT) {
cm.sendOk("The Monster Carnival is currently unavailable.");
cm.dispose();
return;
}
var selStr = "The Monster Carnival is currently unavailable, but instead I offer a steadfast #bore refining#k service for you, taxing #r" + ((feeMultiplier * 100) | 0) + "%#k over the usual fee to synthetize them. What will you do?#b";
var options = new Array("Refine mineral ores","Refine jewel ores");
if(refineCrystals) {
options.push("Refine crystal ores");
}
if(refineRocks) {
options.push("Refine plates/jewels");
}
for (var i = 0; i < options.length; i++){
selStr += "\r\n#L" + i + "# " + options[i] + "#l";
}
cm.sendSimple(selStr);
} else if(status == 1) {
var allDone;
if (selection == 0) {
allDone = refineItems(0); // minerals
} else if (selection == 1) {
allDone = refineItems(1); // jewels
} else if (selection == 2 && refineCrystals) {
allDone = refineItems(2); // crystals
} else if (selection == 2 && !refineCrystals || selection == 3) {
allDone = refineRockItems(); // moon/star rock
}
if(allDone) {
cm.sendOk("Done. Thanks for showing up~.");
} else {
cm.sendOk("Done. Be aware some of the items #rcould not be synthetized#k because either you have a lack of space on your ETC inventory or there's not enough mesos to cover the fee.");
}
cm.dispose();
}
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && status == 0) {
cm.dispose();
return;
}
}
function getRefineFee(fee) {
return ((feeMultiplier * fee) | 0);
}
function isRefineTarget(refineType, refineItemid) {
if(refineType == 0) { //mineral refine
return refineItemid >= 4010000 && refineItemid <= 4010007 && !(refineItemid == 4010007 && !refineSpecials);
} else if(refineType == 1) { //jewel refine
return refineItemid >= 4020000 && refineItemid <= 4020008 && !(refineItemid == 4020008 && !refineSpecials);
} else if(refineType == 2) { //crystal refine
return refineItemid >= 4004000 && refineItemid <= 4004004 && !(refineItemid == 4004004 && !refineSpecials);
}
return false;
}
function getRockRefineTarget(refineItemid) {
if(refineItemid >= 4011000 && refineItemid <= 4011006) {
return 0;
} else if(refineItemid >= 4021000 && refineItemid <= 4021008) {
return 1;
}
return -1;
}
function refineItems(refineType) {
var allDone = true;
var refineFees = [[300,300,300,500,500,500,800,270],[500,500,500,500,500,500,500,1000,3000],[5000,5000,5000,5000,1000000]];
var itemCount = {};
var iter = cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).iterator();
while (iter.hasNext()) {
var it = iter.next();
var itemid = it.getItemId();
if(isRefineTarget(refineType, itemid)) {
var ic = itemCount[itemid];
if(ic != undefined) {
itemCount[itemid] += it.getQuantity();
if (mode == 1)
status++;
else
status--;
if (status == 0) {
if (cm.getParty() == null) {
status = 10;
cm.sendOk("#eÉ necessário criar um grupo antes de começar o Festival de Monstros!#k");
} else if (!cm.isLeader()) {
status = 10;
cm.sendOk("Se você quer começar o Festival, avise o #blíder do grupo#k para falar comigo.");
} else {
itemCount[itemid] = it.getQuantity();
}
}
}
for(var key in itemCount) {
var itemqty = itemCount[key];
var itemid = parseInt(key);
var refineQty = ((itemqty / 10) | 0);
if(refineQty <= 0) continue;
while(true) {
itemqty = refineQty * 10;
var fee = getRefineFee(refineFees[refineType][(itemid % 100) | 0] * refineQty);
if(cm.canHold(itemid + 1000, refineQty, itemid, itemqty) && cm.getMeso() >= fee) {
cm.gainMeso(-fee);
cm.gainItem(itemid, -itemqty);
cm.gainItem(itemid + (itemid != 4010007 ? 1000 : 1001), refineQty);
break;
} else if(refineQty <= 1) {
allDone = false;
break;
} else {
refineQty--;
}
}
}
return allDone;
}
function refineRockItems() {
var allDone = true;
var minItems = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]];
var minRocks = [2147483647, 2147483647];
var rockItems = [4011007, 4021009];
var rockFees = [10000, 15000];
var iter = cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).iterator();
while (iter.hasNext()) {
var it = iter.next();
var itemid = it.getItemId();
var rockRefine = getRockRefineTarget(itemid);
if(rockRefine >= 0) {
var rockItem = ((itemid % 100) | 0);
var itemqty = it.getQuantity();
minItems[rockRefine][rockItem] += itemqty;
}
}
for(var i = 0; i < minRocks.length; i++) {
for(var j = 0; j < minItems[i].length; j++) {
if(minRocks[i] > minItems[i][j]) {
minRocks[i] = minItems[i][j];
}
}
if(minRocks[i] <= 0 || minRocks[i] == 2147483647) continue;
var refineQty = minRocks[i];
while(true) {
var fee = getRefineFee(rockFees[i] * refineQty);
if(cm.canHold(rockItems[i], refineQty) && cm.getMeso() >= fee) {
cm.gainMeso(-fee);
var j;
if(i == 0) {
for(j = 4011000; j < 4011007; j++) {
cm.gainItem(j, -refineQty);
var party = cm.getParty().getMembers();
var inMap = cm.partyMembersInMap();
var lvlOk = 0;
var isInMap = 0;
for (var i = 0; i < party.size(); i++) {
if (party.get(i).getLevel() >= minLvl && party.get(i).getLevel() <= maxLvl) {
lvlOk++;
}
cm.gainItem(j, refineQty);
if (party.get(i).getPlayer().getMapId() != 980000000) {
//isInMap = false;
isInMap++
}
}
if (party >= 1) {
status = 10;
cm.sendOk("Você não tem número suficiente de pessoas em seu grupo. Você precisa de um grupo com #b" + minAmt + "#k - #r" + maxAmt + "#k membros e eles devem estar no mapa com você.");
} else if (lvlOk != inMap) {
status = 10;
cm.sendOk("Certifique se todos em seu grupo estão dentre os níveis corretos (" + minLvl + "~" + maxLvl + ")!");
} else if (isInMap > 0) {
status = 10;
cm.sendOk("Existe alguém do grupo que não esta no mapa!");
} else {
for(j = 4021000; j < 4021009; j++) {
cm.gainItem(j, -refineQty);
}
cm.gainItem(j, refineQty);
cm.sendCPQMapLists();
}
break;
} else if(refineQty <= 1) {
allDone = false;
break;
} else {
refineQty--;
}
} else if (status == 1) {
if (cm.fieldTaken(selection)) {
if (cm.fieldLobbied(selection)) {
cm.challengeParty(selection);
cm.dispose();
} else {
cm.sendOk("A sala esta cheia.");
cm.dispose();
}
} else {
var party = cm.getParty().getMembers();
if ((selection === 0 || selection === 1 || selection === 2 || selection === 3) && party.size() < 2) {
cm.sendOk("Você precisa de no mínimo 2 player para entrar na competição.");
} else if ((selection === 4 || selection === 5) && party.size() < 3) {
cm.sendOk("Você precisa de no mínimo 3 player para entrar na competição.");
} else {
cm.cpqLobby(selection);
}
cm.dispose();
}
} else if (status == 11) {
cm.dispose();
}
}
return allDone;
}
}