Jump to content

Recommended Posts

Posted

 

 

package ru.catssoftware.gameserver.handler.itemhandler;

import org.apache.log4j.Logger;
import ru.catssoftware.gameserver.ThreadPoolManager;
import ru.catssoftware.gameserver.datatables.NpcTable;
import ru.catssoftware.gameserver.handler.IItemHandler;
import ru.catssoftware.gameserver.idfactory.IdFactory;
import ru.catssoftware.gameserver.model.L2ItemInstance;
import ru.catssoftware.gameserver.model.actor.instance.L2NpcInstance;
import ru.catssoftware.gameserver.model.actor.instance.L2PcInstance;
import ru.catssoftware.gameserver.model.actor.instance.L2PlayableInstance;
import ru.catssoftware.gameserver.network.SystemMessageId;
import ru.catssoftware.gameserver.templates.chars.L2NpcTemplate;

/**
 * Created by IntelliJ IDEA.
 * User: masone
 * Date: 02.07.15
 * Time: 20:07
 * To change this template use File | Settings | File Templates.
 */
public class spawnitem implements IItemHandler
{
    protected static Logger _log = Logger.getLogger(spawnitem.class.getName());

    private static final int[] ITEM_IDS = { 6673 };
    public void useItem(L2PlayableInstance playable, L2ItemInstance item, boolean par){}

    public int[] getItemIds()
    {
        return ITEM_IDS;
    }


    public void useItem(L2PlayableInstance playable, L2ItemInstance item)
    {
        _log.info("use item" +item);
        L2PcInstance activeChar;
        activeChar = (L2PcInstance) playable;

        L2NpcTemplate template;
        template = NpcTable.getInstance().getTemplate(60000);

        if (activeChar.isInOlympiadMode())
        {
            activeChar.sendPacket(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
            return;
        }

        //TODO flood protector

        L2NpcInstance npc = new L2NpcInstance(IdFactory.getInstance().getNextId(), template);
        npc.setInstanceId(activeChar.getInstanceId());
        npc.setIsInvul(true);
        npc.setTitle(activeChar.getName());
        npc.setName("masone");
        npc.updateAbnormalEffect();
        npc.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());

        ThreadPoolManager.getInstance().scheduleGeneral(new deleteNPC(npc), 60000);

        //  activeChar.destroyItem("Summon", item.getObjectId(), 1, null, true);
    }

    public class deleteNPC implements Runnable
    {

        protected L2NpcInstance _npc;
        public void run()
        {

            _npc.deleteMe();
        }
        deleteNPC(L2NpcInstance npc)
        {
            _npc = npc;
        }
    }
} 

 

 

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


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

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock