[楓之谷私服]v120 點裝附魔系統

最後更新於 2021 年 10 月 10 日

ttJAM9tXu [楓之谷私服]v120 點裝附魔系統
1580488136327 [楓之谷私服]v120 點裝附魔系統
1580488139108 [楓之谷私服]v120 點裝附魔系統
1580488141737 [楓之谷私服]v120 點裝附魔系統

SRC

  1. 打開scripting\NPCConversationManager.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 處加上

import tools.StringTool;

如果導包出錯,發現沒有 StringTool,請在 tools 資料夾底下新增 StringTool.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塞下方的腳本:

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個重新附魔此點裝...");
    }
    
    }
0 0 評分數
Article Rating
訂閱
通知
guest
19 Comments
在線反饋
查看所有評論
CAT
CAT
1 年 前

讚!有成功

lala
lala
1 年 前

請問這行出現錯誤要怎麼解決
StringTool.getIntFromString(sel.getOwner())

lala 最後編輯於 1 年 前
lala
lala
回复  pluto
1 年 前

這個加了還是跳出錯誤

lala
lala
回复  pluto
1 年 前

感謝!!很成功

xia
xia
9 月 前

是不是我的JAVA有問題,才看不到程式碼QQ

faker
faker
回复  pluto
9 月 前

I don’t know why, if you don’t log in, you can’t see the code. You just can see it after log in

faker 最後編輯於 9 月 前
Vic
Vic
6 月 前

你好,我試著加到GMS083
解決到剩這行可以幫我看一下嗎 感恩!
GMS083\src\tools\StringTool.java:95: error: incompatible types: Object cannot be converted to String
    for (String str : infos) {
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

Vic
Vic
回复  pluto
6 月 前

GMS083對應TMS113 (TMS113=GMS083=CMS079)
我想說TMS113跟120好像有蠻多一樣的東西
只能再試試看了

XKY
XKY
2 月 前

大大請問StringTool.java這個資料夾 是要在IDE裡面開啟src新增後一起導出 還是在伺服端的資料夾裡直接新增上去?

XKY
XKY
回复  pluto
2 月 前

我在IDE 裡面直接在對應的資料夾內新增 StringTool.java後 原本NPCConversationManager.java裡的錯誤有消失了
反倒現在StringTool.java裡的for (String str : infos) 這段出現錯誤了

454.jpg
Simonliao
Simonliao
1 月 前

您好
我是用您提供的V120 端
原本這個端就有string tool.java
請問是否就直接將您文中的內容複製進去即可呢?

Simonliao
Simonliao
回复  pluto
1 月 前

謝謝您
原本導入NPCConversationManager.java有報錯誤for (String str : infos) 
將 文中StringTool.java 貼進SRC,就沒有報錯誤
但是在跑腳本時,提示了以下錯誤
Error executing script. Path: Libs/scripts/special/4.點裝附魔.js
Exception javax.script.ScriptException: <eval>:26:22 Expected ) but found ;
  if (mode == 0 &amp;&amp; status == 0) {
           ^ in <eval> at line number 26 at column number 22
因為腳本是複製的,內容也沒有跑掉,有點奇怪
&amp;&amp; 這段是”或”的意思嗎?

更新一下,已經解決腳本問題了將以下字串改掉就好
if (mode == 0 &amp;&amp; status == 0) {
改成
if (mode == 0 && status == 0) {

for (var i = 0; i &lt; 96; i++) {
改成
 for (var i = 0; i < 96; i++) {

Simonliao 最後編輯於 1 月 前