package ai.individual.monster;

import l2.universe.gameserver.model.L2Skill;
import l2.universe.gameserver.model.actor.L2Npc;
import l2.universe.gameserver.model.actor.instance.L2PcInstance;
import l2.universe.gameserver.model.quest.Quest;
import l2.universe.gameserver.network.serverpackets.NpcSay;
import l2.universe.util.Rnd;

public class CatsEyeBandit extends Quest
{
    private boolean firstAttacked = false;

    public CatsEyeBandit(int questId, String name, String descr)
	{
		super(questId, name, descr);
        addKillId(27038);
        addAttackId(27038);
    }

    public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isPet, L2Skill skill)
    {
        if (firstAttacked)
        {
           if (Rnd.get(80) < 40) return super.onAttack(npc,player,damage,isPet,skill);
           npc.broadcastPacket(new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), 40306));
        }
        else
           firstAttacked = true;
        return super.onAttack(npc,player,damage,isPet,skill);
    }

    public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
    {
        if (npc.getNpcId() == 27038)
        {
            if (Rnd.get(100)<80)
                npc.broadcastPacket(new NpcSay(npc.getObjectId(), 0, npc.getNpcId(), 40307));
            firstAttacked = false;
        }
        else if (firstAttacked)
            addSpawn(npc.getNpcId(), npc);
        return super.onKill(npc,player,isPet);
    }

    public static void main(String[] args)
	{
		new CatsEyeBandit(-1, "CatsEyeBandit", "ai");
	}
}
