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

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
Reply to this topic...

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



×
×
  • Create New...

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