- 0
This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..
Question
DarthVader
Hello. Well, I'm trying to addapt gracia final faction engine to interlude and I almost did it, but I got two errors and I have no idea how to fix that.
Errors:
And here is code:
package net.sf.l2j.gameserver.model.actor.instance; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.logging.Logger; import net.sf.l2j.L2DatabaseFactory; import net.sf.l2j.gameserver.Announcements; import net.sf.l2j.gameserver.ai.CtrlIntention; import net.sf.l2j.gameserver.datatables.NpcTable; import net.sf.l2j.gameserver.idfactory.IdFactory; import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.actor.L2Character; import net.sf.l2j.gameserver.model.actor.L2Npc; import net.sf.l2j.gameserver.model.entity.FactionMaps; import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected; import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate; import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation; import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate; import net.sf.l2j.gameserver.util.Broadcast; public class L2TpFlagInstance extends L2Npc { private final static Logger _log = Logger.getLogger(L2FactTeleporterInstance.class.getName()); private int _faction=0; private int _occupayable=0; private String _title = ""; private String _flagPlace = ""; public L2TpFlagInstance(int objectId, L2NpcTemplate template) { super(objectId, template); } public static void spawnFlags() { Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM faction_crystals WHERE mapId=?"); statement.setInt(1, FactionMaps.getMapId()); ResultSet rset = statement.executeQuery(); while (rset.next()) { String _titlea = ""; if (rset.getInt("factionId") == 1) _titlea = "Blue"; else if (rset.getInt("factionId") == 2) _titlea = "Red"; L2TpFlagInstance flag = new L2TpFlagInstance(IdFactory.getInstance().getNextId(),NpcTable.getInstance().getTemplate(31217)); flag.setTitle(_titlea); flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp()); flag.setHeading(0); flag.setName(rset.getString("flagName")); flag.setFlagName(rset.getString("flagName")); flag.setFlagFactionId(rset.getInt("factionId")); flag.spawnMe(rset.getInt("x"),rset.getInt("y"),rset.getInt("z") + 50); if (rset.getInt("factionId") != 0) { if (rset.getInt("factionId") == 1) L2FactTeleporterInstance._tpBlueFlags.add(flag); else L2FactTeleporterInstance._tpRedFlags.add(flag); flag.setIsInvul(true); flag.setIsUnoccupayable(1); } _log.info("Spawned crystal: " + rset.getString("flagName")); } rset.close(); statement.close(); } catch (Exception e) { _log.warning("Kazkas blogai su kristalais faction:" + e); } finally { try {con.close();} catch (Exception e){} } Announcements.getInstance().announceToAll("Spawned faction map: " + FactionMaps.getMapName()); } public void setFlagName(String a) { _flagPlace = a; } public String getFlagName() { return _flagPlace; } @Override public boolean isAttackable() { return true; } @Override public boolean isAutoAttackable(L2Character attacker) { return true; } @Override public boolean doDie(L2Character killer) { if (!super.doDie(killer)) return false; if (getFlagFactionId() == 1) L2FactTeleporterInstance._tpBlueFlags.remove(this); else if (getFlagFactionId() == 2) L2FactTeleporterInstance._tpRedFlags.remove(this); L2PcInstance player = null; int _faktjon = 0; String _name = ""; if (killer instanceof L2PcInstance) player = (L2PcInstance) killer; else if (killer instanceof L2SummonInstance) player = ((L2SummonInstance) killer).getOwner(); _faktjon = player.getFactionId(); if (_faktjon == 1) _title = "Blue"; else _title = "Red"; L2TpFlagInstance flag = new L2TpFlagInstance(IdFactory.getInstance().getNextId(),NpcTable.getInstance().getTemplate(31217)); _name = this.getName(); flag.setTitle(_title); flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp()); flag.setHeading(0); flag.setName(_name); flag.setFlagName(_name); flag.setIsUnoccupayable(0); flag.setFlagFactionId(_faktjon); flag.spawnMe(this.getX(), this.getY(), this.getZ()); deleteMe(); if (_faktjon == 1) L2FactTeleporterInstance._tpBlueFlags.add(flag); else L2FactTeleporterInstance._tpRedFlags.add(flag); Broadcast.sendMessToAllFactionPlayers(_title + " faction member " + player.getName() + " has occupied " + _flagPlace + " crystal."); return true; } @Override public void onForcedAttack(L2PcInstance player) { onAction(player); } public void setIsUnoccupayable(int a) { _occupayable = a; } public int isUnoccupayable() { return _occupayable; } @Override public void onAction(L2PcInstance player) { if (player == null || !canTarget(player)) return; // Check if the L2PcInstance already target the L2NpcInstance if (this != player.getTarget()/* && player.inWorld() == 1*/) { // Set the target of the L2PcInstance player player.setTarget(this); // Send a Server->Client packet MyTargetSelected to the L2PcInstance player MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()); player.sendPacket(my); // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar StatusUpdate su = new StatusUpdate(getObjectId()); su.addAttribute(StatusUpdate.CUR_HP, (int)getStatus().getCurrentHp() ); su.addAttribute(StatusUpdate.MAX_HP, getMaxHp() ); player.sendPacket(su); // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client player.sendPacket(new ValidateLocation(this)); } else { if (isAutoAttackable(player) && Math.abs(player.getZ() - getZ()) < 100) player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this); else { // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet player.sendPacket(ActionFailed.STATIC_PACKET); } } } public int getFlagFactionId() { return _faction; } public void setFlagFactionId(int i) { _faction = i; } @Override public void reduceCurrentHp(double damage, L2Character attacker, L2Skill skill) { L2PcInstance plajor = null; boolean cord = false; if (attacker instanceof L2PcInstance) plajor = (L2PcInstance) attacker; else if (attacker instanceof L2SummonInstance) plajor = ((L2SummonInstance) attacker).getOwner(); if (/*plajor.inWorld() == 1 && */plajor.getFactionId() != getFlagFactionId()) cord = true; if (cord) super.reduceCurrentHp(damage, attacker, skill); } }::)
2 answers to this question
Recommended Posts