Files
sweetgum-server/scripts/npc/2042001.js
ronancpl bee8b5259b Heal GMS + Improved chnl workers & Pshop tooltip + Equips on party HP
Slightly improved channel and disease announce workers performance.
Completion of repeatable quests no longer generates fame to players.
Equipment drop rates of Leprechaun were slightly decreased.
Fixed Pet Item Ignore not checking certain exploit cases correctly.
Optimized Pet Item Ignore server handler performance.
Fixed some exploits and improved performance on PetLootHandler.
Improved concurrency protection on MapleInventoryManipulator.
Heal skill effect on players now works GMS-intended, as description says. Also removed the delayed Heal cast effect to others.
Fixed party player HPBar not accounting the player's HP stat gained on equips towards the effective MaxHP.
The duration of mists generated by mobs has been rescaled to 10x longer than what has been displayed until now (wz duration property is supposed to actually be in 100ms).
Optimized timer management for mob skill cooldown and elemental effectiveness.
Implemented an additional inventory check system, to be used in cases where it's expected to remove a set group for items (with quantity) to then add a new group of items.
Fixed Player Shop/Hired Merchant "vacancy" tooltip, now properly showing whether the store has a visitor room or is already full at that time.
Fixed Player Shops only using the standard stand type.
Fixed cash pet food ignoring certain pet itemids when reading data from WZ.
2018-07-21 14:40:46 -03:00

227 lines
8.0 KiB
JavaScript

/*
This file is part of the HeavenMS MapleStory Server
Copyleft (L) 2016 - 2018 RonanLana
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);
}
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) {
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 could not be synthetized because either you have a lack of space on your ETC inventory or there's not enough mesos to cover the fee.");
}
cm.dispose();
}
}
}
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();
} 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);
}
cm.gainItem(j, refineQty);
} else {
for(j = 4021000; j < 4021009; j++) {
cm.gainItem(j, -refineQty);
}
cm.gainItem(j, refineQty);
}
break;
} else if(refineQty <= 1) {
allDone = false;
break;
} else {
refineQty--;
}
}
}
return allDone;
}