Jump to content
  • 0

[Help] Problem with adding custom instance


Question

Posted

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:

    [javac] D:\workspace\claw\gameserver\java\net\sf\l2j\gameserver\model\actor\instance\L2TpFlagInstance.java:250: cannot find symbol
    [javac] symbol  : method reduceCurrentHp(double,net.sf.l2j.gameserver.model.actor.L2Character,net.sf.l2j.gameserver.model.L2Skill)
    [javac] location: class net.sf.l2j.gameserver.model.actor.L2Npc
    [javac] 			super.reduceCurrentHp(damage, attacker, skill);
    [javac] 			     ^
    [javac] D:\workspace\claw\gameserver\java\net\sf\l2j\gameserver\model\actor\instance\L2TpFlagInstance.java:236: method does not override or implement a method from a supertype
    [javac]     @Override
    [javac]     ^
    [javac] 2 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

  • 0
Posted

Solved. Here is the fix:

    @Override
public void reduceCurrentHp(double damage, L2Character attacker)
   {
	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);
   }

Guest
This topic is now closed to further replies.


  • Posts

    • Acabei de liberar no TopL2.com o nosso MOD Oficial de VoteSystem, criado para servidores Lineage 2 que querem parar de sofrer com voto “fake” e reward entregue sem controle.   O que ele faz? O mod integra seu GameServer com o site TopL2, valida o voto do jogador e só então libera a recompensa — tudo com mais segurança, rastreio e controle.   Principais vantagens Voto verificado: o servidor confirma o voto registrado no site Reward mais seguro: evita abuso/duplicação e reduz exploit Cooldown configurável por jogador Logs e rastreio para auditoria e suporte   Instalação rápida, com arquivos organizados e prontos para copiar/aplicar   Disponível para download no https://TopL2.com   Se você é admin e quer profissionalizar seu sistema de votos e entregar reward com segurança, esse mod é pra você.  
    • Geia sas paidia eimai new edw mesa kai tha ithela na kanw mia erwtisi an kapoios mporei na me voithisei! Exw highfive (L2JMobius) kai thelw na valw custom weapons alla den exw sql file mporw na ta perasw xwris sql file kai na exw mono ta xml arxeia gia na ta valw stats/items?
    • ## [1.4.0] - 2026-01-28   ### ✨ New Features - **Vote System**: Lineage 2 servers can now use our vote–reward system. Players vote on the website and claim rewards in-game (1 vote = 1 claim) - **Vote Page**: On each server’s page (`/servers/<server>`), a **“Vote for Server”** button opens a dedicated vote page with cooldown info and optional Turnstile verification - **By Votes View**: The **“By Votes”** tab on the main page shows **actual vote counts** per server - **API Documentation**: New **API Docs** page at `/docs` (and footer link) with HMAC auth, endpoints, and examples for game server integration - **Vote API (My Servers)**: Server owners can open **“Vote API”** in My Servers to manage credentials, cooldown, allowed IPs, and open the docs   ### 🔄 Improvements - **Server Pages**: Single-server data is cached and loads faster; server pages can be opened by ID or by name (e.g. `/servers/my-server-name`) - **API Root**: Visiting the API root redirects to the docs URL configured in admin (default: site docs page) - **Admin Panel**: New **“Vote System”** tab for global settings (Turnstile, API security, default cooldown, docs URL)   ### 🔐 Security & Reliability - Turnstile (CAPTCHA) support for vote submissions to reduce abuse - HMAC-protected game server API for secure vote check/claim and stats
  • Topics

×
×
  • Create New...

Important Information

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..