Jump to content

Question

Posted
*
 * 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 java.util.StringTokenizer;


import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;


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


     @Override
    public void onBypassFeedback(L2PcInstance player, String command)
    {
      StringTokenizer st = new StringTokenizer(command, " ");
      String actualCommand = st.nextToken();


      int buffid = 0;
      int bufflevel = 1;
        String nextWindow = null;
      if (st.countTokens() == 3) {
         buffid = Integer.valueOf(st.nextToken());
         bufflevel = Integer.valueOf(st.nextToken());
            nextWindow = st.nextToken();
      }
      else if (st.countTokens() == 1)
      buffid = Integer.valueOf(st.nextToken());


      if (actualCommand.equalsIgnoreCase("getbuff"))
      {
         if (buffid != 0)
         {
            MagicSkillUse mgc = new MagicSkillUse(this, player, buffid, bufflevel, 5, 0);
            SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
            showMessageWindow(player);
            player.broadcastPacket(mgc);
                showChatWindow(player, nextWindow);
         }
      }
      else if (actualCommand.equalsIgnoreCase("restore")) {
         player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
         player.setCurrentCp(player.getMaxCp());
         showMessageWindow(player);
      }
      else if (actualCommand.equalsIgnoreCase("cancel")) {
         player.stopAllEffects();
         showMessageWindow(player);
      }
      else
         super.onBypassFeedback(player, command);
    }


    @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)) {
         player.setCurrentFolkNPC(this);
         showMessageWindow(player);
         player.sendPacket(ActionFailed.STATIC_PACKET);
      }
      else {
         player.getAI().setIntention(CtrlIntention.INTERACT, this);
         player.sendPacket(ActionFailed.STATIC_PACKET);
      }
    }
   
    private void showMessageWindow(L2PcInstance player)
    {
      String filename = "data/html/buffer/" + getNpcId() + ".htm";
      
      filename = getHtmlPath(getNpcId(), 0);
      NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
      html.setFile(filename);
      html.replace("%objectId%", String.valueOf(getObjectId()));
      html.replace("%npcname%", getName());
      player.sendPacket(html);      
    }
   @Override
   public String getHtmlPath(int npcId, int val)
   {
      String pom = "";
      if (val == 0)
         pom = "" + npcId;
      else
         pom = npcId + "-" + val;
      
      return "data/html/buffer/" + pom + ".htm";
   }   
}

Ρε μαγκες μου εδωσαν αυτον τον κωδικα σε ενα L2BufferInstance  πως θα το βαλω μεσο του eclipse  ωστε στην συνεχεια να κανω compile...

3 answers to this question

Recommended Posts

  • 0
Posted

package net.sf.l2j.gameserver.model.actor.instance;

miazei gia aCis pack tha pas sto net.sf.l2j.gameserver.model.actor.instance kai tha kaneis ena neo arxeio me onoma L2BufferInstance.java kai tha kaneis epikolisi auta pou exeis panw

meta tha pas stin db tha kaneis ena npc L2Buffer

kai kanto spawn

logika idi perases ta html sto datapack... opote den tha uparxoun provlimata

  • 0
Posted

ευχαριστω για την βοηθεια φιλε μου

Νταξει τα καταφερα απλα ειχα παρα πολυ καιρο να ασχοληθώ και δεν ημουν και τιποτα σπουδαιο παλαιοτερα 

  • 0
Posted (edited)

den eipa kati oloi kolame wres wres xarika pou voithisa

edit ta npc sto aCis einai se xml oxi db :P to eixa ksexasei auto

Edited by Nightw0lf

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.



×
×
  • Create New...