chenhui540

判定相同ID的NPC座標識別

發表於 2023-7-8 23:35:34
chenhui540 發表於 2023-7-8 23:35:34 | 顯示全部樓層 |閱讀模式
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, 下載次數: 2666)


茱麗葉.rar (12.46 KB, 下載次數: 2631)


任務:隱藏的文件.rar (1.14 KB, 下載次數: 2121)

瀏覽 3616 回復 1

您需要登錄後才可以回帖 登錄 | 註冊會員

:標題是不是錯了XD 2023-07-10 00:01回復
返回頂部