Jump to content

[GRACIA-FINAL][L2JSERVER] Skill Player Menu


Rafael FBS

Recommended Posts

Bom, estou tentando criar uma skill que tenha um player menu AiO (GMSHOP, BUFF, TP, ETC).

 

Mas como não sou nem programador, ae fica dificil ^^.

 

Vou dexar aqui o que eu consegui fazer e qria a ajuda de vcs pra continuar esse "projeto".

 

Script SkillHandler "OpenPlayerMenu.java" (data/scripts/handlers/skillhandlers):

package handlers.skillhandlers;

import net.sf.l2j.gameserver.cache.HtmCache;
import net.sf.l2j.gameserver.handler.ISkillHandler;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.templates.skills.L2SkillType;

/**
*
* @author  Rafaelfbs
*/
public class OpenPlayerMenu implements ISkillHandler
{


private static final L2SkillType[] SKILL_IDS =
{
	L2SkillType.OPEN_MENU
};

public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
	String htmFile = "data/scripts/custom/OpenMenu/menu.htm";
	String htmContent = HtmCache.getInstance().getHtm(htmFile);

	NpcHtmlMessage infoHtml = new NpcHtmlMessage(1);
	infoHtml.setHtml(htmContent);
	activeChar.sendPacket(infoHtml);
}



/**
 * 
 * @see net.sf.l2j.gameserver.handler.ISkillHandler#getSkillIds()
 */
public L2SkillType[] getSkillIds()
{
	return SKILL_IDS;
}
}

 

Obs: Creio que dê pra colocar um skilltype qqer (ao invés de criar uma skilltype nova no core) e entaum por algo parecido com isso:

.......

