SRC- 打開scripting\NPCConversationManager.java 在最下方 } 前加上:
仔細看,裡頭可以修改附魔的能力,按照個人喜好設定。
[Java] 纯文本查看 复制代码 //點裝附魔
public String EnchantCashEqip(byte slot) {
Equip item = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(slot);
Equip sel = (Equip) item;
int itemid = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(slot).getItemId();
boolean isCash = MapleItemInformationProvider.getInstance().isCash(itemid);
String msg = "";
if (isCash) {
msg += "您此次所附魔的點裝為#b#z" + itemid + "##k\r\n";
msg += "您此次的附魔為:\r\n";
msg += "-----------------------\r\n";
short Str = (short) Randomizer.rand(5, 10);
sel.setStr((short) (sel.getStr() + Str));
msg += "力量 +" + " " + Str + "\r\n";
short Dex = (short) Randomizer.rand(5, 10);
sel.setDex((short) (sel.getDex() + Dex));
msg += "敏捷: " + " " + Dex + "\r\n";
short Int = (short) Randomizer.rand(5, 10);
sel.setInt((short) (sel.getInt() + Int));
msg += "智力: " + " " + Int + "\r\n";
short Luk = (short) Randomizer.rand(5, 10);
sel.setLuk((short) (sel.getLuk() + Luk));
msg += "幸運: " + " " + Luk + "\r\n";
short Watk = (short) Randomizer.rand(5, 10);
sel.setWatk((short) (sel.getWatk() + Watk));
msg += "物理攻擊: " + " " + Watk + "\r\n";
short Matk = (short) Randomizer.rand(5, 10);
sel.setMatk((short) (sel.getMatk() + Matk));
msg += "魔法攻擊: " + " " + Matk + "\r\n";
msg += "-----------------------\r\n";
msg += "請問您是否要繼續附魔?\r\n#d[點選#r是#d,繼續附魔] [點選#r否#d,存取目前附魔]\r\n#d若裝備素質未改變,請重新登入或換頻即可生效!";
int used = StringTool.getIntFromString(sel.getOwner());
used++;
sel.setOwner("已附魔" + used + "次");
item = (Equip) sel.copy();
MapleInventoryManipulator.removeFromSlot(getClient(), MapleInventoryType.EQUIP, (short) slot, item.getQuantity(), false);
MapleInventoryManipulator.addFromDrop(getClient(), item, false);
c.getPlayer().equipChanged();
return msg;
} else {
return "此裝備並非點裝唷!僅有點裝才可以附魔~";
}
}
然後在最上方 import 處加上
[AppleScript] 纯文本查看 复制代码 import tools.StringTool;
如果導包出錯,發現沒有 StringTool,請在 tools 資料夾底下新增 StringTool.java 貼上
[Java] 纯文本查看 复制代码 /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tools;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author pungin
*/
public class StringTool {
public static boolean parseBoolean(final String info) {
return info != null && info.equalsIgnoreCase("true") || parseLong(info) > 0;
}
public static int getIntFromString(String a) {
String regEx = "[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(a);
return parseInt(m.replaceAll("").trim());
}
public static byte parseSByte(final String info) {
return (byte) parseLong(info);
}
public static short parseByte(final String info) {
return (short) (parseLong(info) & 0xFF) ;
}
public static short parseShort(final String info) {
return (short) parseLong(info);
}
public static int parseUShort(final String info) {
return (short) (parseLong(info) & 0xFFFF);
}
public static int parseInt(final String info) {
return (int) parseLong(info);
}
public static long parseUInt(final String info) {
return (parseLong(info) & 0xFFFFFFFF);
}
public static long parseLong(final String info) {
return (long) parseDouble(info);
}
public static float parseFloat(final String info) {
return (float) Double.parseDouble(info);
}
public static double parseDouble(final String info) {
if (info == null || info.isEmpty() || !info.matches("-?[0-9]*.?[0-9]*")) {
return 0.0D;
}
return Double.parseDouble(info);
}
public static List splitList(final String info, final String value) {
if (info == null || value == null) {
return null;
}
List list = new LinkedList();
list.addAll(Arrays.asList(split(info, value)));
return list;
}
public static String[] split(final String info, final String value) {
if (info == null || value == null) {
return null;
}
return info.split(value);
}
public static String unite(String[] infos, final String value) {
return unite(Arrays.asList(infos), value);
}
public static String unite(final List infos, final String value) {
if (infos == null || infos.isEmpty() || value == null) {
return null;
}
String info = "";
for (String str : infos) {
info += str + value;
}
info = info.isEmpty() ? info : info.substring(0, info.length() - value.length());
return info;
}
public static String getOneValue(final String info, final String key) {
if (info == null || key == null) {
return null;
}
final String[] split = info.split(";");
for (String x : split) {
final String[] split2 = x.split("=");
if (split2.length == 2 && split2[0].equals(key)) {
return split2[1];
}
}
return null;
}
public static String updateOneValue(String info, final String key, final String value) {
if (key == null) {
return null;
}
if (info == null) {
if (value != null) {
info = key + "=" + value;
}
return info;
}
final String[] split = info.split(";");
boolean changed = false;
boolean match = false;
final StringBuilder newValue = new StringBuilder();
for (String x : split) {
final String[] split2 = x.split("=");
if (split2.length != 2) {
continue;
}
if (split2[0].equals(key)) {
if (value != null) {
newValue.append(key).append("=").append(value);
}
match = true;
} else {
newValue.append(x);
}
newValue.append(";");
changed = true;
}
if (!match && value != null) {
newValue.append(key).append("=").append(value).append(";");
}
info = changed ? newValue.toString().substring(0, newValue.toString().length() - 1) : newValue.toString();
if (info.isEmpty()) {
return null;
}
return info;
}
}
NPC腳本隨便找一個NPC塞下方的腳本: [JavaScript] 纯文本查看 复制代码 load('nashorn:mozilla_compat.js');
importPackage(java.lang);
var status = -1;
var slot = Array();
var sel;
var item = 4001126; //附魔時需要消耗的道具ID
function start() {
//status = -1;
action(1, 0, 0);
}
var icon01 = "#fUI/UIWindow.img/CashTradingRoom/BtCoin/normal/0#";
var icon02 = "#fUI/UIWindow.img/UserInfo/bossPetCrown#";
var icon03 = "#fUI/UIWindow.img/AriantMatch/characterIcon/0#";
var icon04 = "#fUI/UIWindow.img/AriantMatch/characterIcon/1#";
var icon05 = "#fUI/UIWindow.img/AriantMatch/characterIcon/2#";
var icon06 = "#fUI/UIWindow.img/AriantMatch/characterIcon/3#";
var icon07 = "#fUI/UIWindow.img/AriantMatch/characterIcon/4#";
var icon08 = "#fUI/UIWindow.img/AriantMatch/characterIcon/5#";
var icon09 = "#fUI/UIWindow.img/Megaphone/0#";
var icon10 = "#fUI/UIWindow.img/CashTradingRoom/icon1#";
var status = -1;
function action(mode, type, selection) {
if (mode == 0 && status == 0) {
cm.dispose();
return;
}
if (mode == 1) {
status++;
} else {
status--;
}
if (status == 0) {
cm.sendSimple(
"#b請問您是否要使用點裝附魔功能呢?#d"+
"\r\n\r\n#L1#附魔一次需要使用#r#z"+item+"##k#d350個!#l"
);
} else if (status == 1) {
sel = selection;
var avail = "";
for (var i = 0; i < 96; i++) {
if (cm.getInventory(1).getItem(i) != null) {
if (Packages.server.MapleItemInformationProvider.getInstance().isCash(cm.getInventory(1).getItem(i).getItemId())) {
avail += "#L" + Math.abs(i) + "##z" + cm.getInventory(1).getItem(i).getItemId() + "##l\r\n";
}
}
}
if(avail == ""){
avail += "很抱歉,您的裝備欄沒有任何的點裝哦!!~";
}
cm.sendSimple("想要附魔哪一件點數裝備呢??\r\n#b" + avail);
} else if (status == 2) {
selected = selection;
cm.sendYesNo("你想要附魔的點裝是 #b#t" + cm.getInventory(1).getItem(selected).getItemId() + "##k.\r\n您確定要對此點裝賦魔??\r\n");
} else if (status == 3) {
var type ;
if (cm.haveItem(item, 350)) { //消耗的數量
status = 5;
cm.sendYesNo(cm.EnchantCashEqip(selected));
cm.gainItem(item,-350); //消耗的數量
} else {
status = 3;
cm.sendOk("您的#b#z" + item + "##k不足哦!!");
}
} else if (status == 4) {
//cm.getPlayer().fakeRelog();
cm.dispose();
} else if (status == 6) {
status = 2;
cm.sendOk("即將花費#b#z"+item+"##k350個重新附魔此點裝...");
}
}
|