Jump to content
  • 0

Summon Pking


Question

Posted

Hello guys, i need some help, if you summon pet in town and you try to use it to attack players its not working, if you first use the pet to attack npc and then a player its working and people are pking in town by using their pets.

My npcs are not attackable but i dont know why pets or summons can attack them.

I have to make npcs not attackable from pets too or fix this with another way. Any help?

9 answers to this question

Recommended Posts

  • 0
Posted

i am using l2jesios

 

	protected void doAttack(L2Character target)
{
	if (Config.DEBUG)
		_log.fine(getName() + " doAttack: target=" + target);

	if (!isAlikeDead() && target != null)
	{
		if (this instanceof L2Npc && target.isAlikeDead() || !getKnownList().knowsObject(target))
		{
			getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
			sendPacket(ActionFailed.STATIC_PACKET);
			return;
		}
		else if (this instanceof L2PcInstance)
		{
			if (target.isDead())
			{
				getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
				sendPacket(ActionFailed.STATIC_PACKET);
				return;
			}

			L2PcInstance actor = (L2PcInstance) this;
			// Players riding wyvern can only do melee attacks
			if (actor.isMounted() && actor.getMountNpcId() == 12621)
			{
				sendPacket(ActionFailed.STATIC_PACKET);
				return;
			}
		}
	}

	if (isAttackingDisabled())
		return;

	if (this instanceof L2PcInstance)
	{
		if (((L2PcInstance) this).inObserverMode())
		{
			sendPacket(SystemMessage.getSystemMessage(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE));
			sendPacket(ActionFailed.STATIC_PACKET);
			return;
		}

		// Checking if target has moved to peace zone
		if (target.isInsidePeaceZone((L2PcInstance) this))
		{
			getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
			sendPacket(ActionFailed.STATIC_PACKET);
			return;
		}
	}

  • 0
Posted

Soz, post me the onForcedAttack() method too, if u can :P

 

	public void onForcedAttack(L2PcInstance player)
{
	if (isInsidePeaceZone(player))
	{
		// If L2Character or target is in a peace zone, send a system message TARGET_IN_PEACEZONE a Server->Client packet ActionFailed
		player.sendPacket(SystemMessageId.TARGET_IN_PEACEZONE);
		player.sendPacket(ActionFailed.STATIC_PACKET);
		return;
	}

	if (player.isInOlympiadMode() && player.getTarget() != null && player.getTarget() instanceof L2Playable)
	{
		L2PcInstance target = player.getTarget().getActingPlayer();
		if (target == null || (target.isInOlympiadMode() && (!player.isOlympiadStart() || player.getOlympiadGameId() != target.getOlympiadGameId())))
		{
			// if L2PcInstance is in Olympia and the match isn't already start, send a Server->Client packet ActionFailed
			player.sendPacket(ActionFailed.STATIC_PACKET);
			return;
		}
	}

	if (player.getTarget() != null && !player.getTarget().isAttackable() && !player.getAccessLevel().allowPeaceAttack())
	{
		// If target is not attackable, send a Server->Client packet ActionFailed
		player.sendPacket(ActionFailed.STATIC_PACKET);
		return;
	}

	if (player.isConfused())
	{
		// If target is confused, send a Server->Client packet ActionFailed
		player.sendPacket(ActionFailed.STATIC_PACKET);
		return;
	}

	// GeoData Los Check or dz > 1000
	if (!GeoData.getInstance().canSeeTarget(player, this))
	{
		player.sendPacket(SystemMessageId.CANT_SEE_TARGET);
		player.sendPacket(ActionFailed.STATIC_PACKET);
		return;
	}

	// Notify AI with AI_INTENTION_ATTACK
	player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
}

  • 0
Posted

-beep-, I'm just sleepy as hell.

More than probably the 2 methods I told you to post, don't matter at all.

We need to check the canAttack() from L2Summon, if you have that file in that pack.

:rage: :rage: :rage:

  • 0
Posted

-beep-, I'm just sleepy as hell.

More than probably the 2 methods I told you to post, don't matter at all.

We need to check the canAttack() from L2Summon, if you have that file in that pack.

:rage: :rage: :rage:

haha okay, i dont have this method in l2summon

  • 0
Posted

And do you have this one?

 

/**
 * Performs an attack to the owner's target.
 */
public void doAttack()
{
	if (getOwner() != null)
	{
		final L2Object target = getOwner().getTarget();
		if (target != null)
		{
			setTarget(target);
			getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
		}
	}
}

 

If yes, you could try with (not the best option but could work):

 

/**
 * Performs an attack to the owner's target.
 */
public void doAttack()
{
	if (getOwner() != null)
	{
		final L2Object target = getOwner().getTarget();
		if (target != null)
		{
			if(target instanceof L2Npc /* or u can try with target instanceof L2PcInstance too, if u want NPC attackables */ && isInsidePeaceZone(target)
			{
				return;
			}
			setTarget(target);
			getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
		}
	}
}

 

  • 0
Posted

Stupid me i didnt even had a doattack method...

 

I used this one

	protected void doAttack(L2Character target)
{
	if(getOwner() != null && getOwner() == target && !getOwner().isBetrayed())
	{
		sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
		return;
	}
	if(isInsidePeaceZone(this, target))
	{
		getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
		return;
	}
	if(!target.isAttackable())
	{
		if (!(this instanceof L2SiegeSummonInstance))
		{
		getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
		return;
		}
	}

	super.doAttack(target);
}

 

Thx for helping anyway Wyatt ;)

Guest
This topic is now closed to further replies.


×
×
  • Create New...