Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Auto pilot Flying Gatekeeper

Iniciado por Swarlog, Sep 01, 2022, 12:22 AM

Tema anterior - Siguiente tema

Swarlog


/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package net.sf.l2j.gameserver.model.actor.instance;

import javolution.text.TextBuilder;

import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.model.L2CharPosition;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
import net.sf.l2j.util.Rnd;

/**
*
* @author AbsolutePower
*
*/
public final class L2FWyrenInstance extends L2NpcInstance
{
    public L2FWyrenInstance(int objectId, L2NpcTemplate template)
    {
        super(objectId, template);
    }

    @Override
    public void onBypassFeedback(L2PcInstance p, String co)
    {     
      if(co.startsWith("giran"))
      {
        ridefly(p);
        goToLocationDismountAndMessage(p,82698, 148638, -3473);
      }
      else if(co.startsWith("goddard"))
      {
      ridefly(p);
      goToLocationDismountAndMessage(p,147725, -56517, -2780);
      }
      else if(co.startsWith("aden"))
      {
      ridefly(p);
      goToLocationDismountAndMessage(p,147456, 26886, -2207);
      }
      p.sendPacket(ActionFailed.STATIC_PACKET);

    }

    @Override
    public void onAction(L2PcInstance player)
    {
if (this != player.getTarget())
{
player.setTarget(this);
player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
player.sendPacket(new ValidateLocation(this));
}
else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false)) {
SocialAction sa = new SocialAction(this, Rnd.get(8));
broadcastPacket(sa);
player.setCurrentFolkNPC(this);
showMessageWindow(player);
player.sendPacket(ActionFailed.STATIC_PACKET);
}
else
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
player.sendPacket(ActionFailed.STATIC_PACKET);
}
    }
    private void showMessageWindow(L2PcInstance p)
    {
      NpcHtmlMessage nhm = new NpcHtmlMessage(5);
      TextBuilder tb = new TextBuilder("");
     
      if (p.isSitting() || p.isAlikeDead() || p.isInCombat() || p.isInOlympiadMode() || p.isAcademyMember()
      || p.isAfraid() || p.isInCraftMode() || p.isInJail() || p.getPrivateStoreType() != 0)
      {
         p.sendMessage("You can't use the gk now!");
   return;
      }
     
      tb.append("<html><head><title>CustomGateKeeper</title></head><body>");
      tb.append("<center>");
      tb.append("<img src=\"L2Font-e.mini_logo-e\" width=200 height=120 align=center>");
      tb.append("</center>");
      tb.append("<center>");   
      tb.append("<td valign=\"top\"><font color=\"FFFFFF\">" + p.getName()+" Choose your destination!</font><br>"); 
      tb.append("<button value=\"Giran\" action=\"bypass -h npc_" + getObjectId() + "_giran\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>");
      tb.append("<button value=\"Goddard\" action=\"bypass -h npc_" + getObjectId() + "_goddard\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>");
      tb.append("<button value=\"Aden\" action=\"bypass -h npc_" + getObjectId() + "_aden\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>");
      tb.append("</center>");
      tb.append("<center>");
      tb.append("<img src=\"L2Font-e.mini_logo-e\" width=200 height=120 align=center>");
      tb.append("<font color=\"FFFFFF\">Coded By AbsolutePower</font>");
      tb.append("</center>");
      tb.append("</body></html>");

      nhm.setHtml(tb.toString());
      p.sendPacket(nhm);

      p.sendPacket(ActionFailed.STATIC_PACKET);
    }
   
    private void goToLocationDismountAndMessage(L2PcInstance p,int x,int y,int z)
    {
    p.teleToLocation(x, y, z);
wait(1,false);
p.dismount();
p.sendPacket(new ExShowScreenMessage(p.getName() +" you arrived at your destination ", 4000));
p.setXYZ(x, y, z);
    }
   
    private void ridefly(L2PcInstance p)
    {
        int x,y,z;
        final int px = p.getX();
        final int py = p.getY();
        final int pz = p.getZ();
       
double ph = p.getHeading() / 182.044444444;
ph += 90;

if (ph > 90)
ph -= 90;

ph = (Math.PI * ph) / 90;

x = (int) (px + (1 * Math.cos(ph)));
y = (int) (py + (1 * Math.cos(ph)));
z = (int) (pz + (5000 * Math.cos(ph)));

    p.mount(12621, 0, false);
     
p.abortAttack();
p.abortCast();
p.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
p.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(x, y, z, 0));
p.abortAttack();
p.abortCast();
p.setXYZ(x, y, z);
p.broadcastPacket(new ValidateLocation(p));
wait(1,false);
    }
     
    private void wait(int i ,boolean min)
    {
   
    if(min)
        try
        {
                Thread.sleep(i * 60000);
        }
        catch (InterruptedException ie)
        {
                ie.printStackTrace();
        }
        else
       
            try
            {
                    Thread.sleep(i * 1000);
            }
            catch (InterruptedException ie)
            {
                    ie.printStackTrace();
            }
           
    }   
}