Jump to content




  • 0

Item Spawn Interlude (Magic Gem L2 TENKAI) Ayuda


tensador27

Question

hola tengo un problema con este codigo lo encontre en la fuente de l2jtenkai no recuerdo que cronica exacta es pero lo queria adaptar a interlude y me encuentro con unos problemas

es en acis 401 

https://youtu.be/BRpk92UzuLc

 

me gustaria poner ponerle una proteccion que solo lo puedan usar 1 vez al item y que los npc desaparezcan 

aca 

el codigo 

package net.sf.l2j.gameserver.handler.itemhandlers;

import net.sf.l2j.A.Instance.InstanceManager;
import net.sf.l2j.gameserver.data.xml.SummonItemData;
import net.sf.l2j.gameserver.enums.ZoneId;
import net.sf.l2j.gameserver.handler.IItemHandler;
import net.sf.l2j.gameserver.model.actor.Playable;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.holder.IntIntHolder;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;

public class MagicGem implements IItemHandler {

    @Override
    public void useItem(Playable playable, ItemInstance item, boolean forceUse) {
        if (!(playable instanceof Player)) {
            return;
        }

        Player player = (Player) playable;

		if (player.isSitting())
		{
			player.sendPacket(SystemMessageId.CANT_MOVE_SITTING);
			return;
		}
		
		if (player.isInObserverMode())
			return;
		
		if (player.isAllSkillsDisabled() || player.getCast().isCastingNow())
			return;
		
		final IntIntHolder sitem = SummonItemData.getInstance().getSummonItem(item.getItemId());
		
		if ((player.getSummon() != null || player.isMounted()) && sitem.getValue() > 0)
		{
			player.sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
			return;
		}
		
		if (player.getAttack().isAttackingNow())
		{
			player.sendPacket(SystemMessageId.YOU_CANNOT_SUMMON_IN_COMBAT);
			return;
		}

        if (player.getInstanceId() == 0 &&
                !player.isInsideZone(ZoneId.PVP) &&
                (!player.isInsideZone(ZoneId.NO_SUMMON_FRIEND) ||
             
                !player.isInOlympiadMode() &&
                InstanceManager.getInstance().getInstance(player.getObjectId()) == null && player.getPvpFlag() == 0)){
            player.spawnServitors();
            player.sendMessage("You use a Magic Gem.");
        } else {
            player.sendMessage("You cannot use a Magic Gem right now.");
        }
        return;
    }
}

 

Player.java

	public void spawnServitors() {
		_instance = InstanceManager.getInstance().createInstance();
		Spawn servitor;
		float angle = Rnd.get(1000);
		int sCount = 3;
		for (int i = 0; i < sCount; i++) {
			servitor = getNpcServitor(i);
			if (servitor != null) {
				servitor.setInstanceId(_instance.getId());
				servitor.setLoc(Math.round(getX() + (float) Math.cos(angle / 1000 * 2 * Math.PI) * 30),
						Math.round(getY() + (float) Math.sin(angle / 1000 * 2 * Math.PI) * 30),
								getZ() + 75, i);
				int heading = (int) Math
						.round(Math.atan2(getY() - servitor.getLocY(), getX() - servitor.getLocX()) / Math.PI * 32768);
				if (heading < 0) {
					heading = 65535 + heading;
				}
				servitor.setHeading(heading);

				if (_instance != null) {
					servitor.doSpawn(true);
				}
			}
			angle += 1000 / sCount;
		}
	}

	// Magic Gem
	private Spawn[] _npcServitors = new Spawn[4];

	private Spawn getNpcServitor(int id) {
		if (_npcServitors[id] != null) {
			return _npcServitors[id];
		}
		Spawn spawn = null;
		try {
			NpcTemplate tmpl;
			switch (id) {
				case 0:
					tmpl = NpcData.getInstance().getTemplate(7);
					break;
				case 1:
					tmpl = NpcData.getInstance().getTemplate(50006);
					break;
				case 2:
					tmpl = NpcData.getInstance().getTemplate(30080);
					break;
				default:
					tmpl = NpcData.getInstance().getTemplate(50009);
			}
			spawn = new Spawn(tmpl);
		} catch (Exception e) {
			e.printStackTrace();
		}
		_npcServitors[id] = spawn;
		return _npcServitors[id];
	}	

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Join now

    Be part of the largest and oldest communities about Lineage2 in Latin America.

×
×
  • Create New...

Important Information

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.