微信扫一扫 分享朋友圈

已有 786 人浏览分享

[服務器教學] 判定相同ID的NPC座標識別

[複製鏈接]

初窺門道

Rank: 2

219

威望

710

金錢

338

A幣
主題
32
帖子
64
精華
1
綜合社群主題發文量
0
電玩社群主題發文量
0
娛樂社群主題發文量
0
技術社群主題發文量
32
閱讀權限
20
註冊時間
2021-11-15
  • TA的每日心情
    奮鬥
    2024-1-28 13:17
  • 簽到天數: 1 天

    連續簽到: 1 天

    [LV.1]初來乍到

    chenhui540 發表於  2023-7-8 23:35:34 | 顯示全部樓層 | 閱讀模式
    本帖最後由 chenhui540 於 2023-7-11 18:04 編輯

    1.png
    2.png
    3.png

    搜索:

        public static final void NPCTalk(final LittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) {
            if (chr == null || chr.getMap() == null || chr.getBattle() != null) {
                return;
            }
            final MapleNPC npc = chr.getMap().getNPCByOid(slea.readInt());
            if (npc == null) {
                return;
            }
            if (chr.hasBlockedInventory()) {
                return;
            }
            if (npc.hasShop()) {
                chr.setConversation(1);
                npc.sendShop(c);
            } else {
                NPCScriptManager.getInstance().start(c, npc.getId());
            }
        }

    替換:

        public static final void NPCTalk(final LittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) {
            if (chr == null || chr.getMap() == null || chr.getBattle() != null) {
                return;
            }
            final MapleNPC npc = chr.getMap().getNPCByOid(slea.readInt());
            if (npc == null) {
                return;
            }
            if (chr.hasBlockedInventory()) {
                return;
            }
            if (npc.hasShop()) {
                chr.setConversation(1);
                npc.sendShop(c);
            } else {
                NPCScriptManager.getInstance().start(c, npc.getId(), npc);
            }
        }


    搜索:

        public final void start(final MapleClient c, final int npc) {
            start(c, npc, "");
        }
       
        public final void start(final MapleClient c, final int npc, String filename) {
            final Lock lock = c.getNPCLock();
            lock.lock();
            try {
                if (!cms.containsKey(c) && c.canClickNPC()) {
                if (c.getPlayer().isGM()) {
                    c.getPlayer().dropMessage(5, "[系統提示]您已經建立與NPC: " + npc + " 的對話");
                        }
                    Invocable iv = null;
                    if (filename != null) {
                        iv = getInvocable("npc/" + filename + ".js", c, true);
                    }
                    if (iv == null) {
                        iv = getInvocable("npc/" + npc + ".js", c);
                    }
                    if (iv == null) {
                        iv = getInvocable("npc/notcoded.js", c, true); //safe disposal
                        if (iv == null) {
                            dispose(c);
                            return;
                        }
                    }
                    final ScriptEngine scriptengine = (ScriptEngine) iv;
                    final NPCConversationManager cm = new NPCConversationManager(c, npc, -1, (byte) -1, iv);
                    cms.put(c, cm);
                    scriptengine.put("cm", cm);



    替換:

        public final void start(final MapleClient c, final int npc) {
            start(c, npc, "", null);
        }

        public final void start(final MapleClient c, final int npc, MapleNPC npcob) {
            start(c, npc, "", npcob);
        }

        public final void start(final MapleClient c, final int npc, String filename, MapleNPC npcob) {
            final Lock lock = c.getNPCLock();
            lock.lock();
            try {
                if (!cms.containsKey(c) && c.canClickNPC()) {
                if (c.getPlayer().isGM()) {
                    c.getPlayer().dropMessage(5, "[系統提示]您已經建立與NPC: " + npc + " 的對話");
                        }
                    Invocable iv = null;
                    if (filename != null) {
                        iv = getInvocable("npc/" + filename + ".js", c, true);
                    }
                    if (iv == null) {
                        iv = getInvocable("npc/" + npc + ".js", c);
                    }
                    if (iv == null) {
                        iv = getInvocable("npc/notcoded.js", c, true); //safe disposal
                        if (iv == null) {
                            dispose(c);
                            return;
                        }
                    }
                    final ScriptEngine scriptengine = (ScriptEngine) iv;
                    final NPCConversationManager cm = new NPCConversationManager(c, npc, npcob,  -1, (byte) -1, iv);
                    cms.put(c, cm);
                    scriptengine.put("cm", cm);

    頁首:

    import server.life.MapleNPC;




    搜索:

    public abstract class AbstractPlayerInteraction {

        protected MapleClient c;
        protected int id, id2;

        public AbstractPlayerInteraction(final MapleClient c, final int id, final int id2) {
            this.c = c;
            this.id = id;
            this.id2 = id2;
        }

    替換:


    public abstract class AbstractPlayerInteraction {

        protected MapleClient c;
        protected int id, id2;
        protected MapleNPC npcob;

        public AbstractPlayerInteraction(final MapleClient c, final int id, final int id2) {
            this.c = c;
            this.id = id;
            this.id2 = id2;
        }

        public AbstractPlayerInteraction(final MapleClient c, final int id, final MapleNPC npcob, final int id2) {
            this.c = c;
            this.id = id;
            this.npcob = npcob;
            this.id2 = id2;
        }

    頁首:

    import server.life.MapleNPC;


    搜索:

        public NPCConversationManager(MapleClient c, int npc, int questid, byte type, Invocable iv) {
            super(c, npc, questid);
            this.type = type;
            this.iv = iv;
        }

    替換:

        public NPCConversationManager(MapleClient c, int npc, int questid, byte type, Invocable iv) {
            super(c, npc, questid);
            this.type = type;
            this.iv = iv;
        }

        public NPCConversationManager(MapleClient c, int npc, MapleNPC npcob, int questid, byte type, Invocable iv) {
            super(c, npc, npcob, questid);
            this.type = type;
            this.iv = iv;
        }


    頁首:

    import server.life.MapleNPC;


    搜索:

        public void setFace2(int id) {
            c.getPlayer().setDemonMarking(id);
        }
    }


    替換:

        public void setFace2(int id) {
            c.getPlayer().setDemonMarking(id);
        }

        public MapleNPC getNpcob() {
            return this.npcob;
        }

        public int getNpcdist() {
            int dis =(int) this.npcob.getPosition().distance(c.getPlayer().getPosition());
            return dis;
        }
    }

    頁首:

    import server.life.MapleNPC;


    /*
            名字:        調查結果
            地圖:        可疑的研究室
            描述:        926100000
    */

    var x = [-1638, -1386, -1286, -1252, -1178, -884, -678, -584, -438, -578, -318, -200, 300, 560, 618, 778, 894, 1048, 1234, 1142, 1348, -1366, -1496, -1040, -908, 784, 132];


    function start() {
            eim = cm.getPlayer().getEventInstance();
            if (eim.getProperty("1st") == null || eim.getProperty("2st") == null) {
                    eim.setProperty("1st", Math.floor(Math.random() * 26));
                    eim.setProperty("2st", Math.floor(Math.random() * 26));
                    }
                    for (var i = 0; i < x.length; i++)
            if (cm.getNpcob().getPosition().x == x[i]) {
                    y = i;
                    }
                    var progress = eim.getProperty("3st");
            if ((progress >> y) % 2 == 0) {
            if (eim.getProperty("1st") == y) {
                    cm.gainItem(4001131, 1);
                    cm.sendNext("你發現了一封信,好像是封寫給愛人的信。");
                    }
            if (eim.getProperty("2st") == y) {
                    cm.getMap().getReactorByName("d00").forceHitReactor(1);
                    cm.playerMessage(-1, "你打開了進入實驗室的通道。");
                    cm.getMap().broadcastMessage(Packages.tools.packet.EtcPacket.showEffect("quest/party/clear"));
                    cm.getMap().broadcastMessage(Packages.tools.packet.EtcPacket.playSound("Party1/Clear"));
                    }
                    progress |= (1 << y);
                    cm.gainMeso(500 + (Math.random() * 600));
                    eim.setProperty("3st", progress);
                    }
                    cm.dispose();
    }



    /*
            名字:        隱藏的文件
            地圖:        猶利塔的實驗室2
            描述:        926130102
    */

    var x = [-295, -509, -487, -401, -884, -776, -660, -996, -1641, -1455, -1273, -1837, -1671, -2000, -1869, 170, 230, 393, 371, 369, 668, 852, 863, 710, 596, 988, 1182, 1405, 974, -1860];

    function start() {
            if (cm.getQuestStatus(3367) != 1) {
                    cm.dispose();
                    return;
                    }
            if (cm.getPlayer().getInventory(Packages.client.inventory.MapleInventoryType.ETC).getNumFreeSlot() < 1) {
                    cm.playerMessage(1, "其它道具視窗的欄位不足!");
                    cm.dispose();
                    return;
                    }
                    for (var i = 0; i < x.length; i++)
            if (cm.getNpcob().getPosition().x == x
    [i]) {
                    y = i;
                    }
                    var progress = cm.getQuestRecord(3367).getCustomData();
            if ((progress >> y) % 2 == 0) {
                    progress |= (1 << y);
                    cm.gainItem(4031797, 1);
                    cm.getQuestRecord(3367).setCustomData(progress);
                    }
                    cm.dispose();
    }

    /*
            名字:        隱藏地圖
            地圖:        實驗室入口
            描述:        926130100
    */

    function enter(pi) {
            if (pi.getQuestStatus(3367) != 1) {
                    pi.playerMessage(6, "[Portal]猶利塔的實驗室2禁止外來者訪問。");
                    return false;
                    }
            if (pi.getMap(926130102).getCharacters().size() > 0) {
                    pi.playerMessage(6, "[Portal]猶利塔的實驗室2目前擁擠,請稍後再試。");
                    return false;
                    }
                    pi.getMap(926130102).resetFully();
                    pi.getPlayer().changeMap(pi.getMap(926130102), pi.getMap(926130102).getPortal(1)); //猶利塔的實驗室2
                    pi.getPlayer().startMapTimeLimitTask(600, pi.getMap(926130100));
                    return true;
    }

    源碼修改的內容不同的端會有差別,可以作為參考,如果你有更簡單的識別方法,可以教下我!謝謝!!


    羅密歐.rar (14.74 KB, 下載次數: 268)

    區域版主

    Rank: 10Rank: 10Rank: 10

    256

    威望

    1206

    金錢

    600

    A幣
    主題
    137
    帖子
    253
    精華
    0
    綜合社群主題發文量
    9
    電玩社群主題發文量
    10
    娛樂社群主題發文量
    0
    技術社群主題發文量
    93
    閱讀權限
    100
    註冊時間
    2016-5-17
  • TA的每日心情

    2022-4-29 14:36
  • 簽到天數: 5 天

    連續簽到: 1 天

    [LV.2]偶爾看看I

    t9540513 發表於 2023-7-10 00:01:04 | 顯示全部樓層
    標題是不是錯了XD
    您需要登錄後才可以回帖 登錄 | 註冊會員

    本版積分規則

    64

    發文

    710

    金錢

    338

    A幣

    ----------榮譽勳章----------

    熱門推薦
    圖文推薦
    • 聯繫我們

    小黑屋|AICL社群娛樂集團

    GMT+8, 2024-5-6 20:39 , 網路刷新 0.106942 秒 .

    歡迎來到 AICL網路社群

    版權AICL社群所有 2011-2021.

    Total:123 Today:213 Online:322