public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
{
if (activeChar.getLastSkillCast().getId = "9010")
{ .......

 

Dpois criei uma skill qqer no xml com id = 9010 e coloquei skilltype como OPEN_MENU (criei no core), adicionei ela no client, e funcionou. Abriu uma janela no L2.

 

 

Mas aew que tá o problema, bypass como "bypass -h npc_%objectId%_algumacoisa" nao funcionam. Comandos de admin funcionam, se vc tiver permissão. Foi entaum que pensei em criar comandos de admin com permissão 0, ou então criar outro CommandHandler.. tipo um EtcCommandHandler. Só que fiquei empacado nessa parte.

 

Qual dica vcs podem me dar? ou alguem que esta disposto a me ajudar possa me dar uma luz aqui. Acho que fui até alem do alcance do meu conhecimento :rolleyes:

 

Conto com a ajuda de vcs... bom jogo e L2JBrasil na veia ^^.

 

:vlw_l2jbr:

Link to comment
Share on other sites


qndvc clica na skill aparece uma janela..

c nao da pra bupass

crie um botao e redireciona para o merchante ..

ai ja coloka outros tbm como buffer, classmaster, subclass etc,,

 

fikaria massa.

account_tiny.gif

svn | timeline

activeMember.sendMessage("Quase tudo é possível quando se tem dedicação e habilidade. Grandes trabalhos são realizados não pela força, mas pela perseverança")

Link to comment
Share on other sites

Mas desvio de html é feito por bypass tbm, o maximo que vc deve conseguir e fazer abrir uma janela com informações.

"In a way, the supernatural is what's behind the curtain. Normally, you only need to see what's happening on stage. That's how reality works. If you don't know then it's for the best. Actually, learning about the supernatural only increases the number of things you don't know."'

Link to comment
Share on other sites

Você pode tentar algo parecido com isso:

 

package net.sf.l2j.gameserver.handler.itemhandlers;

 

import net.sf.l2j.Config;

import net.sf.l2j.gameserver.handler.IItemHandler;

import net.sf.l2j.gameserver.GameServer;

import net.sf.l2j.gameserver.cache.HtmCache;

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

import net.sf.l2j.gameserver.handler.IItemHandler;

import net.sf.l2j.gameserver.model.L2ItemInstance;

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;

 

 

 

/**

* @author Cobra

*

*/

public class Item implements IItemHandler

{

private static final int[] ITEM_IDS = { 99999 };

 

public void useItem(L2PlayableInstance playable, L2ItemInstance item)

{

if (!(playable instanceof L2PcInstance))

return;

L2PcInstance activeChar = (L2PcInstance)playable;

int itemId = item.getItemId();

 

if (itemId == 10639)

{

String htmFile = "data/html/mods/chatitem.htm";

String htmContent = HtmCache.getInstance().getHtm(htmFile);

 

NpcHtmlMessage infoHtml = new NpcHtmlMessage(1);

infoHtml.setHtml(htmContent);

activeChar.sendPacket(infoHtml);

}

}

public int[] getItemIds()

{

return ITEM_IDS;

}

}

Link to comment
Share on other sites

Gente.. acho q soh bypass de npc e quest q nao funcionam (de quest nao tenho certeza, nao tentei e ainda nao sei fazer um script de quest hehe). Mas como ja disse comando como "bypass -h admin_admin" funcionam.

 

Mas desvio de html é feito por bypass tbm, o maximo que vc deve conseguir e fazer abrir uma janela com informações.

 

Creio que uma forma mais facil (nao pra fazer, e sim pra adicionar opcoes dpois) seria criar um CommandHandler novo, e entaum adicionar comandos (algo assim: "menuplayer_buff" entaum eu passaria como "bypass -h menuplayer_buff skillID skillLVL"). Tornaria mais pratico.

 

Edit: Descobri como funciona parte do AdminCommandHandler. A única coisa q eu nao descobri ainda é como que o servidor reconhece o "//" como sendo "admin_".

 

:vlw_l2jbr:

Edited by Rafael FBS
Link to comment
Share on other sites

Fuuuncionooouu.. consegui criar um CustomCommandHandler. Vou tentar explicar aki:

 

No codigo:

 

Primeiro crie um arquivo java dentro do "net.sf.l2j.gameserver.handler" chamado CustomCommandHandler com este codigo:

 

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.handler;

import java.util.Map;
import java.util.logging.Logger;

import javolution.util.FastMap;
import net.sf.l2j.Config;

public class CustomCommandHandler
{
private static Logger _log = Logger.getLogger(CustomCommandHandler.class.getName());

private Map<String, ICustomCommandHandler> _datatable;

public static CustomCommandHandler getInstance()
{
	return SingletonHolder._instance;
}

private CustomCommandHandler()
{
	_datatable = new FastMap<String, ICustomCommandHandler>();
}

public void registerCustomCommandHandler(ICustomCommandHandler handler)
{
	String[] ids = handler.getCustomCommandList();
	for (int i = 0; i < ids.length; i++)
	{
		if (Config.DEBUG)
			_log.fine("Adding handler for command " + ids[i]);
		_datatable.put(ids[i], handler);
	}
}

public ICustomCommandHandler getCustomCommandHandler(String customCommand)
{
	String command = customCommand;
	if (customCommand.indexOf(" ") != -1)
	{
		command = customCommand.substring(0, customCommand.indexOf(" "));
	}
	if (Config.DEBUG)
		_log.fine("getting handler for command: " + command + " -> " + (_datatable.get(command) != null));
	return _datatable.get(command);
}


public int size()
{
	return _datatable.size();
}

@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
	protected static final CustomCommandHandler _instance = new CustomCommandHandler();
}
}

 

e outro arquivo java também dentro do "net.sf.l2j.gameserver.handler" com nome ICustomCommandHandler com esse codigo:

 

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.handler;

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;


public interface ICustomCommandHandler
{
public boolean useCustomCommand(String command, L2PcInstance activeChar);

public String[] getCustomCommandList();
}

 

Dpois altera o RequestBypassToServer do "net.sf.l2j.gameserver.network.clientpackets" com esse code:

Index: C:/Documents and Settings/Administrador/Desktop/arquivos/rfbs/eclipse/projetos/L2J Core/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- C:/Documents and Settings/Administrador/Desktop/arquivos/rfbs/eclipse/projetos/L2J Core/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 3695)
+++ C:/Documents and Settings/Administrador/Desktop/arquivos/rfbs/eclipse/projetos/L2J Core/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(working copy)
@@ -23,7 +23,9 @@
import net.sf.l2j.gameserver.communitybbs.CommunityBoard;
import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
import net.sf.l2j.gameserver.handler.AdminCommandHandler;
+import net.sf.l2j.gameserver.handler.CustomCommandHandler;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
+import net.sf.l2j.gameserver.handler.ICustomCommandHandler;
import net.sf.l2j.gameserver.model.L2CharPosition;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2World;
@@ -98,6 +100,19 @@

				ach.useAdminCommand(_command, activeChar);
			}
