85207889 發表於 2016-9-9 00:15

簡易的仿官方 新地龍三段變身

【Java教學】【★★★★★】簡易的仿官方 新地龍三段變身



有個地方要宣告一下,自己找

L1Teleport

L1MonsterInstance.java

搜尋
startDeleteTimer();
下面新增
//死亡後創怪 J
int npcid = getNpcTemplate().get_npcId();

if (npcid == 97043 || npcid == 97044 || npcid == 97045) { //npcid Lv1~Lv3等安塔瑞斯
      try {//
      for (L1PcInstance pc : L1World.getInstance().getAllPlayers()) {
      if (pc.getMapId() == 1005) {//限定地圖
                switch(npcid) {
                case 97043: //Lv1
                Thread.sleep(10000); //10秒後
                deadspawn(pc, 97044, 6, 32789, 32685, (short)1005);
                break;
                case 97044: //Lv2
                Thread.sleep(10000); //10秒後
                deadspawn(pc, 97045, 6, 32789, 32685, (short)1005);
                break;
                case 97045: //Lv3
                Thread.sleep(10000); //10秒後傳送到奇岩村
                L1Teleport.teleport(pc, 33442, 32797, (short) 4, pc.getHeading(), true);
                                 }
                               }
                        }
                } catch (Exception e) {                        
         }
   }//死亡後創怪end
复制代码
搜尋

@Override
protected void transform(int transformId) {

上方新增
//死亡後創怪 J
public static void deadspawn(L1PcInstance pc, int npcId, int randomRange, int to_x, int to_y, short mapid) {
                {
                try
                {
                  L1NpcInstance npc = NpcTable.getInstance().newNpcInstance(npcId);
                  npc.setId(IdFactory.getInstance().nextId());   
                  npc.setMap(pc.getMapId());
                  if(randomRange == 0)
                  {
                        npc.getLocation().set(pc.getLocation());
                        npc.getLocation().forward(pc.getHeading());
                  } else
                  {
                        int tryCount = 0;
                        do
                        {
                            tryCount++;
                            npc.setX((to_x + (int)(Math.random() * (double)randomRange)) - (int)(Math.random() * (double)randomRange));
                            npc.setY((to_y + (int)(Math.random() * (double)randomRange)) - (int)(Math.random() * (double)randomRange));
                            if(npc.getMap().isInMap(npc.getLocation()) && npc.getMap().isPassable(npc.getLocation()))
                              break;
                            Thread.sleep(1L);
                        } while(tryCount < 50);
                        if(tryCount >= 50)
                        {
                            npc.getLocation().set(pc.getLocation());
                            npc.getLocation().forward(pc.getHeading());
                        }
                  }
                  npc.setMap((short)mapid);
                  npc.setHomeX(npc.getX());
                  npc.setHomeY(npc.getY());
                  npc.setHeading(pc.getHeading());
                  L1World.getInstance().storeObject(npc);
                  L1World.getInstance().addVisibleObject(npc);

                  npc.broadcastPacket(new S_DoActionGFX(npc.getId(), 11));
                  npc.setStatus(3);
                  npc.broadcastPacket(new S_NPCPack(npc));
                  npc.broadcastPacket(new S_DoActionGFX(npc.getId(), 11));
                  npc.setStatus(0);
                  npc.broadcastPacket(new S_NPCPack(npc));

                  npc.onNpcAI();   //創造動作
                  npc.turnOnOffLight();
                  npc.startChat(0);
                }catch(Exception e)
                {
                  _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
                }
            }
      }
      ////死亡後創怪 J end
复制代码
PS.簡易寫來測試,希望對仿官服的有些幫助!

// 安塔瑞斯(第一階段) gfxid = 7539
//安塔瑞斯(第二階段) gfxid = 7557
//安塔瑞斯(第三階段) gfxid = 7558       


vn523205 發表於 2017-1-7 10:14

感謝您的分享

blackjack 發表於 2019-8-4 14:47

感謝分享新手學習中^_^

013101 發表於 2019-8-4 21:02

感謝感謝 一定有幫助

19870922 發表於 2019-8-4 22:59

感謝分享

kuailefanhua 發表於 2019-8-5 06:49

感謝您的分享

j89211047 發表於 2020-10-12 10:08

感謝您的分享

Lineagelike520 發表於 2020-10-19 07:02

感謝分享~很實用

LINEAGEGG天堂 發表於 2020-10-21 00:43

GOOD THXYOU@@

michaeljordan18 發表於 2020-10-21 06:39

感謝大大得分享

野性覺醒 發表於 2021-3-31 18:53

感謝分享

Nai610808 發表於 2021-3-31 22:02

感謝分享

bennyst 發表於 2021-7-20 08:17

Sinnay 發表於 2022-2-12 21:02

感謝分享唷

CClineage45 發表於 2022-2-14 00:11

謝謝樓主大哥分享

danny199075 發表於 2022-2-14 00:14

6666666666
頁: [1]
查看完整版本: 簡易的仿官方 新地龍三段變身