Remove custom NPC script: Dalair equipment merge
This commit is contained in:
@@ -19,72 +19,9 @@
|
||||
*/
|
||||
/* Dalair
|
||||
Medal NPC.
|
||||
|
||||
NPC Equipment Merger:
|
||||
* @author Ronan Lana
|
||||
*/
|
||||
|
||||
var status;
|
||||
var mergeFee = 50000;
|
||||
var name;
|
||||
|
||||
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) {
|
||||
const YamlConfig = Java.type('config.YamlConfig');
|
||||
if (!YamlConfig.config.server.USE_ENABLE_CUSTOM_NPC_SCRIPT) {
|
||||
cm.sendOk("The medal ranking system is currently unavailable...");
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
var levelLimit = !cm.getPlayer().isCygnus() ? 160 : 110;
|
||||
var selStr = "The medal ranking system is currently unavailable... Therefore, I am providing the #bEquipment Merge#k service! ";
|
||||
|
||||
const MakerProcessor = Java.type('client.processor.action.MakerProcessor');
|
||||
if (!YamlConfig.config.server.USE_STARTER_MERGE && (cm.getPlayer().getLevel() < levelLimit || MakerProcessor.getMakerSkillLevel(cm.getPlayer()) < 3)) {
|
||||
selStr += "However, you must have #rMaker level 3#k and at least #rlevel 110#k (Cygnus Knight), #rlevel 160#k (other classes) and a fund of #r" + cm.numberWithCommas(mergeFee) + " mesos#k to use the service.";
|
||||
cm.sendOk(selStr);
|
||||
cm.dispose();
|
||||
} else if (cm.getMeso() < mergeFee) {
|
||||
selStr += "I'm sorry, but this service tax is of #r" + cm.numberWithCommas(mergeFee) + " mesos#k, which it seems you unfortunately don't have right now... Please, stop by again later.";
|
||||
cm.sendOk(selStr);
|
||||
cm.dispose();
|
||||
} else {
|
||||
selStr += "For the fee of #r" + cm.numberWithCommas(mergeFee) + "#k mesos, merge unnecessary equipments in your inventory into your currently equipped gears to get stat boosts into them, statups based on the attributes of the items used on the merge!";
|
||||
cm.sendNext(selStr);
|
||||
}
|
||||
} else if (status == 1) {
|
||||
selStr = "#rWARNING#b: Make sure you have your items ready to merge at the slots #rAFTER#b the item you have selected to merge.#k Any items #bunder#k the item selected will be merged thoroughly.\r\n\r\nNote that equipments receiving bonuses from merge are going to become #rUntradeable#k thereon, and equipments that already received the merge bonus #rcannot be used for merge#k.\r\n\r\n";
|
||||
cm.sendGetText(selStr);
|
||||
} else if (status == 2) {
|
||||
name = cm.getText();
|
||||
|
||||
if (cm.getPlayer().mergeAllItemsFromName(name)) {
|
||||
cm.gainMeso(-mergeFee);
|
||||
cm.sendOk("Merging complete! Thanks for using the service and enjoy your new equipment stats.");
|
||||
} else {
|
||||
cm.sendOk("There is no #b'" + name + "'#k in your #bEQUIP#k inventory!");
|
||||
}
|
||||
|
||||
cm.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ package client;
|
||||
import client.autoban.AutobanManager;
|
||||
import client.creator.CharacterFactoryRecipe;
|
||||
import client.inventory.Equip;
|
||||
import client.inventory.Equip.StatUpgrade;
|
||||
import client.inventory.Inventory;
|
||||
import client.inventory.InventoryProof;
|
||||
import client.inventory.InventoryType;
|
||||
@@ -9192,164 +9191,6 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasMergeFlag(Item item) {
|
||||
return (item.getFlag() & ItemConstants.MERGE_UNTRADEABLE) == ItemConstants.MERGE_UNTRADEABLE;
|
||||
}
|
||||
|
||||
private static void setMergeFlag(Item item) {
|
||||
short flag = item.getFlag();
|
||||
flag |= ItemConstants.MERGE_UNTRADEABLE;
|
||||
flag |= ItemConstants.UNTRADEABLE;
|
||||
item.setFlag(flag);
|
||||
}
|
||||
|
||||
private List<Equip> getUpgradeableEquipped() {
|
||||
List<Equip> list = new LinkedList<>();
|
||||
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
for (Item item : getInventory(InventoryType.EQUIPPED)) {
|
||||
if (ii.isUpgradeable(item.getItemId())) {
|
||||
list.add((Equip) item);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<Equip> getEquipsWithStat(List<Pair<Equip, Map<StatUpgrade, Short>>> equipped, StatUpgrade stat) {
|
||||
List<Equip> equippedWithStat = new LinkedList<>();
|
||||
|
||||
for (Pair<Equip, Map<StatUpgrade, Short>> eq : equipped) {
|
||||
if (eq.getRight().containsKey(stat)) {
|
||||
equippedWithStat.add(eq.getLeft());
|
||||
}
|
||||
}
|
||||
|
||||
return equippedWithStat;
|
||||
}
|
||||
|
||||
public boolean mergeAllItemsFromName(String name) {
|
||||
InventoryType type = InventoryType.EQUIP;
|
||||
|
||||
Inventory inv = getInventory(type);
|
||||
inv.lockInventory();
|
||||
try {
|
||||
Item it = inv.findByName(name);
|
||||
if (it == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<StatUpgrade, Float> statups = new LinkedHashMap<>();
|
||||
mergeAllItemsFromPosition(statups, it.getPosition());
|
||||
|
||||
List<Pair<Equip, Map<StatUpgrade, Short>>> upgradeableEquipped = new LinkedList<>();
|
||||
Map<Equip, List<Pair<StatUpgrade, Integer>>> equipUpgrades = new LinkedHashMap<>();
|
||||
for (Equip eq : getUpgradeableEquipped()) {
|
||||
upgradeableEquipped.add(new Pair<>(eq, eq.getStats()));
|
||||
equipUpgrades.put(eq, new LinkedList<Pair<StatUpgrade, Integer>>());
|
||||
}
|
||||
|
||||
/*
|
||||
for (Entry<StatUpgrade, Float> es : statups.entrySet()) {
|
||||
System.out.println(es);
|
||||
}
|
||||
*/
|
||||
|
||||
for (Entry<StatUpgrade, Float> e : statups.entrySet()) {
|
||||
Double ev = Math.sqrt(e.getValue());
|
||||
|
||||
Set<Equip> extraEquipped = new LinkedHashSet<>(equipUpgrades.keySet());
|
||||
List<Equip> statEquipped = getEquipsWithStat(upgradeableEquipped, e.getKey());
|
||||
float extraRate = (float) (0.2 * Math.random());
|
||||
|
||||
if (!statEquipped.isEmpty()) {
|
||||
float statRate = 1.0f - extraRate;
|
||||
|
||||
int statup = (int) Math.ceil((ev * statRate) / statEquipped.size());
|
||||
for (Equip statEq : statEquipped) {
|
||||
equipUpgrades.get(statEq).add(new Pair<>(e.getKey(), statup));
|
||||
extraEquipped.remove(statEq);
|
||||
}
|
||||
}
|
||||
|
||||
if (!extraEquipped.isEmpty()) {
|
||||
int statup = (int) Math.round((ev * extraRate) / extraEquipped.size());
|
||||
if (statup > 0) {
|
||||
for (Equip extraEq : extraEquipped) {
|
||||
equipUpgrades.get(extraEq).add(new Pair<>(e.getKey(), statup));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dropMessage(6, "EQUIPMENT MERGE operation results:");
|
||||
for (Entry<Equip, List<Pair<StatUpgrade, Integer>>> eqpUpg : equipUpgrades.entrySet()) {
|
||||
List<Pair<StatUpgrade, Integer>> eqpStatups = eqpUpg.getValue();
|
||||
if (!eqpStatups.isEmpty()) {
|
||||
Equip eqp = eqpUpg.getKey();
|
||||
setMergeFlag(eqp);
|
||||
|
||||
String showStr = " '" + ItemInformationProvider.getInstance().getName(eqp.getItemId()) + "': ";
|
||||
String upgdStr = eqp.gainStats(eqpStatups).getLeft();
|
||||
|
||||
this.forceUpdateItem(eqp);
|
||||
|
||||
showStr += upgdStr;
|
||||
dropMessage(6, showStr);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
inv.unlockInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public void mergeAllItemsFromPosition(Map<StatUpgrade, Float> statups, short pos) {
|
||||
Inventory inv = getInventory(InventoryType.EQUIP);
|
||||
inv.lockInventory();
|
||||
try {
|
||||
for (short i = pos; i <= inv.getSlotLimit(); i++) {
|
||||
standaloneMerge(statups, getClient(), InventoryType.EQUIP, i, inv.getItem(i));
|
||||
}
|
||||
} finally {
|
||||
inv.unlockInventory();
|
||||
}
|
||||
}
|
||||
|
||||
private void standaloneMerge(Map<StatUpgrade, Float> statups, Client c, InventoryType type, short slot, Item item) {
|
||||
short quantity;
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
if (item == null || (quantity = item.getQuantity()) < 1 || ii.isCash(item.getItemId()) || !ii.isUpgradeable(item.getItemId()) || hasMergeFlag(item)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Equip e = (Equip) item;
|
||||
for (Entry<StatUpgrade, Short> s : e.getStats().entrySet()) {
|
||||
Float newVal = statups.get(s.getKey());
|
||||
|
||||
float incVal = s.getValue().floatValue();
|
||||
switch (s.getKey()) {
|
||||
case incPAD:
|
||||
case incMAD:
|
||||
case incPDD:
|
||||
case incMDD:
|
||||
incVal = (float) Math.log(incVal);
|
||||
break;
|
||||
}
|
||||
|
||||
if (newVal != null) {
|
||||
newVal += incVal;
|
||||
} else {
|
||||
newVal = incVal;
|
||||
}
|
||||
|
||||
statups.put(s.getKey(), newVal);
|
||||
}
|
||||
|
||||
InventoryManipulator.removeFromSlot(c, type, (byte) slot, quantity, false);
|
||||
}
|
||||
|
||||
public void setShop(Shop shop) {
|
||||
this.shop = shop;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ public class ServerConfig {
|
||||
|
||||
//Custom Configuration
|
||||
public boolean USE_ENABLE_CUSTOM_NPC_SCRIPT;
|
||||
public boolean USE_STARTER_MERGE;
|
||||
|
||||
//Commands Configuration
|
||||
public boolean BLOCK_GENERATE_CASH_ITEM;
|
||||
|
||||
Reference in New Issue
Block a user