+			else if (_command.startsWith("custom_"))
+			{
+				String command = _command.split(" ")[0];
+				
+				ICustomCommandHandler cch = CustomCommandHandler.getInstance().getCustomCommandHandler(command);
+				if (cch == null)
+				{
+					_log.warning("No handler registered for custom command '" + command + "'");
+					return;
+				}
+				
+				cch.useCustomCommand(_command, activeChar);
+			}
			else if (_command.equals("come_here") && ( activeChar.isGM()))
			{
				comeHere(activeChar);

 

No data:

 

Vá no seu "data/scripts/handlers" e crie uma pasta com nome "customcommandhandlers", e crie uma arquivo chamado CustomBuffs.java com este codigo:

 

package handlers.customcommandhandlers;

import java.util.StringTokenizer;

import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.handler.ICustomCommandHandler;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.templates.skills.L2SkillType;



public class CustomBuffer implements ICustomCommandHandler
{
private static final String[] CUSTOM_COMMANDS = 
{
	"custom_buff",
};

public boolean useCustomCommand(String command, L2PcInstance activeChar) {
	if (command.startsWith("custom_buff"))
	{
		String val = command.substring(12);
		StringTokenizer st = new StringTokenizer(val);

		if(st.countTokens() == 2)
		{
			String sbuffID = st.nextToken();
			int buffID = Integer.parseInt(sbuffID);
			String sbuffLvl = st.nextToken();
			int buffLvl = Integer.parseInt(sbuffLvl);

			L2Skill buffSkill = SkillTable.getInstance().getInfo(buffID, buffLvl);

			if (buffSkill.getSkillType() == L2SkillType.BUFF)
			{
				activeChar.useMagic(buffSkill, true, false);
				return true;
			} else
			{
				activeChar.sendMessage("this skillid is not a buff");
				return false;
			}
		} else
		{
			activeChar.sendMessage("wrong command");
			return false;
		}
	}
	return true;
}

public String[] getCustomCommandList() {
	return CUSTOM_COMMANDS;
}
}

 

Agora adicione estas linhas no MasterHandler.java:

 

public class MasterHandler
{
private static Logger _log = Logger.getLogger(MasterHandler.class.getName());

+	private static void loadCustomHandlers()
+	{
+		CustomCommandHandler.getInstance().registerCustomCommandHandler(new CustomBuffer());
+		_log.config("Loaded " + CustomCommandHandler.getInstance().size() + "  CustomCommandHandlers");
+	}

public static void main(String[] args)
{
	_log.config("Loading Handlers...");
+		loadCustomHandlers();
	loadAdminHandlers();
	loadChatHandlers();
	loadItemHandlers();
	loadSkillHandlers();

 

Dpois disso vc pode usar esse comando pra buffar: "bypass -h custom_buff SkillID SkillLvl" (onde SkillID é a ID do buff e SkillLvl é o lvl da skill :rolleyes: )

 

Obs: usei no script o "useMagic()" então as animacoes das skills aparecem ^^.

 

Aew com isso eu consegui fazer meu PlayerMenu hehe.. funcionando perfeitim. Qualquer duvida com relação ao tópico manda pm que eu tento esclarecer.

 

Pra adicionar mais commandos é soh criar outro script handler, ou entao pode agrupar por tipo (ex: se for um comando de buff adiciona ele nos strings do CustomBuffer e poe um "if (command.startsWith("custom_seucomandodebuff"))". Usa a imaginação hehehe

 

Ainda nao sei como faz pra criar um comando do tipo "//" ou alguma outra coisa como "*". dpois eu procuro. creio que seja essas strings aki:

 

private static final String _C__6E_REQUESTGMCOMMAND = "[C] 6e RequestGMCommand";

 

se alguem souber posta aew ou manda pm.

 

:vlw_l2jbr:

Link to comment
Share on other sites

Eita cara parabens , depois vc podia tentar fazer conexao com uma tabela da DB pra simplificar o modo de como adicionar os buff's

"In a way, the supernatural is what's behind the curtain. Normally, you only need to see what's happening on stage. That's how reality works. If you don't know then it's for the best. Actually, learning about the supernatural only increases the number of things you don't know."'

Link to comment
Share on other sites

Da uma olhada nos npcs buffer que fazem isso, pode te ajudar...

"In a way, the supernatural is what's behind the curtain. Normally, you only need to see what's happening on stage. That's how reality works. If you don't know then it's for the best. Actually, learning about the supernatural only increases the number of things you don't know."'

Link to comment
Share on other sites

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.

Loading...



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.