2017年9月8日 星期五

敵對陣營系統-ok



NpcTable

Integer hostileFamily = _familyTypes.get(rs.getString("hostile_family"));//敵對陣營
if (hostileFamily == null) {
npc.set_hostileFamily(0);
} else {
npc.set_hostileFamily(hostileFamily.intValue());
}


L1Npc

// 敵對陣營
private int _hostileFamily;
public int get_hostileFamily() {
return _hostileFamily;
}
public void set_hostileFamily(int i) {
_hostileFamily = i;
}
// 敵對陣營 end


L1MonsterInstance




// ターゲットを探す
public static int[][] _classGfxId = { { 0, 1 }, { 48, 61 }, { 37, 138 },
{ 734, 1186 }, { 2786, 2796 } };



// 闘技場内は変身/未変身に限らず全てアクティブ

這段上面之前

改成


@Override
//TODO 敵對系統 by80363000
    public void searchTarget() {
        // ターゲット捜索
        L1PcInstance targetPlayer = null;  
        // 加入搜索敵對陣營為目標
        L1MonsterInstance targetNpc = null;
        int thisNpcFamily = getNpcTemplate().get_hostileFamily();
        if (thisNpcFamily != 0) {//有設定敵對陣營才需要搜索
                int map = getMapId();
                Point npcpt = getLocation();
                for (L1Object object : L1World.getInstance().getObject()) {
                        if (object instanceof L1MonsterInstance) {
                                L1MonsterInstance tgnpc = (L1MonsterInstance) object;
                                if (tgnpc.getNpcTemplate().get_family() == thisNpcFamily) {
                                        if (map != tgnpc.getMapId()) {
                           continue;
                    }
                                        if (tgnpc != null && tgnpc.getCurrentHp() > 0 && !tgnpc.isDead() && npcpt.isInScreen(tgnpc.getLocation())) {
                               targetNpc = tgnpc;
                                           break;
                        }
                                }
                        }
                }
        }

        for (L1PcInstance pc : L1World.getInstance().getVisiblePlayer(this)) {
                if (pc.getCurrentHp() <= 0 || pc.isDead() || pc.isGm()
                                || pc.isMonitor() || pc.isGhost()) {
                        continue;
                }//TODO 敵對系統 by80363000 end



之後找

// リンクの設定
@Override
public void setLink(L1Character cha) {
if ((cha != null) && _hateList.isEmpty()) { // ターゲットがいない場合のみ追加
_hateList.add(cha, 0);
checkTarget();
}
}

上面追加

        //TODO 敵對系統 by80363000
        if (targetNpc != null) {
            _hateList.add(targetNpc, 0);
                _target = targetNpc;
        } else if (targetPlayer != null) {
                _hateList.add(targetPlayer, 0);
                _target = targetPlayer;
        }





2 則留言: