Jump to content

Recommended Posts

Posted (edited)

simplest custom buffer - easy in use, intuitive window. magical support has been divided onto five independent groups where users can buffup themselves manually or automatically via two pre-definied sets (mage, fighter).

 

also there's an additional option to bestow heroic valor effect in exchange for any item (in this case: gold bar).

i recommend to combine this feature with vote reward system :)

 

preview: http://s9.postimg.org/czbrb670v/buffer.gif

 

 

create new instance:

java/gameserver/model/actor/instance/L2BufferInstance.java

/*
 * 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.commons.random.Rnd;
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.model.actor.template.NpcTemplate;

/**
*
* @author Caparso
*/

public final class L2BufferInstance extends L2NpcInstance
{
	int fighterbuffs [] = {1397,1087,1044,1243,1304,1259,1204,1068,1388,1040,1036,1035,1048,1045,1077,1242,1086,1043,1240,1268,1032,1033,1191,1189,1182,1354,1353,1352,1392,1393,4699,4700,1416,1363,277,307,309,311,310,272,271,275,274,264,269,265,270,267,268,266,364,349,308,306,304};
	int magebuffs [] = {1397,1087,1044,1243,1304,1259,1204,1040,1389,1036,1035,1048,1045,1085,1078,1303,1059,1032,1033,1191,1189,1182,1353,1354,1352,1392,1393,4703,1416,1363,273,276,365,307,309,311,264,265,270,267,268,266,363,349,308,306,304};
	int voterewards [] = {1374};
	
    public L2BufferInstance(int objectId, NpcTemplate 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, -1, 0);
				SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
				showMessageWindow(player);
				player.broadcastPacket(mgc);
                showChatWindow(player, nextWindow);
			}
		}
		else if (actualCommand.equalsIgnoreCase("fighterset"))
		{
			for (int id: fighterbuffs)
			{
				SkillTable.getInstance().getInfo(id, SkillTable.getInstance().getMaxLevel(id)).getEffects(this, player);
			}
			showChatWindow(player);
		}
		else if (actualCommand.equalsIgnoreCase("mageset"))
		{
			for (int id: magebuffs)
			{
				SkillTable.getInstance().getInfo(id, SkillTable.getInstance().getMaxLevel(id)).getEffects(this, player);
			}
    	  showChatWindow(player);
		}
		else if (actualCommand.equalsIgnoreCase("rewards"))
		{
			if (player.destroyItemByItemId("voterewards",10600,1, player.getCurrentFolkNPC(), true))
			{
				for (int id: voterewards)
				{
    			SkillTable.getInstance().getInfo(id, SkillTable.getInstance().getMaxLevel(id)).getEffects(this, player);
				}
			}	
			else
			{
				player.sendMessage("You don't have heroic's certifications to exchange.");
			}
			showChatWindow(player);
		}
		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.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";
   }   
}
create new npc:

<npc id="9001" idTemplate="31081" name="BUFFER" title="L2EUPHORIA.COM">
        <set name="level" val="70"/>
        <set name="radius" val="8"/>
        <set name="height" val="30.5"/>
        <set name="rHand" val="0"/>
        <set name="lHand" val="5802"/>
        <set name="type" val="L2Buffer"/>
        <set name="exp" val="0"/>
        <set name="sp" val="0"/>
        <set name="hp" val="2444.46819"/>
        <set name="mp" val="1345.8"/>
        <set name="hpRegen" val="7.5"/>
        <set name="mpRegen" val="2.7"/>
        <set name="pAtk" val="688.86373"/>
        <set name="pDef" val="295.91597"/>
        <set name="mAtk" val="470.40463"/>
        <set name="mDef" val="216.53847"/>
        <set name="crit" val="4"/>
        <set name="atkSpd" val="253"/>
        <set name="str" val="40"/>
        <set name="int" val="21"/>
        <set name="dex" val="30"/>
        <set name="wit" val="20"/>
        <set name="con" val="43"/>
        <set name="men" val="20"/>
        <set name="corpseTime" val="7"/>
        <set name="walkSpd" val="50"/>
        <set name="runSpd" val="120"/>
        <set name="dropHerbGroup" val="0"/>
        <set name="attackRange" val="40"/>
        <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
        <skills>
            <skill id="4045" level="1"/>
            <skill id="4416" level="14"/>
        </skills>
    </npc>
don't forget to paste this folder within htmls in the right section (gameserver/data/html), then spawn 9001. Edited by Caparso
  • 4 months later...
Posted (edited)


    [javac] C:\Users\ElTyto\workspace\aCis_gameserver\java\net\sf\l2j\gameserver\model\actor\instance\L2BufferInstance.java:23: error: package net.sf.l2j.commons.random does not exist

    [javac] import net.sf.l2j.commons.random.Rnd;

    [javac]                                 ^

    [javac] C:\Users\ElTyto\workspace\aCis_gameserver\java\net\sf\l2j\gameserver\model\actor\instance\L2BufferInstance.java:139: error: cannot find symbol

    [javac] SocialAction sa = new SocialAction(this, Rnd.get(8));

    [javac]                                         ^

    [javac]   symbol:   variable Rnd

    [javac]   location: class L2BufferInstance

    [javac] 2 errors

Edited by ElTyto
Posted
    [javac] C:\Users\ElTyto\workspace\aCis_gameserver\java\net\sf\l2j\gameserver\model\actor\instance\L2BufferInstance.java:23: error: package net.sf.l2j.commons.random does not exist
    [javac] import net.sf.l2j.commons.random.Rnd;
    [javac]                                 ^
    [javac] C:\Users\ElTyto\workspace\aCis_gameserver\java\net\sf\l2j\gameserver\model\actor\instance\L2BufferInstance.java:139: error: cannot find symbol
    [javac]  SocialAction sa = new SocialAction(this, Rnd.get(8));
    [javac]                                           ^
    [javac]   symbol:   variable Rnd
    [javac]   location: class L2BufferInstance
    [javac] 2 errors

 

Replace it with 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.model.actor.template.NpcTemplate;

/**
*
* @author Caparso
*/

public final class L2BufferInstance extends L2NpcInstance
{
	int fighterbuffs [] = {1397,1087,1044,1243,1304,1259,1204,1068,1388,1040,1036,1035,1048,1045,1077,1242,1086,1043,1240,1268,1032,1033,1191,1189,1182,1354,1353,1352,1392,1393,4699,4700,1416,1363,277,307,309,311,310,272,271,275,274,264,269,265,270,267,268,266,364,349,308,306,304};
	int magebuffs [] = {1397,1087,1044,1243,1304,1259,1204,1040,1389,1036,1035,1048,1045,1085,1078,1303,1059,1032,1033,1191,1189,1182,1353,1354,1352,1392,1393,4703,1416,1363,273,276,365,307,309,311,264,265,270,267,268,266,363,349,308,306,304};
	int voterewards [] = {1374};
	
    public L2BufferInstance(int objectId, NpcTemplate 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, -1, 0);
				SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
				showMessageWindow(player);
				player.broadcastPacket(mgc);
                showChatWindow(player, nextWindow);
			}
		}
		else if (actualCommand.equalsIgnoreCase("fighterset"))
		{
			for (int id: fighterbuffs)
			{
				SkillTable.getInstance().getInfo(id, SkillTable.getInstance().getMaxLevel(id)).getEffects(this, player);
			}
			showChatWindow(player);
		}
		else if (actualCommand.equalsIgnoreCase("mageset"))
		{
			for (int id: magebuffs)
			{
				SkillTable.getInstance().getInfo(id, SkillTable.getInstance().getMaxLevel(id)).getEffects(this, player);
			}
    	  showChatWindow(player);
		}
		else if (actualCommand.equalsIgnoreCase("rewards"))
		{
			if (player.destroyItemByItemId("voterewards",10600,1, player.getCurrentFolkNPC(), true))
			{
				for (int id: voterewards)
				{
    			SkillTable.getInstance().getInfo(id, SkillTable.getInstance().getMaxLevel(id)).getEffects(this, player);
				}
			}	
			else
			{
				player.sendMessage("You don't have heroic's certifications to exchange.");
			}
			showChatWindow(player);
		}
		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, 1);
			broadcastPacket(sa);
			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";
   }   

It will work...

Posted (edited)

There is no errors, else you use old rev :P About your 'error', ush Ctrl + Shift + O.

 

If you still have error here SocialAction sa = new SocialAction(this, Rnd.get( 8)); do like SocialAction sa = new SocialAction(this, 2); or any number, it's social action animation or remove it.

Edited by SweeTs
Posted

There is no errors, else you use old rev :P About your 'error', ush Ctrl + Shift + O.

 

If you still have error here SocialAction sa = new SocialAction(this, Rnd.get( 8)); do like SocialAction sa = new SocialAction(this, 2); or any number, it's social action animation or remove it.

I dont get it ^^

  • 4 months later...
Posted (edited)

what item id need for buff valor?

also there's an additional option to bestow heroic valor effect in exchange for any item (in this case: gold bar).

Edited by thanosdk

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.




×
×
  • Create New...