Jump to content
  • 0

Question

Posted

So I take aCis free 254 rev and decided to make a buffer to it. I found the Buffer of darthvader

 

Changed the showMessageWindow to make a html file.

and know i have this

/*
* 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.SocialAction;
import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
import net.sf.l2j.util.StringUtil;
import net.sf.l2j.util.Rnd;

/**
*
* @author DarthVader
* @version 1.3
*/
public final class L2Buffer2Instance extends L2NpcInstance
{
    public L2Buffer2Instance(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;
	if (st.countTokens() == 2) {
		buffid = Integer.valueOf(st.nextToken());
		bufflevel = Integer.valueOf(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);
		}
	}
	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)) {
		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 player)
    {
	/*
	player.sendPacket(ActionFailed.STATIC_PACKET);		
	NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());		
	html.setFile("data/html/Buffer/" + getTemplate().getNpcId() + ".htm");		
	html.replace("%objectId%", String.valueOf(getObjectId()));
	html.replace("%name%", player.getName());				
	player.sendPacket(html);
	*/

	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";
}	
}

 

I made html for buffer in data/html/buffer/id.htm. id-1.htm for buffs, id-2.htm for dances etc.

but when i am on dances htm and get for example Dance of fire, I'm going to main htm.(id.htm) I want to go back to id-2.htm.

 

Did you get it what I want? can you give me opinions?

2 answers to this question

Recommended Posts

  • 0
Posted

Replace your onBypassFeedback() method with this:

 

    @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);
    }

 

And use the bypass of npc_%objectId%_getBuff id lvl like this: npc_%objectId%_getBuff id lvl id-x.htm (where x you add the window you want to return after buff).

Guest
This topic is now closed to further replies.


×
×
  • Create New...